Skip to content

fix(vscode): stabilize sandbox button across session switches - #11770

Merged
marius-kilocode merged 1 commit into
mainfrom
ludicrous-circus
Jun 29, 2026
Merged

fix(vscode): stabilize sandbox button across session switches#11770
marius-kilocode merged 1 commit into
mainfrom
ludicrous-circus

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

The session sandbox toggle in the VS Code chat composer had two remaining rough edges after the initial sandbox controls landed.

When switching between worktrees or sessions, the lock button briefly reset to an unknown/inactive state and then snapped back once the backend status arrived, producing a visible flicker on every switch. The webview only held a single sandbox status, so any session change discarded the previously fetched state and re-rendered the button as "not ready" while the new request was in flight.

Separately, toggling the sandbox while composing the very first message reset the prompt's scroll position. Toggling before a session exists recreates the draft scope, and the textarea scroll offset was not part of the carried-over draft, so a long prompt jumped back to the top. The intent is for sandbox toggling to be invisible to the user: the draft, attachments, and scroll position should stay exactly where they were.

This change makes the sandbox state per session. Each session's status is cached and keyed by session id, so revisiting a session renders its last known state immediately with no flicker, while still honoring backend version/revision ordering. In-flight toggle requests are tracked per session rather than globally, so rapid back-and-forth switching during a pending toggle can no longer strand a button as disabled, and a late response for an inactive session can no longer cancel the active session's retry. The prompt scroll offset is now captured and restored alongside text, review comments, and image attachments, including when an initial draft is promoted to a newly created session and when Agent Manager carries a draft into a worktree session.

Disabling or enabling the sandbox mid-stream is unchanged and intentionally does not abort or restart the active turn: a tool already executing finishes under the policy it started with, and only subsequently started tool/MCP calls observe the new policy.

Cache sandbox status per session so switching worktrees or sessions shows the known state immediately instead of flickering, track in-flight toggles per session, and preserve the prompt textarea scroll position when toggling sandbox before the first message.
Comment thread packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
@kilo-code-bot

kilo-code-bot Bot commented Jun 29, 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/components/chat/PromptInput.tsx 167 Per-session sandbox cache is never pruned, so deleted or abandoned sessions accumulate retained state for the lifetime of the connected webview.

Fix these issues in Kilo Cloud

Files Reviewed (7 files)
  • .changeset/keep-sandbox-toggle-drafts.md - 0 issues
  • packages/kilo-vscode/tests/unit/prompt-drafts.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/prompt-input-connection-guard.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/prompt-input-utils.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/components/chat/prompt-input-utils.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/utils/prompt-drafts.ts - 0 issues

Reviewed by gpt-5.4-20260305 · Input: 93.6K · Output: 16.5K · Cached: 993.8K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 0a69b89 into main Jun 29, 2026
21 checks passed
@marius-kilocode
marius-kilocode deleted the ludicrous-circus branch June 29, 2026 09:18
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
fix(vscode): stabilize sandbox button across session switches
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