🤖 feat: view output for background bash tasks #1754
+557
−89
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
Implementation notes
workspace.backgroundBashes.getOutputlets the UI peek backgroundoutput.logwithout consuming the agent cursor (bash_output/task_await).Testing
make static-check📋 Implementation Plan
Plan: Show buffered output for backgrounded bash tasks
Goal
When a
bashtool call is running in the background (run_in_background: trueor foreground→background), let the user inspect the accumulated stdout/stderr so far in the UI (similar to the foregroundBashToolCalloutput view).UX target:
liveBashOutputBuffer).Non-goals (initial cut):
output.log).Implementation (chosen): On-demand popover log viewer + new ORPC endpoint (net +250–450 LoC)
Backend: expose “peek” output without consuming the tool cursor
Why:
BackgroundProcessManager.getOutput()mutatesproc.outputBytesRead(used bybash_output/task_await). The UI must not advance that cursor or the agent will miss output.Implement a separate read path that:
output.logat a caller-provided byte offset{ chunk, nextOffset, status }proc.outputBytesReadorproc.incompleteLineBufferConcrete steps:
ORPC schema
workspace.backgroundBashes.getOutput:{ workspaceId, processId, fromOffset?: number, tailBytes?: number }fromOffsetis omitted, treat as “initial open” and return a tail chunk (defaulttailBytes = 64_000).{ success, data?: { status, output, nextOffset, truncatedStart }, error? }truncatedStart: booleanindicates we started from a non-zero offset.router + workspaceService
backgroundBashes.getOutput.WorkspaceService.getBackgroundProcessOutput(...)that:workspaceId(same pattern asterminateBackgroundProcess).backgroundProcessManager
readOutput(processId, { fromOffset?: number; tailBytes?: number }).getProcess(processId)to refresh status/exitCode.fromOffsetis provided:proc.handle.readOutput(fromOffset).proc.outputBytesRead.BackgroundHandle support for tail
BackgroundHandle.readOutput(offset)reads “offset → EOF”; for initial open we want “EOF - N → EOF”.Preferred implementation:
BackgroundHandlewithgetOutputFileSize(): Promise<number>.stat -c%s, fallback tostat -f%z, fallback towc -c.startOffset = Math.max(0, size - tailBytes).Defensive guardrails
tailBytesto a sane max (e.g. 1MB).Renderer: reusable BackgroundBashOutputViewer (popover or modal)
Add a component that:
{ workspaceId, processId, displayName? }api.workspace.backgroundBashes.getOutput()offsetcursor (startsundefinedto trigger the initial tail fetch)buffer(append chunks; keep last ~1MB)truncatedStart+bufferTruncatedstatus(running|exited|killed|failed)Polling (only while viewer is open)
getOutput({ fromOffset: offset })UI integration
src/browser/components/BackgroundProcessesBanner.tsx)Popover(orDialog) that renders the viewer.src/browser/components/tools/BashToolCall.tsx)"backgroundProcessId" in result, add an inline “View output” action.Display details
DetailContent/OutputSection).truncatedStart(e.g., “Showing last 64KB”).Validation
Generated with
mux• Model: openai:gpt-5.2 • Thinking: xhigh • Cost: $9.12