Skip to content

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

Honor the latest call choice across bots and trim Fish agent IDs

vincent7de9e2640994
diff --git a/src/components/CallView.start-request.test.ts b/src/components/CallView.start-request.test.ts
index e8672d5571..aff3bc5050 100644
--- a/src/components/CallView.start-request.test.ts
+++ b/src/components/CallView.start-request.test.ts
@@ -40,8 +40,8 @@ const { newChatThreadId } = await import("@/state/new-chat");
let root: Root;
let container: HTMLDivElement;
const onStart = vi.fn();
-const render = (threadId = "thread-atlas") => flushSync(() => root.render(createElement(CallTargetButton, {
- targetId: "atlas", targetName: "Atlas", threadId, voices: ["v"],
+const render = (threadId = "thread-atlas", targetId = "atlas") => flushSync(() => root.render(createElement(CallTargetButton, {
+ targetId, targetName: targetId, threadId, voices: ["v"],
requireExplicitVoices: false, liveCapable: true, placement: "composer", fill: "#8057C8", onStart,
})));
const remount = () => {
@@ -99,6 +99,17 @@ describe("a call started from the composer's + menu", () => {
expect(liveMedia()).toMatchObject({ phase: "starting", botId: "atlas", threadId: "made" });
});
+ it("keeps the newer Turns call when another bot's pending Live start finishes", async () => {
+ render(newChatThreadId("atlas"));
+ flushSync(() => requestCallStart("atlas", "live"));
+ render("thread-juniper", "juniper");
+ flushSync(() => requestCallStart("juniper", "turns"));
+ flushSync(() => fixture.dispatch.mock.calls[0][0].onMade("made"));
+ await Promise.resolve();
+ expect(currentCall()).toBe("juniper");
+ expect(liveMedia().phase).toBe("idle");
+ });
+
it("waits for the blank chat's Live start when Live is pressed again before its settings are saved", async () => {
render(newChatThreadId("atlas"));
flushSync(() => requestCallStart("atlas", "live"));
diff --git a/src/components/CallView.tsx b/src/components/CallView.tsx
index ec1dfcba78..bc4bb07662 100644
--- a/src/components/CallView.tsx
+++ b/src/components/CallView.tsx
@@ -196,6 +196,12 @@ export function CallTargetButton({
const start = (next: CallMode) => {
setHelpOpen(false);
setMenuOpen(false);
+ for (const [other, start] of liveStarts) {
+ if (other !== targetId) {
+ start.request++;
+ liveStarts.delete(other);
+ }
+ }
const pending = liveStartOf(targetId);
if (next === "live" && pending.waiting && pending.waiting === pending.request) return;
const request = ++pending.request;
diff --git a/src/components/bot-settings/VoiceSection.dom.test.ts b/src/components/bot-settings/VoiceSection.dom.test.ts
index e7710af47a..ae1892f443 100644
--- a/src/components/bot-settings/VoiceSection.dom.test.ts
+++ b/src/components/bot-settings/VoiceSection.dom.test.ts
@@ -88,7 +88,7 @@ describe("a bot's Live call voice in its voice settings", () => {
render(openAiLive, { ...atlas, liveOverride: { provider: "fish" } });
const agent = card()?.querySelector("input");
expect(agent).toBeDefined();
- agent!.value = "fish-atlas";
+ agent!.value = " fish-atlas ";
flushSync(() => agent!.dispatchEvent(new Event("focusout", { bubbles: true })));
expect(patch).toHaveBeenLastCalledWith({ liveOverride: { provider: "fish", fishAgentId: "fish-atlas" } });
diff --git a/src/components/bot-settings/VoiceSection.tsx b/src/components/bot-settings/VoiceSection.tsx
index 818a939690..44187dd8bf 100644
--- a/src/components/bot-settings/VoiceSection.tsx
+++ b/src/components/bot-settings/VoiceSection.tsx
@@ -55,6 +55,7 @@ export function VoiceSection({
onKeyDown={(event) => { if (event.key === "Enter" && !event.nativeEvent.isComposing) event.currentTarget.blur(); }}
onBlur={(event) => {
const id = event.currentTarget.value.trim();
+ event.currentTarget.value = id;
if (!event.currentTarget.reportValidity() || id === fishAgentId) return;
patch({ liveOverride: id ? { provider: "fish", fishAgentId: id } : { provider: "fish" } });
}} />