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(society): stop @google from picking a NotebookLM Drive tool
rubenluetke10-beep755b7b0f7ea9
diff --git a/jarvis/clis/tool.py b/jarvis/clis/tool.pyindex 59039e9b56..c506f665d4 100644--- a/jarvis/clis/tool.py+++ b/jarvis/clis/tool.py@@ -74,6 +74,7 @@ class CliTool:self._auth = authself._usage = usage_logself.name: str = f"{TOOL_NAME_PREFIX}{spec.name}"+ self.display_name: str = spec.display_nameself.description: str = self._build_description(spec)self.risk_tier: str = spec.risk.default_tierself.schema: dict[str, Any] = {diff --git a/jarvis/society/capabilities.py b/jarvis/society/capabilities.pyindex d8caca4efc..080d1492ae 100644--- a/jarvis/society/capabilities.py+++ b/jarvis/society/capabilities.py@@ -180,9 +180,12 @@ def _one_liner(text: str, limit: int = 140) -> str:return first[:limit]-def _label(tool_name: str, kind: CapabilityKind) -> str:+def _label(tool_name: str, kind: CapabilityKind, tool: Any = None) -> str:if kind is CapabilityKind.CLI:- return tool_name[4:]+ display = getattr(tool, "display_name", None)+ if isinstance(display, str) and display.strip():+ return display.strip()+ return tool_name[4:] if tool_name.startswith("cli_") else tool_nameif kind is CapabilityKind.MCP:return tool_namereturn tool_name.replace("_", "-")@@ -237,7 +240,7 @@ def build_catalog(CapabilityRow(id=cap_id,kind=kind,- label="Chrome / Browser" if cap_id == "core:browser" else _label(name, kind),+ label="Chrome / Browser" if cap_id == "core:browser" else _label(name, kind, tool),one_liner=_one_liner(getattr(tool, "description", "") or ""),risk_tier=str(getattr(tool, "risk_tier", "monitor") or "monitor"),connected=is_connected,diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsxindex f28dc7addf..2ccda39862 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx@@ -1130,6 +1130,7 @@ export function Composer({ agent, mentionable, busy, sessionId, cwd, provider, sactiveIndex={activeIndex}onHover={setActiveIndex}onPick={insertMention}+ grouped={!mention?.query.trim()}/><divref={composerRef}diff --git a/jarvis/ui/web/frontend/src/components/society/chat/MentionPicker.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/MentionPicker.test.tsxindex bdad5df860..a1b7044edd 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/MentionPicker.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/MentionPicker.test.tsx@@ -86,4 +86,50 @@ describe("MentionPicker", () => {fireEvent.click(gmail!);expect(picked).toEqual(["gmail"]);});++ it("keeps search hits in the given order without regrouping by kind", () => {+ const items = filterMentions(+ buildMentionCatalog(+ [],+ [+ cap({+ id: "cli:gws",+ label: "Google Workspace CLI",+ one_liner: "Google Workspace: Gmail, Drive.",+ }),+ cap({+ id: "mcp:notebooklm-mcp/notebook_add_drive",+ one_liner: "Add Google Drive document as source.",+ }),+ cap({+ id: "mcp:notebooklm-mcp/notebook_list",+ one_liner: "List notebooks.",+ }),+ ],+ ),+ "google",+ );+ const anchor = createRef<HTMLDivElement>();+ render(+ <>+ <div ref={anchor} />+ <MentionPicker+ anchorRef={anchor}+ open+ items={items}+ loading={false}+ activeIndex={0}+ grouped={false}+ onHover={() => undefined}+ onPick={() => undefined}+ />+ </>,+ );+ expect(screen.queryByText("MCP servers")).toBeNull();+ expect(screen.queryByText("CLIs")).toBeNull();+ const rows = screen.getAllByTestId("mention-picker-item");+ expect(rows[0]?.textContent).toContain("@gws");+ expect(rows[0]?.getAttribute("aria-selected")).toBe("true");+ expect(rows.some((row) => (row.textContent ?? "").includes("notebook_add_drive"))).toBe(false);+ });});diff --git a/jarvis/ui/web/frontend/src/components/society/chat/MentionPicker.tsx b/jarvis/ui/web/frontend/src/components/society/chat/MentionPicker.tsxindex ce48e8c87c..2b8813ea0f 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/MentionPicker.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/MentionPicker.tsx@@ -1,6 +1,10 @@/*** The list over the society composer after "@" — agents, plugins, MCP- * servers, CLIs, skills and Jarvis tools, grouped, with the service's mark.+ * servers, CLIs, skills and Jarvis tools, with the service's mark.+ *+ * Browsing (empty query) groups the rows under headings; searching shows one+ * flat list from A to Z across all groups, in exactly the order the items+ * arrive, so the arrow keys follow what the eye sees.** Portalled into the agent card (a Radix dialog) the way Combobox is, so a* click still lands: the dialog sets pointer-events none on body. Drawn@@ -36,6 +40,7 @@ export function MentionPicker({activeIndex,onHover,onPick,+ grouped = true,}: {anchorRef: RefObject<HTMLElement | null>;open: boolean;@@ -44,6 +49,8 @@ export function MentionPicker({activeIndex: number;onHover: (index: number) => void;onPick: (item: MentionItem) => void;+ /** False while searching: one flat A-Z list, no group headings. */+ grouped?: boolean;}) {const t = useT();const listId = useId();@@ -93,7 +100,7 @@ export function MentionPicker({if (!open || !position) return null;- const runs = groupMentions(items);+ const runs = grouped ? groupMentions(items) : [];let runningIndex = 0;const host = panelHost(anchorRef.current);@@ -118,7 +125,7 @@ export function MentionPicker({<div className="px-3 py-2 text-xs text-muted-foreground" data-testid="mention-picker-empty">{loading ? t("society.chat.mention_loading") : t("society.chat.mention_empty")}</div>- ) : (+ ) : grouped ? (runs.map((run) => (<div key={run.group} role="group" aria-label={groupLabel(run.group, t)}><div className="px-2 pb-0.5 pt-1.5 text-micro font-semibold text-muted-foreground">@@ -127,54 +134,67 @@ export function MentionPicker({{run.items.map((item) => {const index = runningIndex;runningIndex += 1;- const active = index === activeIndex;- return (- <div- key={item.key}- role="option"- aria-selected={active}- data-index={index}- data-kind={item.kind}- data-testid="mention-picker-item"- style={item.agent || item.codingAgent ? undefined : toolIdentityStyle(mentionChoice(item))}- onMouseEnter={() => onHover(index)}- aria-disabled={item.kind === "coding" && !item.connected || undefined}- onClick={() => { if (item.kind !== "coding" || item.connected) onPick(item); }}- className={cn(- !item.agent && !item.codingAgent && "tool-identity",- "flex cursor-pointer items-center gap-3 rounded-xl px-2 py-2",- active ? "bg-secondary text-foreground" : "text-foreground",- !item.connected && "opacity-50",- )}- >- <Mark item={item} />- <span className="min-w-0 flex-1">- <span className="flex items-baseline gap-1.5">- <span className="truncate text-sm font-medium text-foreground">{item.label}</span>- <span className="shrink-0 font-mono text-micro text-muted-foreground">- @{item.value}- </span>- </span>- {item.hint ? (- <span className="mt-0.5 block truncate text-xs text-muted-foreground">{item.hint}</span>- ) : null}- </span>- {!item.connected ? (- <span className="shrink-0 text-micro text-muted-foreground">- {t(item.codingAgent ? (item.codingAgent.accepts_prompts === false ? "society.chat.coding_unsupported" : "society.chat.coding_not_installed") : "society.chat.mention_disconnected")}- </span>- ) : null}- </div>- );+ return <PickerRow key={item.key} item={item} index={index} active={index === activeIndex} onHover={onHover} onPick={onPick} t={t} />;})}</div>))+ ) : (+ items.map((item, index) => (+ <PickerRow key={item.key} item={item} index={index} active={index === activeIndex} onHover={onHover} onPick={onPick} t={t} />+ )))}</div>,host,);}+function PickerRow({ item, index, active, onHover, onPick, t }: {+ item: MentionItem;+ index: number;+ active: boolean;+ onHover: (index: number) => void;+ onPick: (item: MentionItem) => void;+ t: (key: string) => string;+}) {+ return (+ <div+ role="option"+ aria-selected={active}+ data-index={index}+ data-kind={item.kind}+ data-testid="mention-picker-item"+ style={item.agent || item.codingAgent ? undefined : toolIdentityStyle(mentionChoice(item))}+ onMouseEnter={() => onHover(index)}+ aria-disabled={item.kind === "coding" && !item.connected || undefined}+ onClick={() => { if (item.kind !== "coding" || item.connected) onPick(item); }}+ className={cn(+ !item.agent && !item.codingAgent && "tool-identity",+ "flex cursor-pointer items-center gap-3 rounded-xl px-2 py-2",+ active ? "bg-secondary text-foreground" : "text-foreground",+ !item.connected && "opacity-50",+ )}+ >+ <Mark item={item} />+ <span className="min-w-0 flex-1">+ <span className="flex items-baseline gap-1.5">+ <span className="truncate text-sm font-medium text-foreground">{item.label}</span>+ <span className="shrink-0 font-mono text-micro text-muted-foreground">+ @{item.value}+ </span>+ </span>+ {item.hint ? (+ <span className="mt-0.5 block truncate text-xs text-muted-foreground">{item.hint}</span>+ ) : null}+ </span>+ {!item.connected ? (+ <span className="shrink-0 text-micro text-muted-foreground">+ {t(item.codingAgent ? (item.codingAgent.accepts_prompts === false ? "society.chat.coding_unsupported" : "society.chat.coding_not_installed") : "society.chat.mention_disconnected")}+ </span>+ ) : null}+ </div>+ );+}+function groupLabel(group: MentionGroup, t: (key: string) => string): string {switch (group) {case "agents":diff --git a/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.test.ts b/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.test.tsindex 8e4ae02bb7..7166fcd925 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.test.ts+++ b/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.test.ts@@ -255,6 +255,61 @@ describe("filterMentions", () => {expect(filterMentions(items, "notion").map((i) => i.value)).toEqual(["notion"]);});+ it("does not pick an MCP Drive tool when searching for Google Workspace", () => {+ const catalog = buildMentionCatalog(+ [],+ [+ cap({+ id: "cli:gws",+ label: "Google Workspace CLI",+ one_liner: "Google Workspace: Gmail, Drive, Docs, Sheets, Calendar, Tasks, Chat, Slides.",+ }),+ cap({+ id: "mcp:notebooklm-mcp/notebook_add_drive",+ label: "notebooklm-mcp/notebook_add_drive",+ one_liner: "Add Google Drive document as source.",+ }),+ cap({+ id: "mcp:notebooklm-mcp/notebook_list",+ label: "notebooklm-mcp/notebook_list",+ one_liner: "List notebooks.",+ }),+ ],+ );+ const values = (q: string) => filterMentions(catalog, q).map((item) => item.value);+ expect(values("google")[0]).toBe("gws");+ expect(values("google")).not.toContain("notebooklm-mcp/notebook_add_drive");+ expect(values("workspace")[0]).toBe("gws");+ expect(values("google-workspace")[0]).toBe("gws");+ expect(values("gws")[0]).toBe("gws");+ expect(values("notebook_add_drive")[0]).toBe("notebooklm-mcp/notebook_add_drive");+ });++ it("still finds a CLI when only the short tag is labelled, via the product words", () => {+ const catalog = buildMentionCatalog(+ [],+ [+ cap({+ id: "cli:gws",+ label: "gws",+ one_liner: "Google Workspace CLI — Google Workspace: Gmail, Drive, Docs.",+ }),+ cap({+ id: "mcp:notebooklm-mcp/notebook_add_drive",+ one_liner: "Add Google Drive document as source.",+ }),+ cap({+ id: "mcp:notebooklm-mcp/notebook_list",+ one_liner: "List notebooks.",+ }),+ ],+ );+ expect(filterMentions(catalog, "google")[0]?.value).toBe("gws");+ expect(filterMentions(catalog, "google").map((item) => item.value)).not.toContain(+ "notebooklm-mcp/notebook_add_drive",+ );+ });+it("a single letter only matches tags and labels starting with it", () => {const catalog = buildMentionCatalog([agent({ agentId: "nala", name: "Nala", title: "X-Marketing Lead & Growth Specialist" })],diff --git a/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.ts b/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.tsindex 5a6db8a370..5f625326cc 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.ts+++ b/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.ts@@ -329,22 +329,57 @@ export function buildMentionCatalog(return items;}-function scoreItem(item: MentionItem, q: string): number | null {+function wordsOf(text: string): string[] {+ return text.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);+}++function hasWordPrefix(text: string, q: string): boolean {+ return wordsOf(text).some((word) => word.startsWith(q));+}++function toolNameOf(item: MentionItem): string {+ const value = item.value.toLowerCase();+ const slash = value.lastIndexOf("/");+ return slash === -1 ? value : value.slice(slash + 1);+}++/** Lower is better. Null = no match. */+function scoreQuery(item: MentionItem, q: string): number | null {const value = item.value.toLowerCase();const label = item.label.toLowerCase();+ const tool = toolNameOf(item);if (value.startsWith(q) || label.startsWith(q)) return 0;// A single letter sits inside almost every description ("x" in "X-Marketing",// "xAI", "codex", "dropbox"). Keep such queries strictly alphabetical:// only a tag or label starting with that letter may match.if (q.length <= 1) return null;- if (value.includes(q) || label.includes(q)) return 1;- if (item.searchText.includes(q) || item.hint.toLowerCase().includes(q)) return 2;+ if (hasWordPrefix(label, q) || hasWordPrefix(value, q)) return 1;+ if (value.includes(q) || label.includes(q) || tool.startsWith(q) || tool.includes(q)) return 2;+ // Individual MCP tools unfold when the query names them, not when their+ // description happens to mention the same product ("Google Drive" vs+ // "Google Workspace CLI"). Server rows stay name-only for the same reason.+ if (item.detail || item.kind === "mcp") return null;+ if (hasWordPrefix(item.hint, q) || hasWordPrefix(item.searchText, q)) return 3;+ if (item.searchText.includes(q) || item.hint.toLowerCase().includes(q)) return 4;return null;}+function scoreItem(item: MentionItem, q: string): number | null {+ const parts = q.split(/[\s_./-]+/).filter(Boolean);+ if (parts.length <= 1) return scoreQuery(item, q);+ const scores = parts.map((part) => scoreQuery(item, part));+ if (scores.some((score) => score === null)) return null;+ const phrase = parts.join(" ");+ if (item.label.toLowerCase().includes(phrase) || item.value.toLowerCase().includes(q)) return 0;+ if (item.hint.toLowerCase().includes(phrase)) return 1;+ return Math.max(...(scores as number[]));+}+/**- * Empty query: the browse list (no disconnected rows, no individual MCP- * tools). A query searches everything, disconnected included, ranked.+ * Empty query: the browse list, grouped by kind (no disconnected rows, no+ * individual MCP tools). A query searches everything, disconnected included,+ * and answers ONE list from A to Z across all groups — rank first, then the+ * `@tag`, then the label — so typing more letters only ever narrows it down.*/export function filterMentions(items: readonly MentionItem[], query: string): MentionItem[] {const q = query.trim().toLowerCase();@@ -365,7 +400,7 @@ export function filterMentions(items: readonly MentionItem[], query: string): Mea.item.label.localeCompare(b.item.label, undefined, { sensitivity: "base" }) ||a.index - b.index,);- return groupMentions(ranked.map((r) => r.item)).flatMap((group) => group.items);+ return ranked.map((r) => r.item);}export function groupMentions(diff --git a/tests/unit/clis/test_tool.py b/tests/unit/clis/test_tool.pyindex 2ea0d967d9..2a1fd77df0 100644--- a/tests/unit/clis/test_tool.py+++ b/tests/unit/clis/test_tool.py@@ -78,6 +78,11 @@ def test_tool_name_is_prefixed() -> None:assert tool.name == "cli_pytool"+def test_tool_exposes_display_name() -> None:+ tool, _ = _make_tool(Path("."))+ assert tool.display_name == "Python Tool"++def test_tool_risk_tier_from_spec() -> None:tool, _ = _make_tool(Path("."))assert tool.risk_tier == "safe"diff --git a/tests/unit/society/test_capabilities.py b/tests/unit/society/test_capabilities.pyindex 91025fa6e8..6df6416796 100644--- a/tests/unit/society/test_capabilities.py+++ b/tests/unit/society/test_capabilities.py@@ -82,6 +82,29 @@ def test_catalog_groups_orders_and_filters():assert all("spawn" not in r.id and "navigate" not in r.id for r in rows)+def test_cli_label_uses_display_name() -> None:+ rows = build_catalog(+ {+ "cli_gws": _tool("cli_gws", "Google Workspace: Gmail, Drive."),+ }+ )+ assert rows[0].id == "cli:gws"+ assert rows[0].label == "gws"++ rows = build_catalog(+ {+ "cli_gws": SimpleNamespace(+ name="cli_gws",+ description="Google Workspace: Gmail, Drive.",+ risk_tier="monitor",+ schema={},+ display_name="Google Workspace CLI",+ )+ }+ )+ assert rows[0].label == "Google Workspace CLI"++def test_catalog_marks_disconnected_and_sorts_them_last():tools = {"gmail": _tool("gmail"), "spotify": _tool("spotify")}rows = build_catalog(tools, connected=lambda name, kind: name != "gmail")