refactor(vscode): simplify speech state lookups
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user