Skip to content

feat: Continue in notebook card, History row menu items and Download code (E4.3) - #692

Merged
neuromechanist merged 10 commits into
developfrom
feature/issue-675-continue-in-notebook-and-download-code
Nov 11, 2026
Merged

neuromechanist merged 10 commits into
developfrom
feature/issue-675-continue-in-notebook-and-download-code

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

E4.3 of the NEMAR AI experience plan: a way out of a chat's code.

  • A quiet card under the last reply after the first successful run: "N steps ran in this chat. Keep going in a notebook with all of their code." with Continue in notebook and Download code. Bordered note in the notice tokens, secondary-style buttons, no icon, 44 px targets, no new hex colors outside tokens (one new --osa-danger-text token, light and dark).
  • Continue in notebook builds with OSARuntime.buildConversationNotebook and calls importNotebookToTab; disabled while it waits, errors inline with role="alert", becomes Open notebook (no second import) until a new run changes the step count or the import is undone. Offered only for a capsule widget whose page dataset (with a Zarr copy) is the chat's dataset; otherwise only Download code.
  • Download code menu: Notebook (.ipynb) and Python script with cells (.py), saved through saveFile as <dataset>-chat.ipynb / .py, with the builder's exact notebook JSON and script text. Escape closes and returns focus.
  • History row menu gains Continue in notebook (disabled with a visible reason unless that dataset is the page's and the notebook is available; works on a non-active chat and closes the sheet) and Download code, for dataset chats with a successful run.
  • No change to the builder, the bridge, the notebook page, the tabs, the runtime bundle or its SRI constant.
  • All new code is in one block, // --- Notebook entry points (E4.3) ---, with one-line hooks in renderMessages, renderLauncherIcons, startBrowserTools and the History row, sheet and click handler. New suite frontend/test-widget-notebook-entry.js is wired into tests.yml after the notebook strip step. docs/community-widget.md and CHANGELOG.md updated.

Closes #675

Commands run

  • bun install
  • bun frontend/test-widget-notebook-entry.js (128 passed)
  • notebook-import (117), notebook-strip (169), notebook-tab (168), history-panel (200, file unchanged), history-store, run-card (261), notebook-builder (130), runtime-bundle (32) suites; every other frontend/test-widget-*.js also exits 0
  • bun scripts/build-runtime-bundle.js --check (bundle is current)
  • node --check frontend/osa-chat-widget.js
  • uv run pytest tests/test_frontend -q (144 passed; the attribute-escaping drift test caught my first draft and is green)
  • uv run ruff check . passes; uv run ruff format --check . reports 8 pre-existing Markdown files under .context/ (none touched here)

…(E4.3)

Adds the Notebook entry points block to the widget: a quiet card under the
last reply after a successful run, Continue in notebook and Download code
(.ipynb or .py) from the runtime bundle's builder, and the two History row
menu items. Tested in the next commit with the frontend suites.
Runs the real widget and runtime bundle over the shared notebook
conversations: card visibility rules, Continue and Open notebook, Download
code files, the History row items, escaping and a failing builder. Passes
with the other frontend suites.
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-675-continue-i-demo.osc.earth
Branch feature/issue-675-continue-in-notebook-and-download-code
Commit b02fb08

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

… its list (E4.3 review)

Focus returns to Continue (or Download code) when an import fails with focus nowhere, and to the History button when a History import is refused on the chat tab. The Download code popup keeps only menu items inside role=menu, with the note beside it, aria-controls, Home/End and Up from the button. The card's build is cached per chat state and a builder failure is logged once. importNotebookToTab now has a record-returning core used by the card, and a superseded import keeps the path its answer named. The History row menu is capped at the list's height and scrolled into view. Comments and the ADR say the card calls the import. Tested: frontend suites and the real-Chrome check pass.
…ths for the notebook entry points

Adds 46 checks to the notebook entry suite (174 in all): the card waits for the reveal, a refusal before and after the tab opens, focus after a failed import, the menu's roles and keys, the build cache, History builder errors, a deleted chat and a refusal on the chat tab, and a superseded import. Tested: bun frontend/test-widget-notebook-entry.js.
Measures the card and the Download code menu at 400 px in light and dark (inside the panel, 44 px controls, 4.5:1 text) and that the tallest History row menu is wholly inside the list that clips it. Tested: passes locally, and fails without the menu's height cap.
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 1: outcome for each finding. Fixes are in 07fb653, e783ca0 and 7be6e4b on this branch.

  • Focus dropped after Continue (important): fixed. runNotebookImport takes refocus (set when Continue had focus at the click). When the import fails and focus is nowhere (body or inside the card), the card redraws with focus on Continue, or on Download code when Continue is gone. Focus the reader has moved elsewhere is left alone. For History, a refusal that leaves the reader on the chat tab now focuses the History button. Tests: bridge error with focus nowhere, focus elsewhere kept, a refusal before the tab opens, and the History refusal.
  • Download code menu roles (important): fixed. The note is now beside the role="menu" (the menu holds only its two items) and aria-describedby points at it. The trigger has aria-controls. Home and End work, and ArrowUp from the trigger goes to the last item. Tests assert the roles of the menu's children, the aria wiring and the keys.
  • Missing tests (important): fixed. Added (a) the card hidden while revealingIndex is the reply and drawn when it clears (new setRevealingIndex test hook); (b) a refusal from importNotebookToTab before the tab opens (dataset moves between draw and click), and the "notebook did not open here" refusal; (c) History: builder throws on Continue, chat deleted before Continue and before Download code, builder throws on Download code, and the showError path (a duplicate Continue refused while the chat is on the chat tab) with focus; (d) document.activeElement after a failed import. 46 new checks, 174 in the suite.
  • Future-tense comments (suggestion): fixed. The __notebook hook comment and ADR 0017 line 69 now say the card and the History item call the import.
  • notebookEmbed.import read after the call (suggestion): fixed. startNotebookImport returns {record, pending}; importNotebookToTab is a thin wrapper, so its public contract is unchanged. A superseded import (another import took the banner) now stores the path its answer named instead of a record stuck in importing; a test checks that Open notebook asks for that path.
  • Builder run on every redraw (suggestion): fixed. The card's build is cached for the last chat drawn, keyed on everything the builder reads (id, title, createdAt, context, each run's status, code, description, stepTitle, local and error stderr) and on the builder itself. A failure is cached too, so it is logged once. Clicks still build fresh. hasSuccessfulRun has a comment that it must track planCells. Tests count builder calls across redraws and warnings from a throwing builder.
  • History menu height and no real-Chrome check (suggestion): fixed, and it found a real bug. New frontend/browser-harness/notebook-entry-check.mjs, wired into tests.yml, at 400 px in light and dark: the card inside the panel, no sideways scroll, controls at least 44 px, text at 4.5:1, the Download code menu inside the panel, and the last History row's menu with Download code unfolded. That last check failed at first: the unfolded menu (351 px) was taller than the list (302 px) and the list clipped it, so scrolling into view alone was not enough. The menu is now capped at the list's height (it scrolls on its own) and scrolled into view when opened and when Download code unfolds. The check fails without the cap. Not changed: the card button's border contrast (about 1.5:1). The labels carry the meaning and meet 4.5:1 in both schemes, so the border is not what identifies the control; the card is intentionally low-emphasis (secondary buttons in the notice colors).
  • Checked and clean (suggestion, "no action"): no change. Informational; nothing to fix.

Tests rerun at 7be6e4b: notebook-entry 174/174, history-panel 200/200, notebook-import 117/117, notebook-tab 168/168, notebook-strip 169/169, capsule 133/133, tools 443/443, run-card 261/261, notebook-builder 130/130, bun scripts/build-runtime-bundle.js --check (no bundle change), node --check on the widget, tests/test_frontend 144 passed, and the History, run card and new notebook-entry checks in headless Chrome. No Python changed.

…the last assistant reply without building an array per message (JS suites pass)
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 2 outcomes (commits 8c3e5b2, 4c7dc57):

  • critical, hygiene test fails on notebook-entry-check.mjs: fixed. Added frontend/browser-harness/notebook-entry-check.mjs to _RELATIVE_PATH_HARNESS_ALLOWLIST with the same reason text as the sibling harness pages. uv run pytest tests/test_frontend: 144 passed.
  • suggestion, Download code choices stay unfolded after the row menu closes: fixed. closeHistoryMenus now hides .osa-history-save-choices, resets the Download code toggle to aria-expanded="false", and clears the inline maxHeight. Added assertions to the Escape test in frontend/test-widget-notebook-entry.js (closed menu folded, reopened menu starts folded).
  • suggestion, notebookEntryCard builds an array per rendered message: fixed. The last assistant index is now found with a backward scan that stops at the first assistant reply, so no array is built per message and the cost is constant for a normal transcript.

Tests run: frontend/test-widget-notebook-entry.js (177 passed), frontend/test-widget-history-panel.js (200 passed), tests/test_frontend (144 passed), ruff check clean (ruff format --check flags 8 files this PR does not touch).

@neuromechanist

Copy link
Copy Markdown
Member Author

PM verdict at 4c7dc57: all acceptance criteria checked against the diff and tests and met; every review finding from rounds 1 and 2 has an outcome in a PR comment. All checks pass (Lint, Test 3.11, Test 3.12, Frontend Tests, deploy; Integration Tests skipping). Branch is not behind develop. Re-ran locally: notebook-entry 177/177, history-panel 200/200 (file unchanged), notebook-import 117/117, notebook-builder 130/130, bundle --check current, node --check ok. Not merged by this run: the merge was blocked by the permission system because the PR has no approving review, so it is waiting on a maintainer other than the author to approve and merge (squash).

@neuromechanist
neuromechanist merged commit 2eb0a08 into develop Nov 11, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-675-continue-in-notebook-and-download-code branch November 11, 2026 05:46
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