Skip to content

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

fix(voice): expose and allow clearing voice.baseUrl in settings and app_settings

jonathanwxh-cellcc0bf24d8558
diff --git a/server/app-settings/host.test.ts b/server/app-settings/host.test.ts
index 137ea146e9..589ed2f910 100644
--- a/server/app-settings/host.test.ts
+++ b/server/app-settings/host.test.ts
@@ -19,7 +19,7 @@ afterEach(() => {
for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
});
-function fixture(options: { owner?: boolean; ownerRefusal?: TurnOwnerRefusal; guest?: boolean; group?: boolean; window?: boolean; pictureRefusal?: string; patchRefusal?: string; patchRefusalFor?: (botId: string) => string | null; emptyRegistryBots?: boolean; automated?: boolean } = {}) {
+function fixture(options: { owner?: boolean; ownerRefusal?: TurnOwnerRefusal; guest?: boolean; group?: boolean; window?: boolean; pictureRefusal?: string; patchRefusal?: string; patchRefusalFor?: (botId: string) => string | null; emptyRegistryBots?: boolean; automated?: boolean; tts?: AppConfig["tts"] } = {}) {
const dataDir = mkdtempSync(join(tmpdir(), "app-settings-"));
dirs.push(dataDir);
const bots: BotRecord[] = [
@@ -27,6 +27,7 @@ function fixture(options: { owner?: boolean; ownerRefusal?: TurnOwnerRefusal; gu
{ id: "clive", name: "Clive", color: "blue", threadId: "t-clive", approvalMode: "ask", modelSelection: { instanceId: "claude", model: "sonnet" }, assignedSkills: ["notes"] } as unknown as BotRecord,
];
const cfg = { language: "en", rooms: { turnTimeoutMinutes: 30 }, mcp: {}, threads: { maxConcurrentPerBot: 3 }, openai: { key: OPENAI_KEY }, anthropic: { url: "https://api.anthropic.com" },
+ ...(options.tts ? { tts: options.tts } : {}),
instances: { "openai-compat-gw": { driver: "openai-compat", displayName: "Gateway", config: { key: GATEWAY_KEY, url: "https://gw.example/v1" } } } } as unknown as AppConfig;
const engineCalls: unknown[] = [];
const engines = [{ instanceId: "claude", name: "Claude", working: true }, { instanceId: "openai-compat-gw", name: "Gateway", working: true }];
@@ -476,6 +477,23 @@ describe("every other setting applies at once with Undo, Full access or not", ()
expect(readDecisions(fx.dataDir, 10)).toMatchObject([{ decision: "auto-approved", source: "app-settings", tool: "app_settings", summary: expect.stringMatching(new RegExp(`^${id.replaceAll(".", "\\.")}: `)) }]);
});
+ it("reads, updates, and clears voice.baseUrl without re-sending saved tts keys", async () => {
+ const fx = fixture({
+ tts: { provider: "elevenlabs", key: "el-secret", fishKey: "fish-secret", geminiKey: "gem-secret", baseUrl: "http://127.0.0.1:4123" },
+ });
+ const got = JSON.parse(String((await fx.host.handle({ action: "get", id: "voice.baseUrl" }, fx.turn)).body.text));
+ expect(got).toMatchObject({ tier: "safe", value: "http://127.0.0.1:4123" });
+ expect((await fx.set("voice.baseUrl", "http://127.0.0.1:5000")).status).toBe(200);
+ expect(fx.cards()[0]!.card.subtitle).toBe("http://127.0.0.1:4123 → http://127.0.0.1:5000");
+ expect((await fx.set("voice.baseUrl", "")).status).toBe(200);
+ expect(await fx.undo()).toEqual({ claimed: true, state: "undone" });
+ expect(fx.saved).toEqual([
+ { tts: { baseUrl: "http://127.0.0.1:5000" } },
+ { tts: { baseUrl: "" } },
+ { tts: { baseUrl: "http://127.0.0.1:5000" } },
+ ]);
+ });
+
it("an approval mode change says what it allows and applies at once; Undo restores the earlier mode", async () => {
const fx = fixture();
const got = JSON.parse(String((await fx.host.handle({ action: "get", id: "bots.approvalModes" }, fx.turn)).body.text));
diff --git a/server/app-settings/registry.ts b/server/app-settings/registry.ts
index 59bd6f0573..1a5c08f0dd 100644
--- a/server/app-settings/registry.ts
+++ b/server/app-settings/registry.ts
@@ -259,7 +259,7 @@ export function createSettingsRegistry(deps: RegistryDeps): SettingEntry[] {
synonyms: ["openai compatible", "custom provider", "model name"], value: z.string().trim().max(200), allowed: "a model name, or empty to clear",
current: () => cfg().openaiCompat?.model ?? "", write: config((model: string) => ({ openaiCompat: { ...cfg().openaiCompat, model } })),
}),
- provider("voice.baseUrl", "Voice server address", ["tts", "voice", "speech", "chatterbox"], () => cfg().tts?.baseUrl, (text) => ({ tts: { ...cfg().tts, baseUrl: text } })),
+ provider("voice.baseUrl", "Voice server address", ["tts", "voice", "speech", "chatterbox"], () => cfg().tts?.baseUrl, (text) => ({ tts: { baseUrl: text } })),
];
const secret: SettingEntry[] = (Object.keys(CREDENTIAL_TARGETS) as CredentialTargetId[]).map((credentialId) => {
diff --git a/server/tts/index.ts b/server/tts/index.ts
index dfc39b01fd..8f96001ff1 100644
--- a/server/tts/index.ts
+++ b/server/tts/index.ts
@@ -109,7 +109,7 @@ export function describeVoice(cfg: AppConfig) {
ready: voiceConfigured(cfg),
voice: cfg.tts?.voice ?? "",
provider,
- baseUrl: provider === "chatterbox" ? (cfg.tts?.baseUrl ?? "") : "",
+ baseUrl: cfg.tts?.baseUrl ?? "",
model: provider === "gemini" ? (cfg.tts?.model || gemini.DEFAULT_GEMINI_MODEL) : provider === "chatterbox" ? (cfg.tts?.model ?? "") : "",
...(provider === "fish" ? { fishModel: cfg.tts?.fishModel ?? fish.DEFAULT_FISH_MODEL } : {}),
...(included ? { included: true as const } : {}),
diff --git a/server/tts/tts.test.ts b/server/tts/tts.test.ts
index 0ac0d51480..61afa51f7e 100644
--- a/server/tts/tts.test.ts
+++ b/server/tts/tts.test.ts
@@ -192,6 +192,7 @@ describe("configuration", () => {
const described = describeVoice(cfg({ key: "sk-secret", voice: "v-1" }));
expect(described).toEqual({ configured: true, ready: true, voice: "v-1", provider: "elevenlabs", baseUrl: "", model: "" });
expect(JSON.stringify(described)).not.toContain("sk-secret");
+ expect(describeVoice(cfg({ key: "sk-secret", voice: "v-1", baseUrl: "http://127.0.0.1:4123" })).baseUrl).toBe("http://127.0.0.1:4123");
});
it("distinguishes 'no key' from 'no voice picked'", async () => {
diff --git a/src/components/VoiceSettings.test.ts b/src/components/VoiceSettings.test.ts
index f56c3c908c..a4807f41ae 100644
--- a/src/components/VoiceSettings.test.ts
+++ b/src/components/VoiceSettings.test.ts
@@ -213,3 +213,20 @@ it("keeps a voice selected before the pending provider save completes, even befo
await act(async () => resolve({ tts: { provider: "openai", configured: true } }));
expect(onPatch).toHaveBeenCalledExactlyOnceWith({ voice: "cedar" });
});
+
+it("lets a saved Chatterbox server address be cleared", async () => {
+ fixture.config = { tts: { provider: "chatterbox", configured: true, baseUrl: "http://127.0.0.1:4123", model: "" } };
+ fixture.api.mockResolvedValue({ tts: { provider: "chatterbox", configured: false, baseUrl: "", model: "" } });
+ await render(bot("pepper"), vi.fn());
+ const input = host.querySelector<HTMLInputElement>('input[aria-label="Chatterbox server address"]')!;
+ const save = host.querySelector<HTMLButtonElement>('input[aria-label="Chatterbox server address"] + button')!;
+ expect(input.value).toBe("http://127.0.0.1:4123");
+ expect(save.disabled).toBe(false);
+ await act(async () => {
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(input, "");
+ input.dispatchEvent(new Event("input", { bubbles: true }));
+ });
+ expect(save.disabled).toBe(false);
+ await act(async () => { save.click(); });
+ expect(fixture.api).toHaveBeenCalledWith("/api/config", { method: "PUT", body: JSON.stringify({ tts: { baseUrl: "", model: "" } }) });
+});
diff --git a/src/components/VoiceSettings.tsx b/src/components/VoiceSettings.tsx
index 48f5ebf3af..f3560766d9 100644
--- a/src/components/VoiceSettings.tsx
+++ b/src/components/VoiceSettings.tsx
@@ -248,9 +248,10 @@ export function VoiceSettings({
};
const saveServer = () => {
+ const savedUrl = tts?.baseUrl?.trim() ?? "";
const next = serverUrl.trim();
- if (!next || savingServer) return Promise.resolve();
- if (!/^https?:\/\//i.test(next)) {
+ if (savingServer || (!next && !savedUrl)) return Promise.resolve();
+ if (next && !/^https?:\/\//i.test(next)) {
setError(t("voice.serverAddressError"));
return Promise.resolve();
}
@@ -465,7 +466,7 @@ export function VoiceSettings({
/>
<button
onClick={() => void saveServer()}
- disabled={savingServer || !serverUrl.trim()}
+ disabled={savingServer || (!serverUrl.trim() && !tts?.baseUrl?.trim())}
className="flex w-[72px] shrink-0 items-center justify-center gap-1.5 rounded-lg bg-control py-2 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50"
>
{savingServer ? <Loader2 size={13} className="animate-spin" /> : <><Check size={13} />{t("common.save")}</>}
diff --git a/src/components/keys/KeyPanels.tsx b/src/components/keys/KeyPanels.tsx
index da19c1fc99..2821db315d 100644
--- a/src/components/keys/KeyPanels.tsx
+++ b/src/components/keys/KeyPanels.tsx
@@ -1,6 +1,7 @@
import { useEffect, useRef, useState } from "react";
import { Loader2, TriangleAlert } from "lucide-react";
import { api, useStore, type ConfigStatus } from "@/state/store";
+import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import { Switch } from "../SettingsPrimitives";
@@ -181,3 +182,61 @@ export function OpenAiCompatUrl() {
</div>
);
}
+
+/** Exposes tts.baseUrl in AI › Other services so stale voice server addresses can be viewed, changed, or cleared. */
+export function VoiceServerUrl() {
+ const state = useStoreSelector((s) => ({ config: s.config }), sameFields),
+ dispatch = useStoreDispatch();
+ const saved = state.config?.tts?.baseUrl?.trim() ?? "";
+ const [value, setValue] = useState(saved);
+ const [saving, setSaving] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const savingRef = useRef(false);
+ useEffect(() => { setValue(saved); }, [saved]);
+
+ const trimmed = value.trim();
+ const dirty = trimmed !== saved;
+
+ const submit = (next: string) => {
+ if (savingRef.current) return;
+ if (next && !/^https?:\/\//i.test(next)) {
+ setError(t("voice.serverAddressError"));
+ return;
+ }
+ savingRef.current = true;
+ setSaving(true);
+ setError(null);
+ api("/api/config", { method: "PUT", body: JSON.stringify({ tts: { baseUrl: next } }) })
+ .then((status: ConfigStatus) => dispatch({ type: "configStatus", config: status }))
+ .catch((e: Error) => setError(e.message))
+ .finally(() => { savingRef.current = false; setSaving(false); });
+ };
+
+ return (
+ <div data-voice-server-url className="flex flex-col gap-1.5">
+ <div className="flex flex-wrap items-center gap-2">
+ <input
+ type="url"
+ value={value}
+ onChange={(e) => { setError(null); setValue(e.target.value); }}
+ onKeyDown={(e) => e.key === "Enter" && dirty && submit(trimmed)}
+ disabled={saving}
+ placeholder="http://127.0.0.1:4123"
+ aria-label={t("voice.chatterboxAddress")}
+ autoComplete="off"
+ spellCheck={false}
+ className={cn(KEY_FIELD, "w-auto min-w-[min(100%,12rem)] flex-1")}
+ />
+ <button type="button" onClick={() => submit(trimmed)} disabled={saving || !dirty} className="ui-button shrink-0">
+ {saving ? <Loader2 size={13} className="animate-spin" aria-hidden="true" /> : t("common.save")}
+ </button>
+ {saved && (
+ <button type="button" onClick={() => submit("")} disabled={saving} className="ui-button shrink-0">
+ {t("keys.row.remove")}
+ </button>
+ )}
+ </div>
+ {error && <div role="alert" className="text-[12px] leading-4 text-danger">{error}</div>}
+ </div>
+ );
+}
diff --git a/src/components/keys/KeysPage.dom.test.ts b/src/components/keys/KeysPage.dom.test.ts
index 03d75170a9..5295267160 100644
--- a/src/components/keys/KeysPage.dom.test.ts
+++ b/src/components/keys/KeysPage.dom.test.ts
@@ -771,3 +771,31 @@ describe("Your own servers (SSH)", () => {
expect(field("Server name").value).toBe("Lab");
});
});
+
+describe("Voice server address in Other services", () => {
+ const voiceInput = () => host.querySelector<HTMLInputElement>('input[aria-label="Chatterbox server address"]')!;
+ const voiceAction = (label: string) =>
+ [...host.querySelectorAll<HTMLButtonElement>("[data-voice-server-url] button")].find((button) => button.textContent === label)!;
+
+ it("shows, validates, updates, and clears a stale voice server address even when another voice provider is active", async () => {
+ setConfig({ ...fx.config, tts: { provider: "elevenlabs", configured: true, ready: true, voice: "v1", baseUrl: "http://127.0.0.1:4123", model: "" } });
+ page();
+ expect(expanded("voice")).toBe("true");
+ expect(voiceInput().value).toBe("http://127.0.0.1:4123");
+
+ type(voiceInput(), "not-a-url");
+ flushSync(() => voiceAction("Save").click());
+ expect(host.querySelector("[data-voice-server-url] [role=alert]")!.textContent).toContain("http:// or https://");
+ expect(fx.api).not.toHaveBeenCalled();
+
+ fx.api.mockResolvedValueOnce({ ...fx.config, tts: { provider: "elevenlabs", configured: true, ready: true, voice: "v1", baseUrl: "http://127.0.0.1:4124", model: "" } });
+ type(voiceInput(), "http://127.0.0.1:4124");
+ await answered(() => voiceAction("Save").click());
+ expect(fx.api).toHaveBeenLastCalledWith("/api/config", { method: "PUT", body: JSON.stringify({ tts: { baseUrl: "http://127.0.0.1:4124" } }) });
+
+ fx.api.mockResolvedValueOnce({ ...fx.config, tts: { provider: "elevenlabs", configured: true, ready: true, voice: "v1", baseUrl: "", model: "" } });
+ await answered(() => voiceAction("Remove").click());
+ expect(fx.api).toHaveBeenLastCalledWith("/api/config", { method: "PUT", body: JSON.stringify({ tts: { baseUrl: "" } }) });
+ expect(voiceInput().value).toBe("");
+ });
+});
diff --git a/src/components/keys/KeysPage.tsx b/src/components/keys/KeysPage.tsx
index 3779b51ebf..35b57dda57 100644
--- a/src/components/keys/KeysPage.tsx
+++ b/src/components/keys/KeysPage.tsx
@@ -13,7 +13,7 @@ import { BuiltInReplyWait, LmStudioServer, OtherOpenAiCompatServers } from "../O
import { OllamaServer } from "../OllamaServer";
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 } from "./KeyPanels";
+import { AnthropicEveryClaudeBot, OpenAiCompatUrl, OpenCodeProviderKeys, VoiceServerUrl } from "./KeyPanels";
import { VpsConnection } from "./VpsServersPanel";
import { KEY_CONTENT, KEY_ROW, KeyRow, MaskedKey, RowHeading, type KeyStatus } from "./KeyRow";
import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select";
@@ -25,6 +25,7 @@ const PANELS: Partial<Record<KeyId, (visible: boolean) => ReactNode>> = {
opencodeProviders: () => <OpenCodeProviderKeys />,
ollama: (visible) => <OllamaServer visible={visible} />,
lmStudio: () => <LmStudioServer heading={false} />,
+ chatterbox: () => <VoiceServerUrl />,
vps: () => <VpsConnection />,
};
diff --git a/src/components/keys/key-catalog.ts b/src/components/keys/key-catalog.ts
index 43b509d41b..3de704b1a4 100644
--- a/src/components/keys/key-catalog.ts
+++ b/src/components/keys/key-catalog.ts
@@ -48,7 +48,7 @@ export interface KeyTarget {
export type KeyId =
| "openai" | "anthropic" | "xai" | "openrouter" | "mistral" | "cerebras" | "groq" | "greenference" | "modelgo" | "meta" | "deepseek" | "opencodeGo" | "opencodeProviders"
- | "ollama" | "lmStudio" | "openaiCompat" | "liveCalls" | "liveKey" | "elevenlabs" | "fishAudio" | "geminiTts" | "box" | "vps" | "onePassword" | "composio" | "treg" | "postiz"
+ | "ollama" | "lmStudio" | "openaiCompat" | "liveCalls" | "liveKey" | "elevenlabs" | "fishAudio" | "geminiTts" | "chatterbox" | "box" | "vps" | "onePassword" | "composio" | "treg" | "postiz"
| "jev" | "openrouterHelper" | "workersAi" | "customDecider" | "imageOpenai" | "imageGemini" | "imageCustom";
export type KeyMark = { driverKind: string; preset?: ProviderIconPreset } | { icon: LucideIcon };
@@ -158,6 +158,9 @@ export const KEY_CATALOG: readonly KeyEntry[] = [
target: { patch: (value) => ({ tts: { fishKey: value } }), slot: "fishAudioKey", verifiedOnSave: true,
saved: (config) => flag(config.savedKeys?.fishAudioKey ?? { configured: config.tts?.provider === "fish" && config.tts.configured }),
placeholder: "…", placeholderKey: "voice.fish.keyPlaceholder", href: "https://fish.audio/app/api-keys/", analytics: "fish_audio" } },
+ { id: "chatterbox", section: "voice", labelKey: "voice.chatterboxServer", purposeKey: "voice.chatterboxHelp", name: "Chatterbox", env: [],
+ words: ["chatterbox", "voice", "tts", "speech", "base url", "server", "address", "local"], mark: { icon: AudioLines }, kind: "panel",
+ status: (config) => ({ configured: Boolean(config.tts?.baseUrl?.trim()) }) },
{ id: "box", section: "computers", labelKey: "keys.boat.label", purposeKey: "keys.purpose.box", name: "boat.dev", env: ["BOX_TOKEN"],
words: ["boat", "box", "cloud desktop", "cloud computer", "computer", "sandbox"], mark: { icon: Monitor }, kind: "key",
target: { patch: (value) => ({ box: { token: value } }), slot: "boxToken", verifiedOnSave: true,