Repository navigation
Show a code playground's data files as read-only tabs - #1171
TomNaessens wants to merge 1 commit into
Conversation
df35fb9 to
896f856
Compare
896f856 to
bf59f6e
Compare
bf59f6e to
1a98c08
Compare
1a98c08 to
dce80a6
Compare
dce80a6 to
d2c5330
Compare
| `; | ||
| } | ||
| const readonly = this.papyros.debugger.active; | ||
| const readonly = this.readonly || this.papyros.debugger.active; |
There was a problem hiding this comment.
🤖 [P2] Ignore editor change events in read-only previews
readonly prevents typing, but changing .value on a reused p-file-editor still dispatches change. Switching between two loaded text previews therefore reaches onEditorChange, which checks only debugger.active, and writes the preview to the backend after 300 ms. If another playground is paused in input(), this can overwrite its files on the shared runtime. I reproduced the running playground printing from B instead of its original from A after switching B's read-only preview. Return early from onEditorChange when this.readonly is true, and cover preview switching without backend writes.
There was a problem hiding this comment.
🤖 Fixed in 85ccb80: onEditorChange returns early when the viewer is read-only, so setting .value on the reused editor while switching previews no longer writes anything to the workspace. Tests: switching between two read-only previews makes no updateFile or updateFileContent call (fails without the guard), and an editable viewer still writes after a switch.
bmesuere
left a comment
There was a problem hiding this comment.
🤖 Reviewed this PR against its stack base. One reproducible issue is described inline. The additional regression check reproduces it with a real Python run. Validation of the complete stack at 530ba26: 334 existing tests passed; TypeScript checking, ESLint, and the app build passed.
d2c5330 to
85ccb80
Compare
f3ea61e to
cf5c477
Compare
|
🤖 Rebase notes for #1194 (reviewed at 910fb15). The notes on #1169 and #1168 cover the files below this PR; these are the parts specific to the read-only data-file tabs.
|
|
🤖 todo (non-blocking): once #1196 is merged, it adds No other change is needed. Read-only tabs render neither the rename input nor the add-file button, so they add no Escape that needs cancelling, and the |
cf5c477 to
61e88a6
Compare
|
🤖 Rebased onto main as 61e88a6:
|
61e88a6 to
1663574
Compare
|
🤖 Simplify pass after the rebase (now 1663574):
|
1663574 to
105c39c
Compare
105c39c to
785a36c
Compare
|
🤖 Minor findings. Plain review (no code-review skill) with a checkout of the PR head. Covers the full PR against its base #1170 (step 4 of the stack in dodona-edu/dodona#9402). Two inline comments: Stop during a slow file load ends in a worker restart after 5 s, and the "Open file" link text. Checked and fine:
Generated by Claude Code |
785a36c to
29353fe
Compare
|
🤖 note: Changed since the approval (29353fe): fixes for two review-routine findings.
|
<p-code-playground> takes a files attribute: space-separated paths, resolved against the document's base URL, that every run starts with. They show as read-only tabs above the editor and load when their tab is first opened or when Run needs them; a file that fails to load shows an alert, stops the run and is retried when its tab is opened again or on the next Run, and duplicate or invalid names (such as `media/`) are a configuration error. p-editor-tabs, p-editor-tab and p-file-viewer get a readonly mode for this; the sandbox keeps editable tabs. Binary files and text over 100 kB are not previewed and link to the file instead; the link names the file and says it opens in a new tab. The files option of Runner.start() also takes a promise, so Run claims the runtime at the click: the run waits for the files in its Loading phase, and ends without running when they fail to load. Stop ends a run that has not reached the worker yet on the spot, and the run ignores its files when they arrive, so a slow file never holds the runtime or restarts the worker. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
29353fe to
3184fc0
Compare
This pull request lets a code playground declare data files, shown as read-only tabs next to the code, as reviewers asked on dodona-edu/dodona#9211. It is step 4 of 5; see #1168 for the overview.
Stacked on #1170. Dodona side: dodona-edu/dodona#9305 passes the
filesattribute on.<p-code-playground files="media/grades.txt media/other.csv">: space-separated paths, resolved against the page's base URL and stored in the workspace under their base name. Every Run starts from a workspace holding exactly these files (runner.start(RunMode.Run, files)from Let a run start from a workspace with only the given files #1159), so a run gives the same result every time and two playgrounds can use different files with the same name.runner.start()waits for the files (itsfilesoption also takes a promise): Stop works while they load and other playgrounds wait. A file that fails to load shows an alert and the run ends without running the code; the next Run or reopening the tab retries.loadFile(url)(state/Files.ts): fetches once per URL (a failure is retried), rejects on an HTTP error, and returns text for valid UTF-8, otherwise base64.readonlyonp-editor-tabs,p-editor-tabandp-file-viewer: no add, rename or close, and a read-only editor. With aurl,p-file-viewershows an "Open file" link to it for binary files and text over 100 kB. The sandbox keeps the editable defaults.Deliberately left out:
fetchAndAddUrl, andprovideFiles, which still writes HTTP error pages into files): a separate change.Manual testing instructions
yarn vitest run --exclude '**/.claude/**'files="media/grades.txt"shows agrades.txttab with the file's contents and prints it on Run. A PNG shows the open link; a missing file shows the alert without running.Screenshots (Dodona test page)
Checklist
FileLoader.test.ts,EditorTabs.test.tsandFileViewer.test.ts(read-only modes), the playground files cases (including a real Pyodide run readinggrades.txt); full suite green locally (511)tabpanel🤖 Generated with Claude Code