Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(settings): hide the Live calls key hit while Live uses Azure or Fish Audio

Nathaniel1161e25221a1
diff --git a/src/components/keys/KeysPage.tsx b/src/components/keys/KeysPage.tsx
index 27f700ffa7..eed5f5a8fc 100644
--- a/src/components/keys/KeysPage.tsx
+++ b/src/components/keys/KeysPage.tsx
@@ -10,7 +10,7 @@ import { LiveProviderSettings } from "../LiveProviderSettings";
import { VoiceEveryReplySetting } from "../VoiceEveryReplySetting";
import { BuiltInReplyWait, LmStudioServer, OtherOpenAiCompatServers } from "../OpenAiCompatServers";
import { OllamaServer } from "../OllamaServer";
-import { KEY_CATALOG, KEY_SECTIONS, keyMatches, savedState, type KeyEntry, type KeyId, type KeySectionId } from "./key-catalog";
+import { KEY_CATALOG, KEY_SECTIONS, keyHidden, keyMatches, savedState, type KeyEntry, type KeyId, type KeySectionId } from "./key-catalog";
import { finishKeyFocus, useKeyFocus, type KeyFocusRequest } from "./key-focus";
import { AnthropicEveryClaudeBot, OpenAiCompatUrl, OpenCodeProviderKeys, VpsConnection } from "./KeyPanels";
import { KEY_CONTENT, KEY_ROW, KeyRow, MaskedKey, RowHeading, type KeyStatus } from "./KeyRow";
@@ -152,9 +152,7 @@ export function KeysPage({ bare = false, exclude = [] }: { bare?: boolean; exclu
return () => window.cancelAnimationFrame(frame);
}, [focus]);
- // With Azure or Fish Audio chosen, Live calls do not use the OpenAI key that row points at.
- const azureLive = state.config?.live?.provider === "azure" || state.config?.live?.provider === "fish";
- const rows = KEY_CATALOG.filter((entry) => keyMatches(entry, q, state.config) && !(azureLive && entry.id === "liveCalls"));
+ const rows = KEY_CATALOG.filter((entry) => keyMatches(entry, q, state.config) && !keyHidden(entry.id, state.config));
const asked = focus ? KEY_CATALOG.find((entry) => entry.id === focus.row)?.section : undefined;
const sections = KEY_SECTIONS.filter((section) => !exclude.includes(section.id) || section.id === asked).flatMap((section) => {
const own = rows.filter((entry) => entry.section === section.id);
diff --git a/src/components/keys/key-catalog.test.ts b/src/components/keys/key-catalog.test.ts
index 0dc052051c..3606505609 100644
--- a/src/components/keys/key-catalog.test.ts
+++ b/src/components/keys/key-catalog.test.ts
@@ -4,7 +4,7 @@ import { setLocale, t } from "@/lib/i18n";
import type { ConfigStatus } from "@/state/store";
import { WORKSPACE_CREDENTIAL_ENV } from "../../../server/credential-env.ts";
import { CREDENTIAL_TARGETS, credentialConfigPatch, desktopCredentialSlot, isConfigCredentialTarget } from "../../../shared/credential-request";
-import { KEY_CATALOG, KEY_SECTIONS, keyEntry, keyForInstance, keyMatches, looksLikeOtherKey, savedState, type KeyId } from "./key-catalog";
+import { KEY_CATALOG, KEY_SECTIONS, keyEntry, keyForInstance, keyHidden, keyMatches, looksLikeOtherKey, savedState, type KeyId } from "./key-catalog";
const NOT_A_PERSONS_KEY: Record<string, string> = {
OMB_ANTHROPIC_API_URL: "the address the Anthropic key goes to, set by a hosted install",
@@ -119,6 +119,14 @@ describe("searching the keys", () => {
expect(shown("azure", "azure")).toContain("liveKey");
expect(found("fish")).not.toContain("liveKey");
});
+
+ it("hides the Live calls row while Live calls use Azure or Fish Audio", () => {
+ expect(keyHidden("liveCalls", { live: { provider: "fish" } } as never)).toBe(true);
+ expect(keyHidden("liveCalls", { live: { provider: "azure" } } as never)).toBe(true);
+ expect(keyHidden("liveCalls", { live: { provider: "openai" } } as never)).toBe(false);
+ expect(keyHidden("liveCalls", null)).toBe(false);
+ expect(keyHidden("liveKey", { live: { provider: "fish" } } as never)).toBe(false);
+ });
});
describe("a key pasted into the wrong row", () => {
diff --git a/src/components/keys/key-catalog.ts b/src/components/keys/key-catalog.ts
index b527924c1e..4e007d623f 100644
--- a/src/components/keys/key-catalog.ts
+++ b/src/components/keys/key-catalog.ts
@@ -239,6 +239,12 @@ export function savedState(entry: KeyEntry, config: ConfigStatus | null | undefi
}
/** With `config`, the row is matched as shown: the Live key row by the provider Live calls use. */
+/** With Azure or Fish Audio chosen, Live calls do not use the OpenAI key the Live calls row points at, so that row is hidden. */
+export function keyHidden(id: KeyId, config: ConfigStatus | null | undefined): boolean {
+ const provider = config?.live?.provider;
+ return id === "liveCalls" && (provider === "azure" || provider === "fish");
+}
+
export function keyMatches(entry: KeyEntry, query: string, config?: ConfigStatus | null): boolean {
const q = query.trim().toLowerCase();
if (!q) return true;
diff --git a/src/components/settings/SettingsWindow.tsx b/src/components/settings/SettingsWindow.tsx
index 4fdf73c775..2f0cd37f04 100644
--- a/src/components/settings/SettingsWindow.tsx
+++ b/src/components/settings/SettingsWindow.tsx
@@ -13,7 +13,7 @@ import { shortcutLabel } from "../ShortcutHint";
import { SettingsLook } from "../SettingsPrimitives";
import { SettingsPageBody } from "./pages/SettingsPageBody";
import { useSwitchToComputer } from "./inert";
-import { KEY_CATALOG, keyMatches, type KeyEntry } from "../keys/key-catalog";
+import { KEY_CATALOG, keyHidden, keyMatches, type KeyEntry } from "../keys/key-catalog";
import { openKeySettings } from "../keys/key-focus";
import { useSettingsContext, useSettingsPlace } from "./settings-context";
import { needsAdvanced, pageById, resolveSettingsTarget, searchSettings, visiblePages, type SearchHit, type SettingsPageId } from "./settings-index";
@@ -80,7 +80,7 @@ export function SettingsWindow() {
const hits = useMemo(() => searchSettings(query, ctx, (entry) => hitLabel({ entry, elsewhere: false, score: 0 }, place, ctx.desktop),
(candidate) => pageLabel(candidate, place, ctx.desktop)), [query, ctx, place]);
- const keyHits = useMemo(() => (ctx.client || !query.trim() ? [] : KEY_CATALOG.filter((entry) => keyMatches(entry, query.trim().toLowerCase(), state.config)).slice(0, 8)), [ctx.client, query, state.config]);
+ const keyHits = useMemo(() => (ctx.client || !query.trim() ? [] : KEY_CATALOG.filter((entry) => !keyHidden(entry.id, state.config) && keyMatches(entry, query.trim().toLowerCase(), state.config)).slice(0, 8)), [ctx.client, query, state.config]);
const openKey = (entry: KeyEntry) => { setQuery(""); setNarrowPage(true); dispatch(entry.uses ? openKeySettings(entry.uses, entry.id) : openKeySettings(entry.id)); };
const computer = useSwitchToComputer();
const close = () => dispatch({ type: "toggleAppSettings", open: false });