Repository navigation
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This is obviously not ready for review, just had an agent do a first slop pass trying to fix a bug I hit in opencode2. I'll figure out a repro case, validate the fix, and clean up the code sometime in the next couple of days. |
|
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. |
Problem
Clicking to expand a streaming
<thinking>block in the TUI can stall the UI until reasoning finishes.Root cause chain:
session.next.reasoning.delta(andtext.delta/tool.input.delta) events per chunk, unbuffered (packages/core/src/session/runner/publish-llm-event.ts:278).match.text += event.data.deltaon each event (packages/tui/src/context/data.tsx).Note the web app already avoids this exact problem with per-part delta accumulation (
part_text_accum_delta, #26822); the TUI had no equivalent.Change
Adds a per-frame delta coalescer (
packages/tui/src/context/delta-buffer.ts):(kind, sessionID, messageID, partID); the store is rewritten at most once per animation frame instead of once per event.drain()runs before any non-delta event (e.g.*.ended) so terminating events that replace the full part text still observe the final accumulated deltas; also drains on provider unmount.text.delta,reasoning.delta, andtool.input.delta(identical pattern, same fix).Testing
createDeltaBuffer(coalescing, per-part isolation, drain semantics, stale flush no-op, single-schedule).bun testpasses 5/5.tsgo --noEmitin this environment (tool not installed); changes are type-annotated to match the module's existing usage.Follow-up (not included)
packages/core/src/session/message-updater.ts:358) performs the same per-delta full-text rewrite; worth batching there separately.