Skip to content

fix: coalesce shell progress updates - #46287

Closed
kvyb wants to merge 1 commit into
anomalyco:devfrom
kvyb:shell-progress-rate
Closed

kvyb wants to merge 1 commit into
anomalyco:devfrom
kvyb:shell-progress-rate

Conversation

@kvyb

@kvyb kvyb commented Aug 30, 2026

Copy link
Copy Markdown

Summary

  • keep draining and truncating every shell output chunk immediately
  • publish changed shell metadata previews at most once per 100 ms
  • force the latest changed preview after process settlement

Why

Each metadata callback persists and broadcasts another complete message.part.updated.1 snapshot. Fast or chatty commands can therefore generate many full-preview updates without improving the UI at chunk-level cadence.

A synthetic burst wrote 30 numbered chunks 10 ms apart, then kept the process alive until metadata exposed the final line. Across 10 fresh test processes per implementation:

Implementation Median metadata updates Range
Exact baseline 30 30-30
This change 4 4-5

That is an 86.7% median callback-count reduction in this workload. It does not claim an RSS reduction or equivalent production database-byte savings.

The implementation does not group the output stream: pipe draining, output capture, truncation, abort, and timeout behavior still process every chunk. The periodic publisher is scope-bound, deduplicates unchanged previews, and the final forced update prevents a burst ending between intervals from becoming stale.

Related: #33356

Validation

  • bun test ./test/tool/shell.test.ts: 25 pass, 0 fail on clean rerun
  • bun test ./test/session/prompt.test.ts -t 'cancel finalizes interrupted bash tool output through normal truncation': 1 pass, 0 fail
  • bun typecheck: pass
  • targeted oxlint on both changed files: 0 errors
  • independent defect-first review: no implementation blocker

The package-wide run reached 3,394 pass, 22 skip, 1 todo, with 2 unrelated PTY/session-route failures; both passed immediate targeted reruns.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 30, 2026
@github-actions github-actions Bot closed this Aug 30, 2026
@kvyb

kvyb commented Aug 31, 2026

Copy link
Copy Markdown
Author

The closure was correct: I missed the required PR template and closing issue link. I also later found #37653, which already implements the same targeted shell batching fix and was closed only by automated age/reaction cleanup. I will not resubmit this duplicate; I added the new measurements and a reopen request to #37653.

@kvyb
kvyb deleted the shell-progress-rate branch August 31, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant