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
fix(ui): quick switcher opens the API Keys page, not the voice tab
rubenluetke10-beep8497cf9962c5
diff --git a/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsx b/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsxindex f79c7dc22c..76b5528e7a 100644--- a/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsx+++ b/jarvis/ui/web/frontend/src/components/QuickSwitcher.tsx@@ -19,7 +19,12 @@ 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 {+ ambiguousEntryKeys,+ rankQuickSwitch,+ strongSettingsMatches,+ type QuickSwitchEntry,+} from "@/lib/quickSwitch";import { searchSettingsOptions } from "@/views/settings/settingsSearch";import { cn } from "@/lib/utils";@@ -65,7 +70,9 @@ export function QuickSwitcher({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 labelFor = (item: QuickSwitchEntry) => label(item.labelKey, item.fallbackLabel);+ const ranked = rankQuickSwitch(query, labelFor);+ const ambiguous = ambiguousEntryKeys(labelFor);const settingsMatches = useMemo(() => strongSettingsMatches(query, searchSettingsOptions(language, query, t)),[query, language, t],@@ -137,6 +144,10 @@ export function QuickSwitcher({{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.Itemkey={item.key}@@ -148,13 +159,9 @@ export function QuickSwitcher({<span className={TILE}><Icon className="h-4 w-4" aria-hidden /></span>- <span className="min-w-0 truncate">{text}</span>+ <span className="min-w-0 truncate">{shown}</span><span className={DETAIL}>- {here- ? t("quick_switch.current")- : item.parentLabelKey- ? label(item.parentLabelKey, "")- : ""}+ {here ? t("quick_switch.current") : shown === text ? area : ""}</span></Command.Item>);diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitch.test.ts b/jarvis/ui/web/frontend/src/lib/quickSwitch.test.tsindex 879c0dd4e3..f3aafad94c 100644--- a/jarvis/ui/web/frontend/src/lib/quickSwitch.test.ts+++ b/jarvis/ui/web/frontend/src/lib/quickSwitch.test.ts@@ -6,7 +6,16 @@ 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";+import de from "@/i18n/locales/de.json";+import es from "@/i18n/locales/es.json";+import {+ QUICK_SWITCH_ENTRIES,+ ambiguousEntryKeys,+ 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 {@@ -111,3 +120,38 @@ describe("strongSettingsMatches", () => {expect(strongSettingsMatches("w", [...hits, ...hits, ...hits], 2)).toHaveLength(2);});});++/** Labels as a given UI language shows them. */+function labelIn(tree: Record<string, unknown>) {+ return (item: { labelKey: string; fallbackLabel: string }) => {+ const value = item.labelKey+ .split(".")+ .reduce<unknown>((node, part) => (node as Record<string, unknown> | undefined)?.[part], tree);+ return typeof value === "string" ? value.replace("{name}", "Jarvis") : item.fallbackLabel;+ };+}++describe("typing a row's own name lands on that row", () => {+ // The bug this guards: "API Keys" is both a page and a voice tab, and the+ // switcher sent someone to the tab. A page must win its own name in every UI+ // language; a tab must at least be reachable by its name.+ for (const [language, tree] of [["en", en], ["de", de], ["es", es]] as const) {+ const labelFor = labelIn(tree);+ it(`in ${language}`, () => {+ for (const item of QUICK_SWITCH_ENTRIES) {+ const rows = rankQuickSwitch(labelFor(item), labelFor);+ if (item.parentLabelKey) {+ expect(rows.map((r) => r.entry.key), item.key).toContain(item.key);+ } else {+ expect(rows[0]?.entry.key, `${language}: "${labelFor(item)}"`).toBe(item.key);+ }+ }+ });+ }++ it("ranks the API Keys page above the voice tab of the same name", () => {+ const keys = rankQuickSwitch("API Keys", englishLabel).map((r) => r.entry.key);+ expect(keys.indexOf("apikeys")).toBeLessThan(keys.indexOf("voice-api-keys"));+ expect(ambiguousEntryKeys(englishLabel)).toEqual(new Set(["apikeys", "voice-api-keys"]));+ });+});diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitch.ts b/jarvis/ui/web/frontend/src/lib/quickSwitch.tsindex 9c67922bdb..e95578211a 100644--- a/jarvis/ui/web/frontend/src/lib/quickSwitch.ts+++ b/jarvis/ui/web/frontend/src/lib/quickSwitch.ts@@ -244,6 +244,9 @@ export function scoreTerm(term: string, needle: string): number {return 0;}+/** How far a tab ranks below a top-level page with the same match quality. */+const TAB_PENALTY = 25;+export interface RankedEntry {entry: QuickSwitchEntry;label: string;@@ -263,9 +266,14 @@ export function rankQuickSwitch(const needle = normalizeQuery(query);const all = entries.map((item) => {const label = labelFor(item);- const score = needle+ let score = needle? Math.max(0, ...entryTerms(item, label).map((term) => scoreTerm(term, needle))): 1;+ // A tab inside another area yields to a page of its own on the same word:+ // "API Keys" means the API Keys page, not the voice section's key tab, and+ // a word for "language" the app languages, not the dictation language. Large enough to+ // drop an exact tab hit (100) below a page's prefix hit (80).+ if (needle && score > 0 && item.parentLabelKey) score = Math.max(1, score - TAB_PENALTY);return { entry: item, label, score };});return all.filter((row) => row.score > 0).sort((a, b) => b.score - a.score);@@ -291,3 +299,20 @@ export function strongSettingsMatches<T extends { label: string; detail?: string).slice(0, limit);}++/**+ * Keys of the entries whose label another entry also uses ("API Keys" is both a+ * page and a voice tab). The row then names its area as well, so two rows that+ * look identical never send someone to the wrong place.+ */+export function ambiguousEntryKeys(+ labelFor: (item: QuickSwitchEntry) => string,+ entries: readonly QuickSwitchEntry[] = QUICK_SWITCH_ENTRIES,+): Set<string> {+ const seen = new Map<string, string[]>();+ for (const item of entries) {+ const label = normalizeQuery(labelFor(item));+ seen.set(label, [...(seen.get(label) ?? []), item.key]);+ }+ return new Set([...seen.values()].filter((keys) => keys.length > 1).flat());+}