Add a live `run_code` REPL panel to the `clai2` web UI
Part 10 of the clai2 web UI stack (… → #10277 → this PR). Based on #10277. No linked issue: requested by the CLAI maintainer.
Why. Let the user see the run_code REPL at any time in code mode: what the model is writing, what it calls, and what it gets back.
What changes
- The web plugin now shows a
run_codecell as soon as the model starts writing it and streams its source (args_delta). Code mode runs a cell's statements while it is still being written, so this matters. - The tools a cell calls from its sandbox are attached to the cell, with their results and shell output. They come from CLAI's
SandboxCallStartedEvent/SandboxCallFinishedEvent, matched to the cell by thePARENT__Nid (NESTED_CALL). Until now the browser dropped these events, so in code mode it only ever saw the outerrun_code. - The browser gets a REPL panel (⌘J, or the topbar button) with every cell as
In [n]: code (highlighted, with a caret while streaming), its calls (live, with speculative launches marked), andOut [n]. - Cells are numbered across the session (
In [n]), as a notebook numbers them: code mode keeps the REPL with the session since #10256. Each turn starts with a divider, andrestart: truemarks a reset and starts the count again. - Saved sessions keep no sandbox call log, so their cells list the calls found in their code, shown dimmer.
- Transcript rows for multi-call cells now read as the calls they made: "Ran list_files · read_file · grep".
Read-only here. Running your own code in the session's REPL comes in the next PR of the stack.
New public surface. None (web plugin wire fields only).
Verification. Unit tests cover the streamed cell, the three argument shapes it can start with, sandbox calls and their shell output (nested and top-level ids), and the item log; the plugin has 100% branch coverage over 50 tests. Headed Playwright against clai2 --web with claude-code:claude-haiku-4-5 in code mode checked the following, with no page errors:
- the code length grew while the cell streamed (156 → 300 characters);
- the cell listed
list_files .,read_file app.pyandgrep def, then printed its output; - a second cell
n = 21 * 2gaveOut [2]: 42; - across three turns,
x = 41thenprint(x + 1)printed 42 (state kept with the session), and arestart: truecell started again atIn [1]; - after a reload, both cells came back from history.
What changes for existing users. Nothing until they enable web.
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
- PR title is fit for the release changelog.