Skip to content

fix(opencode): batch direct shell output updates#37788

Open
flowluap wants to merge 1 commit into
anomalyco:devfrom
flowluap:prompt-shell-batch
Open

fix(opencode): batch direct shell output updates#37788
flowluap wants to merge 1 commit into
anomalyco:devfrom
flowluap:prompt-shell-batch

Conversation

@flowluap

Copy link
Copy Markdown

Issue for this PR

Closes #37787

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The direct user shell awaited a durable part update for every decoded output chunk. This coupled pipe consumption to SQLite projection and event broadcast work.

This change consumes output immediately and publishes the latest cumulative running snapshot at most every 100 ms. A version counter keeps output dirty when bytes arrive during an update. The publisher is interrupted before the existing final part update, so completion remains authoritative and no running update can arrive afterward.

How did you verify your code works?

  • bun test test/session/prompt.test.ts: 59 pass, 1 platform skip
  • Package typecheck and full commit-hook monorepo typecheck: 30 successful packages
  • Prettier and git diff --check
  • 20 paced writes: 4 running updates instead of up to 20 (80% fewer)
  • Durable event payload: 9,156 bytes to 3,128 bytes (65.8% lower)
  • Final output remained byte-for-byte complete

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found a related PR that appears to be a near-duplicate:

Related PR:

Why it's related:
This PR also addresses batching of shell output updates, which is very similar in scope to PR #37788 (fix(opencode): batch direct shell output updates). The main difference appears to be that #37788 specifically targets "direct" shell output, while #37653 may have addressed a broader shell output batching issue. You should verify whether these PRs handle different code paths or if one supersedes the other.

@flowluap

Copy link
Copy Markdown
Author

Related, but they cover separate implementations:

The paths do not call each other and the PRs have no overlapping files. Merging #37653 does not change the per-chunk sessions.updatePart calls in the direct shell path. The same 100 ms batching policy is intentional so both shell implementations avoid coupling pipe consumption to durable updates. They can be reviewed and merged independently.

@flowluap flowluap closed this Jul 19, 2026
@flowluap flowluap reopened this Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Direct shell persists every output chunk synchronously

1 participant