Skip to content

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

fix(live): hold Azure endpoint and Fish agent saves while a key save is pending

Nathaniel79b33ef8b58b
diff --git a/src/components/LiveProviderSettings.tsx b/src/components/LiveProviderSettings.tsx
index 38a181ce56..393eaebcd6 100644
--- a/src/components/LiveProviderSettings.tsx
+++ b/src/components/LiveProviderSettings.tsx
@@ -9,7 +9,7 @@ type ProviderPatch = Partial<Pick<LiveSettings, "provider" | "azureEndpoint" | "
const FIELD = "w-full rounded-lg border border-hairline bg-inset px-2.5 py-1.5 text-[13px] text-ink outline-none focus:border-accent/60";
-/** `locked` holds the provider while a key save is pending; `onSaving` reports a pending provider change. */
+/** `locked` holds the provider, Azure endpoint and Fish agent while a key save is pending; `onSaving` reports a pending change to them. */
export function LiveProviderSettings({ locked = false, onSaving }: { locked?: boolean; onSaving?: (saving: boolean) => void } = {}) {
const { state, dispatch } = useStore();
const live: LiveSettings = state.config?.live ?? { configured: false, voice: "", readTypedReplies: true, idleMinutes: 5 };
@@ -23,6 +23,7 @@ export function LiveProviderSettings({ locked = false, onSaving }: { locked?: bo
const agentChanged = agentId.trim() !== (live.fishAgentId ?? "");
const save = async (patch: ProviderPatch) => {
+ if (locked) return;
setSaving(true);
onSaving?.(true);
setError(null);
@@ -89,7 +90,7 @@ export function LiveProviderSettings({ locked = false, onSaving }: { locked?: bo
{azureChanged && (
<button
type="submit"
- disabled={saving}
+ disabled={saving || locked}
className="self-start rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50"
>
{t("common.save")}
@@ -120,7 +121,7 @@ export function LiveProviderSettings({ locked = false, onSaving }: { locked?: bo
{agentChanged && (
<button
type="submit"
- disabled={saving}
+ disabled={saving || locked}
className="self-start rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-50"
>
{t("common.save")}
diff --git a/src/components/keys/KeysPage.dom.test.ts b/src/components/keys/KeysPage.dom.test.ts
index 3f3d80d960..b06b235e7b 100644
--- a/src/components/keys/KeysPage.dom.test.ts
+++ b/src/components/keys/KeysPage.dom.test.ts
@@ -166,7 +166,7 @@ describe("the keys page", () => {
expect(host.querySelector("[data-keys-empty]")!.textContent).toBe("No keys match “zzz”.");
});
- it("holds the Live provider while a key save is pending, and the key while a provider change is", async () => {
+ it("holds the Live provider and Fish agent while a key save is pending, and the key while a provider change is", async () => {
const live = { configured: false, provider: "fish", fishAgentId: "agent_1", voice: "", readTypedReplies: true, idleMinutes: 5 };
setConfig({ ...fx.config, live });
let answer: (value: unknown) => void = () => {};
@@ -178,6 +178,11 @@ describe("the keys page", () => {
flushSync(() => saveKey().click());
expect(fx.api).toHaveBeenCalledWith("/api/config", expect.objectContaining({ method: "PUT" }));
expect(provider().disabled).toBe(true);
+ const agentForm = [...host.querySelectorAll("form")].find((form) => !form.querySelector('input[type="password"]'))!;
+ type(agentForm.querySelector<HTMLInputElement>("input")!, "agent_2");
+ expect(agentForm.querySelector<HTMLButtonElement>('button[type="submit"]')!.disabled).toBe(true);
+ flushSync(() => agentForm.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true })));
+ expect(fx.api).toHaveBeenCalledTimes(1);
await answered(() => answer({ ...fx.config, live: { ...live, keySource: "live" } }));
expect(provider().disabled).toBe(false);