Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
I reproduced the bug on the base and confirmed this fixes it. I ran the script from #62173 against each checkout from source, with a mock model:
- Base: two
in_progressupdates with nocontent, thencompletedwith all five lines about 5s later. - This PR: an
in_progressupdate every second with the output so far, then a singlecompletedupdate at the end.
The packages/cli ACP tests pass (102), and so does typecheck:tsc.
The ordering holds up. ShellStop goes through FiberMap.remove, which waits for the polling fiber to end, and sends can't be interrupted, so no running update can arrive after the final one. The cursor and catch-up logic matches the TUI's polling.
Public API: unchanged. ACP in_progress updates for shell tools carry content again, as they did in v1.18.
No blocking concerns.
This branch has not been deployed
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.
What was wrong
Since v2.0, ACP clients don't see a shell command's output while it runs. The
tool_call_updatewithstatus: "in_progress"has nocontent, and all the output only shows up on thecompletedupdate. Up to v1.18 the in-progress updates included the output so far, which let clients show a live terminal.Root cause
In v2, live shell output moved into the core Shell service. The service writes output to a file and serves it by cursor through
GET /api/shell/:id/output. While a command runs, the shell tool only reports{ shellID }as progress, and the TUI polls that route to show live output. The ACP bridge was never hooked up to it:runningToolUpdatehad nocontent, andsession.tool.progresssent a bare running update.Fix
The ACP bridge now follows a running shell the same way the TUI does:
translate.ts: when ashelltool reports progress with ashellID, it emitsShellFollow. When that tool succeeds, fails, or is abandoned on cancel, it emitsShellStopbefore the terminal update.turn.ts: each followed shell gets a fiber in a per-turnFiberMap, scoped to the turn's subscription. The fiber readsclient.shell.outputby cursor in the session's location. It catches up right away, then waitsShellOutputInterval(1s, same as the TUI) between reads. Each new chunk sends anin_progresstool_call_updatewith the output so far ascontent.opencode/session/child_updatework too....prefix, like v1.18's preview. A noisy command skips ahead instead of re-reading everything.ShellStopwaits for the fiber to end. So a running update never arrives after the tool'scompletedorfailedupdate.tool.ts:runningToolUpdateaccepts an optionaloutput, which becomescontent.The core shell tool and the server are unchanged. No feature flag, since this restores behavior that regressed.
How verified
packages/cli/test/acp/prompt.test.ts("streams a running shell command's output until the tool completes"). A fake server serves growing shell output. The test checks that in-progress updates carryline 1\n, thenline 1\nline 2\n, that the read uses the session location, and that the last update is the singlecompletedone. It fails ondevand passes here, including with--rerun-each 20.packages/cli/test/acp/shell-output.subprocess.test.ts. It runs the realopencode acpover stdio JSON-RPC withcreateAcpFixture, in an isolated env with a mock LLM. The mock model callsshellwithecho line 1; sleep 2; echo line 2; sleep 2; echo line 3. The test checks that anin_progressupdate carriesline 1\n…beforeline 3is printed, that every running text is a prefix of the final output, and that the turn ends withcompleted. Onorigin/devsource it fails (no running update has content). With the fix it passes (3/3 reruns). The subprocess harness now records the requests and notifications the agent sends (received()).repro.sh, with the mock model and an isolated HOME/XDG, against this branch's CLI. Before:pending,in_progress(no content) ×2, thencompleted5s later. After:in_progresswithline 1, thenline 1\nline 2, and so on, once per second, thencompleted.bun typecheckinpackages/cli. These ACP suites pass: prompt, translate, turn, permission, replay, session, compaction, elicitation, plus the subprocess tests.Visual
Closes #62173