[PR #10076] refactor: extract shared Output utility for command streaming #13324

Closed
opened 2026-02-16 18:18:11 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10076

State: closed
Merged: No


What does this PR do?

Both bash.ts (BashTool) and prompt.ts (shell command execution) had duplicated logic for accumulating command output that caused O(n²) memory usage from repeated string concatenation.

Extract a shared Output utility that:

  • Accumulates output in memory up to a threshold (50KB)
  • Streams to a temp file when threshold is exceeded
  • Provides preview for UI display while streaming
  • Handles cleanup on abort

This prep commit deduplicates the streaming logic so both code paths benefit from the fix and future improvements only need to be made once.

Assisted-by: OpenCode (Claude claude-sonnet-4-20250514)

How did you verify your code works?

Ran unit tests (though some fail locally here on git main too), and some light interactive testing.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10076 **State:** closed **Merged:** No --- ### What does this PR do? Both bash.ts (BashTool) and prompt.ts (shell command execution) had duplicated logic for accumulating command output that caused O(n²) memory usage from repeated string concatenation. Extract a shared Output utility that: - Accumulates output in memory up to a threshold (50KB) - Streams to a temp file when threshold is exceeded - Provides preview for UI display while streaming - Handles cleanup on abort This prep commit deduplicates the streaming logic so both code paths benefit from the fix and future improvements only need to be made once. Assisted-by: OpenCode (Claude claude-sonnet-4-20250514) ### How did you verify your code works? Ran unit tests (though some fail locally here on git main too), and some light interactive testing.
yindo added the pull-request label 2026-02-16 18:18:11 -05:00
yindo closed this issue 2026-02-16 18:18:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13324