diff --git a/doc/connections/MCP-APPS.md b/doc/connections/MCP-APPS.md index e4c9ff8f855..1281f109fce 100644 --- a/doc/connections/MCP-APPS.md +++ b/doc/connections/MCP-APPS.md @@ -67,6 +67,10 @@ listing. See [CONNECTION-SEARCH.md](./CONNECTION-SEARCH.md). | View context | A view's `ui/update-model-context` is stored per view (`tool_mcp_app_views.model_context`, 16 KB at most) by `PUT …/:viewId/model-context`. Identical updates are deduped in the browser and on the server; a change logs `issue.mcp_app_context_updated`; an empty update clears it. The task's next run receives the three most recently updated contexts as an "App context (untrusted)" section of its wake prompt, quoted as JSON data and labelled as third-party data, not instructions. It is read in parallel with the other run preparation and never fails the run. | `server/src/services/mcp-app-views.ts`, `heartbeat/execution-configuration.ts`, `renderPaperclipWakePrompt` | | Tool icons | Provider `icons` (SEP-973) on MCP tools are sanitized into `tool_catalog_entries.icons`, outside the version hash. Task chat tool rows and the app's actions list show them, falling back to the usual icons. | `server/src/services/tool-access/catalog/`, `ui/src/components/ProviderToolIcon.tsx` | +GitHub's `get_me` profile view (`ui://github-mcp-server/get-me`) is omitted from +reply widgets, including views saved by earlier runs. Identity lookups remain +in the folded tool history. Other app views keep their normal reply placement. + ### Sandbox The view runs in a `srcdoc` iframe with `sandbox="allow-scripts allow-popups diff --git a/ui/src/components/mcp-app/McpAppTurnViews.test.tsx b/ui/src/components/mcp-app/McpAppTurnViews.test.tsx index d9e1a5f4502..bee89cdb6c6 100644 --- a/ui/src/components/mcp-app/McpAppTurnViews.test.tsx +++ b/ui/src/components/mcp-app/McpAppTurnViews.test.tsx @@ -32,9 +32,9 @@ class FakeIntersectionObserver { takeRecords() { return []; } } -async function render(count: number) { +async function render(input: number | McpAppViewSummary[]) { const client = new QueryClient({ defaultOptions: { queries: { retry: false } } }); - client.setQueryData(queryKeys.mcpApps.views("issue-1"), views(count)); + client.setQueryData(queryKeys.mcpApps.views("issue-1"), typeof input === "number" ? views(input) : input); const container = document.createElement("div"); const root = createRoot(container); await act(async () => root.render( @@ -52,6 +52,38 @@ afterEach(() => { }); describe("McpAppTurnViews", () => { + const identityViews = (): McpAppViewSummary[] => views(4).map((view) => ({ + ...view, + id: `profile-${view.id}`, + applicationName: "GitHub", + toolName: "mcp.github:get-me", + upstreamToolName: "get_me", + resourceUri: "ui://github-mcp-server/get-me", + })); + + it("renders no cards or documents for repeated saved GitHub identity lookups", async () => { + vi.stubGlobal("IntersectionObserver", FakeIntersectionObserver); + const { container, root } = await render(identityViews()); + expect(container.childElementCount).toBe(0); + expect(observers).toHaveLength(0); + expect(detail).not.toHaveBeenCalled(); + await act(async () => root.unmount()); + }); + + it("counts only visible widgets toward the per-run limit", async () => { + vi.stubGlobal("IntersectionObserver", FakeIntersectionObserver); + const { container, root } = await render([...identityViews(), ...views(7)]); + expect(container.querySelectorAll("[data-testid=mcp-app-turn-view]")).toHaveLength(5); + expect(container.textContent).not.toContain("Get me"); + const more = [...container.querySelectorAll("button")].find((button) => button.textContent === "Show 2 more"); + expect(more).toBeTruthy(); + await act(async () => more!.click()); + expect(container.querySelectorAll("[data-testid=mcp-app-turn-view]")).toHaveLength(7); + expect(container.textContent).not.toContain("Get me"); + expect(detail).not.toHaveBeenCalled(); + await act(async () => root.unmount()); + }); + it("loads a view's document only when it nears the viewport", async () => { vi.stubGlobal("IntersectionObserver", FakeIntersectionObserver); vi.stubGlobal("navigation", { addEventListener: () => undefined }); diff --git a/ui/src/components/mcp-app/mcp-app-matching.test.ts b/ui/src/components/mcp-app/mcp-app-matching.test.ts index 0b374164d21..86d4fb43875 100644 --- a/ui/src/components/mcp-app/mcp-app-matching.test.ts +++ b/ui/src/components/mcp-app/mcp-app-matching.test.ts @@ -27,6 +27,22 @@ describe("mcp app view index", () => { expect(index.forRun("run-3")).toEqual([]); }); + it("omits GitHub identity widgets while retaining other app views", () => { + const githubIdentity = { + applicationName: "GitHub", + upstreamToolName: "get_me", + resourceUri: "ui://github-mcp-server/get-me", + }; + const index = createMcpAppViewIndex([ + view("profile-1", githubIdentity), + view("meeting"), + view("profile-2", githubIdentity), + view("github-result", { ...githubIdentity, upstreamToolName: "search_pull_requests", resourceUri: "ui://github-mcp-server/pull-requests" }), + view("other-app-profile", { upstreamToolName: "get_me", resourceUri: "ui://another-app/profile" }), + ]); + expect(index.forRun("run-1").map((v) => v.id)).toEqual(["meeting", "github-result", "other-app-profile"]); + }); + it("builds one index per loaded list and answers each reply without rescanning", () => { // Realistic upper bound: 200 saved views over 100 runs, 2,000 rendered replies. const views = Array.from({ length: 200 }, (_, index) => view(`v${index}`, { runId: `run-${index % 100}` })); diff --git a/ui/src/components/mcp-app/mcp-app-matching.ts b/ui/src/components/mcp-app/mcp-app-matching.ts index c9e0b328881..f3b7892a09b 100644 --- a/ui/src/components/mcp-app/mcp-app-matching.ts +++ b/ui/src/components/mcp-app/mcp-app-matching.ts @@ -12,6 +12,7 @@ export function createMcpAppViewIndex(views: readonly McpAppViewSummary[]): McpA const byRun = new Map(); for (const view of views) { if (!view.runId) continue; + if (view.upstreamToolName === "get_me" && view.resourceUri === "ui://github-mcp-server/get-me") continue; const list = byRun.get(view.runId); if (list) list.push(view); else byRun.set(view.runId, [view]);