fix(ui): keep GitHub identity widgets out of replies (#22217)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Agents call connected apps while they work on tasks.
> - Some app tools include a widget that Paperclip shows with the reply.
> - GitHub identity lookups include a profile widget. Repeated lookups
fill the reply with copies of the same card.
> - This pull request omits the known GitHub identity view when
Paperclip selects reply widgets.
> - The benefit is that task replies show useful app results while
identity calls remain in the tool history.

## Linked Issues or Issue Description

**What happened?**
A task that reads GitHub activity showed four copies of the connected
account's profile widget. Each copy came from a successful `get_me`
call. Paperclip showed these intermediate lookup results with the reply.

**Expected behavior**
GitHub identity lookups stay in the folded tool history. Other app
widgets keep their normal reply placement.

**Steps to reproduce**
1. Connect GitHub through its MCP server.
2. Run a task that calls `get_me` several times to find the connected
account.
3. Open the task reply. Each lookup adds a profile card.

**Paperclip version or commit**
Reproduced in the UI tests against base commit `8285a81280db`.

**Deployment mode**
Authenticated server. The rendering path is shared with local instances.

Related work: [MCP Apps
support](https://github.com/paperclipai/paperclip/pull/21119), [MCP Apps
reply views](https://github.com/paperclipai/paperclip/pull/21266).
Searched open issues and PRs for `get_me`, GitHub widgets, and MCP Apps.
No duplicate fix was found.

## What Changed

- Omit a view from the reply index only when its upstream tool is
`get_me` and its resource is `ui://github-mcp-server/get-me`.
- Apply the filter before the per-run widget limit. This covers saved
history and live replies through their shared index.
- Add tests for repeated saved identity calls, widget pagination, and
other GitHub and app views.
- Document the display policy in the MCP Apps guide.

The MCP Apps UI owns reply selection. Tool execution, view storage, API
responses, and the folded tool history keep their existing behavior.

## Verification

- Red-green reproduction: the three new regression tests failed before
the source change and passed after it.
- `pnpm exec vitest run ui/src/components/mcp-app/`: 6 files, 36 tests
passed.
- `pnpm --filter @paperclipai/ui typecheck`: passed after building the
worktree's missing SDK declarations with `pnpm --filter
@paperclipai/plugin-sdk ensure-build-deps`. The first typecheck failed
because those generated declarations were absent.
- `git diff --check`: passed. Reviewed the diff for secrets, personal
data, and run artifacts.
- `pnpm verify --explain`: exited 2 because the guide is a global CI
input. Required CI must supply broad coverage. An earlier selection was
invalidated by the guide edit and was rerun.
- Browser acceptance and a deployed staging check have not been run. The
saved-widget regression uses the shared React reply component.
- [Greptile
review](https://github.com/paperclipai/paperclip/pull/22217#issuecomment-6988213101):
5/5 for head `c842d21bff6de1b2084593abfff69e789775b163`, with no
actionable findings or unresolved review threads. Required CI is still
running.

## Risks

- Low risk. The display filter matches one known tool and resource pair.
Other widgets remain visible.
- This release hides GitHub profile cards even when a task intentionally
calls this tool to read a profile. The text result remains in the tool
history.
- No schema migration or stored-data cleanup is required. Existing saved
cards disappear from replies after the updated UI loads.

## Model Used

- OpenAI GPT-6.1 Sol (`gpt-6.1-sol`) through Codex in T3 Code, with
xhigh reasoning effort, tool use, and code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip authored and GitHub committed 2026-11-18 11:11:51 -08:00
1 parent 651749bdb4
commit f4d44ac13e
4 files changed
+55 -2

No files matched your search

+4
View File
@@ -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
@@ -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 });
@@ -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}` }));
@@ -12,6 +12,7 @@ export function createMcpAppViewIndex(views: readonly McpAppViewSummary[]): McpA
const byRun = new Map<string, McpAppViewSummary[]>();
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]);