Skip to content

fix(client): preserve live activity during hydration - #45975

Merged
kitlangton merged 1 commit into
v2from
spinner-audit
Aug 28, 2026
Merged

kitlangton merged 1 commit into
v2from
spinner-audit

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

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.

Ordering Result
Success, failure, or interruption arrives before an older running snapshot Session remains idle
Execution starts before an older empty snapshot arrives Session remains running
Session is deleted while its activity snapshot is outstanding Deleted activity stays removed
An older connection's snapshot arrives after the newer connection's Older response is ignored
Another session has no intervening event Its activity still hydrates from the snapshot
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 idle
Loading

Demo

Matched OpenCode Drive recording: before 936c73b54d, after 8aad0dceed. 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

# packages/client
bun run test
bun typecheck

# packages/tui
bun run test test/cli/tui/data.test.tsx test/context/session-tabs.test.tsx

# opencode-drive/packages/drive
bun run drive check .tmp/spinner-demo.ts

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.

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.
@kitlangton
kitlangton merged commit e8fa7da into v2 Aug 28, 2026
10 checks passed
@kitlangton
kitlangton deleted the spinner-audit branch August 28, 2026 16:30
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.
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