fix(opencode): coalesce stream updates and add reconnect backoff#13026
fix(opencode): coalesce stream updates and add reconnect backoff#13026chindris-mihai-alexandru wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
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. |
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
|
Please merge this PR. I am suffering for the performance issue of TUI everyday! |
|
hey @thdxr @rekram1-node @adamdotdevin - I think this is worth taking a look at and would greatly benefit the OpenCode community. Lmk your thoughts / suggestions / objections. |
6964e3a to
546238a
Compare
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
I narrowed this PR to a surgical scope and force-pushed the branch. Current diff is only 3 files in existing TUI paths:
The changes focus on:
No new rendering subsystem is introduced in this version. |
Summary
This PR narrows the scope to surgical TUI performance fixes in the existing OpenTUI path. It focuses on stream event coalescing, reconnect backoff, and lower-cost part updates during streaming.
Related to #13027.
What Changed
1) Redraw coalescing for stream updates
packages/opencode/src/cli/cmd/tui/context/sdk.tsxmessage.part.updatedevents now use a slightly longer batch window than non-stream events.2) Idle CPU guard for SSE reconnects
packages/opencode/src/cli/cmd/tui/context/sdk.tsx3) Lower-cost stream part updates
packages/opencode/src/cli/cmd/tui/context/sync.tsxreconcile(...)on everymessage.part.updatedevent.4) Stream append path optimization in message rendering
packages/opencode/src/cli/cmd/tui/routes/session/index.tsxtrim()calls on streaming text content.contentaccessor for markdown/code renderables.Why This Scope
The previous branch attempted a broader architecture path. This version keeps the implementation in the current renderer/data flow and addresses known hotspots directly.
Notes
Related Context
These changes align with common TUI guidance to avoid continuous redraw pressure and busy reconnect loops:
terminal.draw): Extremely high CPU usage of theterminal.drawmethod ratatui/ratatui#1338Validation
I ran local typecheck, but the workspace currently has many unrelated baseline errors in this environment. The changes in this PR are small and isolated to TUI event/render paths.