Repository navigation
Phase 4a: a browser workspace, osa.save_script and save_artifact, and export - #455
Merged
neuromechanist merged 34 commits intoSep 23, 2026
Conversation
E5: a run may save at most 32 distinct explicit files, matching ClientToolResult.artifacts' own cap, so saved always equals announced. D7: path validation runs on the caller's raw name/path before scripts/ or artifacts/ is prefixed, so an absolute-looking argument is refused for what it actually is.
save_script/save_artifact now check the caller's raw name/path for being relative and well-formed before scripts/ or artifacts/ is added, so an absolute path is refused as "must be relative" rather than as a confusing empty path segment. Docstrings state the numeric limits (D3) and point to the Settings panel's whole-workspace download/delete, never a per-file delete (D5).
E1: every public method races a deadline (default 10s, overridable per instance like PyodideRuntime's bootTimeoutMs), and _open reacts to onblocked and resets its cached promise on rejection, so a stuck IndexedDB request reports failure instead of hanging a chat turn. C1: ordinal assignment is now atomic. _reserveOrdinal reads a session's highest ordinal and writes a RESERVED placeholder in ONE readwrite transaction, relying on IndexedDB serializing overlapping transactions across tabs and connections, so two tabs recording at once never collide on run-NNN and silently overwrite each other. deriveManifest and exportZip leave a still-reserved run out. E2: the run-record and deleteAll transactions gain onabort, matching putFile's existing three-handler pattern. D4/C2/E5(host): the 25MB per-run budget and the 32-file cap apply only to explicit saves, both re-checked on the host; automatic files are bounded by their own caps (_FULL_CHARS, image limits) and never compete with a path Python already accepted for the same budget.
C3: buildStoredZip throws rather than writing a wrapped entry count past the 16-bit end-of-central-directory field's 65,535-entry limit. C4: local and central headers set the general-purpose flag's UTF-8 bit (0x0800), so a future caller passing a non-ASCII name gets a correctly labeled archive.
E3: a genuine (non-timeout) rejection from recordRun -- WorkspaceStore's own failures always resolve to a value -- is logged with console.error and every explicit save for that run is dropped from artifacts, with a deterministic stderr line naming the failure, so a bug here never lets the model believe an unverifiable save succeeded. E4: the workspace failure note is appended AFTER the run's own stderr is clipped to the community's limit, keeping only whole lines (with an "and N more" trailer) rather than letting toClientToolResult's own clipping cut the note away or truncate it mid-line.
Covers E3 (a genuine recordRun rejection is logged and drops every explicit save) and E4 (a note is never clipped mid-line even when stderr_chars is set to its 256-character floor). Also drops a stale reference to a plan document in a comment (D2).
E1: a real dbFactory whose open() never settles proves the deadline reports failure rather than hanging, and a fast rejecting one proves _open resets its cached promise rather than replaying it. T2: a second session in the zip-writer test proves exportZip scopes each session's manifest and notebook to only its own runs. T5: the exact per-file byte cap passes, mirroring the existing community-cap pair. C3/C4: buildStoredZip's entry-count refusal and its UTF-8 flag bit, the latter checked against Python's zipfile since the system unzip on this machine mis-decodes UTF-8 names regardless of the flag.
Adds setWorkspaceStore, formatWorkspaceBytes, refreshWorkspacePanel, downloadWorkspace, handleWorkspaceDeleteClick and closeSettings to the __OSA_TEST__ surface, so a test can exercise the Settings workspace panel against a real WorkspaceStore without booting a runtime (T3).
Size formatting across B/KB/MB/GB boundaries, hidden when there is no store, the first Delete click only arms it while the second attempts the delete, reopening Settings disarms a pending confirm, and a failed size read or delete shows an error rather than nothing -- all against a real WorkspaceStore, genuinely unavailable under happy-dom exactly as it is under Bun.
BADFILE reports one artifact whose base64 is genuinely invalid, something real encoding can never produce, so a real recordRun call against it makes atob() throw for real -- the trigger the browser harness needs to exercise ClientToolController#persist's catch path.
Against real IndexedDB, since none of these are reachable under Bun: E3 (a genuine recordRun failure logs and reports, via a protocol- speaking worker rather than real Pyodide), E5 host-side (the 32-file cap), T1 (the per-run byte budget), T4 (ordinals survive a reload), T6 (two sessions in one community), and C1 (two connections recording concurrently for one session never collide on an ordinal). E6 bounds each phase by its own deadline so a hang fails loudly.
A second session in the fixture, with its own run and its own scripts/run-001.py, proves each session's manifest and notebook in the exported zip hold only that session's own content, never leaking a call_id across the shared archive.
WORKSPACE_LIMITS in osa-workspace.js mirrors five constants declared in the Python buildOutputCaptureSource generates; this test reads them out of that generated text and compares, the same drift-guard pattern already used for SERVER_LIMITS.
results/run-NNN's stdout/stderr/summary are bounded at 262,144 characters (_FULL_CHARS), the same copy get_full_output keeps, not literally the full, untruncated text as the doc previously claimed.
Regenerated from the review-fix changes to osa-workspace.js, osa-controller.js, osa-egress.js, osa-output.js and osa-worker-core.js.
Labels like E3 and T6 named review items, not anything in the repository; each comment now states its rule. Suites and chrome.js rerun green.
Member
Author
Local review, and what was done with each findingFour Sonnet reviewers: code and security, tests, error handling, and comments and docs. Every finding was addressed. Error handling
Code and security
Tests
Comments and docs
|
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
neuromechanist
merged commit Sep 23, 2026
2bb13a8
into
feature/issue-429-epic-browser-execution
14 checks passed
This was referenced Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 4's workspace (#433): what a run leaves behind now survives, in the reader's own browser, and nothing leaves it unless the reader exports it.
<community>/<session>/:scripts/run-NNN.py(the code as it ran) andresults/run-NNN/(its stdout, stderr and summary, bounded at 262,144 characters asget_full_outputalready keeps them, and each figure as a PNG). A per-sessionmanifest.jsonis derived from the stored records whenever it is needed, never stored, so it cannot drift.osa.save_script(name, code)andosa.save_artifact(path, data)in the sealed runtime. Only these explicit saves are listed back to the model in the result'sartifacts(sorted and deterministic, so the prompt cache holds). The bytes travel back to the host the way full output already does, are stripped before anything is sent, and never reach the server.[A-Za-z0-9._-]segments, no.or.., depth at most 4, at most 200 characters, checked on the caller's own argument in Python and again on the host. At most 10 MB per file, 25 MB and 32 files of explicit saves per run, 250 MB per community. Any write that fails (quota, private browsing, IndexedDB unavailable, a hang past the deadline) is reported in that run's result as whole, sorted stderr lines, and the file is dropped fromartifacts: the model is never told a file exists when it does not.notebook.ipynb(nbformat 4.5, one code cell per run with its outputs), which opens in Jupyter, JupyterLite, VS Code or Colab. Delete is confirmed inline. The zip writer is one module (frontend/osa-zip.js) that the test wheel builder now shares.execute_codedescription anddocs/community-browser-runtime.mddescribe the workspace, its limits, and that it is per origin (the popout window on another origin sees neither the chat history nor the workspace).Test plan
uv run pytest -m "not network": 2716 passed, 50 skipped; the one failure is test_version_shows_version fails locally and passes in CI, because rich colorizes on a TTY #434.ruff checkandruff format --checkare clean.test-worker-core.js190 (real Pyodide),test-widget-tools.js149,test-runtime-lifecycle.js177,test-controller.js95,test-workspace.js77 (new),test-output.js76,test-egress.js80,test-data-lane.js57,test-runtime-bundle.js25, and the rest. The bundle check is current.test_workspace_export.pywrites a real export through the real modules and validates it withzipfileandnbformat, across two sessions.chrome.json real IndexedDB in Chrome 153: the workspace write page (36 checks, including two concurrent writers, the host-side run budget and 32-file cap, and a genuinely malformed file) and a second page load reading it back (12 checks, including a run continuing at run-003); all other pages pass.Part of #433 and epic #429.