Promote legacy notes UI to native notes.html route

This commit is contained in:
2026-03-28 19:22:11 +00:00
parent d6b0e3192a
commit 17904cff3a
2 changed files with 3409 additions and 69 deletions
+3407
View File
File diff suppressed because it is too large Load Diff
+1 -68
View File
@@ -24,10 +24,6 @@ const ONENOTE_TARGET = {
notebookName: 'Billing Notes', notebookName: 'Billing Notes',
}; };
const WORKSPACE_ROOT = new URL('./', import.meta.url).pathname;
const LEGACY_NOTES_COMMIT = '4c6058c';
let legacyNotesHtmlCache: string | null = null;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// App // App
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -62,42 +58,6 @@ function getBearerToken(header: string | undefined | null): string | null {
return m?.[1] || null; return m?.[1] || null;
} }
function decorateLegacyNotesHtml(html: string): string {
const nav = `
<div style="position:fixed;top:12px;left:12px;z-index:100000;display:flex;flex-wrap:wrap;gap:8px;align-items:center;max-width:min(90vw,960px);">
<a href="/" style="display:inline-flex;align-items:center;padding:8px 12px;border-radius:999px;background:#0f172a;color:#e2e8f0;text-decoration:none;font:600 13px/1.2 ui-sans-serif,system-ui,sans-serif;border:1px solid #334155;box-shadow:0 8px 20px rgba(15,23,42,.28);">Testing Harness</a>
<a href="/tasks" style="display:inline-flex;align-items:center;padding:8px 12px;border-radius:999px;background:#0f172a;color:#e2e8f0;text-decoration:none;font:600 13px/1.2 ui-sans-serif,system-ui,sans-serif;border:1px solid #334155;box-shadow:0 8px 20px rgba(15,23,42,.28);">Tasks</a>
<span style="display:inline-flex;align-items:center;padding:8px 12px;border-radius:999px;background:rgba(15,23,42,.92);color:#67e8f9;font:600 12px/1.2 ui-sans-serif,system-ui,sans-serif;border:1px solid rgba(103,232,249,.35);box-shadow:0 8px 20px rgba(15,23,42,.28);">Legacy Notes UI · restored from ${LEGACY_NOTES_COMMIT}</span>
</div>`;
return html
.replace('<title>Prism Notes</title>', '<title>Prism Notes Legacy</title>')
.replace(/<body([^>]*)>/i, `<body$1>${nav}`);
}
async function loadLegacyNotesHtml(): Promise<string> {
if (legacyNotesHtmlCache) return legacyNotesHtmlCache;
const proc = Bun.spawn(['git', '--no-pager', 'show', `${LEGACY_NOTES_COMMIT}:index.html`], {
cwd: WORKSPACE_ROOT,
stdout: 'pipe',
stderr: 'pipe',
});
const [stdout, stderr, exitCode] = await Promise.all([
new Response(proc.stdout).text(),
new Response(proc.stderr).text(),
proc.exited,
]);
if (exitCode !== 0) {
throw new Error(stderr || `git show failed for ${LEGACY_NOTES_COMMIT}:index.html`);
}
legacyNotesHtmlCache = decorateLegacyNotesHtml(stdout);
return legacyNotesHtmlCache;
}
function escapeHtml(s: string): string { function escapeHtml(s: string): string {
return s return s
.replace(/&/g, '&amp;') .replace(/&/g, '&amp;')
@@ -1126,35 +1086,8 @@ app.get('/', async (c) => {
}); });
app.get('/notes', async (c) => { app.get('/notes', async (c) => {
try { const html = await Bun.file(new URL('./notes.html', import.meta.url)).text();
const html = await loadLegacyNotesHtml();
return c.html(html); return c.html(html);
} catch (error) {
console.error('Failed to load legacy notes UI', error);
return c.html(`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Prism Notes Legacy</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="min-h-screen bg-slate-950 text-slate-100">
<main class="mx-auto max-w-3xl px-6 py-16">
<div class="rounded-2xl border border-slate-800 bg-slate-900/80 p-6 shadow-2xl">
<p class="text-xs uppercase tracking-[0.3em] text-cyan-400">Prism Notes</p>
<h1 class="mt-2 text-3xl font-semibold tracking-tight">Legacy notes UI unavailable</h1>
<p class="mt-4 text-sm text-slate-300">The current server could not load the historical notes interface from git commit <strong>${LEGACY_NOTES_COMMIT}</strong>.</p>
<pre class="mt-4 overflow-x-auto rounded-xl border border-slate-800 bg-slate-950 p-4 text-xs text-rose-200">${escapeHtml(String(error instanceof Error ? error.message : error || 'Unknown error'))}</pre>
<div class="mt-6 flex flex-wrap gap-3">
<a href="/" class="rounded-xl border border-slate-700 bg-slate-900 px-4 py-2 text-sm font-semibold text-slate-100">Back to Testing Harness</a>
<a href="/tasks" class="rounded-xl border border-slate-700 bg-slate-900 px-4 py-2 text-sm font-semibold text-slate-100">Open Tasks View</a>
</div>
</div>
</main>
</body>
</html>`, 500);
}
}); });
app.get('/tasks', async (c) => { app.get('/tasks', async (c) => {