fix(agent-manager): keep chat in sync with session selection while offline - #11843
Merged
Merged
Conversation
…fline selectSession bailed out entirely when the webview's backend connection was momentarily unavailable. In Agent Manager the side diff is resolved from the worktree selection independently of currentSessionID, so a switch during a transient disconnect moved the diff while the chat stayed frozen on the previous session (the 'switching only changes the sidebar diff' report). Update currentSessionID/draft synchronously regardless of connection so the chat always follows the selection, and gate only the message fetch on the connection. A fetch deferred while offline is replayed once the backend reconnects, scoped to the still-current unloaded session so the normal connected path never double-fetches.
chrarnoldus
approved these changes
Jun 30, 2026
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous Review Summary (commit 76d0b21)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 76d0b21)Status: 1 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Files Reviewed (3 files)
Reviewed by gpt-5.4-20260305 · Input: 80.1K · Output: 7.3K · Cached: 364.5K Review guidance: REVIEW.md from base branch |
A session selected while offline now defers its load regardless of whether it was already cached, and the reconnect effect replays it with the same focus/replace choice as a live selection. Clearing the deferral for cached sessions skipped the focus load on reconnect, which is what re-focuses the backend (focusSession, contextSessionID, SSE tracking, active worktree) and runs the reconcile self-heal, so the extension could stay focused on the previously selected session.
marius-kilocode
enabled auto-merge
July 1, 2026 10:52
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
…sion-switch-offline fix(agent-manager): keep chat in sync with session selection while offline
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
In Agent Manager, switching sessions sometimes updated only the side diff while the chat stayed frozen on the previously selected session. The two views are driven by different signals: the chat follows
currentSessionID(moved only byselectSession), while the side diff resolves its session from the selected worktree and has a fallback that does not depend oncurrentSessionID.selectSessionbailed out early and silently whenever the webview's backend connection was not"connected"at the moment of the click:So during a transient disconnect (backend restart, an SSE reconnect, or a stale connection signal in that webview) a click still ran
setSelection(...)and moved the diff, butsetCurrentSessionIDnever ran and the conversation pane stayed on the old session. Because the not-connected window is brief, the behavior was intermittent and hard to reproduce on demand.Change
selectSessionnow updatescurrentSessionIDand the draft selection synchronously, regardless of connection state. These are local signals and need no backend, so the chat always tracks the sidebar/tab selection. Only the message fetch depends on the backend: when offline the fetch is deferred rather than dropped, and it is replayed once the connection is restored, scoped to the still-current and still-unloaded session so the normal connected path never double-fetches. Cached sessions render immediately from the store.This removes the divergence between the chat and the side diff: both always reflect the same selected session, and a momentary not-connected state defers the network load instead of freezing the pane.