DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(reading): send the action the reading composer displays
jiangbianshu1d268987fcfe
diff --git a/web/hooks/useWorkspaceChatActions.ts b/web/hooks/useWorkspaceChatActions.tsindex a514209b7..6214d4438 100644--- a/web/hooks/useWorkspaceChatActions.ts+++ b/web/hooks/useWorkspaceChatActions.ts@@ -22,7 +22,8 @@ export function useWorkspaceChatActions() {const { pinnedCapability } = options;const { state, setCapability, setTools } = useChatStateAdapter();- const { capabilities: catalogCapabilities } = useCapabilityCatalog();+ const { capabilities: catalogCapabilities, isLoading: catalogLoading } =+ useCapabilityCatalog();const workspaceCapabilities = useMemo(() =>pinnedCapability@@ -54,6 +55,21 @@ export function useWorkspaceChatActions(if (state.activeCapability === pinnedCapability) return;setCapability(pinnedCapability);}, [pinnedCapability, setCapability, state.activeCapability]);+ // The same holds for an unpinned workspace: an action the menu does not+ // offer (Course Study, carried in by a course hand-off) is displayed as+ // Chat, so send Chat. Wait for the catalog, or a plugin action that only the+ // server lists would be reset before it is known.+ useEffect(() => {+ if (pinnedCapability || catalogLoading) return;+ if ((state.activeCapability || "") === activeValue) return;+ setCapability(activeValue || null);+ }, [+ activeValue,+ catalogLoading,+ pinnedCapability,+ setCapability,+ state.activeCapability,+ ]);const activeCapability = useMemo(() =>workspaceCapabilities.find(diff --git a/web/tests/workspace-chat-actions-hidden-capability.spec.tsx b/web/tests/workspace-chat-actions-hidden-capability.spec.tsxnew file mode 100644index 000000000..6a7a7aa5f--- /dev/null+++ b/web/tests/workspace-chat-actions-hidden-capability.spec.tsx@@ -0,0 +1,75 @@+import { renderHook } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";++import { CHAT_CAPABILITIES } from "@/features/capabilities/presentation";++const captured = vi.hoisted(() => ({+ activeCapability: null as string | null,+ catalogLoading: false,+ setCapability: vi.fn(),+}));++vi.mock("@/features/chat/ChatStateAdapter", () => ({+ useChatStateAdapter: () => ({+ state: { activeCapability: captured.activeCapability, enabledTools: [] },+ setCapability: captured.setCapability,+ setTools: vi.fn(),+ }),+}));++vi.mock("@/features/capabilities/useCapabilityCatalog", () => ({+ useCapabilityCatalog: () => ({+ capabilities: CHAT_CAPABILITIES,+ isLoading: captured.catalogLoading,+ }),+}));++vi.mock("@/lib/tools-settings", () => ({+ getEnabledOptionalTools: () => Promise.resolve([]),+}));++const { useWorkspaceChatActions } = await import(+ "@/hooks/useWorkspaceChatActions"+);++describe("useWorkspaceChatActions with a stored action the workspace hides", () => {+ beforeEach(() => {+ captured.activeCapability = null;+ captured.catalogLoading = false;+ captured.setCapability.mockClear();+ });++ it("sends Chat when Course Study is carried into Reading", () => {+ captured.activeCapability = "course_study";+ const { result } = renderHook(() => useWorkspaceChatActions());++ expect(result.current.activeCapabilityValue).toBe("");+ expect(captured.setCapability).toHaveBeenCalledWith(null);+ });++ it("keeps an action the workspace offers", () => {+ captured.activeCapability = "deep_solve";+ const { result } = renderHook(() => useWorkspaceChatActions());++ expect(result.current.activeCapabilityValue).toBe("deep_solve");+ expect(captured.setCapability).not.toHaveBeenCalled();+ });++ it("waits for the catalog before resetting an unknown action", () => {+ captured.activeCapability = "plugin_only_action";+ captured.catalogLoading = true;+ renderHook(() => useWorkspaceChatActions());++ expect(captured.setCapability).not.toHaveBeenCalled();+ });++ it("still asserts a pinned action", () => {+ captured.activeCapability = "course_study";+ renderHook(() =>+ useWorkspaceChatActions({ pinnedCapability: "mastery_path" }),+ );++ expect(captured.setCapability).toHaveBeenCalledWith("mastery_path");+ expect(captured.setCapability).not.toHaveBeenCalledWith(null);+ });+});