feat: report active CLI and VS Code app and session presence#12159
Conversation
|
@eshurakov looks good, can you check if those are relevant? Medium: idle presence sockets remain open indefinitely Medium: closed VS Code tabs leak registration map entries Medium: console presence requests can run on every streaming-message refresh |
|
All three fixed in commit ba6bfb6. 1. Idle presence sockets — Added disconnect when desired.size === 0 in the existing-client path of reconcilePresence(). When all viewers go inactive, the socket is now fully disconnected instead of staying open with pings. 2. Closed tab map leak — dispose() was calling focusSession() which set empty arrays via registerVisible/registerAttached, leaving stale map entries. Replaced with direct unregisterVisible/unregisterAttached calls that delete the entries entirely. 3. Console streaming dedup — sendSnapshot now tracks a lastSentKey (URL + sorted session IDs) and skips the HTTP request when unchanged. Streaming messages that do not alter the projected session set no longer trigger redundant /session/viewed calls. |
Code Review SummaryStatus: 14 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (49 files)
Previous Review Summaries (4 snapshots, latest commit 4324f08)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 4324f08)Status: 14 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (49 files)
Previous review (commit d2f8ffa)Status: 19 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (49 files)
Previous review (commit feb6c58)Status: 16 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (49 files)
Previous review (commit ba6bfb6)Status: 12 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (49 files)
[Snapshot truncated.] Additional previous summary content was truncated to keep this comment within platform limits. Reviewed by gpt-5.6-sol · Input: 137.7K · Output: 7.1K · Cached: 378K Review guidance: REVIEW.md from base branch |
ba6bfb6 to
feb6c58
Compare
feb6c58 to
d2f8ffa
Compare
Replace the focused/open session model with a viewer/attached/visible presence system. The TUI and VS Code extension now report a stable viewer id, active flag, attached (retained) sessions, and the single visible session, surfaced via a new KiloViewers service backed by the extracted event-service client. Invalidates presence on Kilo provider auth changes.
d2f8ffa to
4324f08
Compare
The Agent Manager panel uses retainContextWhenHidden, so closing it keeps the webview alive. Its SolidJS effects kept firing openSessions/visibleSession messages, which AgentManagerVisiblePresence.handle() forwarded directly to registerAttached/registerVisible with no visibility gate — leaving sessions stuck in attached and visible after the panel was closed. flush() now gates both visible and attached on panelVisible(): hidden clears both, visible re-registers from stored state. handle() stores into fields then flushes instead of registering directly. clear() resets stored state.
Replace ad-hoc pendingKeys/lastSentKey dedup with a serialized sender queue that drains snapshots in order, coalesces obsolete pending state, and routes 60s check-in renewals and cleanup through the same path.
Extract the setup overlay into a memo and block visible-session reporting while the overlay or an empty context pane covers chat.
Track concurrent connect ticket fetches in a Set so disconnect aborts every one instead of only the most recent, and skip ticket minting after disposal during token lookup.
What changed
Replaces the old
focused/opensession-viewed model with a viewer/attached/visible presence system:activeflag (window focused/blurred), so the backend can distinguish "session open in a tab" from "session actually being looked at."attached= retained/background sessions (tabs kept open),visible= the single session currently displayed. Replaces the ambiguousfocused/openpair that conflated retention with focus.KiloViewersservice (packages/opencode/src/kilocode/presence/) backed by the extracted event-service client (kilocode/event-service/client.ts, moved out ofclaw/). The service layer owns viewer state and exposesupdate(payload)to thesession.viewedhandler.invalidatePresence()to drop the old user's presence socket before instance disposal.KiloConnectionServicetracks attached/visible viaregisterAttached/registerVisible/setDisplayed, flushes on reconnect and on a 60s check-in timer. Agent Manager reports the actually-displayed session id (null when a terminal/review/pending tab is shown) via a newagentManager.visibleSessionwebview message.server.connectedafter a backend restart.Why
The previous model couldn't tell the cloud "you are actively looking at session X" vs. "session X is open in a background tab" — both looked like
focused. This blocked accurate presence indicators (who's viewing what, is anyone active) and made per-viewer session retention ambiguous. The viewer id + active flag also lets presence survive reconnects and distinguishes multiple clients from the same user.Notes
session.viewednow returns400on malformed payloads (missingviewer, non-UUID id, oversizedattached/visiblearrays) — added validation scenarios to the httpapi exerciser.packages/opencode/.kilo/runtime state was deliberately excluded from the commit.viewer/attached/visiblepayload shape.