mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 11:05:31 +08:00
refactor(vscode): gate sandbox controls for developers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { hasIndexingPlugin } from "@kilocode/kilo-indexing/detect"
|
||||
import * as vscode from "vscode"
|
||||
|
||||
type PluginSpec = string | [string, Record<string, unknown>]
|
||||
|
||||
@@ -8,10 +9,12 @@ type ConfigLike = {
|
||||
|
||||
export type Features = {
|
||||
indexing: boolean
|
||||
sandboxControls: boolean
|
||||
}
|
||||
|
||||
export function configFeatures(config?: ConfigLike | null): Features {
|
||||
return {
|
||||
indexing: hasIndexingPlugin(config?.plugin ?? []),
|
||||
sandboxControls: vscode.workspace.getConfiguration("kilo-code.new.internal").get("sandboxControls", false),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1065,30 +1065,32 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
||||
<Icon name="shield" size="small" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
value={
|
||||
sandbox() ? language.t("prompt.action.sandbox.enabled") : language.t("prompt.action.sandbox.disabled")
|
||||
}
|
||||
placement="top"
|
||||
>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
updateConfig({
|
||||
experimental: { ...config().experimental, sandbox: !sandbox() },
|
||||
})
|
||||
saveConfig()
|
||||
}}
|
||||
aria-label={
|
||||
sandbox() ? language.t("prompt.action.sandbox.disable") : language.t("prompt.action.sandbox.enable")
|
||||
<Show when={features().sandboxControls}>
|
||||
<Tooltip
|
||||
value={
|
||||
sandbox() ? language.t("prompt.action.sandbox.enabled") : language.t("prompt.action.sandbox.disabled")
|
||||
}
|
||||
aria-pressed={sandbox()}
|
||||
class={`prompt-status-button ${sandbox() ? "prompt-status-button--active" : ""}`}
|
||||
placement="top"
|
||||
>
|
||||
<Icon name="lock" size="small" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
updateConfig({
|
||||
experimental: { ...config().experimental, sandbox: !sandbox() },
|
||||
})
|
||||
saveConfig()
|
||||
}}
|
||||
aria-label={
|
||||
sandbox() ? language.t("prompt.action.sandbox.disable") : language.t("prompt.action.sandbox.enable")
|
||||
}
|
||||
aria-pressed={sandbox()}
|
||||
class={`prompt-status-button ${sandbox() ? "prompt-status-button--active" : ""}`}
|
||||
>
|
||||
<Icon name="lock" size="small" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Show>
|
||||
<Tooltip value={language.t("prompt.action.enhance")} placement="top">
|
||||
<Button
|
||||
variant="ghost"
|
||||
|
||||
@@ -21,7 +21,7 @@ const SHARE_OPTIONS: ShareOption[] = [
|
||||
]
|
||||
|
||||
const ExperimentalTab: Component = () => {
|
||||
const { config, updateConfig } = useConfig()
|
||||
const { config, features, updateConfig } = useConfig()
|
||||
const language = useLanguage()
|
||||
const vscode = useVSCode()
|
||||
const [active, setActive] = createSignal(false)
|
||||
@@ -171,6 +171,7 @@ const ExperimentalTab: Component = () => {
|
||||
<SettingsRow
|
||||
title={language.t("settings.experimental.mcpTimeout.title")}
|
||||
description={language.t("settings.experimental.mcpTimeout.description")}
|
||||
last={!features().sandboxControls}
|
||||
>
|
||||
<TextField
|
||||
value={String(experimental().mcp_timeout ?? 60000)}
|
||||
@@ -183,19 +184,21 @@ const ExperimentalTab: Component = () => {
|
||||
/>
|
||||
</SettingsRow>
|
||||
|
||||
<SettingsRow
|
||||
title={language.t("settings.experimental.sandbox.title")}
|
||||
description={language.t("settings.experimental.sandbox.description")}
|
||||
last
|
||||
>
|
||||
<Switch
|
||||
checked={experimental().sandbox ?? false}
|
||||
onChange={(checked) => updateExperimental("sandbox", checked)}
|
||||
hideLabel
|
||||
<Show when={features().sandboxControls}>
|
||||
<SettingsRow
|
||||
title={language.t("settings.experimental.sandbox.title")}
|
||||
description={language.t("settings.experimental.sandbox.description")}
|
||||
last
|
||||
>
|
||||
{language.t("settings.experimental.sandbox.title")}
|
||||
</Switch>
|
||||
</SettingsRow>
|
||||
<Switch
|
||||
checked={experimental().sandbox ?? false}
|
||||
onChange={(checked) => updateExperimental("sandbox", checked)}
|
||||
hideLabel
|
||||
>
|
||||
{language.t("settings.experimental.sandbox.title")}
|
||||
</Switch>
|
||||
</SettingsRow>
|
||||
</Show>
|
||||
</Card>
|
||||
|
||||
{/* Tool toggles */}
|
||||
|
||||
@@ -58,7 +58,7 @@ export const ConfigProvider: ParentComponent = (props) => {
|
||||
const [globalConfig, setGlobalConfig] = createSignal<Config>({})
|
||||
const [projectConfig, setProjectConfig] = createSignal<Config>({})
|
||||
const [settings, setSettings] = createSignal<Record<string, unknown>>({})
|
||||
const [features, setFeatures] = createSignal<FeatureFlags>({ indexing: false })
|
||||
const [features, setFeatures] = createSignal<FeatureFlags>({ indexing: false, sandboxControls: false })
|
||||
const [loading, setLoading] = createSignal(true)
|
||||
const [draft, setDraft] = createSignal<Partial<Config>>({})
|
||||
const [globalDraft, setGlobalDraft] = createSignal<Partial<Config>>({})
|
||||
|
||||
@@ -315,6 +315,7 @@ const ConfigWrapper: ParentComponent<{
|
||||
|
||||
return {
|
||||
indexing: hasIndexingPlugin(config.plugin ?? []),
|
||||
sandboxControls: false,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -148,4 +148,5 @@ export interface Config {
|
||||
|
||||
export interface FeatureFlags {
|
||||
indexing: boolean
|
||||
sandboxControls: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user