fix(vscode): stabilize sandbox button across session switches - #11770
Merged
Conversation
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.
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Files Reviewed (7 files)
Reviewed by gpt-5.4-20260305 · Input: 93.6K · Output: 16.5K · Cached: 993.8K Review guidance: REVIEW.md from base branch |
chrarnoldus
approved these changes
Jun 29, 2026
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
fix(vscode): stabilize sandbox button across session switches
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.
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.