fix(vscode): prevent recursive settings saves (#12561)

* fix(vscode): prevent recursive settings saves

* docs: clarify settings save release note
This commit is contained in:
Marius
2026-07-27 15:32:15 +02:00
committed by GitHub
parent 439448291e
commit 44f5963669
4 changed files with 44 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---
Fix settings changes sometimes failing to save and apply in VS Code.
@@ -0,0 +1,4 @@
export function changed<T>(current: T | undefined, next: T | undefined, key: (item: T) => string) {
if (current === undefined || next === undefined) return current !== next
return key(current) !== key(next)
}
@@ -0,0 +1,17 @@
import { describe, expect, test } from "bun:test"
import { changed } from "./select-change"
describe("changed", () => {
const key = (item: { value: string }) => item.value
test("ignores recreated options with the current key", () => {
expect(changed({ value: "ollama" }, { value: "ollama" }, key)).toBe(false)
})
test("reports selected and cleared values", () => {
expect(changed({ value: "ollama" }, { value: "kilo" }, key)).toBe(true)
expect(changed({ value: "ollama" }, undefined, key)).toBe(true)
expect(changed(undefined, { value: "ollama" }, key)).toBe(true)
expect(changed(undefined, undefined, key)).toBe(false)
})
})
@@ -1 +1,19 @@
import { Select as Base, type SelectProps } from "@opencode-ai/ui/select"
import type { ButtonProps } from "@opencode-ai/ui/button"
import { changed } from "./select-change"
export * from "@opencode-ai/ui/select"
export function Select<T>(props: SelectProps<T> & Omit<ButtonProps, "children">) {
const key = (item: T) => (props.value ? props.value(item) : (item as string))
return (
<Base
{...props}
onSelect={(next) => {
if (!changed(props.current, next, key)) return
props.onSelect?.(next)
}}
/>
)
}