Skip to content

fix(agent-manager): keep chat in sync with session selection while offline - #11843

Merged
marius-kilocode merged 3 commits into
mainfrom
fix/agent-manager-session-switch-offline
Jul 1, 2026
Merged

fix(agent-manager): keep chat in sync with session selection while offline#11843
marius-kilocode merged 3 commits into
mainfrom
fix/agent-manager-session-switch-offline

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

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 by selectSession), while the side diff resolves its session from the selected worktree and has a fallback that does not depend on currentSessionID.

selectSession bailed out early and silently whenever the webview's backend connection was not "connected" at the moment of the click:

if (!server.isConnected()) {
  console.warn("[Kilo New] Cannot select session: not connected")
  return
}

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, but setCurrentSessionID never 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

selectSession now updates currentSessionID and 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.

…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.
Comment thread packages/kilo-vscode/webview-ui/src/context/session.tsx Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/kilo-vscode/tests/unit/session-select-connection.test.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx
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

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/src/context/session.tsx 2546 Cached session selections made while offline never replay the focus path after reconnect, so the provider can stay focused on the previous session and skip reconcile/self-heal for the newly selected cached session.
Files Reviewed (3 files)
  • .changeset/fix-agent-manager-session-switch-offline.md
  • packages/kilo-vscode/tests/unit/session-select-connection.test.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx - 1 issue

Reviewed by gpt-5.4-20260305 · Input: 80.1K · Output: 7.3K · Cached: 364.5K

Review guidance: REVIEW.md from base branch main

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
marius-kilocode enabled auto-merge July 1, 2026 10:52
@marius-kilocode
marius-kilocode merged commit 434e410 into main Jul 1, 2026
20 checks passed
@marius-kilocode
marius-kilocode deleted the fix/agent-manager-session-switch-offline branch July 1, 2026 10:55
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants