Repository navigation
fix(client): preserve live activity during hydration - #45975
Merged
Merged
Conversation
Merge session status changes received during an active snapshot request and ignore superseded reconnect responses. Cover terminal events, starts, deletion, and overlapping connections so an idle session cannot regain a stale spinner.
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
Merge session status changes received during activity hydration and ignore superseded reconnect responses. Cover terminal events, starts, deletion, and overlapping connections so idle sessions do not regain stale TUI spinners.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
An idle session can keep spinning in the TUI's tab strip and Sessions picker after a delayed activity snapshot overwrites its completion event. A response from an older connection can also overwrite a newer connection's snapshot, leaving activity incorrect until another event or reconnect repairs it.
What Changes
Activity snapshots now provide a baseline rather than replacing status changes received while the request was outstanding.
sequenceDiagram participant TUI participant Server TUI->>Server: GET /api/session/active Note over Server: Snapshot captures session as running Server-->>TUI: session.execution.succeeded Note over TUI: Set idle immediately and retain the update Server-->>TUI: Delayed running snapshot Note over TUI: Merge retained update; session stays idleDemo
Matched OpenCode Drive recording: before
936c73b54d, after8aad0dceed. Both run the production TUI with the same fixture and 80x24 observer viewport. A simulated model and temporary server response gate make the ordering deterministic; the server's active map and inbox are empty before the comparison. The clips show five seconds side by side without acceleration. Diagnostic server instrumentation is not included in this PR.spinner-comparison.mp4
Scope
This change owns client activity hydration and its regression tests. Inbox-derived busy indicators and event-stream liveness are separate concerns.
Verification
The client suite passes 90 tests, including six activity-ordering regressions. TUI data and tab tests pass all 78 tests. The repository's pre-push hook also passed all 33 typecheck tasks without bypassing hooks. The Drive scenario reproduces the stale tab and picker spinners on the base revision and verifies their absence on the changed revision. The duplicated regression setup is shared, and the start-event case begins idle so its handler is required for the test to pass.