refactor(vscode): simplify speech state lookups

This commit is contained in:
marius-kilocode
2026-06-16 14:11:36 +02:00
parent 2fa0890928
commit e50bb7d1d3
3 changed files with 15 additions and 9 deletions
+4 -7
View File
@@ -59,13 +59,10 @@ export async function fetchProviderData(client: KiloClient, dir: string) {
.then((r) => r.data ?? {})
.catch(() => ({}))
: Promise.resolve({})
const kiloRequest =
typeof client.kilo?.authStatus === "function"
? client.kilo
.authStatus({ directory: dir }, { throwOnError: true })
.then((r) => (r.data?.authenticated ? (r.data.type ?? null) : null))
.catch(() => null)
: Promise.resolve(null)
const kiloRequest = client.kilo
.authStatus({ directory: dir }, { throwOnError: true })
.then((r) => (r.data?.authenticated ? (r.data.type ?? null) : null))
.catch(() => null)
const [{ data: response }, authMethods, kiloAuth] = await Promise.all([
client.provider.list({ directory: dir }, { throwOnError: true }),
@@ -54,6 +54,9 @@ function createCtx(existing: ExistingGlobal = { disabled_providers: [] }, merged
}),
auth: async () => ({ data: {} }),
},
kilo: {
authStatus: async () => ({ data: { authenticated: false } }),
},
global: {
config: {
get: async () => ({ data: existing }),
@@ -435,6 +438,9 @@ describe("fetchProviderData", () => {
}),
auth: async () => ({ data: {} }),
},
kilo: {
authStatus: async () => ({ data: { authenticated: false } }),
},
} as unknown as Parameters<typeof fetchProviderData>[0]
const result = await fetchProviderData(client, "/tmp")
@@ -518,6 +524,9 @@ describe("fetchProviderData", () => {
}),
auth: async () => ({ data: {} }),
},
kilo: {
authStatus: async () => ({ data: { authenticated: false } }),
},
} as unknown as Parameters<typeof fetchProviderData>[0]
const result = await fetchProviderData(client, "/tmp")
@@ -43,8 +43,8 @@ const ModelsTab: Component = () => {
const subagentModel = createMemo(() => parseModelString(config().subagent_model ?? undefined))
const speechModel = createMemo(() => selectedSpeechToTextModel(config()))
const speechOption = createMemo(
() => SPEECH_TO_TEXT_MODEL_OPTIONS.find((item) => item.value === speechModel()) ?? SPEECH_TO_TEXT_MODEL_OPTIONS[0],
const speechOption = createMemo(() =>
SPEECH_TO_TEXT_MODEL_OPTIONS.find((item) => item.value === speechModel()),
)
const kiloReady = createMemo(() => hasSpeechToTextAccess(config(), provider.authStates()))
const variantKey = createMemo(() => config().subagent_model ?? undefined)