fix(cloud-agent-sdk): upgrade read-only CLI sessions to live when the CLI reports them active#4390
Open
iscekic wants to merge 1 commit into
Open
fix(cloud-agent-sdk): upgrade read-only CLI sessions to live when the CLI reports them active#4390iscekic wants to merge 1 commit into
iscekic wants to merge 1 commit into
Conversation
… CLI reports them active resolveSession decides remote vs read-only from activeSessions.list, which reflects CLI heartbeats and is eventually consistent: after enabling remote on the CLI it takes a websocket connect plus a heartbeat round-trip (~12s measured locally) before the session appears active. Opening the session in the app inside that window resolved it read-only, which mounted the snapshot-only historical transport and never re-evaluated - the view stayed frozen on whatever the snapshot contained (for a just-started /local-review-uncommitted run, only the first message). When a session resolves read-only and a user-web connection is available, keep the connection retained and watch sessions.list/sessions.heartbeat; as soon as the CLI reports the session active, re-resolve and swap in the live transport. This also covers resolveSession's silent failure paths (transient tRPC errors map to read-only), which previously froze the screen the same way.
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe new heartbeat-driven upgrade watcher in Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Reviewed by claude-sonnet-5-20260630 · Input: 36 · Output: 21.5K · Cached: 1.3M Review guidance: REVIEW.md from base branch |
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.
Problem
Reported: start a CLI session with
/local-review-uncommitted, enable remote, open the session in the mobile app → the view is stuck on the first message and never updates.Reproduced locally (CLI 7.3.54 against the local stack, mock app client speaking the real tRPC + WS protocol). The CLI↔backend plumbing is healthy in every variant — the bug is a race in session resolution:
resolveSessiondecidesremotevsread-onlyfromactiveSessions.list, which reflects CLI heartbeats and is eventually consistent: after enabling remote it takes a WS connect + heartbeat round-trip (~12s measured locally) before the session shows up as active.read-only→ snapshot-only historical transport, no live socket, andresolveSessiononly re-runs on a full remount. The screen freezes on whatever the snapshot contained — for a just-started review, exactly one message (the slash command).resolveSessionfailure paths silently map toread-onlytoo (barecatch→ read-only in the mobile manager, empty-list fallbacks in the router), producing the same permanent freeze on transient errors.It presents as a
/local-review-uncommittedbug because that's the fire-and-forget flow: start it, enable remote, immediately watch on the phone (inside the window), and keep the screen open for the multi-minute review. Interactive sessions mask the bug via remount → re-resolve.Measured timeline from the repro (remote toggled mid-review, poller replaying the app's resolve logic every 2s):
Fix
When a session resolves
read-onlyand auserWebConnectionis available, arm a watcher: retain the connection (nothing else keeps it alive for a read-only session, and without it no heartbeats arrive) and listen forsessions.list/sessions.heartbeatnaming the session. When the CLI reports it active, re-resolve and swap in the live transport. The watcher is disarmed on upgrade, reconnect, disconnect, and destroy.This is in the shared
cloud-agent-sdksession orchestrator, so web and mobile both get the fix, and it also covers the silent-failure→read-only paths.Testing
session-routing.test.ts: heartbeat-driven upgrade (including ignoring other sessions' heartbeats and watcher cleanup on upgrade), and disarm-on-destroy.cloud-agent-sdksuite: 21 suites, 740 tests pass.tsgotypecheck (web + mobile), oxlint, oxfmt clean.