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): Spotlight-style quick switcher on Ctrl+Space
rubenluetke10-beep046360e8f1d2
diff --git a/jarvis/ui/web/frontend/src/App.tsx b/jarvis/ui/web/frontend/src/App.tsxindex 1dd49e6072..d887bd2a7a 100644--- a/jarvis/ui/web/frontend/src/App.tsx+++ b/jarvis/ui/web/frontend/src/App.tsx@@ -39,6 +39,14 @@ const ShortcutOverlay = lazy(() =>import("@/components/ShortcutOverlay").then((m) => ({ default: m.ShortcutOverlay })),);import { shouldOpenShortcutOverlay } from "@/lib/shortcutOverlayTrigger";+/*+ Lazy for the same reason: the switcher carries every locale for its+ cross-language search, and nobody needs it before the first Ctrl+Space.+*/+const QuickSwitcher = lazy(() =>+ import("@/components/QuickSwitcher").then((m) => ({ default: m.QuickSwitcher })),+);+import { isQuickSwitchChord } from "@/lib/quickSwitchChord";import { JarvisDock } from "@/components/JarvisDock";import { CliConnectPoller } from "@/components/CliConnectPoller";import { OnboardingGate } from "@/components/onboarding/OnboardingGate";@@ -106,6 +114,25 @@ export default function App() {return () => window.removeEventListener("keydown", onKeyDown);}, []);+ /*+ Ctrl+Space opens the quick switcher — the Spotlight-style "type a section,+ press Enter" launcher. Listened for in the CAPTURE phase so it also works+ while a terminal pane has focus: xterm handles keys on its own textarea and+ would otherwise swallow the chord as a NUL byte for the agent. Pressing it+ again closes the switcher, the way Spotlight's own chord toggles.+ */+ const [switcherOpen, setSwitcherOpen] = useState(false);+ useEffect(() => {+ const onKeyDown = (event: KeyboardEvent) => {+ if (event.repeat || !isQuickSwitchChord(event)) return;+ event.preventDefault();+ event.stopPropagation();+ setSwitcherOpen((open) => !open);+ };+ window.addEventListener("keydown", onKeyDown, true);+ return () => window.removeEventListener("keydown", onKeyDown, true);+ }, []);+useWebSocket();useBrainStatus();useVoiceStatus();@@ -384,6 +411,13 @@ export default function App() {<CliConnectPoller />{/* Blocking onboarding gate — overlays everything until first-run setup is complete. */}<OnboardingGate activeSection={activeSection} />+ {/* Ctrl+Space anywhere; the chunk loads on first use. Main window only:+ a detached solo window IS one section, there is nowhere to switch. */}+ {switcherOpen && (+ <Suspense fallback={null}>+ <QuickSwitcher open onOpenChange={setSwitcherOpen} />+ </Suspense>+ )}{/* `?` anywhere in the app opens this; the chunk loads on first use. */}{shortcutsOpen && (<Suspense fallback={null}>diff --git a/jarvis/ui/web/frontend/src/components/QuickSwitcher.test.tsx b/jarvis/ui/web/frontend/src/components/QuickSwitcher.test.tsxnew file mode 100644index 0000000000..0e7f0987e9--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/QuickSwitcher.test.tsx@@ -0,0 +1,79 @@+/**+ * The quick switcher end to end: type, Enter, you are there.+ */+import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { cleanup, fireEvent, render, screen } from "@testing-library/react";++// Radix Dialog and cmdk touch browser APIs jsdom does not ship.+class ResizeObserverPolyfill {+ observe() {}+ unobserve() {}+ disconnect() {}+}+if (typeof (globalThis as { ResizeObserver?: unknown }).ResizeObserver === "undefined") {+ (globalThis as unknown as { ResizeObserver: typeof ResizeObserverPolyfill }).ResizeObserver =+ ResizeObserverPolyfill;+}+if (typeof Element !== "undefined" && !("scrollIntoView" in Element.prototype)) {+ // @ts-expect-error -- jsdom shim+ Element.prototype.scrollIntoView = () => {};+}++import { QuickSwitcher } from "./QuickSwitcher";+import { useEventStore } from "@/store/events";+import { useHomeStore } from "@/store/home";+import { useSettingsJump } from "@/store/settingsJump";++function renderOpen() {+ const state = { open: true };+ const onOpenChange = (next: boolean) => {+ state.open = next;+ };+ render(<QuickSwitcher open onOpenChange={onOpenChange} />);+ return state;+}++describe("QuickSwitcher", () => {+ beforeEach(() => {+ useEventStore.getState().setActiveSection("chats");+ useSettingsJump.setState({ target: null });+ });+ afterEach(cleanup);++ it("lists every destination before anything is typed", () => {+ renderOpen();+ expect(screen.getByTestId("quick-switch-agentic-ide")).toBeTruthy();+ expect(screen.getByTestId("quick-switch-settings")).toBeTruthy();+ });++ it("goes to the top match on Enter and closes", () => {+ const state = renderOpen();+ const input = screen.getByTestId("quick-switcher-input");+ fireEvent.change(input, { target: { value: "agentic" } });+ fireEvent.keyDown(input, { key: "Enter" });+ expect(useEventStore.getState().activeSection).toBe("agentic-ide");+ expect(state.open).toBe(false);+ });++ it("flips the front page to the face that was picked", () => {+ useHomeStore.getState().setSurface("voice");+ renderOpen();+ fireEvent.click(screen.getByTestId("quick-switch-chat"));+ expect(useEventStore.getState().activeSection).toBe("chats");+ expect(useHomeStore.getState().surface).toBe("chat");+ });++ it("hands a Settings group to the hub", () => {+ renderOpen();+ fireEvent.change(screen.getByTestId("quick-switcher-input"), { target: { value: "wake word" } });+ fireEvent.click(screen.getByTestId("quick-switch-setting-wake-word"));+ expect(useEventStore.getState().activeSection).toBe("settings");+ expect(useSettingsJump.getState().target).toBe("wake-word");+ });++ it("says so when nothing matches", () => {+ renderOpen();+ fireEvent.change(screen.getByTestId("quick-switcher-input"), { target: { value: "zzqxv" } });+ expect(screen.queryByTestId("quick-switch-settings")).toBeNull();+ });+});diff --git a/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsx b/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsxnew file mode 100644index 0000000000..f79c7dc22c--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsx@@ -0,0 +1,204 @@+/**+ * The quick switcher — Ctrl+Space anywhere, 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.+ *+ * 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+ * (the same reason WikiSearch turns it off). Radix Dialog owns Escape, the+ * focus trap and handing focus back to the pane or field you came from.+ */+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 { useT, useUiLanguage } from "@/i18n";+import { useEventStore } from "@/store/events";+import { useHomeStore } from "@/store/home";+import { useSettingsJump } from "@/store/settingsJump";+import { rankQuickSwitch, strongSettingsMatches, type QuickSwitchEntry } from "@/lib/quickSwitch";+import { searchSettingsOptions } from "@/views/settings/settingsSearch";+import { cn } from "@/lib/utils";++/** Resolve a label, falling back when the key is missing (the resolver echoes it). */+function useLabel() {+ const t = useT();+ return (key: string, fallback: string) => {+ const value = t(key);+ return value === key ? fallback : value;+ };+}++const ROW = cn(+ "group flex h-11 cursor-default select-none items-center gap-3 rounded-lg px-2.5",+ "text-base text-foreground outline-none",+ "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground",+);++const TILE = cn(+ "grid h-7 w-7 shrink-0 place-items-center rounded-md bg-secondary text-muted-foreground",+ "group-data-[selected=true]:bg-white/20 group-data-[selected=true]:text-accent-foreground",+);++const DETAIL = cn(+ "ml-auto shrink-0 truncate pl-3 text-sm text-muted-foreground",+ "group-data-[selected=true]:text-accent-foreground/80",+);++export function QuickSwitcher({+ open,+ onOpenChange,+}: {+ open: boolean;+ onOpenChange: (open: boolean) => void;+}) {+ const t = useT();+ const label = useLabel();+ const language = useUiLanguage();+ const activeSection = useEventStore((s) => s.activeSection);+ const setActiveSection = useEventStore((s) => s.setActiveSection);+ const setSurface = useHomeStore((s) => s.setSurface);+ const requestSettingsJump = useSettingsJump((s) => s.request);+ const [query, setQuery] = useState("");++ // About forty destinations — ranked inline on every keystroke, no memo needed.+ const ranked = rankQuickSwitch(query, (item) => label(item.labelKey, item.fallbackLabel));+ const settingsMatches = useMemo(+ () => strongSettingsMatches(query, searchSettingsOptions(language, query, t)),+ [query, language, t],+ );++ const close = () => {+ onOpenChange(false);+ setQuery("");+ };++ const go = (item: QuickSwitchEntry) => {+ if (item.surface) setSurface(item.surface);+ setActiveSection(item.section);+ close();+ };++ const goToSetting = (groupId: string) => {+ requestSettingsJump(groupId);+ setActiveSection("settings");+ close();+ };++ return (+ <Dialog.Root+ open={open}+ onOpenChange={(next) => {+ if (!next) setQuery("");+ onOpenChange(next);+ }}+ >+ <Dialog.Portal>+ {/* Spotlight never dims the desktop: the overlay only catches the+ click that closes it. */}+ <Dialog.Overlay className="fixed inset-0 z-[80]" />+ <Dialog.Content+ data-testid="quick-switcher"+ aria-describedby={undefined}+ className={cn(+ "fixed left-1/2 top-[18%] z-[90] w-[min(640px,calc(100vw-2rem))] -translate-x-1/2",+ "overflow-hidden rounded-2xl border border-border shadow-float",+ "backdrop-blur-2xl backdrop-saturate-150",+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",+ "motion-reduce:animate-none",+ )}+ style={{ backgroundColor: "hsl(var(--popover) / 0.86)" }}+ >+ <Dialog.Title className="sr-only">{t("quick_switch.title")}</Dialog.Title>+ <Command shouldFilter={false} loop label={t("quick_switch.title")}>+ <div className="flex items-center gap-3 px-4">+ <Search className="h-6 w-6 shrink-0 text-muted-foreground" aria-hidden />+ <Command.Input+ autoFocus+ value={query}+ onValueChange={setQuery}+ placeholder={t("quick_switch.placeholder")}+ data-testid="quick-switcher-input"+ 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.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"+ >+ {ranked.map(({ entry: item, label: text }) => {+ const Icon = item.icon;+ const here = item.section === activeSection && !item.surface;+ return (+ <Command.Item+ key={item.key}+ value={`section:${item.key}`}+ 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">{text}</span>+ <span className={DETAIL}>+ {here+ ? t("quick_switch.current")+ : item.parentLabelKey+ ? label(item.parentLabelKey, "")+ : ""}+ </span>+ </Command.Item>+ );+ })}+ </Command.Group>+ )}+ {settingsMatches.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"+ >+ {settingsMatches.map((match) => (+ <Command.Item+ key={match.id}+ value={`setting:${match.id}`}+ 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>+ )}+ </Command.List>+ <div className="flex items-center justify-end gap-4 border-t border-border px-4 py-2 text-xs text-muted-foreground">+ <span className="inline-flex items-center gap-1.5">+ <kbd className="inline-flex h-5 items-center rounded border border-border px-1 font-sans">+ <CornerDownLeft className="h-3 w-3" aria-hidden />+ </kbd>+ {t("quick_switch.hint_open")}+ </span>+ <span className="inline-flex items-center gap-1.5">+ <kbd className="inline-flex h-5 items-center rounded border border-border px-1 font-sans">esc</kbd>+ {t("quick_switch.hint_close")}+ </span>+ </div>+ </Command>+ </Dialog.Content>+ </Dialog.Portal>+ </Dialog.Root>+ );+}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex ab573ec9bc..b508b5725f 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -1584,9 +1584,21 @@"zoom_in": "Terminaltext größer","zoom_out": "Terminaltext kleiner","zoom_reset": "Terminaltextgröße zurücksetzen",- "open_overlay": "Diese Liste öffnen"+ "open_overlay": "Diese Liste öffnen",+ "quick_switch": "Schnell zu jedem Bereich springen"}},+ "quick_switch": {+ "title": "Gehe zu",+ "placeholder": "Wohin? Agentic IDE, Einstellungen, Skills …",+ "no_results": "Nichts gefunden.",+ "group_sections": "Bereiche",+ "group_settings": "Einstellungen",+ "current": "Du bist hier",+ "hint_open": "Öffnen",+ "hint_close": "Schließen",+ "terminal_grid": "Terminal-Raster"+ },"board_view": {"title": "Board","subtitle": "Alles, was du und {name} zusammen gemacht habt — komplett lokal.",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex f5c0150e9d..f04ab915f3 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -1617,9 +1617,21 @@"zoom_in": "Larger terminal text","zoom_out": "Smaller terminal text","zoom_reset": "Reset terminal text size",- "open_overlay": "Open this list"+ "open_overlay": "Open this list",+ "quick_switch": "Quick switch to any section"}},+ "quick_switch": {+ "title": "Go to",+ "placeholder": "Where to? Agentic IDE, Settings, Skills …",+ "no_results": "Nothing matches.",+ "group_sections": "Sections",+ "group_settings": "Settings",+ "current": "You are here",+ "hint_open": "Open",+ "hint_close": "Close",+ "terminal_grid": "Terminal grid"+ },"board_view": {"title": "Board","subtitle": "Everything you and {name} have done together — fully local.",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex b507797018..a8c93f1f1f 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -1584,9 +1584,21 @@"zoom_in": "Texto del terminal más grande","zoom_out": "Texto del terminal más pequeño","zoom_reset": "Restablecer el tamaño del texto",- "open_overlay": "Abrir esta lista"+ "open_overlay": "Abrir esta lista",+ "quick_switch": "Saltar rápido a cualquier sección"}},+ "quick_switch": {+ "title": "Ir a",+ "placeholder": "¿Adónde? Agentic IDE, Ajustes, Skills …",+ "no_results": "No hay coincidencias.",+ "group_sections": "Secciones",+ "group_settings": "Ajustes",+ "current": "Estás aquí",+ "hint_open": "Abrir",+ "hint_close": "Cerrar",+ "terminal_grid": "Cuadrícula de terminales"+ },"board_view": {"title": "Tablero","subtitle": "Todo lo que tú y {name} habéis hecho juntos — totalmente local.",diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitch.test.ts b/jarvis/ui/web/frontend/src/lib/quickSwitch.test.tsnew file mode 100644index 0000000000..879c0dd4e3--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/quickSwitch.test.ts@@ -0,0 +1,113 @@+/**+ * The quick switcher must put the destination people mean FIRST, so Enter+ * without looking lands right — and it must not drift from the sidebar.+ */+import { describe, expect, it } from "vitest";+import { NAV_FOOTER_ITEMS, NAV_GROUPS, SETTINGS_HUB_ONLY_ITEMS } from "@/components/layout/navGroups";+import { SECTION_IDS } from "@/store/events";+import en from "@/i18n/locales/en.json";+import { QUICK_SWITCH_ENTRIES, normalizeQuery, rankQuickSwitch, scoreTerm, strongSettingsMatches } from "./quickSwitch";++/** Resolve labels from the shipped English dictionary, like the UI on "en". */+function englishLabel(item: { labelKey: string; fallbackLabel: string }): string {+ const value = item.labelKey+ .split(".")+ .reduce<unknown>((node, part) => (node as Record<string, unknown> | undefined)?.[part], en);+ return typeof value === "string" ? value.replace("{name}", "Jarvis") : item.fallbackLabel;+}++const top = (query: string) => rankQuickSwitch(query, englishLabel)[0]?.entry.key;++describe("destinations", () => {+ it("covers every row the sidebar and the Settings hub show", () => {+ const sections = new Set(QUICK_SWITCH_ENTRIES.map((e) => e.section));+ for (const item of [...NAV_GROUPS.flat(), ...SETTINGS_HUB_ONLY_ITEMS, ...NAV_FOOTER_ITEMS]) {+ expect(sections.has(item.id)).toBe(true);+ }+ });++ it("only names real sections and has unique keys", () => {+ const keys = QUICK_SWITCH_ENTRIES.map((e) => e.key);+ expect(new Set(keys).size).toBe(keys.length);+ for (const e of QUICK_SWITCH_ENTRIES) expect(SECTION_IDS).toContain(e.section);+ });++ it("offers both faces of the front page", () => {+ const faces = QUICK_SWITCH_ENTRIES.filter((e) => e.section === "chats").map((e) => e.surface);+ expect(faces).toEqual(["voice", "chat"]);+ });+});++describe("ranking", () => {+ it("lists everything in sidebar order for an empty query", () => {+ const rows = rankQuickSwitch("", englishLabel);+ expect(rows.map((r) => r.entry.key)).toEqual(QUICK_SWITCH_ENTRIES.map((e) => e.key));+ });++ it.each([+ ["agentic", "agentic-ide"],+ ["Agentic IDE", "agentic-ide"],+ ["ide", "agentic-ide"],+ ["settings", "settings"],+ ["Einstellungen", "settings"], // i18n-allow: German query proves cross-locale search+ ["einst", "settings"], // i18n-allow: German query prefix+ ["ajustes", "settings"],+ ["skills", "skills"],+ ["api", "apikeys"],+ ["ollama", "local-models"],+ ["market", "marketplace"],+ ["wiki", "memory"],+ ])("puts the meant destination first for %j", (query, expected) => {+ expect(top(query)).toBe(expected);+ });++ it("finds an accented label from its plain spelling", () => {+ // i18n-allow: the German dictionary label carries an umlaut+ expect(rankQuickSwitch("worterbuch", englishLabel).map((r) => r.entry.key)).toContain("dictionary");+ });++ it("keeps a three-letter query to word starts", () => {+ const keys = rankQuickSwitch("ide", englishLabel).map((r) => r.entry.key);+ expect(keys).not.toContain("apikeys");+ });++ it("returns nothing for gibberish", () => {+ expect(rankQuickSwitch("zzqxv", englishLabel)).toEqual([]);+ });+});++describe("scoreTerm", () => {+ it("orders exact > prefix > word start > initials > substring", () => {+ const exact = scoreTerm("settings", "settings");+ const prefix = scoreTerm("settings", "sett");+ const word = scoreTerm("agentic ide", "ide");+ const initials = scoreTerm("run inspector", "ri");+ const inner = scoreTerm("marketplace", "place");+ expect(exact).toBeGreaterThan(prefix);+ expect(prefix).toBeGreaterThan(word);+ expect(word).toBeGreaterThan(initials);+ expect(initials).toBeGreaterThan(inner);+ expect(inner).toBeGreaterThan(0);+ });++ it("ignores one stray letter inside a word", () => {+ expect(scoreTerm("marketplace", "k")).toBe(0);+ });++ it("drops the {name} token from labels", () => {+ expect(normalizeQuery("{name} Voice")).toBe("voice");+ });+});++describe("strongSettingsMatches", () => {+ it("drops hits buried mid-word and caps the list", () => {+ const hits = [+ { label: "App", detail: "Which provider runs it" },+ { label: "Wake word", detail: "Say the name" },+ { label: "Wide layout" },+ ];+ expect(strongSettingsMatches("ide", hits)).toEqual([]);+ expect(strongSettingsMatches("wake", hits).map((h) => h.label)).toEqual(["Wake word"]);+ expect(strongSettingsMatches("w", [...hits, ...hits, ...hits], 2)).toHaveLength(2);+ });+});diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitch.ts b/jarvis/ui/web/frontend/src/lib/quickSwitch.tsnew file mode 100644index 0000000000..9c67922bdb--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/quickSwitch.ts@@ -0,0 +1,293 @@+/**+ * The quick switcher's destinations and ranking — the Spotlight-style "type a+ * section's name, press Enter, be there" launcher.+ *+ * Pure on purpose: what the switcher lists and in which order is the whole+ * feature, and keeping it out of the component makes it testable without+ * mounting a dialog.+ *+ * ## Where the destinations come from+ *+ * The sidebar's own definitions (`NAV_GROUPS`, `NAV_FOOTER_ITEMS`,+ * `SETTINGS_HUB_ONLY_ITEMS`) — never a second hand-written section list (AP-4).+ * Rows that merge several sections (Plugins/MCPs/Skills, CLIs/Test Hub, the+ * voice tabs) are split back into their tabs here, because "skills" should land+ * on Skills, not on whatever tab the merged row opens first.+ *+ * ## Why every locale is searched+ *+ * Someone running the English UI still thinks of the German word for settings, and someone on+ * the German UI still types "settings" — the word in their head is not tied to+ * the interface language. So a destination matches its label in every shipped+ * locale, plus a few English synonyms, while the row shows the label of the+ * active language.+ */+import type { LucideIcon } from "lucide-react";+import { BookA, Grid3x3, Keyboard, Languages, MessageSquare, Mic, Phone, Puzzle, Plug, Sparkles, FlaskConical, KeyRound } from "lucide-react";+import en from "@/i18n/locales/en.json";+import de from "@/i18n/locales/de.json";+import es from "@/i18n/locales/es.json";+import {+ NAV_FOOTER_ITEMS,+ NAV_GROUPS,+ SETTINGS_HUB_ONLY_ITEMS,+ type NavItem,+} from "@/components/layout/navGroups";+import { SECTION_LABELS, type SectionId } from "@/store/events";+import type { HomeSurface } from "@/lib/homeSurface";++type LocaleTree = Record<string, unknown>;+const LOCALES: readonly LocaleTree[] = [en, de, es];++export interface QuickSwitchEntry {+ /** Stable React key and test id. */+ key: string;+ section: SectionId;+ /** The front page has two faces; picking one also flips the switch. */+ surface?: HomeSurface;+ labelKey: string;+ fallbackLabel: string;+ icon: LucideIcon;+ /** The parent area, shown as the row's second line ("Voice", "Settings"). */+ parentLabelKey?: string;+ /** Extra English words that should find this entry. */+ aliases: readonly string[];+}++/** English synonyms per destination — words people type that no label holds. */+const ALIASES: Partial<Record<string, readonly string[]>> = {+ voice: ["home", "start", "talk", "speak"],+ chat: ["home", "start", "message", "conversation"],+ "agentic-ide": ["ide", "code", "coding", "terminal", "panes", "workspace"],+ "agentic-ide-classic": ["terminal", "grid", "panes"],+ agents: ["society", "world", "team"],+ settings: ["preferences", "options", "config", "configuration", "general"],+ apikeys: ["keys", "credentials", "tokens", "providers"],+ "local-models": ["ollama", "llama", "offline", "models"],+ memory: ["notes", "knowledge", "obsidian"],+ visualization: ["outputs", "results", "images", "pages"],+ tasks: ["routines", "schedule", "cron", "recurring"],+ costs: ["tokens", "usage", "money", "billing", "budget"],+ sessions: ["transcripts", "recordings", "history"],+ run_inspector: ["runs", "debug", "trace"],+ computers: ["servers", "ssh", "vps", "remote", "machines"],+ "agent-instructions": ["instructions", "system prompt", "agents md", "claude md"],+ marketplace: ["store", "shop", "install"],+ board: ["stats", "dashboard", "activity"],+ docs: ["documentation", "help", "manual"],+ feedback: ["bug", "report", "issue"],+ appshots: ["screenshot", "capture"],+ "jarvis-actions": ["permissions", "allow", "block", "actions"],+ dictation: ["voice", "speech", "microphone", "mic", "whisper"],+ "voice-shortcuts": ["hotkeys", "keybinds", "keyboard"],+ "voice-language": ["recognition language"],+ "voice-api-keys": ["speech to text", "stt"],+ dictionary: ["vocabulary", "words"],+ telephony: ["phone", "calls", "twilio"],+ languages: ["language", "locale", "translation"],+};++function entry(+ item: NavItem,+ overrides: Partial<QuickSwitchEntry> & { key?: string } = {},+): QuickSwitchEntry {+ const key = overrides.key ?? item.id;+ return {+ key,+ section: item.id,+ labelKey: item.labelKey,+ fallbackLabel: item.fallbackLabel ?? SECTION_LABELS[item.id],+ icon: item.icon,+ aliases: ALIASES[key] ?? [],+ ...overrides,+ };+}++/** A tab inside a merged row: its own label, the row's icon unless given. */+function tab(+ section: SectionId,+ labelKey: string,+ icon: LucideIcon,+ parentLabelKey?: string,+): QuickSwitchEntry {+ return {+ key: section,+ section,+ labelKey,+ fallbackLabel: SECTION_LABELS[section],+ icon,+ parentLabelKey,+ aliases: ALIASES[section] ?? [],+ };+}++/**+ * Merged rows are replaced by their tabs; every other row passes through.+ * Returned as a list in sidebar order so an empty query reads like the nav.+ */+function expand(item: NavItem): QuickSwitchEntry[] {+ switch (item.id) {+ case "chats":+ return [+ entry(item, {+ key: "voice",+ surface: "voice",+ labelKey: "sidebar.surface_voice",+ fallbackLabel: "Voice",+ icon: Mic,+ aliases: ALIASES.voice,+ }),+ entry(item, {+ key: "chat",+ surface: "chat",+ labelKey: "sidebar.surface_chat",+ fallbackLabel: "Chat",+ icon: MessageSquare,+ aliases: ALIASES.chat,+ }),+ ];+ case "plugins":+ return [+ tab("plugins", "nav.plugins", Plug, "nav.extensions"),+ tab("skills", "nav.skills", Sparkles, "nav.extensions"),+ tab("mcps", "nav.mcps", Puzzle, "nav.extensions"),+ ];+ case "clis":+ return [+ entry(item, { labelKey: "nav.clis", fallbackLabel: "CLIs" }),+ tab("cli-test-hub", "nav.cli_test_hub", FlaskConical, "nav.clis"),+ ];+ case "agentic-ide":+ return [+ entry(item),+ tab("agentic-ide-classic", "quick_switch.terminal_grid", Grid3x3, "nav.agentic_ide"),+ ];+ case "apikeys":+ return [entry(item), tab("telephony", "nav.telephony", Phone, "nav.apikeys")];+ case "settings":+ return [entry(item), tab("languages", "nav.languages", Languages, "nav.settings")];+ case "dictation":+ return [+ entry(item),+ tab("dictionary", "nav.dictionary", BookA, "nav.voice"),+ tab("voice-shortcuts", "nav.voice_shortcuts", Keyboard, "nav.voice"),+ tab("voice-language", "nav.voice_language", Languages, "nav.voice"),+ tab("voice-api-keys", "nav.voice_api_keys", KeyRound, "nav.voice"),+ ];+ default:+ return [entry(item)];+ }+}++/** Every place the switcher can take you, in sidebar order. */+export const QUICK_SWITCH_ENTRIES: readonly QuickSwitchEntry[] = [+ ...NAV_GROUPS.flat(),+ ...SETTINGS_HUB_ONLY_ITEMS,+ ...NAV_FOOTER_ITEMS,+].flatMap(expand);++// ── Ranking ──────────────────────────────────────────────────────────────++/** Lowercase with accents folded, so an accented label matches its plain spelling. */+export function normalizeQuery(value: string): string {+ return value+ .normalize("NFD")+ .replace(/[̀-ͯ]/g, "")+ .replace(/\{name\}/g, "")+ .toLowerCase()+ .trim();+}++function atPath(tree: LocaleTree, path: string): unknown {+ return path+ .split(".")+ .reduce<unknown>(+ (node, part) => (node && typeof node === "object" ? (node as LocaleTree)[part] : undefined),+ tree,+ );+}++/** Every word this entry answers to, normalized, across all locales. */+export function entryTerms(item: QuickSwitchEntry, activeLabel: string): string[] {+ const localized = LOCALES.map((tree) => atPath(tree, item.labelKey)).filter(+ (value): value is string => typeof value === "string",+ );+ const terms = [activeLabel, item.fallbackLabel, SECTION_LABELS[item.section], ...localized, ...item.aliases];+ return [...new Set(terms.map(normalizeQuery).filter(Boolean))];+}++/** Do the query's letters appear in order, each starting a word ("aide" → Agentic IDE)? */+function initialsMatch(term: string, needle: string): boolean {+ const initials = term+ .split(/[\s\-_.&/]+/)+ .filter(Boolean)+ .map((word) => word[0])+ .join("");+ return initials.length > 1 && initials.startsWith(needle);+}++/**+ * How well one term matches the query: 0 means not at all.+ *+ * Exact beats prefix beats word-start beats initials beats substring — the+ * order Spotlight uses, which is what makes the first row the right one often+ * enough that Enter without looking works.+ */+export function scoreTerm(term: string, needle: string): number {+ if (!needle) return 0;+ if (term === needle) return 100;+ if (term.startsWith(needle)) return 80;+ if (term.split(/[\s\-_.&/]+/).some((word) => word.startsWith(needle))) return 60;+ if (initialsMatch(term, needle)) return 50;+ // Mid-word hits only from four letters on: "ide" must not find "providers".+ if (needle.length >= 4 && term.includes(needle)) return 40;+ return 0;+}++export interface RankedEntry {+ entry: QuickSwitchEntry;+ label: string;+ score: number;+}++/**+ * The entries that match, best first. An empty query lists everything in+ * sidebar order, so the switcher doubles as a browsable map of the app.+ * Ties keep sidebar order — `Array.prototype.sort` is stable.+ */+export function rankQuickSwitch(+ query: string,+ labelFor: (item: QuickSwitchEntry) => string,+ entries: readonly QuickSwitchEntry[] = QUICK_SWITCH_ENTRIES,+): RankedEntry[] {+ const needle = normalizeQuery(query);+ const all = entries.map((item) => {+ const label = labelFor(item);+ const score = needle+ ? Math.max(0, ...entryTerms(item, label).map((term) => scoreTerm(term, needle)))+ : 1;+ return { entry: item, label, score };+ });+ return all.filter((row) => row.score > 0).sort((a, b) => b.score - a.score);+}++/**+ * Keep a Settings search hit only when one of its words STARTS with the query.+ *+ * The Settings search matches anywhere in a group's copy, which suits its own+ * sidebar but floods a launcher: "ide" hit six groups through "provide",+ * "side" and "slide". Capped as well, so sections stay on screen.+ */+export function strongSettingsMatches<T extends { label: string; detail?: string }>(+ query: string,+ matches: readonly T[],+ limit = 4,+): T[] {+ const needle = normalizeQuery(query);+ if (!needle) return [];+ return matches+ .filter((match) =>+ [match.label, match.detail ?? ""].some((text) => scoreTerm(normalizeQuery(text), needle) >= 60),+ )+ .slice(0, limit);+}diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitchChord.ts b/jarvis/ui/web/frontend/src/lib/quickSwitchChord.tsnew file mode 100644index 0000000000..b10cc4b45e--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/quickSwitchChord.ts@@ -0,0 +1,31 @@+/**+ * The quick switcher's chord, kept apart from `./quickSwitch` on purpose: the+ * app shell checks every keystroke against it, so it ships in the startup+ * chunk — and `./quickSwitch` carries all three locale dictionaries, which+ * must stay in the switcher's own lazy chunk.+ */+export interface QuickSwitchKeyEvent {+ key: string;+ code: string;+ ctrlKey: boolean;+ metaKey: boolean;+ altKey: boolean;+ shiftKey: boolean;+}++/**+ * Ctrl+Space, on every platform.+ *+ * The closest chord to the Mac's ⌘+Space that the app can actually receive:+ * ⌘+Space itself belongs to the OS launcher and never reaches the window, and+ * Ctrl/⌘+K is already the Wiki's and the Docs' own search. Ctrl+Space means+ * nothing to a coding agent's TUI (it would send a NUL byte) and is not one of+ * the voice defaults — those all carry Alt, which disqualifies here.+ *+ * `code` is checked as well as `key` because some layouts and IMEs report the+ * space bar's `key` as something other than " " while a modifier is held.+ */+export function isQuickSwitchChord(event: QuickSwitchKeyEvent): boolean {+ if (!event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return false;+ return event.code === "Space" || event.key === " ";+}diff --git a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.tsindex 005cacbe98..d06cba1183 100644--- a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts+++ b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts@@ -17,6 +17,7 @@ import {type FixedShortcut,} from "./shortcutRegistry";import { shouldOpenShortcutOverlay } from "./shortcutOverlayTrigger";+import { isQuickSwitchChord } from "./quickSwitchChord";/** Turn a declared chord into the event the matcher would see. */function eventFor(keys: string[], isMac: boolean) {@@ -102,6 +103,26 @@ describe("fixed chords agree with the matcher that implements them", () => {});});+describe("the quick switcher chord", () => {+ it("declares the chord its matcher accepts", () => {+ const entry = shortcutsForArea("workspace").find(+ (s) => s.labelKey === "shortcut_overlay.workspace.quick_switch",+ ) as FixedShortcut;+ expect(entry.keys).toEqual(["Ctrl", "Space"]);+ const chord = { key: " ", code: "Space", ctrlKey: true, metaKey: false, altKey: false, shiftKey: false };+ expect(isQuickSwitchChord(chord)).toBe(true);+ });++ it("leaves the voice toggle's Ctrl+Alt+Space and plain typing alone", () => {+ const base = { key: " ", code: "Space", ctrlKey: true, metaKey: false, altKey: false, shiftKey: false };+ expect(isQuickSwitchChord({ ...base, altKey: true })).toBe(false);+ expect(isQuickSwitchChord({ ...base, shiftKey: true })).toBe(false);+ expect(isQuickSwitchChord({ ...base, metaKey: true })).toBe(false);+ expect(isQuickSwitchChord({ ...base, ctrlKey: false })).toBe(false);+ expect(isQuickSwitchChord({ ...base, key: "k", code: "KeyK" })).toBe(false);+ });+});+describe("keyLabel", () => {it("draws the platform modifier the way each keyboard prints it", () => {expect(keyLabel("Mod", true)).toBe("⌘");diff --git a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.tsindex 8f47cf58e7..494757544c 100644--- a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts+++ b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts@@ -103,6 +103,12 @@ export const SHORTCUTS: readonly Shortcut[] = [keys: ["?"],labelKey: "shortcut_overlay.workspace.open_overlay",},+ {+ kind: "fixed",+ area: "workspace",+ keys: ["Ctrl", "Space"],+ labelKey: "shortcut_overlay.workspace.quick_switch",+ },] as const;/** Areas in the order the overlay renders them. */diff --git a/jarvis/ui/web/frontend/src/store/settingsJump.ts b/jarvis/ui/web/frontend/src/store/settingsJump.tsnew file mode 100644index 0000000000..042b25d293--- /dev/null+++ b/jarvis/ui/web/frontend/src/store/settingsJump.ts@@ -0,0 +1,27 @@+/**+ * A Settings group someone asked to land on from OUTSIDE the Settings hub.+ *+ * The hub already scrolls to a group picked from its own search box, but that+ * target lives in the hub's local state, which does not exist yet while the hub+ * is closed. The quick switcher (Ctrl+Space) can pick "Keyboard" or "Wake word"+ * from anywhere, so the request is parked here, the hub opens, and it takes+ * the target over on mount and clears it — a one-shot hand-off, never a+ * standing preference.+ */+import { create } from "zustand";++interface SettingsJumpState {+ target: string | null;+ request: (target: string) => void;+ take: () => string | null;+}++export const useSettingsJump = create<SettingsJumpState>((set, get) => ({+ target: null,+ request: (target) => set({ target }),+ take: () => {+ const { target } = get();+ if (target !== null) set({ target: null });+ return target;+ },+}));diff --git a/jarvis/ui/web/frontend/src/views/SettingsHubView.tsx b/jarvis/ui/web/frontend/src/views/SettingsHubView.tsxindex 2c26f77029..b55de0d8e3 100644--- a/jarvis/ui/web/frontend/src/views/SettingsHubView.tsx+++ b/jarvis/ui/web/frontend/src/views/SettingsHubView.tsx@@ -1,6 +1,6 @@import * as Dialog from "@radix-ui/react-dialog";import { isTourEvent } from "@/components/onboarding/tourEvents";-import { lazy, Suspense, useMemo, useRef, useState, type ComponentType, type LazyExoticComponent } from "react";+import { lazy, Suspense, useEffect, useMemo, useRef, useState, type ComponentType, type LazyExoticComponent } from "react";import { Loader2, Search, X } from "lucide-react";import {NAV_FOOTER_ITEMS,@@ -10,6 +10,7 @@ import {type NavItem,} from "@/components/layout/navGroups";import { useEventStore } from "@/store/events";+import { useSettingsJump } from "@/store/settingsJump";import { useSectionHealth } from "@/hooks/useProviders";import { useT, useUiLanguage } from "@/i18n";import { isComboboxPanelEvent } from "@/components/ui/combobox";@@ -215,6 +216,15 @@ export function SettingsHubView({ onClose }: { onClose: () => void }) {const [searchTarget, setSearchTarget] = useState<string | null>(null);const { health: sectionHealth } = useSectionHealth();+ // A group picked in the quick switcher while the hub was closed (or open on+ // another tab) — take it over once; see store/settingsJump.+ const pendingJump = useSettingsJump((s) => s.target);+ useEffect(() => {+ if (pendingJump === null) return;+ const target = useSettingsJump.getState().take();+ if (target) setSearchTarget(target);+ }, [pendingJump]);+const { content, highlight } = resolveHubTab(active);const Content = TAB_CONTENT[content];