Skip to content

feat(vscode): add experimental hosted cloud sessions - #15436

Open
kirillk wants to merge 3 commits into
mainfrom
feat/hosted-sessions-vscode
Open

kirillk wants to merge 3 commits into
mainfrom
feat/hosted-sessions-vscode

Conversation

@kirillk

@kirillk kirillk commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Task Board

Part of the Kilo Task Board: https://github.com/Kilo-Org/kilo-taskboard/issues/6

Problem

The CLI now exposes a provider-neutral session-host surface for Kilo Cloud hosted sessions, but VS Code had no way to discover, start, or work with them. Any future attempt to add one by talking to Cloud directly would duplicate transport and auth, bypass local routing, and risk mixing a provider's native session ids with local ids.

What changed

Adds an experimental hosted-session experience to the VS Code extension, gated by kilo-code.new.experimental.hostedSessions.

  • Hosted core (src/hosted/): namespaced host:<provider>:<session> view keys, a per-provider attachment registry that coalesces attaches, one-shot re-attach on recoverable attachment failures, and fence/resnapshot-aware stream framing.
  • Control plane: provider availability and session discovery through sessionHost.providers/sessionHost.list, a start flow that always sends an operation key plus message id for retry safety, and durable open through sessionHost.get/sessionHost.transcript.
  • Durable vs live: opening a session reads stored history only and never attaches or subscribes, so a stopped session is not woken. Live work attaches lazily, subscribes to the route-scoped native event stream, and re-snapshots transcript, status, questions, and permissions when continuity cannot be proven.
  • Existing surfaces: hosted sessions reuse the current transcript renderer and session store under the namespaced key. Prompts, abort, question answers, and permission replies route through the local backend with the attachment selector. Local-only actions (Continue in Worktree) and the single-message diff read are suppressed for hosted sessions.
  • Identity safety: hosted keys are distinct from local ids and from the legacy cloud: import preview, so colliding native ids from different providers cannot cross-route tabs, events, or answers.
  • UI: a Hosted tab in History lists sessions, shows provider availability/transport separately from turn state, and offers a start dialog. Availability failures surface with a sign-in path instead of a local fallback.

Verification

From packages/kilo-vscode/:

  • bun run typecheck — passed
  • bun run lint — passed
  • bun run compile — passed
  • bun run knip — passed
  • bun run check-kilocode-change — passed
  • bun test tests/unit/hosted-identity.test.ts tests/unit/hosted-core.test.ts tests/unit/hosted-service.test.ts — 18 passed
  • bun run test:unit — 6982 passed, 2 failed. Both failures are in tests/unit/worktree-pool.test.ts (git/worktree timing under the sandbox) and reproduce when that file runs alone; it imports only WorktreeManager, which this PR does not touch.

New tests cover: key parsing and provider collisions, attachment coalescing and invalidation, Error.cause failure parsing, resnapshot/fence classification, retagging, durable open issuing zero attach/event calls, prompt routing through the attachment selector, one-shot re-attach on a recoverable failure, no retry on an unrecoverable one, and start idempotency fields.

The end-to-end Cloud behavior matrix requires a signed-in account against deployed Cloud M1 and was not exercised here.

Scope

Confined to packages/kilo-vscode/ plus a changeset. No CLI or Cloud changes.

Discover, open, start, and interact with Kilo Cloud hosted sessions
through the local Kilo backend instead of talking to Cloud directly.

Hosted sessions use a namespaced host:<provider>:<session> key and one
attachment registry, so colliding native session ids never cross-route.
Durable reads use the session-host transcript surface and never attach,
while live work attaches lazily, retries once on a recoverable attachment
failure, and re-snapshots when continuity cannot be proven. The feature is
gated by kilo-code.new.experimental.hostedSessions.
@github-actions github-actions Bot added the area:vscode VS Code extension label Oct 23, 2026
Comment thread packages/kilo-vscode/webview-ui/src/context/session.tsx
Comment thread packages/kilo-vscode/webview-ui/src/components/history/HistoryView.tsx Outdated
Comment thread packages/kilo-vscode/src/KiloProvider.ts
Comment thread packages/kilo-vscode/src/hosted/registry.ts
Comment thread packages/kilo-vscode/webview-ui/src/context/hosted-session-bridge.ts Outdated
Comment thread packages/kilo-vscode/tests/unit/hosted-service.test.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/src/context/local-tabs.tsx 194 fresh.add(id) only covers tabs opened in the current webview context. Hosted tabs restored from persisted state are not re-seeded into fresh, so the next complete sessionsLoaded still drops the tab and switches the active session
Files Reviewed (3 files)
  • packages/kilo-vscode/tests/unit/hosted-wiring.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/history/HostedSessionList.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/context/local-tabs.tsx - 1 issue

Fix these issues in Kilo Cloud

Previous Review Summaries (2 snapshots, latest commit cc12454)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit cc12454)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/src/context/local-tabs.tsx 192 openHosted does not add the host: key to fresh, so the next complete sessionsLoaded reconciliation drops the hosted tab, switches the active session, and releases its stream/attachment

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/src/components/history/HostedSessionList.tsx 56 The shared error signal is written by both the provider and session responses, so a provider failure can still be cleared by a successful session list read
Files Reviewed (11 files)
  • packages/kilo-vscode/src/KiloProvider.ts - 0 issues
  • packages/kilo-vscode/src/hosted/registry.ts - 0 issues
  • packages/kilo-vscode/src/hosted/service.ts - 0 issues
  • packages/kilo-vscode/tests/unit/hosted-service.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/hosted-session-bridge.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/hosted-wiring.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/history/HistoryView.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/history/HostedSessionList.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/context/hosted-session-bridge.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/context/local-tabs.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/context/session.tsx - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 8bab99c)

Status: 7 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 4
SUGGESTION 2
Issue Details (click to expand)

CRITICAL

File Line Issue
packages/kilo-vscode/webview-ui/src/context/session.tsx 2677 selectHostedSession leaves a stale cloudPreviewId; the next prompt is routed as importAndSend to the previously previewed cloud session instead of the hosted key

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/src/components/history/HistoryView.tsx 176 Hosted tabpanel is nested inside the history-view-tabs row (and inside role="tablist"), so the list renders inside the header
packages/kilo-vscode/src/KiloProvider.ts 5362 Hosted subscriptions are never released (no sender for hostedDetachSession), leaking one live/reconnecting SSE stream per opened hosted session
packages/kilo-vscode/src/hosted/registry.ts 76 In-flight attachment minted after invalidation is rejected without port.detach, leaking a provider attachment
packages/kilo-vscode/webview-ui/src/context/hosted-session-bridge.ts 45 Late hostedSessionLoaded unconditionally replaces the current session and clears loading, unlike the local handler

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/src/components/history/HostedSessionList.tsx 50 Provider/session discovery error fields are ignored; failures look like an empty account
packages/kilo-vscode/tests/unit/hosted-service.test.ts 234 Stub returns the same attachment id for both providers, so the test cannot prove attachment isolation
Files Reviewed (52 files)
  • .changeset/hosted-sessions-vscode.md - 0 issues
  • packages/kilo-vscode/package.json - 0 issues
  • packages/kilo-vscode/src/KiloProvider.ts - 1 issue
  • packages/kilo-vscode/src/diff/sources/catalog.ts - 0 issues
  • packages/kilo-vscode/src/hosted/events.ts - 0 issues
  • packages/kilo-vscode/src/hosted/failure.ts - 0 issues
  • packages/kilo-vscode/src/hosted/identity.ts - 0 issues
  • packages/kilo-vscode/src/hosted/registry.ts - 1 issue
  • packages/kilo-vscode/src/hosted/service.ts - 0 issues
  • packages/kilo-vscode/src/kilo-provider/chat-settings.ts - 0 issues
  • packages/kilo-vscode/src/kilo-provider/handlers/hosted.ts - 0 issues
  • packages/kilo-vscode/src/services/cli-backend/connection-service.ts - 0 issues
  • packages/kilo-vscode/tests/unit/chat-settings-message.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/hosted-core.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/hosted-identity.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/hosted-service.test.ts - 1 issue
  • packages/kilo-vscode/tests/unit/prompt-send-contract.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/App.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/history/HistoryView.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/components/history/HostedSessionList.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/components/history/HostedStartDialog.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/settings/ExperimentalTab.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/context/cloud-session-failure.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/context/config.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/context/hosted-session-bridge.ts - 1 issue
  • packages/kilo-vscode/webview-ui/src/context/session-store.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/context/session-types.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/context/session.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/i18n/ar.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/br.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/da.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/de.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/en.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/es.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/fa.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/fr.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/it.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/ja.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/ko.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/nl.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/no.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/pl.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/ru.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/th.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/tr.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/uk.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/zh.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/zht.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/styles/history.css - 0 issues
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/types/messages/webview-messages.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-flash-latest · Input: 56K · Output: 12K · Cached: 955.4K

Review guidance: REVIEW.md from base branch main

Clear the stale cloud preview when a hosted session is selected so prompts
cannot be routed to a previously previewed cloud session, and keep the
preview fallback off hosted keys entirely.

Move the hosted panel out of the tab list so it renders in the history body,
release hosted subscriptions when a session is no longer open, and detach an
attachment that lost the invalidation race instead of leaking it. A late
hosted load no longer steals focus or clears another session's loading state,
and provider/session discovery errors are surfaced with a retry.
Comment thread packages/kilo-vscode/webview-ui/src/context/local-tabs.tsx
Comment thread packages/kilo-vscode/webview-ui/src/components/history/HostedSessionList.tsx Outdated
Keep opened hosted tabs through local session reconciliation and track provider and session discovery failures independently so one successful response cannot hide the other request's error.
setCloud(undefined)
// Complete local session lists never contain hosted keys. Preserve this
// tab until the user closes it instead of reconciling it away.
fresh.add(id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: This only preserves hosted tabs opened in the current webview context, so a restored hosted tab is still reconciled away.

persist() writes hosted keys into sidebarSessionTabIDs and restoreTabs brings them back on the next webview start (for example after hiding and re-showing the sidebar), but fresh starts empty and nothing re-seeds it for restored ids. The connect effect then calls session.loadSessions() whenever real() is non-empty, and tabsForLoadedSessions keeps only ids present in the response, preserveSessionIds, or fresh. Hosted keys are in none of those, so the restored hosted tab is removed and focus(next.active) switches the user to another session - the same failure this change fixes for freshly opened tabs. Consider seeding fresh from the restored hosted ids (or having reconcileTabs skip host: ids).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:vscode VS Code extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant