Skip to content

feat: history panel and saved figures in restored chats and the pop-out (E1.4, E1.5) - #689

Merged
neuromechanist merged 18 commits into
developfrom
feature/issue-657-history-panel-figures
Nov 11, 2026
Merged

neuromechanist merged 18 commits into
developfrom
feature/issue-657-history-panel-figures

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

E1.4 and E1.5 of the NEMAR AI experience plan.

  • History sheet (board A4): a header History button (aria-pressed, aria-controls, hidden on the notebook tab) opens a bottom sheet with a scrim over the chat (role=dialog, Escape closes, focus enters and returns to the button, the chat behind is inert). Chats are listed by day (Today, Yesterday, Earlier) with title, dataset id, step and figure counts, time, and a lazily loaded thumbnail of the first figure (object URLs revoked on close). A row or the menu's Open makes the chat live (activateConversation then evaluateContextSwitch, so a chat of another dataset shows the A1 notice); Delete, + New chat and a two-click Clear all history (new clearAllConversations) are there too. Everything is off, with a note, while a reply loads. Footer: "Saved in this browser only, the last 30 chats with their figures."
  • Saved figures in restored chats and the pop-out: new WorkspaceStore.figuresForCalls(callIds) reads figure-1.. of each run by call id from the real IndexedDB. A run now stores figureCount (0..3) while saveHistory keeps dropping the images; hydrateFigures() reads them back into memory once the runtime is ready, after load and after opening a chat. A figure the workspace no longer has shows a one-line note. The pop-out reads the same IndexedDB through its own init; no bytes pass through openPopout.

Closes #657
Closes #658
Closes #493

Commits

  1. WorkspaceStore.figuresForCalls (bundle rebuilt with Bun 1.4.3).
  2. figureCount persistence and hydrateFigures.
  3. History sheet.
  4. Real-Chrome harness and CI wiring.
  5. Changelog.

Commands run

  • bun frontend/test-widget-history-panel.js: 161 passed, 0 failed (new; a real v3 record of three chats, real WorkspaceStore from the real bundle over an in-memory IndexedDB)
  • bun frontend/test-widget-history-store.js (212), test-widget-fresh-return.js (59), test-widget-context-switch.js (160), test-widget-run-card.js (261), test-widget-popout.js (141), test-workspace.js (95): all pass. Also run: notebook-tab, capsule, first-paint, color-scheme, tools, settings, controller: all pass
  • bun scripts/build-runtime-bundle.js --check and bun frontend/test-runtime-bundle.js (32): pass
  • bun frontend/browser-harness/history-check.mjs: 30 checks pass in real Chrome 157 (figure drawn, saved, reload, found in the restored chat, the opened chat, the History thumbnail and the pop-out at 390x844; dark scheme; Escape returns focus)
  • bun frontend/browser-harness/chrome.js: pass, including figuresForCalls returning the exact PNG bytes after the reload (workspace write 44 checks, read 16 checks)
  • bun frontend/browser-harness/run-card-check.mjs and popout-check.mjs --serve: pass
  • node --check frontend/osa-chat-widget.js: ok
  • uv run --all-extras pytest tests/test_frontend -q: 144 passed
  • uv run ruff check .: all checks passed
  • uv run ruff format --check .: reports 8 Markdown files under .context/ and .rules/ that this branch does not touch (code blocks in docs); no Python file is affected

Notes

  • person-run-N call ids restart with every page load, so figuresForCalls leaves out a call id that two run records share rather than show the wrong run's figures; such a run shows the missing-figure note.
  • The header title now wraps (flex-wrap) so the added button does not overlap the Experimental badge at phone width.

#658)

Reads figure-1.. of each run found by call id, bounded by the operation
deadline; a call id two runs share is left out. Bundle rebuilt.
Tested: bun frontend/test-workspace.js (in-memory dbFactory), real IndexedDB
write/read phases in the Chrome harness (exact PNG bytes after reload).
…ored chats (#658, closes #493)

A run stores figureCount (0..3) beside images: [], written from the images in
memory and kept when there are none. hydrateFigures reads them from the
workspace once the runtime is ready, after load and after opening a chat, into
memory only; a missing figure shows a one-line note. The pop-out reads the same
IndexedDB through its own init.
Tested: bun frontend/test-widget-history-store.js; panel suite in the next commit.
Header History button, a bottom sheet with scrim (dialog, Escape, focus return,
inert chat behind), rows with dataset, step and figure counts and a lazy
thumbnail, Open/Delete/+ New chat, two-click Clear all (clearAllConversations),
off while a reply loads, hidden on the notebook tab.
Tested: bun frontend/test-widget-history-panel.js (161 checks, in-memory
IndexedDB under the real WorkspaceStore).
…CI (#657, #658)

history-check.mjs runs a figure through the real controller and IndexedDB,
reloads, and finds it in the restored chat, the opened chat, the History
thumbnail and the pop-out at 390x844, light and dark. The widget header title
now wraps so the extra button does not overlap the badge. Both new scripts run
in the frontend-tests job.
Tested: history-check.mjs, chrome.js, run-card-check.mjs, popout-check.mjs.
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-657-history-pa-demo.osc.earth
Branch feature/issue-657-history-panel-figures
Commit 1c32ac4

This preview will be updated automatically when you push new commits.

…ids; test on the shared in-memory IndexedDB (tested: test-workspace.js, bundle rebuilt)
…y on the next hydrate (tested: test-widget-history-panel.js)
…gure 1 only; no object URL for a read the sheet outlived (tested: test-widget-history-panel.js)
… keep the scrim below a header that changes height (tested: test-widget-history-panel.js)
…ain disclosure, busy reason reachable without a tooltip (tested: test-widget-history-panel.js)
…ace; cap from MAX_CONVERSATIONS (tested: test-widget-history-panel.js)
… likeliest low-contrast controls, uploads screenshots on CI failure (tested: history-check.mjs in Chrome)
…er's locale; rewrite the seed comment (tested: test-widget-history-panel.js, also under LC_ALL=de_DE)
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 1: outcome for each finding. Fixes are commits on this branch (afbbb5c to 792eb71).

  • Footer implies figures go with the chats (important): fixed. I took the copy route, not a new store method: a workspace run and its figures are shared state (downloadable, listed in Settings), so the History sheet now says what it does. The footer reads "Saved in this browser only, the last 30 chats. Figures and code stay in this browser's workspace until you delete it in Settings.", with the number built from MAX_CONVERSATIONS. The Clear all confirm step now shows the note "This removes the chats only. Their figures and code stay in this browser's workspace until you delete it in Settings." Tests cover both strings (93fd663).
  • hydrateFigures treats every failure as missing (important): fixed. hydrateFigures now tracks whether the workspace answered. If the store is absent, the read rejects, or the call id is ambiguous, the run gets _figuresUnavailable and the note "Figures from this run could not be loaded.", figureCount is untouched, and the next hydrate retries. _figuresMissing is set only when the store answered with fewer figures. figuresForCalls now exposes ambiguous (the call ids it leaves out because two runs share them) so person-run-N is no longer reported as gone. Tests: a store whose figuresForCalls rejects (then recovers on the next read), and a shared call id (3e560f3, afbbb5c).
  • aria-modal sheet with a live header (important): fixed. openSettings, resetChat and openPopout now close the sheet first (focus not restored), so Escape in Settings cannot close a sheet underneath and the sheet never lists a chat Clear discarded. Test clicks Settings, Clear and Pop-out with the sheet open (d1b495b).
  • Accessibility of the new controls (important): fixed, with one part kept. The row menu is now a plain disclosure: no role=menu, role=menuitem or aria-haspopup; aria-expanded plus aria-controls; the list is a role=group. The History button uses aria-expanded with aria-controls (CSS and the Chrome harness updated). While a reply loads the button is aria-disabled (still focusable) and aria-describedby points at a screen-reader-only line with the reason, as well as the title. The Open item in the row menu is kept: it is the board A4 menu's first action and harmless once the roles are gone; the row button remains the primary route (d0e246c).
  • Thumbnail loading scans every run per row (important): fixed. Rows that come into view in one turn are read in one figuresForCalls call, so a batch costs one _allRuns scan, and the call passes the new { limit: 1 } so only figure 1 of each run is read. A generation counter means a read that outlives the sheet (close and reopen mid-read) creates no object URL, which also closes the blob-URL leak noted under the last finding. Test: one call with {limit: 1} for the rows in view, and a stale read that makes no URL (5a183db, afbbb5c).
  • figuresForCalls test hand-rolls an IndexedDB (suggestion): fixed. The test now uses memoryIndexedDB() and seeds through recordRun; hand-written rows remain only for the figure gap, the reservation with a call id, and the ambiguous call id. The IDBKeyRange global is restored afterwards (afbbb5c).
  • history-check.mjs: double-counted timeout, no screenshots on CI failure, no contrast (suggestion): fixed. waitFor no longer reports; the caller's report counts a timeout once. Screenshots are written when HISTORY_CHECK_SCREENSHOTS is set (or an argument is given); the workflow sets it and uploads the directory when the step fails. New computed-contrast checks in both schemes for the expanded History button (3:1), the Delete menu item and the Clear-all confirm button (4.5:1); all pass in Chrome 157. While re-running the Python tests I found test_embed_snippet_hygiene.py was failing on this PR (the History harness page was not on its harness allowlist, the only failing test in the red Test (3.11) and Test (3.12) jobs); added it with its reason (cb4f4c6, a9f6585).
  • Scrim top fixed at open; blob URL leak; garbled comment; locale-dependent assertions (suggestion): fixed. The scrim now follows the header's height with a ResizeObserver for as long as the sheet is open and stops on close (test with a stubbed observer). The duplicate-read blob leak is fixed by the generation counter above. The seed comment in test-widget-history-panel.js is rewritten, and the time and date assertions now compare against the same toLocaleTimeString / toLocaleDateString call the widget makes (the suite also passes under LC_ALL=de_DE) (d1b495b, 5a183db, 8ea8199).

Nothing rejected and nothing filed as a new issue; every finding concerned code this PR touches.

Verification: all frontend/test-*.js suites exit 0 under Bun 1.4.3 (history panel suite 201 checks); frontend/browser-harness/history-check.mjs passes in real Chrome including the new contrast checks; uv run pytest tests/test_frontend passes (144); node --check frontend/osa-chat-widget.js is clean; uv run ruff check . is clean. The runtime bundle and its integrity hash were rebuilt for the osa-workspace.js change. ruff format --check . reports 8 files that this branch does not touch (no Python was changed here beyond one allowlist entry in a file that is already formatted).

…a failing database factory, not a hand-written store (tested: test-widget-history-panel.js)
…like the other header buttons (tested: widget frontend tests, tests/test_frontend)
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 2: outcomes

  • Hand-written store in the "read rejects" test (frontend/test-widget-history-panel.js): fixed in 4b0f430. The test now builds a real WorkspaceStore over a dbFactory that wraps the shared memoryIndexedDB helper and answers open() with an error while a flag is set. The unavailable-not-missing assertions go through the store's own _open and raceDeadline; the flag is then cleared and the same store is read again to check the retry. The fake store is gone.
  • Disabled History button still shows the hover wash (frontend/osa-chat-widget.js): fixed in a354586. .osa-history-btn[aria-disabled="true"]:hover now keeps a transparent background, and the disabled opacity is 0.4 to match .osa-header-btn:disabled.

Tested: test-widget-history-panel.js (200 passed) and the other frontend/test-widget-*.js suites, plus tests/test_frontend (144 passed).

… only conflict; tested: runtime bundle check, frontend suites)
@neuromechanist
neuromechanist merged commit 480f1c9 into develop Nov 11, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-657-history-panel-figures branch November 11, 2026 04:00
@neuromechanist

Copy link
Copy Markdown
Member Author

PM verdict: all acceptance criteria met (history panel suite, workspace harness PNG bytes, history-check.mjs, both workflow steps, runtime bundle check passes). Both review rounds have outcomes in comments. The branch conflicted with develop in CHANGELOG.md only; merged develop in (both entries kept) and re-ran CI, all checks green. Squash-merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant