Skip to content

feat(agent-manager): add sandbox toggle to new worktree modal - #11689

Merged
marius-kilocode merged 6 commits into
mainfrom
feat/agent-manager-worktree-sandbox
Jun 26, 2026
Merged

feat(agent-manager): add sandbox toggle to new worktree modal#11689
marius-kilocode merged 6 commits into
mainfrom
feat/agent-manager-worktree-sandbox

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

The Agent Manager New Worktree modal cannot choose sandbox isolation before creating a session. Users must currently wait for each worktree session to appear and toggle sandbox afterward, which is especially cumbersome for multi-version worktrees.

This adds the same shared sandbox lock button used by the chat prompt to the New Worktree modal. The control is available in single-version and compare-models modes, requires both sandbox-control availability and the experimental.sandbox opt-in, and sends the selected state with the worktree creation request.

Because session.create has no sandbox parameter, Agent Manager reconciles the effective state immediately after creating each session and before registering it, marking the worktree ready, or sending its initial prompt. Reconciliation verifies the routed directory and final state, toggling only when needed. If sandbox setup cannot be confirmed, that version fails closed: Agent Manager reports the setup error, deletes the fresh session and worktree, and never sends the initial prompt under the wrong policy.

file-f548d7a9d5faa18f5b83df0265be7313

Let users choose whether a worktree session starts in the sandbox from the
Agent Manager New Worktree modal. The lock button mirrors the sidebar prompt
sandbox toggle and is gated by the same features().sandboxControls flag.

The CLI session.create endpoint exposes no sandbox parameter, so after each
worktree session is created the provider reconciles its sandbox override to
the user's choice via sandbox.status then sandbox.toggle (toggling only when
the current state differs, so it is safe regardless of the global default).
Sandbox setup is best-effort: failures are logged and the worktree stays
usable with manual toggle available from the prompt.

Visibility is forward-compatible with the sandbox experiment exposure work:
the button is hidden until sandboxControls is available, so it requires no
change to appear once that lands.
… modal

Extract the sandbox lock toggle into a shared SandboxButtonBase component so the
chat prompt and the Agent Manager New Worktree modal render the exact same
control instead of duplicating the markup. The base accepts enabled/availability/
reason/disabled/onToggle props; the prompt wires live session sandbox state and
the modal wires a local preference, but both surface identical visuals (lock
icon, prompt-status-button active styling, tooltip, aria).
Comment thread packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (7 files)
  • packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts
  • packages/kilo-vscode/tests/unit/prompt-input-connection-guard.test.ts
  • packages/kilo-vscode/tests/unit/sandbox-bootstrap.test.ts
  • packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
  • packages/kilo-vscode/webview-ui/src/components/shared/SandboxButton.tsx
  • packages/kilo-vscode/webview-ui/src/stories/prompt-input.stories.tsx
Previous Review Summaries (2 snapshots, latest commit 26ea495)

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

Previous review (commit 26ea495)

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/src/agent-manager/AgentManagerProvider.ts 870 Sandbox setup rollback removes the worktree but leaves the newly created branch behind, so repeated failures can accumulate orphan local branches.

Fix these issues in Kilo Cloud

Files Reviewed (6 files)
  • packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts - 1 issue
  • packages/kilo-vscode/src/agent-manager/sandbox-bootstrap.ts - 0 issues
  • packages/kilo-vscode/tests/unit/prompt-input-connection-guard.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/sandbox-bootstrap.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/shared/SandboxButton.tsx - 0 issues

Previous review (commit 3a072e9)

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/src/agent-manager/AgentManagerProvider.ts 1292 Worktree is marked ready before sandbox reconciliation finishes, so the first manual prompt can still race outside the requested sandbox.

Fix these issues in Kilo Cloud

Files Reviewed (8 files)
  • .changeset/agent-manager-worktree-sandbox.md - 0 issues
  • packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts - 1 issue
  • packages/kilo-vscode/src/agent-manager/sandbox-bootstrap.ts - 0 issues
  • packages/kilo-vscode/src/agent-manager/types.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/shared/SandboxButton.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/types/messages/webview-messages.ts - 0 issues

Reviewed by gpt-5.4-20260305 · Input: 153.2K · Output: 15.8K · Cached: 1M

Review guidance: REVIEW.md from base branch main

Require the sandbox experiment for the New Worktree control and omit the request field when the experiment is unavailable. Verify the selected sandbox state and routed directory before exposing each new session. If reconciliation fails, report the setup error, delete the fresh session and worktree, and skip the initial prompt so execution cannot continue unrestricted. Add SDK-backed reconciliation tests and update the shared prompt button contract test.
Comment thread packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts Outdated
…rktree-sandbox

# Conflicts:
#	packages/kilo-vscode/tests/unit/prompt-input-connection-guard.test.ts
#	packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
…rktree-sandbox

# Conflicts:
#	packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
Place the New Worktree sandbox toggle in the right-aligned action group beside speech-to-text instead of grouping it with mode, model, and thinking selectors. Add a structural regression assertion for the action placement.
@marius-kilocode
marius-kilocode merged commit fe6f857 into main Jun 26, 2026
25 of 26 checks passed
@marius-kilocode
marius-kilocode deleted the feat/agent-manager-worktree-sandbox branch June 26, 2026 11:43
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…rktree-sandbox

feat(agent-manager): add sandbox toggle to new worktree modal
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