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(chat): keep mention inventory current and selections unambiguous
rubenluetke10-beep9113eaec4d01
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/composerChips.ts b/jarvis/ui/web/frontend/src/components/agentchat/composerChips.tsindex 67d766bf57..a865e3f49f 100644--- a/jarvis/ui/web/frontend/src/components/agentchat/composerChips.ts+++ b/jarvis/ui/web/frontend/src/components/agentchat/composerChips.ts@@ -5,6 +5,8 @@ import type { ToolChoice } from "./toolChoices";const CHIP_RE = /(@[^\s@]+)/g;export function choiceTag(row: ToolChoice): string {+ // Keep the agent-card catalog's collision-free tag through chip serialization.+ if ("mentionValue" in row && typeof row.mentionValue === "string") return row.mentionValue;const raw = row.brand || row.id.replace(/^(plugin|mcp|cli|skill|core):/i, "");return raw.replace(/_/g, "-").toLowerCase();}@@ -16,7 +18,8 @@ export function choiceToken(row: ToolChoice): string {export function choiceLookup(choices: readonly ToolChoice[]): Map<string, ToolChoice> {const tags = new Map<string, ToolChoice>();for (const row of choices) {- tags.set(choiceTag(row), row);+ tags.set(choiceTag(row).toLowerCase(), row);+ if ("mentionValue" in row) continue;const rest = row.id.replace(/^(plugin|mcp|cli|skill|core):/i, "").toLowerCase();tags.set(rest.replace(/_/g, "-"), row);tags.set(rest.replace(/-/g, "_"), row);diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsxindex 59f9fb9d3a..e479b1bc2e 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx@@ -996,10 +996,10 @@ export function Composer({ agent, mentionable, busy, sessionId, cwd, provider, s.finally(() => { if (current) setCodingLoading(false); });return () => { current = false; };}, [mentionOpen, codingRetry]);- const capabilities = useSocietyCapabilities();+ const capabilities = useSocietyCapabilities(true, mentionOpen);const catalog = useMemo(- () => buildMentionCatalog(mentionable, capabilities.data ?? [], codingAgents),- [mentionable, capabilities.data, codingAgents],+ () => buildMentionCatalog(mentionable, capabilities.data ?? [], codingAgents, capabilities.plugins ?? []),+ [mentionable, capabilities.data, codingAgents, capabilities.plugins],);const codingSelections = useMemo(() => codingMentionsInText(value, catalog), [value, catalog]);useEffect(() => { if (!codingSelections.length) setCodingFolder(""); }, [codingSelections.length]);@@ -1056,7 +1056,19 @@ export function Composer({ agent, mentionable, busy, sessionId, cwd, provider, ssetProblem(null);return;}- const named = mentionsInText(text, catalog);+ const chosenIds = new Set((draft?.choices ?? []).map((row) => row.id));+ const chosen = [...chosenIds].map((id) => catalog.find((item) => item.key === id));+ if (chosen.some((item) => !item || !item.connected)) {+ setProblem(t("common.error_generic"));+ return;+ }+ // Chips hold stable catalog IDs, even if new entries have changed short tags.+ const chosenTags = new Set((draft?.choices ?? []).map((row) => choiceToken(row).toLowerCase()));+ const unselectedText = text.replace(/(^|\s)(@[^\s@]+)/g, (whole, space: string, token: string) =>+ chosenTags.has(token.toLowerCase()) ? space : whole,+ );+ const named = mentionsInText(unselectedText, catalog);+ named.pinIds = [...new Set([...named.pinIds, ...chosen.flatMap((item) => item?.pinIds ?? [])])];const lines: string[] = [];if (named.agents.length > 0 && surface === "society") {const teammates = named.agents.map((a) => `${JSON.stringify(a.name)} (id ${JSON.stringify(a.agentId)})`).join(", ");@@ -1092,12 +1104,13 @@ export function Composer({ agent, mentionable, busy, sessionId, cwd, provider, s}};- const pickerOpen = Boolean(mention) && (matches.length > 0 || (mention?.query.length ?? 0) > 0 || capabilities.isLoading || codingLoading);+ const pickerOpen = mentionOpen;return (<div className="shrink-0 border-t border-border px-3 pb-3 pt-2">{problem ? <p className="mb-1 px-1 text-xs text-destructive">{problem}</p> : null}{mentionOpen && codingError ? <button type="button" className="mb-1 text-xs text-destructive underline" onClick={() => setCodingRetry((n) => n + 1)}>{t("society.chat.coding_retry")}</button> : null}+ {mentionOpen && capabilities.inventoryError ? <button type="button" className="mb-1 text-xs text-destructive underline" onClick={capabilities.retryInventory}>{t("common.retry")}</button> : null}<div className={CHAT_MEASURE}><ChatAttachmentStrip attachments={attachments.attachments} analyzing={attachments.analyzing} onRemove={attachments.remove} /></div>diff --git a/jarvis/ui/web/frontend/src/components/society/chat/mentionChoices.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/mentionChoices.test.tsxindex 1a2da62d73..f536ad7d77 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/mentionChoices.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/mentionChoices.test.tsx@@ -1,9 +1,33 @@import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";import { afterEach, expect, it, vi } from "vitest";import { Composer, UserBubble } from "./AgentChatPanel";-import { pinnedMessageChoices, withoutChoiceTokens } from "./mentionChoices";+import { mentionChoice, pinnedMessageChoices, withoutChoiceTokens } from "./mentionChoices";+import { buildMentionCatalog, mentionsInText } from "./mentionItems";+import { choiceLookup, choiceToken } from "@/components/agentchat/composerChips";import type { SocietyAgent } from "../data";+it("preserves exact skill, server and tool tags when converting them to chips", () => {+ const caps = ["skill:my_skill", "mcp:sentry/read_issue", "mcp:sentry/list_issues"].map((id) => ({+ id, kind: id.split(":")[0], label: id, one_liner: "", risk_tier: "monitor", connected: true, tool_name: "",+ }));+ const catalog = buildMentionCatalog([], caps);+ for (const item of catalog) {+ const row = mentionChoice(item);+ expect(choiceToken(row)).toBe(`@${item.value}`);+ expect(mentionsInText(choiceToken(row), catalog).pinIds).toEqual(item.pinIds);+ }+});++it("does not turn a teammate tag into a plugin chip when their names collide", () => {+ const catalog = buildMentionCatalog([{ agentId: "mail-agent", name: "gmail" } as SocietyAgent], [{+ id: "plugin:gmail", kind: "plugin", label: "Gmail", one_liner: "", risk_tier: "monitor", connected: true, tool_name: "gmail",+ }]);+ const row = mentionChoice(catalog.find((item) => item.kind === "plugin")!);+ expect(choiceToken(row)).toBe("@plugin:gmail");+ expect(choiceLookup([row]).has("gmail")).toBe(false);+ expect(mentionsInText(choiceToken(row), catalog).agents).toEqual([]);+});+vi.mock("@/i18n", async () => {const { default: en } = await import("@/i18n/locales/en.json");return { useT: () => (key: string) => key === "society.chat.delegate_line" ? en.society.chat.delegate_line : key };@@ -84,6 +108,37 @@ it("reconstructs branded tags from an existing saved agent-card message", () =>).not.toBeNull();});+it("sends the selected plugin ID when an agent has the same name", async () => {+ const send = vi.fn(async (_text: string) => {});+ render(<Composer agent={{ agentId: "test", name: "Test" } as SocietyAgent}+ mentionable={[{ agentId: "mail-agent", name: "gmail", title: "Mail", palette: { primary: "#333", secondary: "#555", accent: "#777" } } as SocietyAgent]}+ busy={false} sessionId="society:test" cwd="" provider="openai" surface="society"+ onSend={send} onCancel={async () => {}} />);+ fireEvent.click(screen.getByRole("button", { name: "society.chat.more" }));+ fireEvent.click(screen.getByRole("button", { name: "chat_tools.all" }));+ fireEvent.click(await screen.findByRole("option", { name: /@plugin:gmail/ }));+ fireEvent.click(screen.getByRole("button", { name: "society.chat.send" }));+ await waitFor(() => expect(send).toHaveBeenCalledOnce());+ expect(send.mock.calls[0][0]).toContain("[tools: plugin:gmail]");+ expect(send.mock.calls[0][0]).not.toContain("Mentioned teammates");+});++it("does not send pins for a chip removed from the draft", async () => {+ const send = vi.fn(async (_text: string) => {});+ render(<Composer agent={{ agentId: "test", name: "Test" } as SocietyAgent} mentionable={[]}+ busy={false} sessionId="society:test" cwd="" provider="openai" surface="society"+ onSend={send} onCancel={async () => {}} />);+ fireEvent.click(screen.getByRole("button", { name: "society.chat.more" }));+ fireEvent.click(screen.getByRole("button", { name: "chat_tools.all" }));+ fireEvent.click(await screen.findByRole("option", { name: /@gmail/ }));+ const box = screen.getByRole("textbox");+ box.textContent = "Explain this instead";+ fireEvent.input(box);+ fireEvent.click(screen.getByRole("button", { name: "society.chat.send" }));+ await waitFor(() => expect(send).toHaveBeenCalledOnce());+ expect(send.mock.calls[0][0]).toBe("Explain this instead");+});+it("collapses server pins but keeps specific MCP tool selections distinct", () => {const choices = pinnedMessageChoices("Use @github\n\n[tools: mcp:github/read, mcp:github/list]");expect(choices).toHaveLength(1);diff --git a/jarvis/ui/web/frontend/src/components/society/chat/mentionChoices.ts b/jarvis/ui/web/frontend/src/components/society/chat/mentionChoices.tsindex b9462ef2e9..3559931a62 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/mentionChoices.ts+++ b/jarvis/ui/web/frontend/src/components/society/chat/mentionChoices.ts@@ -31,11 +31,12 @@ function choice(id: string, name: string, description = ""): ToolChoice {};}-export function mentionChoice(item: MentionItem): ToolChoice {+export function mentionChoice(item: MentionItem): ToolChoice & { mentionValue: string } {const family = item.kind === "plugin" ? pluginFamily(item.toolName) ?? pluginFamily(item.key.replace(/^plugin:/, "")) : undefined;const base = choice(item.key, item.toolName || item.value, item.hint);return {...base,+ mentionValue: item.value,label: item.label || base.label,brand: family?.id || base.brand,category: item.kind === "plugin" ? "plugins" : item.kind === "cli" ? "cli" : base.category,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 6bff82f2f1..0ce86f1849 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@@ -74,6 +74,37 @@ function cap(over: Partial<Capability> & Pick<Capability, "id">): Capability {}describe("buildMentionCatalog", () => {+ it("keeps installed but disconnected community plugins searchable", () => {+ const catalog = buildMentionCatalog([], [], [], [{ id: "todo_fox", display_name: "Todo Fox", description: "Tasks" }]);+ expect(filterMentions(catalog, "")).toEqual([]);+ expect(filterMentions(catalog, "todo")[0]).toMatchObject({ connected: false, pinIds: [], label: "Todo Fox" });+ });+ it("loads a newly installed community plugin from the live catalog", () => {+ const items = buildMentionCatalog([], [cap({ id: "plugin:todo_fox_tool" })], [], [+ { id: "todo_fox", display_name: "Todo Fox", description: "Tasks", native_tool: "todo_fox_tool" },+ ]);+ expect(filterMentions(items, "")).toEqual([expect.objectContaining({+ key: "plugin:todo_fox", label: "Todo Fox", pinIds: ["plugin:todo_fox_tool"],+ })]);+ });++ it("does not hide independent skills or CLIs whose names mention a plugin", () => {+ const items = buildMentionCatalog([], [+ cap({ id: "skill:github-review" }), cap({ id: "cli:github" }),+ cap({ id: "mcp:research/github_search" }),+ ]);+ expect(items.map((item) => item.kind)).toEqual(["skill", "cli", "mcp"]);+ });++ it("allocates distinct tags even when both preferred tags are already taken", () => {+ const items = buildMentionCatalog([+ agent({ agentId: "one", name: "gmail" }),+ agent({ agentId: "two", name: "plugin:gmail" }),+ agent({ agentId: "three", name: "Research Assistant" }),+ ], [cap({ id: "plugin:gmail" })]);+ expect(new Set(items.map((item) => item.value.toLowerCase())).size).toBe(items.length);+ expect(items.every((item) => !/\s/.test(item.value))).toBe(true);+ });it("tags a plugin as @gmail, not @plugin:gmail", () => {const items = buildMentionCatalog([], [cap({ id: "plugin:gmail", label: "gmail" })]);expect(items).toEqual([@@ -172,6 +203,18 @@ describe("buildMentionCatalog", () => {});describe("filterMentions", () => {+ it("keeps all browse and search results in large catalogs", () => {+ const items = buildMentionCatalog([], Array.from({ length: 125 }, (_, i) => cap({ id: `skill:daily-${i}` })));+ expect(filterMentions(items, "")).toHaveLength(125);+ expect(filterMentions(items, "daily")).toHaveLength(125);+ });++ it("returns the same order the grouped picker displays for keyboard selection", () => {+ const items = buildMentionCatalog([], [cap({ id: "core:search-web" }), cap({ id: "cli:gh" }),+ cap({ id: "mcp:sentry/search" }), cap({ id: "skill:brief" })]);+ const matches = filterMentions(items, "");+ expect(matches.map((item) => item.key)).toEqual(groupMentions(matches).flatMap((group) => group.items.map((item) => item.key)));+ });const items = buildMentionCatalog([agent({ agentId: "scout", name: "Scout", title: "Research" })],[@@ -188,7 +231,7 @@ describe("filterMentions", () => {it("on a bare @ lists connected browse rows, not disconnected plugins or MCP tools", () => {const values = filterMentions(items, "").map((i) => i.value);- expect(values).toEqual(["Scout", "gmail", "github", "search-web", "gh", "sentry"]);+ expect(values).toEqual(["Scout", "gmail", "github", "sentry", "gh", "search-web"]);expect(values).not.toContain("notion");expect(values).not.toContain("github/create_issue");expect(values).not.toContain("sentry/create_issue");diff --git a/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.ts b/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.tsindex d10c46e729..a9d0069f1e 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.ts+++ b/jarvis/ui/web/frontend/src/components/society/chat/mentionItems.ts@@ -8,7 +8,7 @@* browsing; typing a tool name unfolds the individual tools.*/-import { marketplacePluginId, pluginFamily } from "@/lib/pluginFamilies";+import { PLUGIN_FAMILIES, marketplacePluginId, pluginFamily } from "@/lib/pluginFamilies";import type { Capability, SocietyAgent } from "../data";import type { AgentStatus } from "@/lib/agenticIdeApi";@@ -59,8 +59,12 @@ const KIND_GROUP: Record<string, MentionGroup> = {core: "tools",};-const BROWSE_LIMIT = 80;-const SEARCH_LIMIT = 60;+export interface MentionPlugin {+ id: string;+ display_name: string;+ description: string;+ native_tool?: string | null;+}function kindOf(cap: Capability): MentionKind {const prefix = cap.id.split(":")[0];@@ -87,12 +91,18 @@ function mcpServer(id: string): string {function takeValue(wanted: string, fallback: string, taken: Set<string>): string {const tryOne = (candidate: string): string | null => {+ candidate = candidate.trim().replace(/\s+/g, "-");const key = candidate.toLowerCase();if (!candidate || taken.has(key)) return null;taken.add(key);return candidate;};- return tryOne(wanted) ?? tryOne(fallback) ?? fallback;+ const value = tryOne(wanted) ?? tryOne(fallback);+ if (value) return value;+ for (let suffix = 2; ; suffix += 1) {+ const unique = tryOne(`${fallback}-${suffix}`);+ if (unique) return unique;+ }}function searchBlob(parts: Array<string | undefined | null>): string {@@ -149,6 +159,7 @@ export function buildMentionCatalog(agents: readonly SocietyAgent[],capabilities: readonly Capability[],codingAgents: readonly AgentStatus[] = [],+ plugins: readonly MentionPlugin[] = [],): MentionItem[] {const taken = new Set<string>();const items: MentionItem[] = [];@@ -186,9 +197,29 @@ export function buildMentionCatalog(const families = new Map<string, Capability[]>();const mcpByServer = new Map<string, Capability[]>();const rest: Capability[] = [];+ const livePlugins = new Map(plugins.map((plugin) => [plugin.id, plugin]));+ const familyIds = new Set([...PLUGIN_FAMILIES.map((plugin) => plugin.id), ...livePlugins.keys()]);+ const familyFor = (cap: Capability): string | undefined => {+ const kind = kindOf(cap);+ const name = capabilityName(cap.id);+ if (kind === "cli" || kind === "core") return undefined;+ if (kind === "skill" && !name.startsWith("plugin-")) return undefined;+ const identity = kind === "mcp" ? mcpServer(cap.id) : kind === "skill" ? name.slice(7) : name;+ // Only an exact owner identity can fold a row, never a tool/skill's prose or suffix.+ const owner = [...familyIds].find((id) => id === identity || id.replace(/_/g, "-") === identity);+ if (owner) return owner;+ const native = plugins.find((plugin) => plugin.native_tool === (cap.tool_name || name));+ if (kind === "plugin" && native) return native.id;+ const seeded = marketplacePluginId(identity);+ const family = seeded ? pluginFamily(seeded) : undefined;+ return family && [family.id, family.tag, "plugin-" + family.id].includes(identity) ? family.id : undefined;+ };+ const seenCapabilities = new Set<string>();for (const cap of capabilities) {+ if (seenCapabilities.has(cap.id)) continue;+ seenCapabilities.add(cap.id);if (cap.id === "core:coding-session" && codingAgents.length) continue;- const familyId = marketplacePluginId(cap.id) || marketplacePluginId(cap.tool_name || "");+ const familyId = familyFor(cap);if (familyId) {const bucket = families.get(familyId);if (bucket) bucket.push(cap);@@ -210,20 +241,27 @@ export function buildMentionCatalog(}}+ for (const plugin of plugins) {+ if (!families.has(plugin.id)) families.set(plugin.id, []);+ }for (const [familyId, members] of families) {const family = pluginFamily(familyId);+ const installed = livePlugins.get(familyId);const live = members.filter((cap) => kindOf(cap) !== "skill");const connected = live.some((cap) => cap.connected);const representative =- members.find((cap) => kindOf(cap) === "plugin") ?? live[0] ?? members[0];+ members.find((cap) => kindOf(cap) === "plugin") ?? live[0] ?? members[0] ?? {+ id: `plugin:${familyId}`, kind: "plugin", label: installed?.display_name ?? familyId,+ one_liner: installed?.description ?? "", connected: false, risk_tier: "monitor", tool_name: "",+ };const tag = family?.tag ?? familyId.replace(/_/g, "-");const value = takeValue(tag, `plugin:${familyId}`, taken);const item = capabilityItem(representative, value, {key: `plugin:${familyId}`,detail: false,pinIds: members.map((cap) => cap.id),- label: family?.displayName ?? representative.label,- hint: family?.description || representative.one_liner,+ label: installed?.display_name ?? family?.displayName ?? representative.label,+ hint: installed?.description || family?.description || representative.one_liner,toolName: familyId,connected,});@@ -307,7 +345,8 @@ function scoreItem(item: MentionItem, q: string): number | null {export function filterMentions(items: readonly MentionItem[], query: string): MentionItem[] {const q = query.trim().toLowerCase();if (!q) {- return items.filter((item) => !item.detail && (item.connected || item.kind === "coding")).slice(0, BROWSE_LIMIT);+ return groupMentions(items.filter((item) => !item.detail && (item.connected || item.kind === "coding")))+ .flatMap((group) => group.items);}const ranked: { score: number; index: number; item: MentionItem }[] = [];items.forEach((item, index) => {@@ -316,7 +355,7 @@ export function filterMentions(items: readonly MentionItem[], query: string): Meranked.push({ score, index, item });});ranked.sort((a, b) => a.score - b.score || a.index - b.index);- return ranked.slice(0, SEARCH_LIMIT).map((r) => r.item);+ return groupMentions(ranked.map((r) => r.item)).flatMap((group) => group.items);}export function groupMentions(diff --git a/jarvis/ui/web/frontend/src/components/society/data.ts b/jarvis/ui/web/frontend/src/components/society/data.tsindex fe9624dcc6..153fe6907f 100644--- a/jarvis/ui/web/frontend/src/components/society/data.ts+++ b/jarvis/ui/web/frontend/src/components/society/data.ts@@ -12,8 +12,9 @@* §2); the const arrays in lib/societyApi.ts are pinned to the Python enums by* the five-layer parity test (AP-4).*/-import { useCallback } from "react";+import { useCallback, useEffect } from "react";import { useQuery, useQueryClient } from "@tanstack/react-query";+import type { MentionPlugin } from "./chat/mentionItems";import type { Checkpoint, SocietyAgentRow } from "@/lib/societyApi";@@ -307,20 +308,37 @@ export interface Capability {}async function fetchCapabilities(): Promise<Capability[]> {- const res = await fetch("/api/society/capabilities");+ const res = await fetch("/api/society/capabilities", { cache: "no-store" });if (!res.ok) throw new Error(`capabilities ${res.status}`);const body = (await res.json()) as { capabilities?: Capability[] };return body.capabilities ?? [];}-export function useSocietyCapabilities(enabled = true) {- return useQuery({+export function useSocietyCapabilities(enabled = true, mentionOpen = false) {+ const query = useQuery({queryKey: CAPABILITIES_QUERY_KEY,queryFn: fetchCapabilities,enabled,staleTime: 60_000,retry: false,});+ const plugins = useQuery({+ queryKey: ["marketplace-plugins"],+ queryFn: async () => {+ const res = await fetch("/api/marketplace/plugins", { cache: "no-store" });+ if (!res.ok) throw new Error(`plugins ${res.status}`);+ return res.json() as Promise<{ plugins: MentionPlugin[] }>;+ },+ enabled: enabled && mentionOpen,+ staleTime: 0,+ retry: false,+ });+ const { refetch } = query;+ useEffect(() => {+ if (enabled && mentionOpen) void refetch();+ }, [enabled, mentionOpen, refetch]);+ return { ...query, plugins: plugins.data?.plugins ?? [], inventoryError: query.isError || plugins.isError,+ retryInventory: () => { void refetch(); void plugins.refetch(); } };}/** A URL-safe id from a display name, unique against the rows already known. */diff --git a/jarvis/ui/web/frontend/src/components/society/mentionInventory.test.tsx b/jarvis/ui/web/frontend/src/components/society/mentionInventory.test.tsxnew file mode 100644index 0000000000..f6436be430--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/society/mentionInventory.test.tsx@@ -0,0 +1,45 @@+import { act, cleanup, renderHook, waitFor } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { afterEach, expect, it, vi } from "vitest";+import type { ReactNode } from "react";+import { useSocietyCapabilities } from "./data";++afterEach(() => { cleanup(); vi.unstubAllGlobals(); });++it("refreshes installed, disabled and removed entries whenever @ is reopened", async () => {+ let ids = ["skill:old"];+ const fetcher = vi.fn(async (url: string) => ({ ok: true, json: async () => url.includes("marketplace")+ ? { plugins: [{ id: "community", display_name: "Community", description: "Tasks" }] }+ : { capabilities: ids.map((id) => ({ id })) } }));+ vi.stubGlobal("fetch", fetcher);+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });+ const wrapper = ({ children }: { children: ReactNode }) => <QueryClientProvider client={client}>{children}</QueryClientProvider>;+ const hook = renderHook(({ open }) => useSocietyCapabilities(true, open), { initialProps: { open: false }, wrapper });+ await waitFor(() => expect(hook.result.current.data?.[0].id).toBe("skill:old"));+ ids = ["skill:new"];+ hook.rerender({ open: true });+ await waitFor(() => expect(hook.result.current.data?.[0].id).toBe("skill:new"));+ await waitFor(() => expect(hook.result.current.plugins[0].id).toBe("community"));+ hook.rerender({ open: false });+ ids = [];+ hook.rerender({ open: true });+ await waitFor(() => expect(hook.result.current.data).toEqual([]));+ expect(fetcher).toHaveBeenCalledWith("/api/society/capabilities", { cache: "no-store" });+ hook.unmount();+ client.clear();+});++it("reports inventory failures and recovers with the retry action", async () => {+ let failed = true;+ vi.stubGlobal("fetch", async () => ({ ok: !failed, status: 503, json: async () => ({ capabilities: [], plugins: [] }) }));+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });+ const wrapper = ({ children }: { children: ReactNode }) => <QueryClientProvider client={client}>{children}</QueryClientProvider>;+ const hook = renderHook(() => useSocietyCapabilities(true, true), { wrapper });+ await waitFor(() => expect(hook.result.current.inventoryError).toBe(true));+ failed = false;+ act(() => hook.result.current.retryInventory());+ await waitFor(() => expect(hook.result.current.inventoryError).toBe(false));+ expect(hook.result.current.data).toEqual([]);+ hook.unmount();+ client.clear();+});diff --git a/jarvis/ui/web/frontend/src/hooks/useWebSocket.test.tsx b/jarvis/ui/web/frontend/src/hooks/useWebSocket.test.tsxindex 1f54f341d2..927ce44ae3 100644--- a/jarvis/ui/web/frontend/src/hooks/useWebSocket.test.tsx+++ b/jarvis/ui/web/frontend/src/hooks/useWebSocket.test.tsx@@ -343,6 +343,17 @@ describe("useWebSocket VoiceBootStatus handling", () => {expect(invalidate).toHaveBeenCalledWith({ queryKey: ["docs"] });});++ it.each(["MarketplaceItemInstalled", "SkillRegistryReloaded", "BrainToolsChanged"])(+ "refreshes open capability pickers after %s", async (eventName) => {+ const invalidate = vi.spyOn(queryClient, "invalidateQueries");+ render(<Harness />);+ await Promise.resolve();+ MockWebSocket.last!.deliver(envelope(eventName, { kind: "skill" }));+ expect(invalidate).toHaveBeenCalledWith({ queryKey: ["society", "capabilities"] });+ invalidate.mockRestore();+ },+ );});describe("useWebSocket connection state (welcome-gated + warming)", () => {diff --git a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts b/jarvis/ui/web/frontend/src/hooks/useWebSocket.tsindex c140d6feb6..0f969e1f04 100644--- a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts+++ b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts@@ -638,6 +638,7 @@ export function useWebSocket(): void {}if (env.event_name === "MarketplaceItemInstalled") {+ void queryClient.invalidateQueries({ queryKey: ["society", "capabilities"] });// The install may have come from anywhere: a terminal running// `jarvis marketplace install`, a spoken sentence, the storefront's// button, or another window of this app. Only the window that@@ -656,6 +657,10 @@ export function useWebSocket(): void {}}+ if (env.event_name === "SkillRegistryReloaded" || env.event_name === "BrainToolsChanged") {+ void queryClient.invalidateQueries({ queryKey: ["society", "capabilities"] });+ }+if (env.event_name === "ActionApprovalRequired") {const p = env.payload as {mission_id?: unknown;