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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(ui): sidebar search bar and chats, terminals, workspaces in the switcher
rubenluetke10-beepcbae158c5946
diff --git a/jarvis/ui/web/frontend/src/App.tsx b/jarvis/ui/web/frontend/src/App.tsxindex c00e51e101..a8f4efd8cb 100644--- a/jarvis/ui/web/frontend/src/App.tsx+++ b/jarvis/ui/web/frontend/src/App.tsx@@ -48,6 +48,7 @@ const QuickSwitcher = lazy(() =>);import { eventMatchesChord } from "@/lib/quickSwitchChord";import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";+import { useQuickSwitcher } from "@/store/quickSwitcher";import { JarvisDock } from "@/components/JarvisDock";import { CliConnectPoller } from "@/components/CliConnectPoller";import { OnboardingGate } from "@/components/onboarding/OnboardingGate";@@ -125,20 +126,21 @@ export default function App() {chord toggles. While the Settings recorder is capturing, the chord mustreach the recorder instead, so a recording session is skipped.*/- const [switcherOpen, setSwitcherOpen] = useState(false);+ const switcherOpen = useQuickSwitcher((s) => s.open);const switcherEnabled = useQuickSwitchSettings((s) => s.enabled);const switcherCombo = useQuickSwitchSettings((s) => s.combo);useEffect(() => {- if (!switcherEnabled || !switcherCombo) {- setSwitcherOpen(false);+ if (!switcherEnabled) {+ useQuickSwitcher.getState().hide();return;}+ if (!switcherCombo) return;const onKeyDown = (event: KeyboardEvent) => {if (event.repeat || !eventMatchesChord(event, switcherCombo)) return;if (document.querySelector('[data-keybind-recording="true"]')) return;event.preventDefault();event.stopPropagation();- setSwitcherOpen((open) => !open);+ useQuickSwitcher.getState().toggle();};window.addEventListener("keydown", onKeyDown, true);return () => window.removeEventListener("keydown", onKeyDown, true);@@ -426,7 +428,11 @@ export default function App() {a detached solo window IS one section, there is nowhere to switch. */}{switcherOpen && (<Suspense fallback={null}>- <QuickSwitcher open onOpenChange={setSwitcherOpen} />+ <QuickSwitcher+ open+ onOpenChange={(next) => (next ? useQuickSwitcher.getState().show() : useQuickSwitcher.getState().hide())}+ initialQuery={useQuickSwitcher.getState().initialQuery}+ /></Suspense>)}{/* `?` anywhere in the app opens this; the chunk loads on first use. */}diff --git a/jarvis/ui/web/frontend/src/components/QuickSwitcher.test.tsx b/jarvis/ui/web/frontend/src/components/QuickSwitcher.test.tsxindex 0e7f0987e9..52e20fdc65 100644--- a/jarvis/ui/web/frontend/src/components/QuickSwitcher.test.tsx+++ b/jarvis/ui/web/frontend/src/components/QuickSwitcher.test.tsx@@ -1,7 +1,7 @@/*** The quick switcher end to end: type, Enter, you are there.*/-import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { cleanup, fireEvent, render, screen } from "@testing-library/react";// Radix Dialog and cmdk touch browser APIs jsdom does not ship.@@ -23,6 +23,8 @@ import { QuickSwitcher } from "./QuickSwitcher";import { useEventStore } from "@/store/events";import { useHomeStore } from "@/store/home";import { useSettingsJump } from "@/store/settingsJump";+import { useIdeSidePanelStore } from "@/store/ideSidePanel";+import { useIdeProjectsStore } from "@/store/ideProjects";function renderOpen() {const state = { open: true };@@ -76,4 +78,89 @@ describe("QuickSwitcher", () => {fireEvent.change(screen.getByTestId("quick-switcher-input"), { target: { value: "zzqxv" } });expect(screen.queryByTestId("quick-switch-settings")).toBeNull();});++ describe("live results", () => {+ const PANE = {+ workspace_id: "ws-2",+ workspace_name: "Blog",+ folder: "/work/blog",+ workspace_active: false,+ key: "T3",+ history_id: "h1",+ name: "codex-3",+ agent: "codex",+ display_name: "Codex",+ accepts_prompts: true,+ status: "live",+ exit_code: null,+ activity: "idle",+ activity_since: 0,+ worked: true,+ started_at: 0,+ last_output_at: 0,+ last_prompt: "speed up the mobile pages",+ last_prompt_at: 0,+ recap: "Blog speed: mobile pages twice as fast",+ has_resume: false,+ readable: true,+ account: null,+ account_label: null,+ archived: false,+ };++ beforeEach(() => {+ useEventStore.setState({+ conversations: [+ {+ kind: "voice",+ id: "c1",+ title: "Browser acceptance",+ preview: "check the browser",+ created_ms: 1,+ updated_ms: 2,+ message_count: 3,+ },+ ],+ });+ vi.stubGlobal(+ "fetch",+ vi.fn(async (url: string) => {+ if (String(url).includes("/api/agentic-ide/panes")) {+ return new Response(JSON.stringify({ panes: [PANE], active_id: "ws-1" }), { status: 200 });+ }+ return new Response("{}", { status: 404 });+ }),+ );+ });+ afterEach(() => vi.unstubAllGlobals());++ it("lists recent chats before anything is typed", () => {+ renderOpen();+ expect(screen.getByTestId("quick-switch-chat-c1")).toBeTruthy();+ });++ it("finds a chat by several words of its title", () => {+ renderOpen();+ fireEvent.change(screen.getByTestId("quick-switcher-input"), { target: { value: "browser accept" } });+ expect(screen.getByTestId("quick-switch-chat-c1")).toBeTruthy();+ });++ it("finds a terminal by its title and frames it in its workspace", async () => {+ renderOpen();+ fireEvent.change(screen.getByTestId("quick-switcher-input"), { target: { value: "mobile pages" } });+ const row = await screen.findByTestId("quick-switch-pane-ws-2-codex-3");+ fireEvent.click(row);+ expect(useEventStore.getState().activeSection).toBe("agentic-ide");+ expect(useIdeProjectsStore.getState().action).toMatchObject({+ kind: "activate-workspace",+ workspaceId: "ws-2",+ });+ expect(useIdeSidePanelStore.getState().spotlight).toEqual({ workspaceId: "ws-2", pane: "codex-3" });+ });++ it("opens with the text typed into the sidebar bar", () => {+ render(<QuickSwitcher open onOpenChange={() => {}} initialQuery="agen" />);+ expect((screen.getByTestId("quick-switcher-input") as HTMLInputElement).value).toBe("agen");+ });+ });});diff --git a/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsx b/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsxindex 76b5528e7a..25b3431916 100644--- a/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsx+++ b/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsx@@ -1,10 +1,13 @@/**- * The quick switcher — Ctrl+Space anywhere, type where you want to go, Enter.+ * The quick switcher — Ctrl+Space anywhere (or the search bar at the top of+ * the sidebar), type where you want to go, Enter.** Modelled on the Mac's Spotlight bar: one large field floating high on the* screen over a frosted panel, results directly underneath with the first one* already selected, the app still visible behind it (no dimming scrim). What it- * lists and how it ranks lives in `@/lib/quickSwitch`; this file only draws it.+ * lists and how it ranks lives in `@/lib/quickSwitch` (sections) and+ * `@/lib/quickSwitchSources` (chats, terminals, workspaces); this file draws it+ * and fetches the live lists once per opening.** cmdk drives the keyboard (arrows, Enter, the active row) with its own* filtering switched OFF — the ranking is ours and must not be re-scored@@ -13,18 +16,37 @@*/import * as Dialog from "@radix-ui/react-dialog";import { Command } from "cmdk";-import { CornerDownLeft, Search, Settings2 } from "lucide-react";-import { useMemo, useState } from "react";+import {+ CornerDownLeft,+ FolderOpen,+ MessageSquare,+ Mic,+ Search,+ Settings2,+ SquareTerminal,+ type LucideIcon,+} from "lucide-react";+import { useEffect, useMemo, useState, type ReactNode } from "react";import { useT, useUiLanguage } from "@/i18n";import { useEventStore } from "@/store/events";import { useHomeStore } from "@/store/home";import { useSettingsJump } from "@/store/settingsJump";+import { useIdeProjectsStore } from "@/store/ideProjects";+import { useIdeSidePanelStore } from "@/store/ideSidePanel";+import { formatChatWhen, useChatRows, type ChatRow } from "@/components/home/chatRows";+import {+ fetchIdeProjects,+ fetchWorkspacePanes,+ type ProjectWorkspace,+ type WorkspacePaneRow,+} from "@/lib/agenticIdeApi";import {ambiguousEntryKeys,rankQuickSwitch,strongSettingsMatches,type QuickSwitchEntry,} from "@/lib/quickSwitch";+import { folderName, rankItems } from "@/lib/quickSwitchSources";import { searchSettingsOptions } from "@/views/settings/settingsSearch";import { cn } from "@/lib/utils";@@ -53,12 +75,91 @@ const DETAIL = cn("group-data-[selected=true]:text-accent-foreground/80",);+const GROUP = cn(+ "[&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:pt-2.5",+ "[&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",+ "[&_[cmdk-group-heading]]:text-muted-foreground",+);++/** How many live results each group may show, so the sections stay in view. */+const LIMIT = { chats: 6, terminals: 6, workspaces: 4, recentChats: 4 } as const;++/** One result row: icon tile, a label that truncates, a quiet detail on the right. */+function ResultRow({+ value,+ testId,+ icon: Icon,+ label,+ detail,+ onSelect,+}: {+ value: string;+ testId: string;+ icon: LucideIcon;+ label: ReactNode;+ detail?: ReactNode;+ onSelect: () => void;+}) {+ return (+ <Command.Item value={value} onSelect={onSelect} data-testid={testId} className={ROW}>+ <span className={TILE}>+ <Icon className="h-4 w-4" aria-hidden />+ </span>+ <span className="min-w-0 truncate">{label}</span>+ {detail ? <span className={DETAIL}>{detail}</span> : null}+ </Command.Item>+ );+}++/**+ * The open workspaces and their panes, fetched once each time the switcher+ * opens. A headless or older backend simply contributes nothing — the+ * switcher must never fail to open because the IDE is not there.+ */+function useIdeResults(): { panes: WorkspacePaneRow[]; workspaces: ProjectWorkspace[] } {+ const [panes, setPanes] = useState<WorkspacePaneRow[]>([]);+ const [workspaces, setWorkspaces] = useState<ProjectWorkspace[]>([]);+ useEffect(() => {+ let live = true;+ fetchWorkspacePanes()+ .then((found) => {+ if (live) setPanes(found.panes.filter((pane) => !pane.archived));+ })+ .catch(() => {+ /* no IDE on this backend — no terminal results */+ });+ fetchIdeProjects()+ .then((found) => {+ if (!live) return;+ const open = found.projects.flatMap((project) =>+ project.workspaces.filter((workspace) => workspace.status === "open"),+ );+ setWorkspaces(open.sort((a, b) => b.last_active_at - a.last_active_at));+ })+ .catch(() => {+ /* no IDE on this backend — no workspace results */+ });+ return () => {+ live = false;+ };+ }, []);+ return { panes, workspaces };+}++/** What a terminal row is called: its title, else its last prompt, else its agent. */+function paneTitle(pane: WorkspacePaneRow): string {+ return pane.recap || pane.last_prompt || pane.display_name || pane.key;+}+export function QuickSwitcher({open,onOpenChange,+ initialQuery = "",}: {open: boolean;onOpenChange: (open: boolean) => void;+ /** Text already typed into the sidebar search bar that opened this. */+ initialQuery?: string;}) {const t = useT();const label = useLabel();@@ -67,7 +168,12 @@ export function QuickSwitcher({const setActiveSection = useEventStore((s) => s.setActiveSection);const setSurface = useHomeStore((s) => s.setSurface);const requestSettingsJump = useSettingsJump((s) => s.request);- const [query, setQuery] = useState("");+ const activateWorkspace = useIdeProjectsStore((s) => s.activateWorkspace);+ const setSpotlight = useIdeSidePanelStore((s) => s.setSpotlight);+ const [query, setQuery] = useState(initialQuery);+ const { rows: chatRows, open: openChat } = useChatRows();+ const { panes, workspaces } = useIdeResults();+ const typed = query.trim() !== "";// About forty destinations — ranked inline on every keystroke, no memo needed.const labelFor = (item: QuickSwitchEntry) => label(item.labelKey, item.fallbackLabel);@@ -77,6 +183,26 @@ export function QuickSwitcher({() => strongSettingsMatches(query, searchSettingsOptions(language, query, t)),[query, language, t],);+ // Nothing typed yet: the most recent chats, like Spotlight's recents.+ const chatHits = typed+ ? rankItems(query, chatRows, (row) => [row.title, row.preview], LIMIT.chats)+ : chatRows.slice(0, LIMIT.recentChats);+ const paneHits = typed+ ? rankItems(+ query,+ panes,+ (pane) => [pane.recap, pane.last_prompt, pane.display_name, pane.key, pane.workspace_name],+ LIMIT.terminals,+ )+ : [];+ const workspaceHits = typed+ ? rankItems(+ query,+ workspaces,+ (workspace) => [workspace.name, folderName(workspace.folder), workspace.branch],+ LIMIT.workspaces,+ )+ : [];const close = () => {onOpenChange(false);@@ -89,6 +215,25 @@ export function QuickSwitcher({close();};+ const goToChat = (row: ChatRow) => {+ openChat(row);+ close();+ };++ /** Bring the pane's workspace to the front and frame the pane in the grid. */+ const goToPane = (pane: WorkspacePaneRow) => {+ setActiveSection("agentic-ide");+ if (!pane.workspace_active) activateWorkspace(pane.workspace_id);+ setSpotlight({ workspaceId: pane.workspace_id, pane: pane.name });+ close();+ };++ const goToWorkspace = (workspace: ProjectWorkspace) => {+ setActiveSection("agentic-ide");+ if (!workspace.active) activateWorkspace(workspace.id);+ close();+ };+const goToSetting = (groupId: string) => {requestSettingsJump(groupId);setActiveSection("settings");@@ -132,61 +277,92 @@ export function QuickSwitcher({className="h-14 flex-1 bg-transparent text-2xl font-light text-foreground outline-none placeholder:text-muted-foreground"/></div>- <Command.List className="max-h-[min(26rem,60dvh)] overflow-y-auto border-t border-border p-1.5 scrollbar-jarvis">+ <Command.List className="max-h-[min(30rem,62dvh)] overflow-y-auto border-t border-border p-1.5 scrollbar-jarvis"><Command.Empty className="px-3 py-6 text-center text-base text-muted-foreground">{t("quick_switch.no_results")}</Command.Empty>{ranked.length > 0 && (- <Command.Group- heading={t("quick_switch.group_sections")}- className="[&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:pt-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground"- >+ <Command.Group heading={t("quick_switch.group_sections")} className={GROUP}>{ranked.map(({ entry: item, label: text }) => {- const Icon = item.icon;const here = item.section === activeSection && !item.surface;const area = item.parentLabelKey ? label(item.parentLabelKey, "") : "";// A label two rows share names its area up front, e.g.// "Voice › API Keys" beside the API Keys page itself.const shown = area && ambiguous.has(item.key) ? `${area} › ${text}` : text;return (- <Command.Item+ <ResultRowkey={item.key}value={`section:${item.key}`}+ testId={`quick-switch-${item.key}`}+ icon={item.icon}+ label={shown}+ detail={here ? t("quick_switch.current") : shown === text ? area : ""}onSelect={() => go(item)}- data-testid={`quick-switch-${item.key}`}- className={ROW}- >- <span className={TILE}>- <Icon className="h-4 w-4" aria-hidden />- </span>- <span className="min-w-0 truncate">{shown}</span>- <span className={DETAIL}>- {here ? t("quick_switch.current") : shown === text ? area : ""}- </span>- </Command.Item>+ />);})}</Command.Group>)}- {settingsMatches.length > 0 && (+ {chatHits.length > 0 && (<Command.Group- heading={t("quick_switch.group_settings")}- className="[&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:pt-2.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground"+ heading={t(typed ? "quick_switch.group_chats" : "quick_switch.group_recent_chats")}+ className={GROUP}>+ {chatHits.map((row) => (+ <ResultRow+ key={`${row.kind}:${row.id}`}+ value={`chat:${row.kind}:${row.id}`}+ testId={`quick-switch-chat-${row.id}`}+ icon={row.kind === "voice" ? Mic : MessageSquare}+ label={row.title || t("quick_switch.untitled_chat")}+ detail={formatChatWhen(row.updatedMs)}+ onSelect={() => goToChat(row)}+ />+ ))}+ </Command.Group>+ )}+ {paneHits.length > 0 && (+ <Command.Group heading={t("quick_switch.group_terminals")} className={GROUP}>+ {paneHits.map((pane) => (+ <ResultRow+ key={`${pane.workspace_id}:${pane.name}`}+ value={`pane:${pane.workspace_id}:${pane.name}`}+ testId={`quick-switch-pane-${pane.workspace_id}-${pane.name}`}+ icon={SquareTerminal}+ label={paneTitle(pane)}+ detail={`${pane.key} · ${pane.workspace_name}`}+ onSelect={() => goToPane(pane)}+ />+ ))}+ </Command.Group>+ )}+ {workspaceHits.length > 0 && (+ <Command.Group heading={t("quick_switch.group_workspaces")} className={GROUP}>+ {workspaceHits.map((workspace) => (+ <ResultRow+ key={workspace.id}+ value={`workspace:${workspace.id}`}+ testId={`quick-switch-workspace-${workspace.id}`}+ icon={FolderOpen}+ label={workspace.name}+ detail={workspace.branch || folderName(workspace.folder)}+ onSelect={() => goToWorkspace(workspace)}+ />+ ))}+ </Command.Group>+ )}+ {settingsMatches.length > 0 && (+ <Command.Group heading={t("quick_switch.group_settings")} className={GROUP}>{settingsMatches.map((match) => (- <Command.Item+ <ResultRowkey={match.id}value={`setting:${match.id}`}+ testId={`quick-switch-setting-${match.id}`}+ icon={Settings2}+ label={match.label}+ detail={label("nav.settings", "Settings")}onSelect={() => goToSetting(match.id)}- data-testid={`quick-switch-setting-${match.id}`}- className={ROW}- >- <span className={TILE}>- <Settings2 className="h-4 w-4" aria-hidden />- </span>- <span className="min-w-0 truncate">{match.label}</span>- <span className={DETAIL}>{label("nav.settings", "Settings")}</span>- </Command.Item>+ />))}</Command.Group>)}diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsxindex 0fcf382e56..cbc8a7d8ec 100644--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx@@ -10,6 +10,8 @@ import {} from "@/components/layout/Sidebar";import { NAV_GROUPS, NAV_FOOTER_ITEMS, SETTINGS_HUB_IDS } from "@/components/layout/navGroups";import { isSectionId, useEventStore } from "@/store/events";+import { useQuickSwitcher } from "@/store/quickSwitcher";+import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";import { useHomeStore } from "@/store/home";import { useIdeChatStore } from "@/store/ideChat";import { useIdeProjectsStore } from "@/store/ideProjects";@@ -236,7 +238,11 @@ describe("Sidebar header avatar", () => {// nothing stable to assert. What matters is that the avatar shows the mark// and not a stale public/ path a browser would serve from cache.test("renders the Gigi app mark from the bundle, not a public path", () => {+ // The mark heads the identity row, which returns when the quick+ // switcher (and with it the search bar) is switched off.+ useQuickSwitchSettings.setState({ enabled: false });const { container } = renderSidebar();+ useQuickSwitchSettings.setState({ enabled: true });const avatar = container.querySelector('[data-testid="sidebar-style-avatar"]');expect(avatar).not.toBeNull();expect(avatar?.getAttribute("data-variant")).toBe("logo");@@ -323,21 +329,44 @@ describe("Sidebar assistant name header", () => {renderSidebar();- expect(screen.getByText("Ruben")).toBeTruthy();- expect(screen.queryByText("Jarvis")).toBeNull();+ // The name lives in the search bar's accessible name now.+ const bar = screen.getByTestId("sidebar-search");+ expect(bar.getAttribute("aria-label")).toContain("Ruben");+ expect(bar.getAttribute("aria-label")).not.toContain("Jarvis");});test("follows a live assistant-name change", () => {useEventStore.setState({ assistantName: "Nova" });renderSidebar();- expect(screen.getByText("Nova")).toBeTruthy();+ const bar = () => screen.getByTestId("sidebar-search").getAttribute("aria-label") ?? "";+ expect(bar()).toContain("Nova");act(() => {useEventStore.setState({ assistantName: "Athena" });});- expect(screen.getByText("Athena")).toBeTruthy();- expect(screen.queryByText("Nova")).toBeNull();+ expect(bar()).toContain("Athena");+ expect(bar()).not.toContain("Nova");+ });++ test("the search bar opens the quick switcher with the typed key", () => {+ renderSidebar();+ const bar = screen.getByTestId("sidebar-search");+ fireEvent.keyDown(bar, { key: "a" });+ expect(useQuickSwitcher.getState()).toMatchObject({ open: true, initialQuery: "a" });+ act(() => useQuickSwitcher.getState().hide());+ fireEvent.click(bar);+ expect(useQuickSwitcher.getState()).toMatchObject({ open: true, initialQuery: "" });+ act(() => useQuickSwitcher.getState().hide());+ });++ test("switching the quick switcher off brings the name row back", () => {+ useEventStore.setState({ assistantName: "Ruben" });+ useQuickSwitchSettings.setState({ enabled: false });+ renderSidebar();+ expect(screen.queryByTestId("sidebar-search")).toBeNull();+ expect(screen.getByText("Ruben")).toBeTruthy();+ useQuickSwitchSettings.setState({ enabled: true });});});diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsxindex 0765f15985..61383714b7 100644--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx@@ -28,6 +28,8 @@ import { RecentChats } from "@/components/home/RecentChats";import { useHomeStore } from "@/store/home";import { IdeProjectTree } from "@/components/agentic/IdeProjectTree";import { useIdeProjectsStore } from "@/store/ideProjects";+import { SidebarSearchBar } from "@/components/layout/SidebarSearchBar";+import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";import { useAppInstance } from "@/hooks/useAppInstance";import { usePublishIdentity } from "@/components/marketplace/PublishIdentity";import { GigiMark } from "@/components/GigiMark";@@ -170,6 +172,9 @@ export function Sidebar({const toggleIdeVoice = useIdeProjectsStore((s) => s.toggleVoice);const voiceState = useEventStore((s) => s.voiceState);const assistantName = useEventStore((s) => s.assistantName);+ // The search bar takes the identity row's place while the quick+ // switcher is on; switched off, the row comes back as it was.+ const searchBarOn = useQuickSwitchSettings((s) => s.enabled);// The dev instance (a second, restartable app beside the live one — see// jarvis.core.instance) shows a small tag so the two windows are never// confused; the default app shows nothing here.@@ -349,7 +354,7 @@ export function Sidebar({railed ? "flex-col justify-center gap-1.5" : "w-full gap-2",)}>- <span+ {(railed || !searchBarOn) && <spandata-testid="sidebar-style-avatar"data-variant="logo"title={railed ? `${assistantName} — ${voiceLabel}` : undefined}@@ -365,7 +370,7 @@ export function Sidebar({</span>)}<GigiMark size={railed ? 36 : 20} />- </span>+ </span>}{/* One quiet row, like the workspace switcher in Linear or Cursor:mark, name, status dot. It used to be a two-line identity cardwhose second line said "Ready" for as long as nothing was wrong,@@ -373,7 +378,49 @@ export function Sidebar({the loudest spot in the column. The dot says "fine" on its own(its hover and accessible name still carry the word); the wordonly appears when there IS news: starting, offline, error. */}- {!railed && (+ {!railed && searchBarOn && (+ <SidebarSearchBar+ assistantName={assistantName}+ status={+ <>+ {voiceHasNews && (+ <span className="max-w-[7rem] shrink-0 truncate text-xs text-muted-foreground">+ {voiceLabel}+ </span>+ )}+ {devTag && (+ <span+ data-testid="sidebar-instance-tag"+ title={t("sidebar.instance_dev_hint")}+ className="shrink-0 rounded-sm bg-primary px-1.5 text-xs font-medium leading-none text-primary-foreground"+ >+ {devTag}+ </span>+ )}+ {showSpinner ? (+ <Loader2+ className="h-3 w-3 shrink-0 animate-spin text-muted-foreground"+ data-testid="voice-starting-spinner"+ aria-hidden+ />+ ) : (+ <span+ data-testid="sidebar-voice-dot"+ role="img"+ aria-label={voiceLabel}+ title={voiceLabel}+ className={cn(+ "h-1.5 w-1.5 shrink-0 rounded-full",+ vs.dot,+ vs.pulse && "animate-jarvis-pulse",+ )}+ />+ )}+ </>+ }+ />+ )}+ {!railed && !searchBarOn && (<divclassName="flex min-w-0 flex-1 items-center gap-2 text-sm"title={voiceLabel}diff --git a/jarvis/ui/web/frontend/src/components/layout/SidebarSearchBar.tsx b/jarvis/ui/web/frontend/src/components/layout/SidebarSearchBar.tsxnew file mode 100644index 0000000000..abc31eca5e--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/layout/SidebarSearchBar.tsx@@ -0,0 +1,83 @@+/**+ * The search bar at the top of the sidebar — the visible door into the quick+ * switcher, in the spot the assistant's name row used to take.+ *+ * It reads and behaves like a search field: click it, press Enter or an arrow,+ * or simply start typing while it has focus. The first character typed opens+ * the switcher with that character already in its field, so a fast typist+ * loses nothing. It reads "Search": the assistant's name beside the chord hint+ * and the voice dot was cut to "Search Ge…" at the default width. The+ * accessible name still says what is searched ("Search George"). The voice+ * status dot (plus the dev-instance tag) sits at its right edge.+ *+ * A button rather than a real <input>: the switcher's own field is where text+ * is edited, and a second editable field that hands its text over on every+ * key would fight it for focus. `role="search"` keeps it a search landmark.+ */+import type { ReactNode } from "react";+import { Search } from "lucide-react";+import { useT } from "@/i18n";+import { useQuickSwitcher } from "@/store/quickSwitcher";+import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";+import { chordCaps } from "@/lib/quickSwitchChord";+import { cn } from "@/lib/utils";++export function SidebarSearchBar({+ assistantName,+ status,+}: {+ assistantName: string;+ /** The voice dot / spinner and the dev tag, drawn at the bar's right edge. */+ status?: ReactNode;+}) {+ const t = useT();+ const show = useQuickSwitcher((s) => s.show);+ const combo = useQuickSwitchSettings((s) => s.combo);+ const caps = combo ? chordCaps(combo) : [];+ const accessibleName = t("quick_switch.sidebar_placeholder").replace("{name}", assistantName);++ return (+ <div role="search" className="min-w-0 flex-1">+ <button+ type="button"+ data-testid="sidebar-search"+ aria-label={accessibleName}+ title={accessibleName}+ onClick={() => show()}+ onKeyDown={(event) => {+ if (event.ctrlKey || event.metaKey || event.altKey) return;+ // A printable key opens the switcher with that key already typed.+ if (event.key.length === 1 && event.key !== " ") {+ event.preventDefault();+ show(event.key);+ } else if (event.key === "ArrowDown") {+ event.preventDefault();+ show();+ }+ }}+ className={cn(+ "group flex h-8 w-full items-center gap-2 rounded-lg border border-border bg-secondary/60 px-2.5",+ "text-left text-sm text-muted-foreground transition-colors",+ "hover:border-border-strong hover:bg-secondary hover:text-foreground",+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",+ )}+ >+ <Search className="h-3.5 w-3.5 shrink-0" aria-hidden />+ <span className="min-w-0 flex-1 truncate">{t("quick_switch.sidebar_search")}</span>+ {status}+ {caps.length > 0 && (+ <span className="hidden shrink-0 items-center gap-0.5 sm:inline-flex" aria-hidden>+ {caps.map((cap) => (+ <kbd+ key={cap}+ className="rounded border border-border bg-background px-1 font-sans text-[10px] leading-4 text-muted-foreground"+ >+ {cap}+ </kbd>+ ))}+ </span>+ )}+ </button>+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 4b6c2aed63..e49d183baa 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -1656,7 +1656,14 @@"current": "Du bist hier","hint_open": "Öffnen","hint_close": "Schließen",- "terminal_grid": "Terminal-Raster"+ "terminal_grid": "Terminal-Raster",+ "sidebar_placeholder": "{name} durchsuchen",+ "sidebar_search": "Suchen",+ "group_chats": "Chats",+ "group_recent_chats": "Letzte Chats",+ "group_terminals": "Terminals",+ "group_workspaces": "Arbeitsbereiche",+ "untitled_chat": "Chat ohne Titel"},"board_view": {"title": "Board",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex a6be6f353f..ab4dbe57e2 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -1689,7 +1689,14 @@"current": "You are here","hint_open": "Open","hint_close": "Close",- "terminal_grid": "Terminal grid"+ "terminal_grid": "Terminal grid",+ "sidebar_placeholder": "Search {name}",+ "sidebar_search": "Search",+ "group_chats": "Chats",+ "group_recent_chats": "Recent chats",+ "group_terminals": "Terminals",+ "group_workspaces": "Workspaces",+ "untitled_chat": "Untitled chat"},"board_view": {"title": "Board",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex a3200c57a2..85734db275 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -1656,7 +1656,14 @@"current": "Estás aquí","hint_open": "Abrir","hint_close": "Cerrar",- "terminal_grid": "Cuadrícula de terminales"+ "terminal_grid": "Cuadrícula de terminales",+ "sidebar_placeholder": "Buscar en {name}",+ "sidebar_search": "Buscar",+ "group_chats": "Chats",+ "group_recent_chats": "Chats recientes",+ "group_terminals": "Terminales",+ "group_workspaces": "Espacios de trabajo",+ "untitled_chat": "Chat sin título"},"board_view": {"title": "Tablero",diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitchChord.ts b/jarvis/ui/web/frontend/src/lib/quickSwitchChord.tsindex d0a516ea7f..0686757343 100644--- a/jarvis/ui/web/frontend/src/lib/quickSwitchChord.ts+++ b/jarvis/ui/web/frontend/src/lib/quickSwitchChord.ts@@ -186,3 +186,20 @@ export function quickSwitchComboProblem(if (primaryOnly) return "app_reserved";return null;}++const MAC_GLYPH: Record<string, string> = { ctrl: "⌃", alt: "⌥", shift: "⇧", meta: "⌘" };+const PC_NAME: Record<string, string> = { ctrl: "Ctrl", alt: "Alt", shift: "Shift", meta: "Win" };+const MOD_ORDER = ["ctrl", "alt", "shift", "meta"] as const;++/**+ * The chord as keycap labels, for a hint next to the sidebar search bar+ * ("Ctrl", "Space" — or "⌥", "Space" on a Mac). Small on purpose: the full+ * formatter lives with the recorder, outside the startup chunk.+ */+export function chordCaps(combo: string, platform: ChordPlatform = hostChordPlatform()): string[] {+ const { mods, keys } = parseChord(combo);+ const names = platform === "mac" ? MAC_GLYPH : PC_NAME;+ const key = (token: string) =>+ token === "space" ? "Space" : token.length === 1 ? token.toUpperCase() : token[0].toUpperCase() + token.slice(1);+ return [...MOD_ORDER.filter((m) => mods.has(m)).map((m) => names[m]), ...keys.map(key)];+}diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitchSources.test.ts b/jarvis/ui/web/frontend/src/lib/quickSwitchSources.test.tsnew file mode 100644index 0000000000..f14101cfb5--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/quickSwitchSources.test.ts@@ -0,0 +1,29 @@+import { describe, expect, it } from "vitest";+import { folderName, matchScore, rankItems } from "./quickSwitchSources";++describe("matchScore", () => {+ it("needs every word of the query somewhere", () => {+ expect(matchScore("browser accept", ["Browser acceptance"])).toBeGreaterThan(0);+ expect(matchScore("browser zebra", ["Browser acceptance"])).toBe(0);+ });++ it("keeps short words to word starts", () => {+ expect(matchScore("ide", ["provide the numbers"])).toBe(0);+ expect(matchScore("ide", ["Agentic IDE"])).toBeGreaterThan(0);+ });+});++describe("rankItems", () => {+ it("ranks better matches first, caps the list and keeps input order on ties", () => {+ const items = ["blog speed", "speed", "speedy blog", "other"];+ expect(rankItems("speed", items, (s) => [s], 2)).toEqual(["speed", "speedy blog"]);+ expect(rankItems("blog", items, (s) => [s], 5)).toEqual(["blog speed", "speedy blog"]);+ });+});++describe("folderName", () => {+ it("takes the last segment on either separator", () => {+ expect(folderName("C:\\work\\blog")).toBe("blog");+ expect(folderName("/home/me/site/")).toBe("site");+ });+});diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitchSources.ts b/jarvis/ui/web/frontend/src/lib/quickSwitchSources.tsnew file mode 100644index 0000000000..91f252baaa--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/quickSwitchSources.ts@@ -0,0 +1,50 @@+/**+ * Ranking for the quick switcher's live results — chats, terminals and+ * workspaces — next to the fixed section list in `./quickSwitch`.+ *+ * These are free text (a chat's title, a terminal's last prompt), so a query+ * of several words matches when EVERY word is found somewhere in the item:+ * "browser accept" finds the chat "Browser acceptance". Each word is scored+ * with the section ranking's own rules (exact > prefix > word start >+ * initials > mid-word from four letters), so "ide" still does not find+ * "provide" here either.+ */+import { normalizeQuery, scoreTerm } from "@/lib/quickSwitch";++/** 0 when some word of the query is found nowhere in `fields`. */+export function matchScore(query: string, fields: readonly (string | null | undefined)[]): number {+ const words = normalizeQuery(query).split(/\s+/).filter(Boolean);+ if (words.length === 0) return 0;+ const texts = fields.map((field) => normalizeQuery(field ?? "")).filter(Boolean);+ let total = 0;+ for (const word of words) {+ const best = Math.max(0, ...texts.map((text) => scoreTerm(text, word)));+ if (best === 0) return 0;+ total += best;+ }+ return total / words.length;+}++/**+ * The items that match, best first, at most `limit`. Ties keep the input+ * order, which the callers make "most recent first".+ */+export function rankItems<T>(+ query: string,+ items: readonly T[],+ fields: (item: T) => readonly (string | null | undefined)[],+ limit: number,+): T[] {+ return items+ .map((item, index) => ({ item, index, score: matchScore(query, fields(item)) }))+ .filter((row) => row.score > 0)+ .sort((a, b) => b.score - a.score || a.index - b.index)+ .slice(0, limit)+ .map((row) => row.item);+}++/** The last path segment of a folder, for a short "where" next to a name. */+export function folderName(folder: string): string {+ const parts = folder.split(/[\\/]+/).filter(Boolean);+ return parts[parts.length - 1] ?? folder;+}diff --git a/jarvis/ui/web/frontend/src/store/quickSwitcher.ts b/jarvis/ui/web/frontend/src/store/quickSwitcher.tsnew file mode 100644index 0000000000..b2d417c5d2--- /dev/null+++ b/jarvis/ui/web/frontend/src/store/quickSwitcher.ts@@ -0,0 +1,27 @@+/**+ * Whether the quick switcher is open, and what it opens with.+ *+ * Two doors lead into it: the chord (App.tsx) and the search bar at the top of+ * the sidebar. The bar is typed into like a field — the first character opens+ * the switcher with that character already in it, so nothing typed is lost —+ * which is why the open state carries an initial query instead of being a bare+ * flag inside App.+ */+import { create } from "zustand";++interface QuickSwitcherState {+ open: boolean;+ /** Seeds the switcher's field when it opens; read once, on mount. */+ initialQuery: string;+ show: (initialQuery?: string) => void;+ hide: () => void;+ toggle: () => void;+}++export const useQuickSwitcher = create<QuickSwitcherState>((set, get) => ({+ open: false,+ initialQuery: "",+ show: (initialQuery = "") => set({ open: true, initialQuery }),+ hide: () => set({ open: false, initialQuery: "" }),+ toggle: () => (get().open ? get().hide() : get().show()),+}));