diff --git a/webui/src/components/settings/system/AppsSettings.tsx b/webui/src/components/settings/system/AppsSettings.tsx index 44df83cf2..d8fe42dd5 100644 --- a/webui/src/components/settings/system/AppsSettings.tsx +++ b/webui/src/components/settings/system/AppsSettings.tsx @@ -211,12 +211,12 @@ export function AppsCatalogSettings({ })), ] .filter((item) => { - if (normalizedQuery) return appsSearchText(item).includes(normalizedQuery); - if (filter === "ready") return appsReady(item); - if (filter === "cli") { - return item.kind === "cli" || item.preset.source === "agent-plugin"; - } - return item.kind === "mcp" && item.preset.source !== "agent-plugin"; + const matchesFilter = filter === "ready" + ? appsReady(item) + : filter === "cli" + ? item.kind === "cli" || item.preset.source === "agent-plugin" + : item.kind === "mcp" && item.preset.source !== "agent-plugin"; + return matchesFilter && (!normalizedQuery || appsSearchText(item).includes(normalizedQuery)); }) .sort((left, right) => { const rank = Number(!appsReady(left)) - Number(!appsReady(right)); @@ -226,7 +226,7 @@ export function AppsCatalogSettings({ ? (cliApps?.apps ?? []).find((app) => app.name === cliFocusName && app.installed) : null; const loading = (mcpPresetsLoading && !mcpPresets) - || ((filter !== "mcp" || Boolean(normalizedQuery)) && cliAppsLoading && !cliApps); + || (filter !== "mcp" && cliAppsLoading && !cliApps); const cliAppCount = cliApps?.apps.length ?? 0; const emptyTitle = normalizedQuery ? tx("settings.apps.empty", "No tools match your search.") diff --git a/webui/src/tests/catalog-loading.test.tsx b/webui/src/tests/catalog-loading.test.tsx index 3d2a89076..17ddecb13 100644 --- a/webui/src/tests/catalog-loading.test.tsx +++ b/webui/src/tests/catalog-loading.test.tsx @@ -57,7 +57,7 @@ describe("catalog loading", () => { expect(screen.queryByRole("status", { name: "Loading apps…" })).not.toBeInTheDocument(); }); - it("finishes an empty MCP category independently but waits for Apps when searching", async () => { + it("searches MCP independently and waits for Apps only after switching tabs", async () => { const cli = deferred(); vi.stubGlobal("fetch", vi.fn((input: RequestInfo | URL) => { const url = String(input); @@ -76,6 +76,9 @@ describe("catalog loading", () => { expect(screen.getByText("No MCP tools available.")).toBeInTheDocument(); expect(screen.queryByRole("status", { name: "Loading apps…" })).not.toBeInTheDocument(); fireEvent.change(screen.getByPlaceholderText("Search tools"), { target: { value: "AnyGen" } }); + expect(screen.getByText("No tools match your search.")).toBeInTheDocument(); + expect(screen.queryByRole("status", { name: "Loading apps…" })).not.toBeInTheDocument(); + fireEvent.click(screen.getByRole("button", { name: "Apps" })); expect(screen.getByRole("status", { name: "Loading apps…" })).toBeInTheDocument(); expect(screen.queryByText("No tools match your search.")).not.toBeInTheDocument(); await act(async () => { cli.resolve(jsonResponse({ apps: [app], installed_count: 1 })); }); diff --git a/webui/src/tests/settings-apps-oauth.test.tsx b/webui/src/tests/settings-apps-oauth.test.tsx index 66c4f72be..369aeaed2 100644 --- a/webui/src/tests/settings-apps-oauth.test.tsx +++ b/webui/src/tests/settings-apps-oauth.test.tsx @@ -43,6 +43,55 @@ async function connectXmind() { describe("SettingsView Apps catalog", () => { installSettingsViewTestHooks(); + it("searches within the selected readiness or kind filter", async () => { + const figmaLocal = { ...xmindMcpPreset, name: "figma-local", display_name: "Figma local" }; + const figmaConnected = { + ...xmindMcpPreset, name: "figma-connected", display_name: "Figma connected", + enabled: true, installed: true, configured: true, status: "configured", + }; + const cliApp = { + name: "figma-cli", display_name: "Figma CLI", category: "design", description: "Figma tools", + requires: "", source: "catalog", entry_point: "figma", install_supported: true, + installed: true, available: true, status: "installed", skill_installed: false, + }; + vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => { + const url = String(input); + if (url === "/api/settings") return jsonResponse(settingsPayload()); + if (url === "/api/settings/cli-apps") return jsonResponse({ + apps: [ + cliApp, + { ...cliApp, name: "figma-pending", display_name: "Figma pending", installed: false }, + { ...cliApp, name: "photoshop-cli", display_name: "Photoshop CLI", description: "Photo tools", entry_point: "photoshop" }, + ], + installed_count: 2, + }); + if (url === "/api/settings/mcp-presets") return jsonResponse({ + presets: [figmaLocal, figmaConnected], installed_count: 1, + }); + return { ok: false, status: 404, text: async () => "Not found" } as Response; + })); + + renderSettingsView({ initialSection: "apps" }); + fireEvent.click(await screen.findByRole("button", { name: "Ready" })); + fireEvent.change(screen.getByPlaceholderText("Search tools"), { target: { value: "figma" } }); + expect(await screen.findByRole("heading", { name: "Figma connected" })).toBeInTheDocument(); + expect(screen.getByRole("heading", { name: "Figma CLI" })).toBeInTheDocument(); + expect(screen.queryByRole("heading", { name: "Figma local" })).not.toBeInTheDocument(); + expect(screen.queryByRole("heading", { name: "Figma pending" })).not.toBeInTheDocument(); + + fireEvent.click(screen.getByRole("button", { name: "MCP" })); + expect(screen.getByRole("heading", { name: "Figma local" })).toBeInTheDocument(); + expect(screen.getByRole("heading", { name: "Figma connected" })).toBeInTheDocument(); + expect(screen.queryByRole("heading", { name: "Figma CLI" })).not.toBeInTheDocument(); + fireEvent.click(screen.getByRole("button", { name: "Apps" })); + expect(screen.getByRole("heading", { name: "Figma pending" })).toBeInTheDocument(); + expect(screen.queryByRole("heading", { name: "Figma local" })).not.toBeInTheDocument(); + expect(screen.queryByRole("heading", { name: "Photoshop CLI" })).not.toBeInTheDocument(); + fireEvent.change(screen.getByPlaceholderText("Search tools"), { target: { value: "" } }); + expect(screen.getByRole("heading", { name: "Photoshop CLI" })).toBeInTheDocument(); + expect(screen.queryByRole("heading", { name: "Figma local" })).not.toBeInTheDocument(); + }); + it.each([null, "", " ", "http://127.0.0.1:8080"])("offers inline proxy setup for missing shared proxy %j", async (proxy) => { const settings = { ...settingsPayload(), runtime_config: { "network.proxy": proxy } }; vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => {