DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(chat): distinguish empty MCP selection from inheritance
dajiaohuang3f985ad04ca3
diff --git a/web/hooks/useComposerResources.ts b/web/hooks/useComposerResources.tsindex bee262f1a..af309e769 100644--- a/web/hooks/useComposerResources.ts+++ b/web/hooks/useComposerResources.ts@@ -40,14 +40,15 @@ export function useComposerResources(// Depend on the contents rather than the array identity: `workspaces` is// refetched on every session change, and re-running on a new array of the// same rows would refetch the catalog with it.- const allowedKey = allowedMcp ? allowedMcp.join("\u0000") : "";+ const allowedKey = JSON.stringify(allowedMcp);useEffect(() => {let alive = true;void getWorkspaceResources(workspaceId ?? "").then((remote) => {if (!alive) return;- const allowed = allowedKey ? new Set(allowedKey.split("\u0000")) : null;+ const selected = JSON.parse(allowedKey) as string[] | null;+ const allowed = selected === null ? null : new Set(selected);setCatalog({skills: remote.skills ?? [],mcp: (remote.mcp ?? []).filter(diff --git a/web/tests/composer-empty-mcp-scope.spec.tsx b/web/tests/composer-empty-mcp-scope.spec.tsxnew file mode 100644index 000000000..72e404267--- /dev/null+++ b/web/tests/composer-empty-mcp-scope.spec.tsx@@ -0,0 +1,47 @@+import { renderHook, waitFor } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";+import { useComposerResources } from "@/hooks/useComposerResources";+import type { ChatWorkspaceRegistration } from "@/lib/workspaces-api";++const api = vi.hoisted(() => ({ fetch: vi.fn() }));+vi.mock("@/lib/api", () => ({ apiFetch: api.fetch, apiUrl: (url: string) => url }));++function workspace(mcp: string[] | null): ChatWorkspaceRegistration {+ return {+ workspace_id: "workspace-a", kind: "workspace", follows_root: true,+ display_name: "Workspace A", path: "/workspace-a", archived: false,+ created_at: "2026-10-05T00:00:00Z", status: "ready", error: "",+ resources: { skills: null, mcp, knowledge_bases: null },+ };+}++function catalog() {+ api.fetch.mockImplementation(() => Promise.resolve(new Response(JSON.stringify({+ skills: [{ id: "skill-a", name: "Skill A" }],+ mcp: [{ id: "server-a", name: "Server A" }, { id: "server-b", name: "Server B" }],+ knowledge_bases: [],+ }))));+}++describe("composer MCP workspace selection", () => {+ it.each([+ [null, ["server-a", "server-b"]],+ [["server-a"], ["server-a"]],+ [[], []],+ ] as const)("respects configured MCP selection %j", async (mcp, expected) => {+ catalog();+ const { result } = renderHook(() => useComposerResources("workspace-a", [workspace(mcp ? [...mcp] : null)]));+ await waitFor(() => expect(result.current.skills).toHaveLength(1));+ expect(result.current.mcp.map(option => option.id)).toEqual(expected);+ });++ it("refreshes when an inherited selection becomes explicitly empty", async () => {+ catalog();+ const { result, rerender } = renderHook(({ mcp }: { mcp: string[] | null }) =>+ useComposerResources("workspace-a", [workspace(mcp)]),+ { initialProps: { mcp: null } as { mcp: string[] | null } });+ await waitFor(() => expect(result.current.mcp).toHaveLength(2));+ rerender({ mcp: [] });+ await waitFor(() => expect(result.current.mcp).toHaveLength(0));+ });+});