Fix structured attachment rendering

This commit is contained in:
ejclaw
2026-04-28 17:24:38 +09:00
parent b2b6a024ce
commit df8ee09bb4
18 changed files with 837 additions and 104 deletions

View File

@@ -46,6 +46,7 @@ import {
buildWebDashboardOverview,
sanitizeScheduledTask,
} from './web-dashboard-data.js';
import { serveValidatedAttachment } from './web-dashboard-attachments.js';
import {
addClaudeAccountFromToken,
getActiveCodexSettingsIndex,
@@ -1570,9 +1571,15 @@ export function createWebDashboardHandler(
return jsonResponse({ error: 'Method not allowed' }, { status: 405 });
}
if (url.pathname === '/api/health') {
return jsonResponse({ ok: true });
}
const simpleGetRoutes: Record<string, () => Response> = {
'/api/health': () => jsonResponse({ ok: true }),
'/api/status-snapshots': () =>
jsonResponse(readSnapshots(statusMaxAgeMs)),
'/api/tasks': () => jsonResponse(loadTasks().map(sanitizeScheduledTask)),
'/api/attachments': () => serveValidatedAttachment(url),
};
const simpleGetRoute = simpleGetRoutes[url.pathname];
if (simpleGetRoute) return simpleGetRoute();
if (url.pathname === '/api/overview') {
const snapshots = readSnapshots(statusMaxAgeMs);
@@ -1593,14 +1600,6 @@ export function createWebDashboardHandler(
});
}
if (url.pathname === '/api/status-snapshots') {
return jsonResponse(readSnapshots(statusMaxAgeMs));
}
if (url.pathname === '/api/tasks') {
return jsonResponse(loadTasks().map(sanitizeScheduledTask));
}
if (url.pathname === '/api/settings/accounts') {
return jsonResponse({
claude: listClaudeAccounts(),