Spaces:
Sleeping
Sleeping
Remove stale Library/History UI (calls deleted /api/library); fix footer copy
Browse files- dee/static/app.js +17 -156
dee/static/app.js
CHANGED
|
@@ -183,8 +183,11 @@ renderGutter();
|
|
| 183 |
// the others; update the sidebar active state to match. Library + History
|
| 184 |
// pages lazy-fetch their data the first time they're shown.
|
| 185 |
|
| 186 |
-
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
function currentRoute() {
|
| 190 |
const hash = (window.location.hash || '').replace('#', '').toLowerCase();
|
|
@@ -207,168 +210,25 @@ function showRoute(name) {
|
|
| 207 |
const crumb = document.querySelector('.crumb-active');
|
| 208 |
if (crumb) {
|
| 209 |
crumb.textContent = {
|
| 210 |
-
design:
|
| 211 |
-
|
| 212 |
-
history: 'Activity',
|
| 213 |
-
docs: 'Documentation',
|
| 214 |
}[name] || name;
|
| 215 |
}
|
| 216 |
-
// Lazy-load data for views that need it.
|
| 217 |
-
if (name === 'library' || name === 'history') {
|
| 218 |
-
if (!routeCache.libraryLoaded) {
|
| 219 |
-
loadLibrary();
|
| 220 |
-
routeCache.libraryLoaded = true;
|
| 221 |
-
}
|
| 222 |
-
}
|
| 223 |
window.scrollTo({ top: 0, behavior: 'instant' });
|
| 224 |
}
|
| 225 |
|
| 226 |
window.addEventListener('hashchange', () => showRoute(currentRoute()));
|
| 227 |
showRoute(currentRoute());
|
| 228 |
|
| 229 |
-
// ====================================================== LIBRARY + HISTORY
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
if (histList) histList.innerHTML = '<div class="empty-state"><h3 class="empty-title">Loading…</h3></div>';
|
| 237 |
-
try {
|
| 238 |
-
const res = await fetch('/api/library');
|
| 239 |
-
const data = await res.json();
|
| 240 |
-
if (!res.ok) throw new Error(data.error || 'Could not list libraries.');
|
| 241 |
-
renderLibrary(data);
|
| 242 |
-
renderHistory(data);
|
| 243 |
-
if (libCount) libCount.textContent = (data.items || []).length;
|
| 244 |
-
const dirEl = document.getElementById('libraryDir');
|
| 245 |
-
if (dirEl && data.output_dir) {
|
| 246 |
-
dirEl.textContent = `Every library you've generated locally · ${data.output_dir}`;
|
| 247 |
-
}
|
| 248 |
-
} catch (err) {
|
| 249 |
-
const msg = `<div class="empty-state"><h3 class="empty-title">Couldn't load libraries</h3><p class="empty-sub">${escapeHtml(err.message)}</p></div>`;
|
| 250 |
-
if (libList) libList.innerHTML = msg;
|
| 251 |
-
if (histList) histList.innerHTML = msg;
|
| 252 |
-
}
|
| 253 |
-
}
|
| 254 |
-
|
| 255 |
-
function renderLibrary(data) {
|
| 256 |
-
const root = document.getElementById('libraryList');
|
| 257 |
-
if (!root) return;
|
| 258 |
-
const items = data.items || [];
|
| 259 |
-
if (!items.length) {
|
| 260 |
-
// Editorial empty state — § kicker + italic display title +
|
| 261 |
-
// lede, no placeholder illustration. Matches the Design view's
|
| 262 |
-
// empty state pattern from the bloat-strip pass.
|
| 263 |
-
root.innerHTML = `
|
| 264 |
-
<div class="empty-state">
|
| 265 |
-
<p class="empty-kicker">§ Empty</p>
|
| 266 |
-
<h3 class="empty-title">No libraries yet.</h3>
|
| 267 |
-
<p class="empty-sub">Generate your first library from the <a href="#design">Design</a> page. Past runs will appear here.</p>
|
| 268 |
-
</div>
|
| 269 |
-
`;
|
| 270 |
-
return;
|
| 271 |
-
}
|
| 272 |
-
root.innerHTML = items.map((it) => {
|
| 273 |
-
const fitness = it.top_fitness != null ? Number(it.top_fitness).toFixed(2) : '—';
|
| 274 |
-
const tsLocal = new Date(it.modified_iso + 'Z').toLocaleString();
|
| 275 |
-
return `
|
| 276 |
-
<div class="lib-row">
|
| 277 |
-
<div class="lib-row-id">
|
| 278 |
-
<span class="lib-row-name">${escapeHtml(it.wt_identifier)}</span>
|
| 279 |
-
<span class="lib-row-meta">${escapeHtml(tsLocal)} · ${escapeHtml(it.filename)}</span>
|
| 280 |
-
</div>
|
| 281 |
-
<div class="lib-row-stat">
|
| 282 |
-
<div class="lib-row-stat-num">${it.variant_count}</div>
|
| 283 |
-
<div class="lib-row-stat-label">variants</div>
|
| 284 |
-
</div>
|
| 285 |
-
<div class="lib-row-stat">
|
| 286 |
-
<div class="lib-row-stat-num">${escapeHtml(fitness)}</div>
|
| 287 |
-
<div class="lib-row-stat-label">top fitness</div>
|
| 288 |
-
</div>
|
| 289 |
-
<div class="lib-row-stat">
|
| 290 |
-
<div class="lib-row-stat-num" title="${escapeHtml(it.top_mutations || '')}">${escapeHtml((it.top_mutations || '—').split(',').slice(0,2).join(','))}${(it.top_mutations || '').split(',').length > 2 ? '…' : ''}</div>
|
| 291 |
-
<div class="lib-row-stat-label">top hit</div>
|
| 292 |
-
</div>
|
| 293 |
-
<div class="lib-row-actions">
|
| 294 |
-
<a class="ghost" href="/api/library/${encodeURIComponent(it.filename)}" download>Download</a>
|
| 295 |
-
<button class="ghost ghost-danger" data-delete-lib="${escapeHtml(it.filename)}">Delete</button>
|
| 296 |
-
</div>
|
| 297 |
-
</div>
|
| 298 |
-
`;
|
| 299 |
-
}).join('');
|
| 300 |
-
|
| 301 |
-
root.querySelectorAll('[data-delete-lib]').forEach((btn) => {
|
| 302 |
-
btn.addEventListener('click', async (e) => {
|
| 303 |
-
const fname = btn.dataset.deleteLib;
|
| 304 |
-
if (!confirm(`Delete "${fname}" permanently?`)) return;
|
| 305 |
-
try {
|
| 306 |
-
const res = await fetch(`/api/library/${encodeURIComponent(fname)}`, { method: 'DELETE' });
|
| 307 |
-
if (!res.ok) throw new Error('delete failed');
|
| 308 |
-
routeCache.libraryLoaded = false;
|
| 309 |
-
loadLibrary();
|
| 310 |
-
} catch (err) {
|
| 311 |
-
showToast(`Could not delete: ${err.message}`, 'warn');
|
| 312 |
-
}
|
| 313 |
-
});
|
| 314 |
-
});
|
| 315 |
-
}
|
| 316 |
-
|
| 317 |
-
function renderHistory(data) {
|
| 318 |
-
const root = document.getElementById('historyTimeline');
|
| 319 |
-
if (!root) return;
|
| 320 |
-
const items = data.items || [];
|
| 321 |
-
if (!items.length) {
|
| 322 |
-
root.innerHTML = `
|
| 323 |
-
<div class="empty-state">
|
| 324 |
-
<p class="empty-kicker">§ Empty</p>
|
| 325 |
-
<h3 class="empty-title">No activity yet.</h3>
|
| 326 |
-
<p class="empty-sub">Run anything on the Design page and it'll show up here.</p>
|
| 327 |
-
</div>
|
| 328 |
-
`;
|
| 329 |
-
return;
|
| 330 |
-
}
|
| 331 |
-
root.innerHTML = items.map((it) => {
|
| 332 |
-
const tsLocal = new Date(it.modified_iso + 'Z').toLocaleString();
|
| 333 |
-
const fitness = it.top_fitness != null ? `top ΣΔLL ${Number(it.top_fitness).toFixed(2)}` : 'no fitness';
|
| 334 |
-
// Hist-dot SVG (Apple-style play triangle) dropped — it read as
|
| 335 |
-
// a decorative chip rather than meaningful information. The row
|
| 336 |
-
// is now just a typeset timeline entry. The CSS rule for
|
| 337 |
-
// .hist-dot is left untouched in case any older renderer is
|
| 338 |
-
// still in flight; CSS just no-ops on a missing element.
|
| 339 |
-
return `
|
| 340 |
-
<div class="hist-item">
|
| 341 |
-
<div class="hist-body">
|
| 342 |
-
<span class="hist-title">Generated library for <strong>${escapeHtml(it.wt_identifier)}</strong></span>
|
| 343 |
-
<span class="hist-meta">${it.variant_count} variants · ${escapeHtml(fitness)} · <a href="/api/library/${encodeURIComponent(it.filename)}" download>${escapeHtml(it.filename)}</a></span>
|
| 344 |
-
</div>
|
| 345 |
-
<span class="hist-time">${escapeHtml(tsLocal)}</span>
|
| 346 |
-
</div>
|
| 347 |
-
`;
|
| 348 |
-
}).join('');
|
| 349 |
-
}
|
| 350 |
-
|
| 351 |
-
// Manual refresh button.
|
| 352 |
-
const libRefresh = document.getElementById('libraryRefresh');
|
| 353 |
-
if (libRefresh) {
|
| 354 |
-
libRefresh.addEventListener('click', () => {
|
| 355 |
-
routeCache.libraryLoaded = false;
|
| 356 |
-
loadLibrary();
|
| 357 |
-
});
|
| 358 |
-
}
|
| 359 |
-
|
| 360 |
-
// Inline SVG used by the empty state when the Library is genuinely empty.
|
| 361 |
-
// EMPTY_ICON_SVG kept as an empty string for any legacy callsite still
|
| 362 |
-
// reading it; the renderers above no longer reference it. The original
|
| 363 |
-
// placeholder-rectangles SVG read as the AI-generated empty-state cliché
|
| 364 |
-
// the audit removed. Hot-swappable back to a real SVG if a designer ever
|
| 365 |
-
// wants a custom illustration here.
|
| 366 |
const EMPTY_ICON_SVG = '';
|
| 367 |
|
| 368 |
-
// Refresh the library count on initial load even if user hasn't visited
|
| 369 |
-
// the Library tab, so the sidebar badge shows real data.
|
| 370 |
-
loadLibrary();
|
| 371 |
-
|
| 372 |
// ====================================================== MOBILE NAV DRAWER
|
| 373 |
// On phones the sidebar is hidden off-screen by default and slides in when
|
| 374 |
// the hamburger button in the topbar is tapped. A scrim overlay covers the
|
|
@@ -962,8 +822,9 @@ function renderResults(data) {
|
|
| 962 |
wireTableControls();
|
| 963 |
renderVariantRows();
|
| 964 |
|
| 965 |
-
|
| 966 |
-
|
|
|
|
| 967 |
|
| 968 |
wireDownloadMenu();
|
| 969 |
|
|
|
|
| 183 |
// the others; update the sidebar active state to match. Library + History
|
| 184 |
// pages lazy-fetch their data the first time they're shown.
|
| 185 |
|
| 186 |
+
// Library + History routes removed 2026-05-27 — the local-filesystem
|
| 187 |
+
// endpoints they depended on (/api/library) were removed in audit fix C2.
|
| 188 |
+
// Per-user saved libraries now live on the landing site's /dashboard/
|
| 189 |
+
// page, backed by Supabase Storage with RLS-gated reads (task #98).
|
| 190 |
+
const ROUTES = ['design', 'docs'];
|
| 191 |
|
| 192 |
function currentRoute() {
|
| 193 |
const hash = (window.location.hash || '').replace('#', '').toLowerCase();
|
|
|
|
| 210 |
const crumb = document.querySelector('.crumb-active');
|
| 211 |
if (crumb) {
|
| 212 |
crumb.textContent = {
|
| 213 |
+
design: 'New library',
|
| 214 |
+
docs: 'Documentation',
|
|
|
|
|
|
|
| 215 |
}[name] || name;
|
| 216 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
window.scrollTo({ top: 0, behavior: 'instant' });
|
| 218 |
}
|
| 219 |
|
| 220 |
window.addEventListener('hashchange', () => showRoute(currentRoute()));
|
| 221 |
showRoute(currentRoute());
|
| 222 |
|
| 223 |
+
// ====================================================== LIBRARY + HISTORY
|
| 224 |
+
// Removed 2026-05-27 along with the /api/library endpoints they called
|
| 225 |
+
// (audit C2). Per-user saved libraries now live on the landing site's
|
| 226 |
+
// /dashboard/ page (task #98), backed by Supabase Storage with RLS-gated
|
| 227 |
+
// reads. The dead-code below previously listed files from the
|
| 228 |
+
// Space-shared ~/.dee/output/ directory — fine for a single-user desktop
|
| 229 |
+
// app, broken for a multi-tenant deployment.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
const EMPTY_ICON_SVG = '';
|
| 231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
// ====================================================== MOBILE NAV DRAWER
|
| 233 |
// On phones the sidebar is hidden off-screen by default and slides in when
|
| 234 |
// the hamburger button in the topbar is tapped. A scrim overlay covers the
|
|
|
|
| 822 |
wireTableControls();
|
| 823 |
renderVariantRows();
|
| 824 |
|
| 825 |
+
// navLibCount badge was removed from the sidebar 2026-05-27 along with
|
| 826 |
+
// the Library tab. Leaving the lookup as a defensive no-op so any
|
| 827 |
+
// future re-introduction of a counter is one selector change away.
|
| 828 |
|
| 829 |
wireDownloadMenu();
|
| 830 |
|