Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(live): apply a changed GPT-Live picker at once instead of a silent draft

rubenluetke10-beepc4ea72dbde3d
diff --git a/jarvis/ui/web/frontend/src/components/providers/LiveProfile.test.tsx b/jarvis/ui/web/frontend/src/components/providers/LiveProfile.test.tsx
index f9570d4210..e732241813 100644
--- a/jarvis/ui/web/frontend/src/components/providers/LiveProfile.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/LiveProfile.test.tsx
@@ -96,3 +96,33 @@ it("recognizes a newly connected key without losing the user's model choice", as
expect(screen.getByRole("combobox", { name: "live.thinking_model" }).textContent).toContain("Chosen");
client.clear();
});
+
+it("applies a new thinking model at once when Live is already set up", async () => {
+ const requests: unknown[] = [];
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async (path: string, init?: RequestInit) => {
+ if (init?.method === "PUT") {
+ requests.push(JSON.parse(String(init.body)));
+ return { ok: true, json: async () => ({}) };
+ }
+ return {
+ ok: true,
+ json: async () => path.endsWith("options") ? {
+ models: [{ id: "old-model", label: "Old" }, { id: "cheap-model", label: "Cheap" }],
+ voices: ["gleam"], efforts: ["medium"],
+ } : {
+ key_ready: true, active: true, agent_configured: true,
+ profile: { model: "gpt-live-1", voice: "gleam", backend_model: "old-model", reasoning_effort: "medium", web_search: true, instructions: "", backend_instructions: "", configured: true },
+ },
+ };
+ }),
+ );
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ render(<QueryClientProvider client={client}><LiveProfile /></QueryClientProvider>);
+ fireEvent.click(await screen.findByRole("combobox", { name: "live.thinking_model" }));
+ fireEvent.click(await screen.findByRole("option", { name: /Cheap/ }));
+ await waitFor(() => expect(requests).toHaveLength(1));
+ expect(requests[0]).toMatchObject({ backend_model: "cheap-model", configured: true });
+ client.clear();
+});
diff --git a/jarvis/ui/web/frontend/src/components/providers/LiveProfile.tsx b/jarvis/ui/web/frontend/src/components/providers/LiveProfile.tsx
index 3b75cb6f83..ae6652ddcb 100644
--- a/jarvis/ui/web/frontend/src/components/providers/LiveProfile.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/LiveProfile.tsx
@@ -97,7 +97,16 @@ export function LiveProfile({ onSaved }: { onSaved?: () => void } = {}) {
window.dispatchEvent(new CustomEvent("jarvis:realtime-switched"));
onSaved?.();
}
- async function save() {
+ // Once Live is set up, a picker change applies at once: a changed dropdown
+ // that silently reverts when the page closes left users billed for a model
+ // they believed they had replaced. Free-text prompts still use the button.
+ const choose = (patch: Partial<LiveProfileValue>) => {
+ const next = { ...value, ...patch };
+ setDraft(next);
+ if (ready) void save(next);
+ };
+ async function save(next?: LiveProfileValue) {
+ const chosen = next ?? value;
setSaving(true);
setMessage("");
setError("");
@@ -105,7 +114,7 @@ export function LiveProfile({ onSaved }: { onSaved?: () => void } = {}) {
const response = await fetch("/api/live/profile", {
method: "PUT",
headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ ...value, configured: true }),
+ body: JSON.stringify({ ...chosen, configured: true }),
});
if (!response.ok)
throw new Error(
@@ -166,7 +175,7 @@ export function LiveProfile({ onSaved }: { onSaved?: () => void } = {}) {
<BrandedSelect
className={field}
value={value.voice}
- onValueChange={(voice) => update({ voice })}
+ onValueChange={(voice) => choose({ voice })}
ariaLabel={t("live.voice")}
options={(options.data?.voices ?? [value.voice]).map((voice) => ({
value: voice,
@@ -188,7 +197,7 @@ export function LiveProfile({ onSaved }: { onSaved?: () => void } = {}) {
<BrandedSelect
className={field}
value={value.backend_model}
- onValueChange={(backend_model) => update({ backend_model })}
+ onValueChange={(backend_model) => choose({ backend_model })}
ariaLabel={t("live.thinking_model")}
placeholder={t("live.choose_model")}
searchPlaceholder={t("live.search_models")}
@@ -200,7 +209,7 @@ export function LiveProfile({ onSaved }: { onSaved?: () => void } = {}) {
<BrandedSelect
className={field}
value={value.reasoning_effort}
- onValueChange={(reasoning_effort) => update({ reasoning_effort })}
+ onValueChange={(reasoning_effort) => choose({ reasoning_effort })}
ariaLabel={t("live.reasoning")}
options={(
options.data?.efforts ?? ["", value.reasoning_effort]
@@ -224,7 +233,7 @@ export function LiveProfile({ onSaved }: { onSaved?: () => void } = {}) {
<Switch
id="live-web-search"
checked={value.web_search}
- onCheckedChange={(web_search) => update({ web_search })}
+ onCheckedChange={(web_search) => choose({ web_search })}
aria-label={t("live.web_search")}
/>
</div>