mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
fix(vscode): gate sandbox controls on setting
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"kilo-code": patch
|
||||
---
|
||||
|
||||
Show sandbox controls only after sandboxing is enabled in settings.
|
||||
@@ -18,7 +18,10 @@ describe("NewWorktreeDialog sandbox toggle", () => {
|
||||
'vscode.postMessage({ type: "setSandboxDefault", enabled: next, requestID: sandboxRequestID })',
|
||||
)
|
||||
expect(src).toContain("sandbox: sandboxVisible() ? sandboxOverride() : undefined")
|
||||
expect(src).toContain("const sandboxVisible = () => features().sandboxControls")
|
||||
expect(src).toContain("const { config, globalConfig, features } = useConfig()")
|
||||
expect(src).toContain(
|
||||
"const sandboxVisible = () => features().sandboxControls && globalConfig().sandbox?.enabled === true",
|
||||
)
|
||||
expect(provider).toContain("await this.fetchAndSendSandboxDefault(message.contextDirectory, message.requestID)")
|
||||
expect(src).not.toContain("createSignal(config().sandbox?.enabled === true)")
|
||||
expect(src).not.toContain("visible as isSandboxVisible")
|
||||
|
||||
@@ -81,11 +81,11 @@ describe("PromptInput sandbox toggle", () => {
|
||||
expect(src).not.toContain("setSandboxTarget")
|
||||
})
|
||||
|
||||
it("keeps persisted sandbox state visible independently of the configured default", () => {
|
||||
it("shows sandbox controls only when the global sandbox setting is enabled", () => {
|
||||
expect(src).toContain(
|
||||
'const sandboxVisible = () => features().sandboxControls && !session.currentSessionID()?.startsWith("cloud:")',
|
||||
'globalConfig().sandbox?.enabled === true &&\n !session.currentSessionID()?.startsWith("cloud:")',
|
||||
)
|
||||
expect(src).not.toContain("config().sandbox?.enabled === true")
|
||||
expect(src).toContain("features().sandboxControls &&")
|
||||
expect(src).toContain("<Show when={sandboxVisible()}>")
|
||||
expect(src).toContain("{ action: toggleSandbox, enabled: () => sandboxVisible() && !sandboxDisabled() }")
|
||||
expect(src).toContain('if (!sandboxVisible()) hidden.add("sandbox")')
|
||||
|
||||
@@ -124,7 +124,9 @@ describe("Agent Manager sandbox startup", () => {
|
||||
})
|
||||
|
||||
test("uses the persisted sandbox default for UI and only sends explicit overrides", () => {
|
||||
expect(dialog).toContain("const sandboxVisible = () => features().sandboxControls")
|
||||
expect(dialog).toContain(
|
||||
"const sandboxVisible = () => features().sandboxControls && globalConfig().sandbox?.enabled === true",
|
||||
)
|
||||
expect(dialog).toContain('vscode.postMessage({ type: "requestSandboxDefault", requestID: sandboxRequestID })')
|
||||
expect(dialog).toContain(
|
||||
'vscode.postMessage({ type: "setSandboxDefault", enabled: next, requestID: sandboxRequestID })',
|
||||
|
||||
@@ -72,7 +72,7 @@ export const NewWorktreeDialog: Component<{ onClose: () => void; defaultBaseBran
|
||||
const server = useServer()
|
||||
const session = useSession()
|
||||
const provider = useProvider()
|
||||
const { config, features } = useConfig()
|
||||
const { config, globalConfig, features } = useConfig()
|
||||
const metrics = tracker(vscode)
|
||||
const track = (button: string, properties?: Record<string, string | number | boolean | undefined>) =>
|
||||
metrics.track(button, "configure_worktree_dialog", properties)
|
||||
@@ -110,7 +110,7 @@ export const NewWorktreeDialog: Component<{ onClose: () => void; defaultBaseBran
|
||||
const [sandboxReason, setSandboxReason] = createSignal<string | undefined>()
|
||||
const [sandboxRevision, setSandboxRevision] = createSignal(-1)
|
||||
const sandboxRequestID = crypto.randomUUID()
|
||||
const sandboxVisible = () => features().sandboxControls
|
||||
const sandboxVisible = () => features().sandboxControls && globalConfig().sandbox?.enabled === true
|
||||
const speech = useSpeechToText(vscode, server, { t })
|
||||
const canUseSpeech = () => canUseSpeechToText(config(), provider.authStates())
|
||||
const speechModel = () => selectedSpeechToTextModel(config())
|
||||
|
||||
@@ -174,7 +174,10 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
||||
const id = session.currentSessionID()
|
||||
return id?.startsWith("cloud:") ? undefined : id
|
||||
}
|
||||
const sandboxVisible = () => features().sandboxControls && !session.currentSessionID()?.startsWith("cloud:")
|
||||
const sandboxVisible = () =>
|
||||
features().sandboxControls &&
|
||||
globalConfig().sandbox?.enabled === true &&
|
||||
!session.currentSessionID()?.startsWith("cloud:")
|
||||
const sandbox = () => {
|
||||
const id = sandboxID()
|
||||
return id ? sandboxes()[id] : undefined
|
||||
|
||||
Reference in New Issue
Block a user