fix(cli): read allow-everything state from config instead of local KV store

The ctrl+p auto-approve toggle was tracking state in a local KV file
that was never initialized from the actual config, causing the label
to be out of sync. Now reads directly from sync.data.config.permission
and listens for global.config.updated SSE events to stay reactive.
This commit is contained in:
Alex Alecu
2026-04-07 12:15:55 +03:00
parent 4365364979
commit 99da10cba3
2 changed files with 25 additions and 6 deletions
+16 -6
View File
@@ -48,6 +48,16 @@ import { initializeTUIDependencies } from "@kilocode/kilo-gateway/tui" // kiloco
import { TuiConfigProvider } from "./context/tui-config"
import { TuiConfig } from "@/config/tui"
// kilocode_change start
function isAllowEverything(permission: unknown): boolean {
if (typeof permission !== "object" || permission === null) return false
const wildcard = (permission as Record<string, unknown>)["*"]
if (typeof wildcard === "string") return wildcard === "allow"
if (typeof wildcard === "object" && wildcard !== null) return (wildcard as Record<string, unknown>)["*"] === "allow"
return false
}
// kilocode_change end
async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
// can't set raw mode if not a TTY
if (!process.stdin.isTTY) return "dark"
@@ -711,21 +721,21 @@ function App() {
},
// kilocode_change start
{
title: kv.get("allow_everything_global") ? "Disable auto-approve mode" : "Enable auto-approve mode",
get title() {
return isAllowEverything(sync.data.config.permission) ? "Disable auto-approve mode" : "Enable auto-approve mode"
},
value: "permission.allow_everything",
category: "System",
onSelect: async (dialog) => {
const enabled = kv.get("allow_everything_global")
const next = !enabled
const result = await sdk.client.permission.allowEverything({ enable: next })
const enabled = isAllowEverything(sync.data.config.permission)
const result = await sdk.client.permission.allowEverything({ enable: !enabled })
if (result.error) {
toast.show({
variant: "error",
message: `Failed to ${next ? "enable" : "disable"} auto-approve mode`,
message: `Failed to ${!enabled ? "enable" : "disable"} auto-approve mode`,
})
return
}
kv.set("allow_everything_global", next)
dialog.clear()
},
},
@@ -390,6 +390,15 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
setStore("vcs", { branch: event.properties.branch })
break
}
// kilocode_change start
case "global.config.updated": {
sdk.client.config.get().then((x) => {
if (x.data) setStore("config", reconcile(x.data))
})
break
}
// kilocode_change end
}
})