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(ui): offer text and voice when starting a new chat

rubenluetke10-beep6d03b82b6ec0
diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx
index c4b0fca08e..3c329f3125 100644
--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx
@@ -140,11 +140,8 @@ describe("Sidebar voice header", () => {
});
});
-/*
- * "+ New" starts a conversation of the KIND on screen. Standing on the voice
- * stage and being thrown onto the chat page was the reported bug: the button
- * looked like it did nothing you asked for.
- */
+// New chat must let users choose either surface without changing the current
+// conversation until they make a choice.
describe("Sidebar new-conversation button", () => {
beforeEach(() => {
vi.stubGlobal(
@@ -175,12 +172,16 @@ describe("Sidebar new-conversation button", () => {
useEventStore.setState({ conversations: [], messages: [], activeThreadId: null });
});
- test("New chat opens typed chat even from the voice stage", async () => {
+ test("offers both kinds and opens typed chat from the voice stage", async () => {
useHomeStore.setState({ surface: "voice", transcript: [] });
renderSidebar();
const button = screen.getByTestId("sidebar-new-chat");
expect(button.textContent).toContain("New chat");
await act(async () => { button.click(); await Promise.resolve(); });
+ expect(useHomeStore.getState().surface).toBe("voice");
+ expect(useEventStore.getState().activeThreadId).toBe("old-voice-thread");
+ expect(screen.getByTestId("new-voice-chat")).toBeTruthy();
+ fireEvent.click(screen.getByTestId("new-text-chat"));
expect(useHomeStore.getState().surface).toBe("chat");
expect(useEventStore.getState().activeSection).toBe("chats");
});
@@ -197,11 +198,41 @@ describe("Sidebar new-conversation button", () => {
button.click();
await Promise.resolve();
});
+ fireEvent.click(screen.getByTestId("new-text-chat"));
expect(useHomeStore.getState().surface).toBe("chat");
const calls = (globalThis.fetch as unknown as { mock: { calls: unknown[][] } }).mock.calls;
expect(calls.some((c) => String(c[0]) === "/api/chats/voice/new")).toBe(false);
});
+
+ test("opens a fresh voice chat from the chat surface", async () => {
+ useHomeStore.setState({ surface: "chat", transcript: [], liveReply: "Previous reply" });
+ renderSidebar();
+ fireEvent.click(screen.getByTestId("sidebar-new-chat"));
+ await act(async () => { fireEvent.click(screen.getByTestId("new-voice-chat")); });
+ expect(fetch).toHaveBeenCalledWith("/api/chats/voice/new", { method: "POST" });
+ expect(useHomeStore.getState().surface).toBe("voice");
+ expect(useHomeStore.getState().liveReply).toBe("");
+ expect(useEventStore.getState().activeSection).toBe("chats");
+ expect(useEventStore.getState().activeKind).toBe("voice");
+ expect(useEventStore.getState().activeThreadId).toBeNull();
+ expect(screen.queryByRole("dialog")).toBeNull();
+ });
+
+ test("keeps the current conversation if creating a voice chat fails", async () => {
+ vi.stubGlobal("fetch", vi.fn(async (url: string) =>
+ String(url) === "/api/chats/voice/new"
+ ? new Response("", { status: 503 })
+ : new Response(JSON.stringify([]), { status: 200 }),
+ ));
+ useHomeStore.setState({ surface: "chat", transcript: [] });
+ renderSidebar();
+ fireEvent.click(screen.getByTestId("sidebar-new-chat"));
+ await act(async () => { fireEvent.click(screen.getByTestId("new-voice-chat")); });
+ expect(useHomeStore.getState().surface).toBe("chat");
+ expect(useEventStore.getState().activeThreadId).toBe("old-voice-thread");
+ expect(screen.getByRole("dialog")).toBeTruthy();
+ });
});
describe("Sidebar header avatar", () => {
@@ -722,7 +753,7 @@ describe("compact sidebar navigation", () => {
test("keeps core destinations above visible recent chats", () => {
renderSidebar();
- for (const id of ["agents", "chats", "tasks", "plugins", "marketplace"]) {
+ for (const id of ["agents", "dictation", "tasks", "plugins", "marketplace"]) {
expect(screen.getByTestId(`nav-row-${id}`)).toBeTruthy();
}
expect(screen.getByTestId("recent-chats")).toBeTruthy();
@@ -734,10 +765,11 @@ describe("compact sidebar navigation", () => {
useHomeStore.setState({ surface: "chat" });
renderSidebar();
expect(screen.queryByTestId("nav-row-visualization")).toBeNull();
- fireEvent.click(screen.getByTestId("nav-row-chats"));
- expect(useHomeStore.getState().surface).toBe("voice");
- expect(useEventStore.getState().activeSection).toBe("chats");
+ fireEvent.click(screen.getByTestId("nav-row-dictation"));
+ expect(useHomeStore.getState().surface).toBe("chat");
+ expect(useEventStore.getState().activeSection).toBe("dictation");
fireEvent.click(screen.getByTestId("sidebar-more-toggle"));
+ expect(screen.getAllByTestId("nav-row-dictation")).toHaveLength(1);
fireEvent.click(screen.getByTestId("nav-row-visualization"));
expect(useEventStore.getState().activeSection).toBe("visualization");
});
diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
index 043783fe3f..c89f66e52d 100644
--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx
@@ -1,5 +1,6 @@
import {
Loader2,
+ MessageSquare,
Mic,
ChevronDown,
ChevronRight,
@@ -37,6 +38,8 @@ import { WorkspaceChats } from "@/components/agentic/WorkspaceChats";
import { useAppInstance } from "@/hooks/useAppInstance";
import { usePublishIdentity } from "@/components/marketplace/PublishIdentity";
import { GigiMark } from "@/components/GigiMark";
+import * as Dialog from "@radix-ui/react-dialog";
+import { startNewVoiceRun } from "@/lib/chatsApi";
/*
* Why `clsx` and not `cn` on the rows below.
@@ -180,10 +183,7 @@ export function Sidebar({
// confused; the default app shows nothing here.
const appInstance = useAppInstance();
const devTag = appInstance?.isDev ? appInstance.name.toUpperCase() : null;
- // "+ New" starts a new conversation of the KIND you are looking at: on the
- // chat surface an empty agent chat, on the voice stage a fresh voice run.
- // Sending someone standing in Voice to the chat page is what the one button
- // used to do, and it read as the button being broken.
+ // New chat offers both conversation types independently of the current view.
const { newChat } = useConversations();
const newAgentChat = useAgentChatStore((s) => s.newChat);
const setSurface = useHomeStore((s) => s.setSurface);
@@ -230,6 +230,9 @@ export function Sidebar({
const [toolsOpen, setToolsOpen] = useState(false);
const [moreOpen, setMoreOpen] = useState(false);
const [profileOpen, setProfileOpen] = useState(false);
+ const [newChatOpen, setNewChatOpen] = useState(false);
+ const [startingVoice, setStartingVoice] = useState(false);
+ const startingVoiceRef = useRef(false);
const profileRef = useRef<HTMLDivElement>(null);
const profileButtonRef = useRef<HTMLButtonElement>(null);
const identity = usePublishIdentity();
@@ -259,6 +262,31 @@ export function Sidebar({
newAgentChat();
setSurface("chat");
setActive("chats");
+ setNewChatOpen(false);
+ };
+ const startVoiceChat = async () => {
+ if (startingVoiceRef.current) return;
+ startingVoiceRef.current = true;
+ setStartingVoice(true);
+ try {
+ await startNewVoiceRun();
+ newAgentChat();
+ const events = useEventStore.getState();
+ events.setActiveConversation("voice", null);
+ events.setMessages([]);
+ events.seedThinkingTraces({});
+ events.setTranscription("", true);
+ useHomeStore.getState().resetTranscript();
+ useHomeStore.setState({ freshVoicePending: false });
+ setSurface("voice");
+ setActive("chats");
+ setNewChatOpen(false);
+ } catch {
+ useEventStore.getState().pushToast("error", `${t("sidebar.new_voice_chat")}: ${t("voice_state.error")}`);
+ } finally {
+ startingVoiceRef.current = false;
+ setStartingVoice(false);
+ }
};
// Shared readiness derivation (same source the banner + chat empty-state use).
const { connected, voiceWarming, bootWarming, warming } = useVoiceReadiness();
@@ -359,8 +387,9 @@ export function Sidebar({
const findItem = (id: string) => allItems.find((item) => item.id === id)!;
const toolIds = ["memory", "board", "docs", "sessions", "run_inspector", "clis", "agentic-ide"];
const toolItems = toolIds.map(findItem);
- const profileItems = [...NAV_GROUPS[3], ...NAV_GROUPS[4], ...NAV_FOOTER_ITEMS];
- const primaryIds = ["chats", "agents", "tasks", "plugins", "marketplace"];
+ const primaryIds = ["chats", "agents", "dictation", "tasks", "plugins", "marketplace"];
+ const profileItems = [...NAV_GROUPS[3], ...NAV_GROUPS[4], ...NAV_FOOTER_ITEMS]
+ .filter((item) => !primaryIds.includes(item.id));
const assignedIds = new Set([...primaryIds, ...toolIds, ...profileItems.map((item) => item.id)]);
const moreItems = [...toolItems, ...allItems.filter((item) => !assignedIds.has(item.id))];
const rowClass = "flex min-h-9 w-full items-center gap-2.5 rounded-md px-3 text-base font-medium text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
@@ -509,15 +538,30 @@ export function Sidebar({
<div className="flex min-h-0 flex-1 flex-col overflow-y-auto scrollbar-jarvis">
<nav aria-label={t("sidebar.sections")} className="space-y-1 px-2 py-2">
<ul className="space-y-1">
- <li><button type="button" onClick={startNewChat} data-testid="sidebar-new-chat"
+ <li><Dialog.Root open={newChatOpen} onOpenChange={(open) => { if (!startingVoiceRef.current) setNewChatOpen(open); }}>
+ <Dialog.Trigger asChild><button type="button" data-testid="sidebar-new-chat"
aria-label={t("sidebar.new_chat")} title={t("sidebar.new_chat")} className={rowClass}>
<Plus aria-hidden className="h-4 w-4 shrink-0" />
{!railed && <span>{t("sidebar.new_chat")}</span>}
- </button></li>
+ </button></Dialog.Trigger>
+ <Dialog.Portal>
+ <Dialog.Overlay className="fixed inset-0 z-[80] bg-background/80 backdrop-blur-sm" />
+ <Dialog.Content aria-describedby={undefined} className="fixed left-1/2 top-1/2 z-[90] w-[min(360px,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-popover p-4 text-popover-foreground shadow-xl">
+ <Dialog.Title className="mb-4 text-lg font-semibold">{t("sidebar.new_chat")}</Dialog.Title>
+ <div className="space-y-2">
+ <button type="button" data-testid="new-text-chat" disabled={startingVoice} onClick={startNewChat} className={cn(rowClass, "border border-border py-3 disabled:opacity-50")}>
+ <MessageSquare aria-hidden className="h-5 w-5" />{t("sidebar.surface_chat")}
+ </button>
+ <button type="button" data-testid="new-voice-chat" disabled={startingVoice} onClick={() => void startVoiceChat()} className={cn(rowClass, "border border-border py-3 disabled:opacity-50")}>
+ {startingVoice ? <Loader2 aria-hidden className="h-5 w-5 animate-spin" /> : <Mic aria-hidden className="h-5 w-5" />}{t("sidebar.new_voice_chat")}
+ </button>
+ </div>
+ <Dialog.Close disabled={startingVoice} className={cn(rowClass, "mt-3 justify-center disabled:opacity-50")}>{t("common.cancel")}</Dialog.Close>
+ </Dialog.Content>
+ </Dialog.Portal>
+ </Dialog.Root></li>
{renderRow(findItem("agents"))}
- <NavRow item={{ ...findItem("chats"), icon: Mic }} label="Jarvis Voice" compact={railed}
- active={active === "chats" && surface === "voice"}
- onClick={() => { setSurface("voice"); setActive("chats"); }} />
+ {renderRow(findItem("dictation"))}
</ul>
<button type="button" onClick={() => { setToolsOpen(!toolsOpen); setMoreOpen(false); }}
aria-expanded={toolsOpen} aria-controls="sidebar-tools" title={t("sidebar.jarvis_tools")}