Skip to content

feat: one run card with Show code, visible errors and warnings - #681

Merged
neuromechanist merged 8 commits into
developfrom
feature/issue-664-run-card
Nov 11, 2026
Merged

neuromechanist merged 8 commits into
developfrom
feature/issue-664-run-card

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

Replaces the widget's three run UIs (the consent/progress panel, the "Ran Python: ..." disclosure, the "Code" disclosure) with one run card, then makes failures and noise legible.

  • One // --- Run card --- block of pure builders in frontend/osa-chat-widget.js (state in, HTML out; no new script or loader). Consent, running, done and every non-ok status render through it; a restored card is the same card without figures.
  • Done card: figures first, a prominent Show code · N lines (aria-expanded, aria-controls, state in run._codeOpen), Copy code with a visible "Copied", Output · N lines, figure Download, and Edit and run with its editor inside the card.
  • Failed run: opens with Type: message, the failing line marked, All code, Full traceback (new stored traceback field, hidden when empty) and Copy error; a retry line while the reply is pending ("run K of 20"); a collapsed "N warnings" for ok runs; "N characters not shown" for cut output.
  • Stored stdout, stderr and traceback are now cut from the middle, keeping both ends, with the dropped count in a marker, so an error written at the end of stderr survives the 4,000-character limit.
  • Docs: docs/community-widget.md, "A run in the chat", rewritten.

Closes #664
Closes #672

Commands run

  • bun install: ok
  • bun frontend/test-widget-run-card.js: 223 passed (new, wired into the frontend-tests job after the activity-status step)
  • bun frontend/test-widget-tools.js, popout, color-scheme, activity-status, dataset-questions: 440, 141, 149, 303, 60 passed; host-styles, settings, first-paint, capsule, notebook-tab, launcher-geometry, paced-streaming and test-controller also pass
  • node --check frontend/osa-chat-widget.js: ok; bun scripts/build-runtime-bundle.js --check: bundle current
  • uv run pytest tests/test_frontend -q: 113 passed
  • uv run ruff check . and uv run ruff format --check .: clean
  • bun frontend/browser-harness/run-card-check.mjs <dir>: all checks pass in headless Chrome 157 (every state at 400 px, light and dark; no overflow, buttons at least 36 px tall, failing line marked, Show code works)

Screenshots (400 px)

State Light Dark
consent
cut-output
done-figure
done-figure-code-open
done-no-figure
failed-cut-stderr
failed-keyerror
failed-no-line
failed-syntax
local
restored
retry
running
statuses
warnings
warnings-open

The PNGs are on the screenshots/issue-664-run-card branch (not part of this change; delete it after merge).

Notes

  • The two commits are the recorded fixtures (real Pyodide output) and the run card with its tests; the E3.1 and E3.2 code share the card builders and could not be cleanly split.
  • Review: no review agents were available in this run, so run /pr-review-toolkit:review-pr (Sonnet) before merge.

Adds record-run-card-fixtures.js, which runs a KeyError, a SyntaxError, an error
with no line, cut stdout, cut stderr and a run with warnings through the worker
core on the npm Pyodide, and the recorded data (stdout, stderr, traceback).
Not yet used; the run card tests read it. Tested: regenerated and diffed.
…672)

Replaces the consent/progress panel, the 'Ran Python' disclosure and the 'Code'
disclosure with one card (a Run card block of pure builders in the widget).
Done cards show figures first, then Show code (aria-expanded/controls), Copy code
with a visible Copied, Output, Download and an in-card Edit and run. A restored
card is the same card without figures.

Failed runs open with Type: message, the failing line marked, All code, Full
traceback (new stored traceback field) and Copy error, plus a retry line while the
reply waits. Warnings of ok runs show as a collapsed count; cut output says how
many characters are not shown. Stored stdout, stderr and traceback are cut from
the middle so an error at the end of stderr survives.

Tests: new test-widget-run-card.js (wired into CI), updated tools, popout and
color-scheme suites, run-card-check.mjs screenshots at 400 px light and dark; docs
rewritten. All frontend suites and tests/test_frontend pass.
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-664-run-card-demo.osc.earth
Branch feature/issue-664-run-card
Commit 8683ab5

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

…ard-scoped panels; docs and changelog (run card tests 246 passed, all widget suites and Chrome harness pass)
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 1: outcome for each finding. Fixes are on this branch (head baea372).

  • Critical, harness script tag fails the embed hygiene test: fixed. run-card-check.mjs is in _RELATIVE_PATH_HARNESS_ALLOWLIST. uv run pytest tests/test_frontend: 113 passed on the committed head.
  • CHANGELOG: fixed. [Unreleased] now covers the run card (Widget: one run card with a visible Show code button #664, Widget: show failed runs open, with the error and the failing line #672), the stored traceback field and the middle cut of stored output.
  • Chrome harness not in CI: fixed. tests.yml runs bun frontend/browser-harness/run-card-check.mjs after the activity-status step. It passes locally in Chrome 157.
  • Retry line promised a run: fixed. It now reads "The assistant is looking at this error and may run the code again (K of 20 runs used)". Tests, harness regex and docs updated.
  • runErrorInfo named the wrong type for multi-line messages: fixed. The type is now the one the stored traceback ends with (first unindented line after the last indented one), and the nearest matching line above the marker is used; without a traceback the old heuristic applies and nothing is hidden. The suggested "nearest preceding type line" scan would not have fixed the example, so the traceback is used instead of a new stderr delimiter (which would change what the model sees). Added recorded real-Pyodide fixtures multiLineMessage and customName and tests for both, including the no-traceback and no-marker cases.
  • Copy error fallback selected different text than it copies: fixed. On a refused clipboard a visible block holding exactly error.text is shown and selected. Added a clipboard-refused test for Copy error.
  • Keyboard access to scrolling excerpt and error text: fixed. Both have tabindex="0" and a :focus-visible outline in --osa-accent.
  • Toggle looked up its panel by document-wide id: fixed. The panel is looked up inside the card. Test added with a stray element holding the same id. Cards with no located reply have no wired buttons, so the shared osa-run fallback id is not reachable by a click.
  • Status title test compared the widget's table to itself: fixed. Literal titles are asserted, plus the key set.
  • Failed run with no stderr, and a huge line number: fixed. A muted "No error message was recorded." line is shown, and a line number above 1,000,000 is not drawn.
  • Show code / Hide code label swap with aria-expanded: rejected, intentional design. The visible label is the accessible name (label in name, WCAG 2.5.3) and aria-expanded carries the state; recorded in a code comment.
  • Stale docs cross-reference and comment: fixed. The browser-runtime sentence says "run card", the stale comment above the copy and download handlers is trimmed, and the worker limits are described as defaults that stdout_chars and stderr_chars can change.

Checks: run card tests 246 passed, all other widget suites pass, ruff check and ruff format --check clean.

… is refused; type read from a module-qualified traceback; error text has a role and name (run card tests 261 passed, all widget suites and Chrome harness pass)
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 2 outcomes (fix commit d4675e3 on this branch):

  • Copy error appends a duplicate error block on every click (important): fixed. copyCodeFromButton now takes selectable as an element or a function and calls it only in the refused-clipboard branch, so the fallback block is built only then. Tests: a successful copy leaves no .osa-run-card-error-fallback; a refused one leaves exactly one holding exactly error.text.
  • Traceback type match regresses for module-qualified exceptions (important): fixed. The traceback name and stderr name are compared by their last dotted segment, and when that finds nothing the EXCEPTION_NAME heuristic runs, so a disagreeing traceback is never worse than none. Two new fixtures recorded from real Pyodide (json.loads("x"), and a json.JSONDecodeError with a multi-line message) assert type, whole message and marked line, with and without a traceback, plus a disagreeing-traceback case. Both failed on the previous code.
  • errorFallbackFor sits between copyCodeFromButton's doc comment and the function (suggestion): fixed. Moved above the "A code block's Copy (Widget: show a run's code in place, with Copy and Download #491)" comment, which now sits on copyCodeFromButton again; the comment also documents the function form of selectable.
  • .osa-run-card-error-text has a tab stop but no role or name (suggestion): fixed. Kept the keyboard-scrollable region and gave it role="group" and aria-label="Error message", matching the excerpt; asserted in the KeyError card test.

Tested: run card tests 261 passed, every frontend/test-*.js suite passes, bun frontend/browser-harness/run-card-check.mjs exits 0, tests/test_frontend 113 passed.

@neuromechanist

Copy link
Copy Markdown
Member Author

PM verdict: ready to merge (not merged). Every acceptance criterion is met against head d4675e3: run card suite (261 checks) wired after the activity-status step, updated widget suites green locally (all frontend/test-*.js), Chrome harness passes, screenshots attached in the PR body, docs section rewritten, and both review rounds have an outcome for every finding. CI is green (Lint re-run after a transient actionlint download failure). The branch is 8 commits behind develop, but those are docs and version bumps only; it merges cleanly, and I verified a local rebase onto origin/develop passes the frontend suites, harness and tests/test_frontend. I could not force-push the rebase, so squash-merge as is.

The run card stores a traceback on every run, and loading fills a missing
one with an empty string. The conversation store test now feeds v2 runs
without it and expects it on load. All frontend suites pass locally.
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