mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-23 21:24:45 +01:00
feat(connections): render MCP Apps views in the task chat, starting with Circleback (#21119)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - Agents reach external apps through MCP connections. Paperclip
records each call and shows it as a tool row in the task chat.
> - MCP Apps (SEP-1865, extension `io.modelcontextprotocol/ui`, spec
2026-01-26) lets an MCP server attach an interactive `ui://` view to a
tool. Claude, Claude Code and VS Code render these views in chat.
Circleback uses them to show meeting cards.
> - Paperclip dropped the tool's `_meta.ui` at discovery and the
result's `_meta` at call time. Its gateway reported MCP App UI as
"unsupported". Circleback was reachable only through Composio, whose
toolkit has no `Display*` tools.
> - This pull request makes Paperclip an MCP Apps host. It also adds
Circleback as a native catalog connection.
> - The benefit is that a Circleback recap in a task shows the same
meeting cards as in Claude, and any other MCP server with views works
the same way.
## Linked Issues or Issue Description
**Subsystem affected**
Connections and apps (remote MCP gateway) and the task chat.
**Problem or motivation**
An agent that uses Circleback in Paperclip can only return text. The
same tools in Claude Code show interactive meeting cards
(`DisplayMeetings`). Paperclip discards the MCP Apps metadata, so it
cannot show them.
**Proposed solution**
Paperclip implements the host side of MCP Apps end to end. It keeps the
tool's view declaration and records each call that has a view. It
renders the view under the tool row in a sandboxed iframe that uses the
MCP Apps postMessage protocol. Circleback becomes a native catalog
connection, so its `Display*` tools are available.
**Alternatives considered**
Composio's `circleback_mcp` toolkit has 11 read tools and no `Display*`
tools, and its meta-tools return plain JSON, so it cannot carry views.
The spec's double-iframe sandbox proxy on a separate origin needs a
second origin that Paperclip does not have. A single opaque-origin
`srcdoc` frame with an injected CSP gives the same isolation.
**Roadmap alignment**
This extends the existing Apps catalog and MCP gateway. It adds no new
integration substrate (decision D4 in doc/connections/README.md).
**Additional context**
The standard, the design and the testing plan are in
`doc/connections/MCP-APPS.md`.
## What Changed
- **Shared:** `packages/shared/src/mcp-apps.ts` adds MCP Apps types,
`_meta.ui` and resource parsing (current and legacy keys), and a CSP
builder that keeps only well-formed `https` origins.
- **DB:** migration `0471` (`online_compatible`) adds
`tool_catalog_entries.ui_meta` and a new `tool_mcp_app_views` table.
- **Server, catalog:** discovery keeps each tool's `_meta.ui`. It is not
part of the version hash, so a view never quarantines a reviewed tool.
- **Server, gateway:**
- Paperclip advertises the MCP Apps client capability when it
initializes a session.
- App-only tools (`visibility: ["app"]`) are hidden from agents.
- The result `_meta` is kept for the view and is not sent to the agent.
- Each successful call to a tool with a view records a view row.
Recording is best effort.
- The gateway's `initialize` now reports `paperclip/mcp-app-ui:
host_rendered`.
- The context protocol (`resources/read`) now uses the injected test
transport, like the other remote calls.
- **Server, routes:** `server/src/routes/mcp-apps.ts`
- `GET /api/issues/:issueId/mcp-app-views` lists a task's views. It
needs task read access.
- `GET /api/issues/:issueId/mcp-app-views/:viewId` returns the view
document, read live through the agent's connection.
- `POST /api/issues/:issueId/mcp-app-views/:viewId/tool-calls` runs the
view's `tools/call`. It needs `tools:use` and reaches only tools of the
same connection that allow `app`. It uses the connection test-call path,
so policy, Ask first and audit apply.
- **UI:** `ui/src/components/mcp-app/`
- The host protocol: `ui/initialize` with theme, style variables and
size limits; tool-input; tool-result; size-changed; `tools/call`;
`ui/open-link` (http and https only); teardown.
- An opaque-origin iframe (`allow-scripts`, never `allow-same-origin`)
with the CSP placed before the view's markup.
- The views of a run render with that run's reply, in the live turn and
in settled history. They are keyed by the reply's run, so history needs
no transcript.
- **Circleback:** a native catalog app (`mcp-oauth`, DCR, `user
user:write`) with:
- the official logo;
- a reviewed risk classifier (Share* tools are writes, Delete* tools are
destructive, Display* tools are reads);
- warnings in the sign-in step;
- `doc/connections/CIRCLEBACK.md`.
Search now prefers a native app over an aggregator listing named "X
MCP".
- **Storybook:** `Tasks/MCP App views` shows the tool row with its view,
the ready state (Refresh calls a tool), loading, view unavailable, and a
tool call that needs approval.
## Verification
- `pnpm exec vitest run packages/shared/src/mcp-apps.test.ts
ui/src/components/mcp-app/`: 19 passed.
- `pnpm exec vitest run server/src/__tests__/mcp-apps.test.ts`: 3
passed, on embedded Postgres. The test connects Circleback through the
catalog with DCR OAuth against a fake Circleback MCP server. It checks:
- `ui_meta` is stored;
- an app-only tool is hidden from the agent;
- an agent call records one view with arguments, structured content and
`_meta`;
- a call without a view records nothing;
- the routes serve the view's HTML and CSP;
- the view's tool call works and a model-only tool is refused;
- another task, another company and an agent actor are refused.
- Circleback connector: 13 focused files, 645 tests passed. These are
the app definitions, search, aggregator fallback, connection intents,
tool policy, `AppsConnect` and `Browse`.
- Typecheck passed for `@paperclipai/shared`, `@paperclipai/server` and
`@paperclipai/ui`. `node scripts/storybook-catalog.mjs` and the
migration compatibility check also passed.
- Storybook check in the browser:
- In both themes, the view runs the handshake, renders the meeting cards
from `structuredContent`, picks up the theme variables, and resizes to
its content.
- Refresh sends `tools/call` and re-renders the cards.
- **Live Circleback end to end** on a local instance, with a real
Circleback account:
- Connected through the catalog entry with Circleback's dynamic client
registration and OAuth.
- Discovery stored the real view declarations:
- `DisplayMeetings` uses `ui://circleback/meetings.v2.html`.
- `DisplayActionItems` and `DisplayCalendarEvents` also have views.
- `ListAssigneeOptions` and `SetCalendarEventRecording` are app-only
helpers with no view. They are hidden from agents.
- A `claude_local` agent called `DisplayMeetings` on two tasks.
- The real 3.5 MB Circleback view rendered the meeting cards with the
agent's reply.
- Clicking a card opened that meeting in Circleback through
`ui/open-link`.
- The live run found two bugs, both fixed in this PR, each with a
regression test:
- The 1 MB tool-result limit blocked the view document.
- Views were hidden inside the folded tool history.
## Risks
- **New migration:** a new table and a nullable column. It is
`online_compatible`.
- **Existing connections:** tools get `ui_meta` on the next catalog
refresh. Until then, no view shows and the tool row is unchanged.
- **Untrusted provider HTML:** the view runs as provider HTML in an
opaque-origin sandbox. It cannot reach Paperclip's session, DOM or API.
Its network access is limited to the origins its server declared. A
view's tool calls use the viewer's permissions and the normal policy and
Ask-first path.
- **Agent tool lists:** app-only tools are removed from them. No current
provider marks tools app-only, so no listed tool disappears.
- **Search:** the change that prefers a native app over an "X MCP"
aggregator listing affects every app.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
subagents (one subagent authored the Circleback catalog connector).
## 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
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6a24b417c0
commit
8ff45c0fa9
67 files changed
+3865
-134
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
@@ -83,6 +83,12 @@
|
||||
"catalogVisible": false,
|
||||
"localAsset": "/brands/apps/candid.png"
|
||||
},
|
||||
{
|
||||
"slug": "circleback",
|
||||
"provider": "Circleback",
|
||||
"catalogVisible": true,
|
||||
"localAsset": "/brands/apps/circleback.png"
|
||||
},
|
||||
{
|
||||
"slug": "clickhouse",
|
||||
"provider": "ClickHouse",
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { McpAppCallToolResult, McpAppViewDetail, McpAppViewSummary } from "@paperclipai/shared";
|
||||
import { api } from "./client";
|
||||
|
||||
/** MCP Apps views recorded for a task's tool calls. */
|
||||
export const mcpAppsApi = {
|
||||
list: (issueId: string) =>
|
||||
api.get<McpAppViewSummary[]>(`/issues/${issueId}/mcp-app-views`, { cache: "no-store" }),
|
||||
detail: (issueId: string, viewId: string, signal?: AbortSignal) =>
|
||||
api.get<McpAppViewDetail>(`/issues/${issueId}/mcp-app-views/${viewId}`, { cache: "no-store", signal }),
|
||||
callTool: (issueId: string, viewId: string, name: string, args: Record<string, unknown>) =>
|
||||
api.post<McpAppCallToolResult>(`/issues/${issueId}/mcp-app-views/${viewId}/tool-calls`, { name, arguments: args }),
|
||||
};
|
||||
@@ -44,6 +44,8 @@ import {
|
||||
} from "@/components/transcript/useLiveRunTranscripts";
|
||||
import { useNativeRunTranscripts } from "@/components/transcript/useNativeRunTranscripts";
|
||||
import { TaskChatLiveTail } from "@/components/task-chat/TaskChatLiveTail";
|
||||
import { McpAppIssueProvider } from "@/components/mcp-app/McpAppIssueContext";
|
||||
import { McpAppTurnViews, mcpAppRunRefreshKey } from "@/components/mcp-app/McpAppTurnViews";
|
||||
import { TaskChatRunnerHeader, TaskChatRunnerTurn } from "@/components/task-chat/TaskChatRunnerTurn";
|
||||
import { partitionRunHealthItems } from "@/components/task-chat/TaskChatRunHealthBanner";
|
||||
import {
|
||||
@@ -3361,6 +3363,7 @@ export function TaskChatThread(props: TaskChatThreadProps) {
|
||||
|
||||
return (
|
||||
<TaskChatRequestHistoryContext.Provider value={issueId ?? "unknown"}>
|
||||
<McpAppIssueProvider issueId={issueId}>
|
||||
<TaskChatExpansionState.Provider value={expansionState.current}>
|
||||
<TaskChatScrollReady.Provider value={(historyRevealed || !historyPending || historyWaitExpired) && !scrollTargetPending}>
|
||||
<TaskChatPresentationProvider
|
||||
@@ -3534,6 +3537,7 @@ export function TaskChatThread(props: TaskChatThreadProps) {
|
||||
/>
|
||||
) : (
|
||||
<TaskChatShimmerScope items={tailItems}>
|
||||
<McpAppTurnViews runId={tailRunId} refreshKey={mcpAppRunRefreshKey(tailItems, tailStatus)} />
|
||||
<TaskChatLiveTail
|
||||
items={tailItems}
|
||||
emptyMessage={
|
||||
@@ -3707,6 +3711,7 @@ export function TaskChatThread(props: TaskChatThreadProps) {
|
||||
</TaskChatPresentationProvider>
|
||||
</TaskChatScrollReady.Provider>
|
||||
</TaskChatExpansionState.Provider>
|
||||
</McpAppIssueProvider>
|
||||
</TaskChatRequestHistoryContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
// @vitest-environment jsdom
|
||||
import { act } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { McpAppFrame } from "./McpAppFrame";
|
||||
|
||||
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
||||
|
||||
function frame(container: HTMLElement) {
|
||||
const iframe = container.querySelector("iframe");
|
||||
if (!iframe) throw new Error("no iframe");
|
||||
return iframe;
|
||||
}
|
||||
|
||||
function fromView(iframe: HTMLIFrameElement, data: unknown) {
|
||||
window.dispatchEvent(new MessageEvent("message", { data, source: iframe.contentWindow }));
|
||||
}
|
||||
|
||||
describe("McpAppFrame", () => {
|
||||
it("ignores a navigated frame's messages and remounts the original view", async () => {
|
||||
const callTool = vi.fn(async () => ({ content: [] }));
|
||||
const container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
const root = createRoot(container);
|
||||
await act(async () => {
|
||||
root.render(
|
||||
<McpAppFrame
|
||||
title="Circleback: Display meetings"
|
||||
viewId="view-1"
|
||||
toolName="DisplayMeetings"
|
||||
resource={{ uri: "ui://circleback/meetings", html: "<p>cards</p>", csp: {}, permissions: {}, prefersBorder: true }}
|
||||
toolInput={{}}
|
||||
toolResult={{ content: [] }}
|
||||
callTool={callTool}
|
||||
/>,
|
||||
);
|
||||
});
|
||||
const original = frame(container);
|
||||
// The view's own document loads first (jsdom fires this for srcdoc).
|
||||
let loaded = original.contentDocument?.readyState === "complete";
|
||||
original.addEventListener("load", () => { loaded = true; });
|
||||
for (let i = 0; i < 100 && !loaded; i += 1) {
|
||||
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 10)); });
|
||||
}
|
||||
expect(loaded).toBe(true);
|
||||
|
||||
// The view's own document works.
|
||||
await act(async () => {
|
||||
fromView(original, { jsonrpc: "2.0", id: 1, method: "ui/initialize", params: {} });
|
||||
fromView(original, { jsonrpc: "2.0", id: 2, method: "tools/call", params: { name: "RefreshMeetingCards", arguments: {} } });
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
});
|
||||
expect(callTool).toHaveBeenCalledTimes(1);
|
||||
|
||||
// The frame loads another document: its channel is dropped.
|
||||
await act(async () => {
|
||||
original.dispatchEvent(new Event("load"));
|
||||
fromView(original, { jsonrpc: "2.0", id: 3, method: "ui/initialize", params: {} });
|
||||
fromView(original, { jsonrpc: "2.0", id: 4, method: "tools/call", params: { name: "DeleteTag", arguments: {} } });
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
});
|
||||
expect(callTool).toHaveBeenCalledTimes(1);
|
||||
// A fresh iframe with the original view replaces it.
|
||||
const remounted = frame(container);
|
||||
expect(remounted).not.toBe(original);
|
||||
expect(remounted.getAttribute("srcdoc")).toContain("<p>cards</p>");
|
||||
await act(async () => root.unmount());
|
||||
container.remove();
|
||||
});
|
||||
|
||||
it("keeps the view's host when a refetch hands over equal data, and remounts for a new document", async () => {
|
||||
const callTool = vi.fn(async () => ({ content: [] }));
|
||||
const container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
const root = createRoot(container);
|
||||
const props = (html: string) => ({
|
||||
title: "Circleback: Display meetings",
|
||||
viewId: "view-1",
|
||||
toolName: "DisplayMeetings",
|
||||
// New object identities on every render, as a refetch produces.
|
||||
resource: { uri: "ui://circleback/meetings", html, csp: {}, permissions: {}, prefersBorder: true },
|
||||
toolInput: { meetingIds: ["m1"] },
|
||||
toolResult: { content: [{ type: "text", text: "ok" }] },
|
||||
callTool,
|
||||
});
|
||||
await act(async () => root.render(<McpAppFrame {...props("<p>cards</p>")} />));
|
||||
const original = frame(container);
|
||||
await act(async () => {
|
||||
fromView(original, { jsonrpc: "2.0", id: 1, method: "ui/initialize", params: {} });
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
});
|
||||
|
||||
await act(async () => root.render(<McpAppFrame {...props("<p>cards</p>")} />));
|
||||
expect(frame(container)).toBe(original);
|
||||
await act(async () => {
|
||||
fromView(original, { jsonrpc: "2.0", id: 2, method: "tools/call", params: { name: "RefreshMeetingCards", arguments: {} } });
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
});
|
||||
// The same host still knows the view finished ui/initialize.
|
||||
expect(callTool).toHaveBeenCalledTimes(1);
|
||||
|
||||
await act(async () => root.render(<McpAppFrame {...props("<p>new cards</p>")} />));
|
||||
expect(frame(container)).not.toBe(original);
|
||||
expect(frame(container).getAttribute("srcdoc")).toContain("new cards");
|
||||
expect(frame(container).getAttribute("sandbox")).toBe("allow-scripts");
|
||||
await act(async () => root.unmount());
|
||||
container.remove();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,145 @@
|
||||
import { useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
import type { McpAppCallToolResult, McpAppResource } from "@paperclipai/shared";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { createMcpAppHost, mcpAppDocument, type McpAppHostContext } from "./mcp-app-host";
|
||||
|
||||
const MAX_HEIGHT = 640;
|
||||
const INITIAL_HEIGHT = 120;
|
||||
const STYLE_VARIABLES: Array<[string, string]> = [
|
||||
["--color-background-primary", "--background"],
|
||||
["--color-background-secondary", "--muted"],
|
||||
["--color-text-primary", "--foreground"],
|
||||
["--color-text-secondary", "--muted-foreground"],
|
||||
["--color-border-primary", "--border"],
|
||||
["--font-sans", "--font-sans"],
|
||||
["--border-radius-md", "--radius"],
|
||||
];
|
||||
|
||||
function resolvedTheme(): "light" | "dark" {
|
||||
return typeof document !== "undefined" && document.documentElement.classList.contains("dark") ? "dark" : "light";
|
||||
}
|
||||
|
||||
function hostStyleVariables(): Record<string, string> {
|
||||
if (typeof document === "undefined") return {};
|
||||
const computed = getComputedStyle(document.documentElement);
|
||||
const variables: Record<string, string> = {};
|
||||
for (const [specName, tokenName] of STYLE_VARIABLES) {
|
||||
const value = computed.getPropertyValue(tokenName).trim();
|
||||
if (value) variables[specName] = value;
|
||||
}
|
||||
return variables;
|
||||
}
|
||||
|
||||
export interface McpAppFrameProps {
|
||||
title: string;
|
||||
viewId: string;
|
||||
toolName: string;
|
||||
resource: McpAppResource;
|
||||
toolInput: Record<string, unknown>;
|
||||
toolResult: McpAppCallToolResult;
|
||||
callTool: (name: string, args: Record<string, unknown>) => Promise<McpAppCallToolResult>;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an MCP Apps view. The document runs in an opaque-origin iframe
|
||||
* (`sandbox="allow-scripts"`, never `allow-same-origin`): it cannot reach
|
||||
* Paperclip's DOM, cookies or storage, and its network access is limited to
|
||||
* the origins its server declared. Everything else goes through the
|
||||
* postMessage protocol in `mcp-app-host.ts`.
|
||||
*/
|
||||
export function McpAppFrame({ title, viewId, toolName, resource, toolInput, toolResult, callTool, className }: McpAppFrameProps) {
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null);
|
||||
const [height, setHeight] = useState(INITIAL_HEIGHT);
|
||||
// One mount is one iframe element and one document. A second `load` means the
|
||||
// frame left the view's document: that frame and its channel are discarded.
|
||||
const [generation, setGeneration] = useState(0);
|
||||
const srcDoc = useMemo(() => mcpAppDocument(resource.html, resource.csp), [resource.html, resource.csp]);
|
||||
// A refetch of the same view hands over new object identities. The host reads
|
||||
// the latest values through refs, so it lives exactly as long as its document.
|
||||
const latest = useRef({ callTool, toolInput, toolResult });
|
||||
latest.current = { callTool, toolInput, toolResult };
|
||||
// A different document is a different frame: remount the iframe with a new host.
|
||||
const documentVersion = useRef({ srcDoc, version: 0 });
|
||||
if (documentVersion.current.srcDoc !== srcDoc) {
|
||||
documentVersion.current = { srcDoc, version: documentVersion.current.version + 1 };
|
||||
}
|
||||
const frameKey = `${generation}:${documentVersion.current.version}`;
|
||||
|
||||
// Layout effect: the listener must exist before the view's first script posts `ui/initialize`.
|
||||
useLayoutEffect(() => {
|
||||
const iframe = iframeRef.current;
|
||||
if (!iframe) return;
|
||||
const hostContext = (): McpAppHostContext => ({
|
||||
theme: resolvedTheme(),
|
||||
displayMode: "inline",
|
||||
availableDisplayModes: ["inline"],
|
||||
containerDimensions: { maxHeight: MAX_HEIGHT, ...(iframe.clientWidth ? { width: iframe.clientWidth } : {}) },
|
||||
locale: navigator.language,
|
||||
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
platform: "web",
|
||||
userAgent: "Paperclip",
|
||||
toolInfo: { id: viewId, tool: { name: toolName, inputSchema: { type: "object" } } },
|
||||
styles: { variables: hostStyleVariables() },
|
||||
});
|
||||
const host = createMcpAppHost({
|
||||
// The view's origin is opaque ("null"), so target "*"; the message only
|
||||
// ever goes to this iframe's own window.
|
||||
post: (message) => iframe.contentWindow?.postMessage(message, "*"),
|
||||
hostContext,
|
||||
get toolInput() { return latest.current.toolInput; },
|
||||
get toolResult() { return latest.current.toolResult; },
|
||||
callTool: (name, args) => latest.current.callTool(name, args),
|
||||
openLink: (url) => window.open(url, "_blank", "noopener,noreferrer"),
|
||||
onSizeChanged: ({ height: next }) => {
|
||||
if (typeof next === "number" && Number.isFinite(next) && next > 0) {
|
||||
setHeight(Math.min(MAX_HEIGHT, Math.ceil(next)));
|
||||
}
|
||||
},
|
||||
});
|
||||
let loads = 0;
|
||||
let navigatedAway = false;
|
||||
const onLoad = () => {
|
||||
loads += 1;
|
||||
if (loads > 1 && !navigatedAway) {
|
||||
navigatedAway = true;
|
||||
host.teardown("The view left its document");
|
||||
setGeneration((value) => value + 1);
|
||||
}
|
||||
};
|
||||
iframe.addEventListener("load", onLoad);
|
||||
const onMessage = (event: MessageEvent) => {
|
||||
if (navigatedAway || event.source !== iframe.contentWindow) return;
|
||||
host.receive(event.data);
|
||||
};
|
||||
window.addEventListener("message", onMessage);
|
||||
const themeObserver = new MutationObserver(() => host.hostContextChanged({ theme: resolvedTheme(), styles: { variables: hostStyleVariables() } }));
|
||||
themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
|
||||
return () => {
|
||||
themeObserver.disconnect();
|
||||
iframe.removeEventListener("load", onLoad);
|
||||
host.teardown();
|
||||
window.removeEventListener("message", onMessage);
|
||||
};
|
||||
// srcDoc is captured by frameKey; tool input and result are read through `latest`.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [frameKey, viewId, toolName]);
|
||||
|
||||
return (
|
||||
<iframe
|
||||
key={frameKey}
|
||||
ref={iframeRef}
|
||||
title={title}
|
||||
srcDoc={srcDoc}
|
||||
// Never add allow-same-origin: the opaque origin is the boundary between
|
||||
// the provider's view and Paperclip's session. No popups either: links
|
||||
// go through `ui/open-link`, which the host opens with noopener.
|
||||
sandbox="allow-scripts"
|
||||
referrerPolicy="no-referrer"
|
||||
allow="camera 'none'; microphone 'none'; geolocation 'none'; clipboard-read 'none'; clipboard-write 'none'; fullscreen 'none'"
|
||||
data-testid="mcp-app-frame"
|
||||
style={{ height }}
|
||||
className={cn("block w-full border-0 bg-transparent", className)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// @vitest-environment jsdom
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { act, type ReactNode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { McpAppViewSummary } from "@paperclipai/shared";
|
||||
|
||||
const list = vi.fn<(issueId: string) => Promise<McpAppViewSummary[]>>();
|
||||
vi.mock("@/api/mcpApps", () => ({ mcpAppsApi: { list: (issueId: string) => list(issueId) } }));
|
||||
|
||||
const { McpAppIssueProvider, useMcpAppViewsForRun } = await import("./McpAppIssueContext");
|
||||
|
||||
function view(id: string, runId: string): McpAppViewSummary {
|
||||
return {
|
||||
id, issueId: "issue-1", runId, connectionId: "conn-1", applicationName: "Circleback",
|
||||
toolName: "mcp.circleback:displaymeetings", upstreamToolName: "DisplayMeetings",
|
||||
resourceUri: "ui://circleback/meetings", toolInput: {}, createdAt: "2026-11-12T00:00:00.000Z",
|
||||
};
|
||||
}
|
||||
|
||||
function wrapper(client: QueryClient) {
|
||||
return ({ children }: { children: ReactNode }) => (
|
||||
<QueryClientProvider client={client}>
|
||||
<McpAppIssueProvider issueId="issue-1">{children}</McpAppIssueProvider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
||||
|
||||
async function renderHook<P, R>(hook: (props: P) => R, options: { wrapper: (props: { children: ReactNode }) => ReactNode; initialProps?: P }) {
|
||||
const result = { current: undefined as unknown as R };
|
||||
const container = document.createElement("div");
|
||||
const root = createRoot(container);
|
||||
const Wrapper = options.wrapper;
|
||||
function Probe({ props }: { props: P }) {
|
||||
result.current = hook(props);
|
||||
return null;
|
||||
}
|
||||
const render = (props: P) => act(() => root.render(<Wrapper><Probe props={props} /></Wrapper>));
|
||||
await render(options.initialProps as P);
|
||||
return { result, rerender: (props: P) => render(props), unmount: () => act(() => root.unmount()) };
|
||||
}
|
||||
|
||||
async function waitFor(check: () => void, timeoutMs = 2000) {
|
||||
const started = Date.now();
|
||||
for (;;) {
|
||||
try {
|
||||
check();
|
||||
return;
|
||||
} catch (error) {
|
||||
if (Date.now() - started > timeoutMs) throw error;
|
||||
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 10)); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(() => list.mockReset());
|
||||
|
||||
describe("useMcpAppViewsForRun", () => {
|
||||
it("refreshes the task's list once when a live run completes another MCP tool call", async () => {
|
||||
list.mockResolvedValueOnce([]).mockResolvedValueOnce([view("v1", "run-1")]);
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
const { result, rerender } = await renderHook(
|
||||
({ refreshKey }: { refreshKey: string }) => useMcpAppViewsForRun("run-1", { refreshKey }),
|
||||
{ wrapper: wrapper(client), initialProps: { refreshKey: "0:running" } },
|
||||
);
|
||||
await waitFor(() => expect(list).toHaveBeenCalledTimes(1));
|
||||
expect(result.current.views).toEqual([]);
|
||||
await rerender({ refreshKey: "1:running" });
|
||||
await waitFor(() => expect(list).toHaveBeenCalledTimes(2));
|
||||
await waitFor(() => expect(result.current.views.map((v) => v.id)).toEqual(["v1"]));
|
||||
await rerender({ refreshKey: "1:running" });
|
||||
expect(list).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("refreshes once for a settled reply newer than the loaded list", async () => {
|
||||
list.mockResolvedValueOnce([]).mockResolvedValue([view("v1", "run-1")]);
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
const { result } = await renderHook(
|
||||
() => useMcpAppViewsForRun("run-1", { notBeforeMs: Date.now() + 60_000 }),
|
||||
{ wrapper: wrapper(client) },
|
||||
);
|
||||
await waitFor(() => expect(result.current.views.map((v) => v.id)).toEqual(["v1"]));
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
expect(list).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("does not refresh for a reply older than the loaded list", async () => {
|
||||
list.mockResolvedValue([view("v1", "run-1")]);
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
const { result } = await renderHook(
|
||||
() => useMcpAppViewsForRun("run-1", { notBeforeMs: Date.now() - 60_000 }),
|
||||
{ wrapper: wrapper(client) },
|
||||
);
|
||||
await waitFor(() => expect(result.current.views).toHaveLength(1));
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
expect(list).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import { createContext, useContext, useEffect, useRef, type ReactNode } from "react";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { McpAppViewSummary } from "@paperclipai/shared";
|
||||
import { mcpAppsApi } from "@/api/mcpApps";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { mcpAppViewIndexFor } from "./mcp-app-matching";
|
||||
|
||||
/** The task whose chat is showing, so a run's replies can find their MCP Apps views. */
|
||||
const McpAppIssueContext = createContext<string | null>(null);
|
||||
|
||||
export function McpAppIssueProvider({ issueId, children }: { issueId: string | null | undefined; children: ReactNode }) {
|
||||
return <McpAppIssueContext.Provider value={issueId ?? null}>{children}</McpAppIssueContext.Provider>;
|
||||
}
|
||||
|
||||
export function useMcpAppIssueId(): string | null {
|
||||
return useContext(McpAppIssueContext);
|
||||
}
|
||||
|
||||
const NO_VIEWS: McpAppViewSummary[] = [];
|
||||
|
||||
export interface McpAppViewsFreshness {
|
||||
/**
|
||||
* Changes when the run may have recorded a new view: for a live run, the
|
||||
* count of its completed MCP tool calls and its status. A change refreshes
|
||||
* the task's list once.
|
||||
*/
|
||||
refreshKey?: string;
|
||||
/** The reply's time (ms). A list loaded before it may miss the run's views, so it is refreshed once. */
|
||||
notBeforeMs?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The views a run recorded. A task's views load in one request, shared by
|
||||
* every reply of the task, and the list is indexed once by run.
|
||||
*/
|
||||
export function useMcpAppViewsForRun(runId: string | null | undefined, freshness: McpAppViewsFreshness = {}): {
|
||||
issueId: string | null;
|
||||
views: McpAppViewSummary[];
|
||||
} {
|
||||
const issueId = useMcpAppIssueId();
|
||||
const queryClient = useQueryClient();
|
||||
const enabled = Boolean(issueId && runId);
|
||||
const queryKey = queryKeys.mcpApps.views(issueId ?? "");
|
||||
const { data, dataUpdatedAt, isFetching } = useQuery({
|
||||
queryKey,
|
||||
queryFn: () => mcpAppsApi.list(issueId!),
|
||||
enabled,
|
||||
staleTime: 30_000,
|
||||
});
|
||||
|
||||
// A run's new tool call can record a view after the list loaded.
|
||||
const lastRefreshKey = useRef(freshness.refreshKey);
|
||||
useEffect(() => {
|
||||
if (!enabled || freshness.refreshKey === undefined || freshness.refreshKey === lastRefreshKey.current) return;
|
||||
lastRefreshKey.current = freshness.refreshKey;
|
||||
void queryClient.invalidateQueries({ queryKey, exact: true });
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- queryKey is derived from issueId
|
||||
}, [enabled, freshness.refreshKey, issueId, queryClient]);
|
||||
|
||||
// A settled reply newer than the loaded list: look once more.
|
||||
const refreshedForReply = useRef(false);
|
||||
const notBeforeMs = freshness.notBeforeMs;
|
||||
useEffect(() => {
|
||||
if (!enabled || refreshedForReply.current || !data || isFetching) return;
|
||||
if (notBeforeMs === undefined || !Number.isFinite(notBeforeMs) || dataUpdatedAt >= notBeforeMs) return;
|
||||
refreshedForReply.current = true;
|
||||
void queryClient.invalidateQueries({ queryKey, exact: true });
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- queryKey is derived from issueId
|
||||
}, [enabled, data, dataUpdatedAt, isFetching, notBeforeMs, issueId, queryClient]);
|
||||
|
||||
const views = enabled && data ? mcpAppViewIndexFor(data).forRun(runId!) : NO_VIEWS;
|
||||
return { issueId, views };
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// @vitest-environment jsdom
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { act } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { McpAppViewSummary } from "@paperclipai/shared";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
|
||||
const detail = vi.fn(() => new Promise(() => undefined));
|
||||
vi.mock("@/api/mcpApps", () => ({ mcpAppsApi: { list: vi.fn(), detail: (...args: unknown[]) => detail(...(args as [])), callTool: vi.fn() } }));
|
||||
|
||||
const { McpAppIssueProvider } = await import("./McpAppIssueContext");
|
||||
const { McpAppTurnViews } = await import("./McpAppTurnViews");
|
||||
|
||||
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
||||
|
||||
function views(count: number): McpAppViewSummary[] {
|
||||
return Array.from({ length: count }, (_, index) => ({
|
||||
id: `00000000-0000-4000-8000-00000000000${index}`, issueId: "issue-1", runId: "run-1", connectionId: "conn-1",
|
||||
applicationName: "Circleback", toolName: "mcp.circleback:displaymeetings", upstreamToolName: "DisplayMeetings",
|
||||
resourceUri: "ui://circleback/meetings", toolInput: {}, createdAt: "2026-11-12T00:00:00.000Z",
|
||||
}));
|
||||
}
|
||||
|
||||
let observers: Array<{ callback: IntersectionObserverCallback; targets: Element[] }> = [];
|
||||
class FakeIntersectionObserver {
|
||||
targets: Element[] = [];
|
||||
constructor(public callback: IntersectionObserverCallback) { observers.push(this); }
|
||||
observe(target: Element) { this.targets.push(target); }
|
||||
disconnect() { this.targets = []; }
|
||||
unobserve() {}
|
||||
takeRecords() { return []; }
|
||||
}
|
||||
|
||||
async function render(count: number) {
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
client.setQueryData(queryKeys.mcpApps.views("issue-1"), views(count));
|
||||
const container = document.createElement("div");
|
||||
const root = createRoot(container);
|
||||
await act(async () => root.render(
|
||||
<QueryClientProvider client={client}>
|
||||
<McpAppIssueProvider issueId="issue-1"><McpAppTurnViews runId="run-1" /></McpAppIssueProvider>
|
||||
</QueryClientProvider>,
|
||||
));
|
||||
return { container, root };
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
observers = [];
|
||||
detail.mockClear();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
describe("McpAppTurnViews", () => {
|
||||
it("loads a view's document only when it nears the viewport", async () => {
|
||||
vi.stubGlobal("IntersectionObserver", FakeIntersectionObserver);
|
||||
vi.stubGlobal("navigation", { addEventListener: () => undefined });
|
||||
const { container, root } = await render(2);
|
||||
expect(container.querySelectorAll("[data-testid=mcp-app-view-placeholder]")).toHaveLength(2);
|
||||
expect(detail).not.toHaveBeenCalled();
|
||||
const first = observers[0]!;
|
||||
await act(async () => first.callback([{ isIntersecting: true, target: first.targets[0]! } as IntersectionObserverEntry], first as unknown as IntersectionObserver));
|
||||
expect(detail).toHaveBeenCalledTimes(1);
|
||||
expect(container.querySelectorAll("[data-testid=mcp-app-view-placeholder]")).toHaveLength(1);
|
||||
await act(async () => root.unmount());
|
||||
});
|
||||
|
||||
it("shows five views per run and the rest on request", async () => {
|
||||
vi.stubGlobal("IntersectionObserver", FakeIntersectionObserver);
|
||||
const { container, root } = await render(7);
|
||||
expect(container.querySelectorAll("[data-testid=mcp-app-turn-view]")).toHaveLength(5);
|
||||
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(detail).not.toHaveBeenCalled();
|
||||
await act(async () => root.unmount());
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,98 @@
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import type { McpAppViewSummary } from "@paperclipai/shared";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useMcpAppIssueId, useMcpAppViewsForRun, type McpAppViewsFreshness } from "./McpAppIssueContext";
|
||||
import { McpAppView } from "./McpAppView";
|
||||
|
||||
/** "DisplayMeetings" → "Display meetings". */
|
||||
export function mcpAppToolDisplayName(toolName: string): string {
|
||||
const words = toolName.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim().toLowerCase();
|
||||
return words ? words[0]!.toUpperCase() + words.slice(1) : toolName;
|
||||
}
|
||||
|
||||
function McpAppRunView({ issueId, view }: { issueId: string; view: McpAppViewSummary }) {
|
||||
const displayName = mcpAppToolDisplayName(view.upstreamToolName);
|
||||
return (
|
||||
<section data-testid="mcp-app-turn-view" aria-label={`${view.applicationName}: ${displayName}`} className="flex min-w-0 flex-col gap-2">
|
||||
<div className="flex min-w-0 items-baseline gap-2 text-xs">
|
||||
<span className="text-muted-foreground">Widget from {view.applicationName}</span>
|
||||
<span className="truncate font-medium text-foreground">{displayName}</span>
|
||||
</div>
|
||||
<NearViewport placeholderLabel={`${view.applicationName}: ${displayName}`}>
|
||||
<McpAppView issueId={issueId} view={view} displayName={displayName} />
|
||||
</NearViewport>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
/** Views start loading this far before they scroll into view. */
|
||||
const NEAR_VIEWPORT_MARGIN = "600px";
|
||||
/** Views shown per run before "Show N more". */
|
||||
export const MCP_APP_VIEWS_PER_RUN = 5;
|
||||
|
||||
/**
|
||||
* Mounts its children (and so fetches the view document, up to 4 MB, and starts
|
||||
* its iframe) only once the placeholder nears the viewport. A long chat with
|
||||
* many recorded views pays only for the ones the reader reaches.
|
||||
*/
|
||||
function NearViewport({ children, placeholderLabel }: { children: ReactNode; placeholderLabel: string }) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const [near, setNear] = useState(() => typeof IntersectionObserver === "undefined");
|
||||
useEffect(() => {
|
||||
if (near || !ref.current) return;
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
if (entries.some((entry) => entry.isIntersecting)) setNear(true);
|
||||
}, { rootMargin: NEAR_VIEWPORT_MARGIN });
|
||||
observer.observe(ref.current);
|
||||
return () => observer.disconnect();
|
||||
}, [near]);
|
||||
if (near) return <>{children}</>;
|
||||
return <div ref={ref} role="status" aria-label={`${placeholderLabel} (not loaded yet)`} data-testid="mcp-app-view-placeholder" className="h-24 rounded-lg border border-border bg-muted/30" />;
|
||||
}
|
||||
|
||||
/**
|
||||
* A run's MCP Apps views, shown with the agent's reply rather than inside the
|
||||
* folded tool history, as other MCP Apps hosts do. Keyed by run, so settled
|
||||
* history needs no transcript to show them.
|
||||
*/
|
||||
export function McpAppTurnViews({ runId, ...freshness }: { runId: string | null | undefined } & McpAppViewsFreshness) {
|
||||
// Outside a task chat (or before a run exists) there is nothing to load.
|
||||
const issueId = useMcpAppIssueId();
|
||||
return issueId && runId ? <RunViews runId={runId} {...freshness} /> : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh key for a live run: its completed MCP tool calls and its status.
|
||||
* Tool rows may be nested in activity phases.
|
||||
*/
|
||||
export function mcpAppRunRefreshKey(items: readonly unknown[], status?: string | null): string {
|
||||
let completed = 0;
|
||||
const visit = (list: readonly unknown[]) => {
|
||||
for (const entry of list) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
const item = entry as { kind?: string; status?: string; rawName?: string; name?: string; items?: unknown };
|
||||
if (item.kind === "tool" && item.status === "completed" && /mcp/i.test(item.rawName ?? item.name ?? "")) completed += 1;
|
||||
else if (Array.isArray(item.items)) visit(item.items);
|
||||
}
|
||||
};
|
||||
visit(items);
|
||||
return `${completed}:${status ?? ""}`;
|
||||
}
|
||||
|
||||
function RunViews({ runId, ...freshness }: { runId: string } & McpAppViewsFreshness) {
|
||||
const { issueId, views } = useMcpAppViewsForRun(runId, freshness);
|
||||
const [showAll, setShowAll] = useState(false);
|
||||
if (!issueId || views.length === 0) return null;
|
||||
const shown = showAll ? views : views.slice(0, MCP_APP_VIEWS_PER_RUN);
|
||||
const hidden = views.length - shown.length;
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col gap-6 py-4" data-testid="mcp-app-turn-views">
|
||||
{shown.map((view) => <McpAppRunView key={view.id} issueId={issueId} view={view} />)}
|
||||
{hidden > 0 ? (
|
||||
<Button type="button" variant="ghost" size="sm" className="self-start" onClick={() => setShowAll(true)}>
|
||||
Show {hidden} more
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// @vitest-environment jsdom
|
||||
import { act } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { McpAppViewDetail } from "@paperclipai/shared";
|
||||
import { McpAppViewContent } from "./McpAppView";
|
||||
import { mcpAppNavigationGuardSupported } from "./mcp-app-host";
|
||||
|
||||
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
||||
|
||||
const detail: McpAppViewDetail = {
|
||||
id: "view-1", issueId: "issue-1", runId: "run-1", connectionId: "conn-1", applicationName: "Circleback",
|
||||
toolName: "mcp.circleback:displaymeetings", upstreamToolName: "DisplayMeetings", resourceUri: "ui://circleback/meetings",
|
||||
toolInput: {}, createdAt: "2026-11-12T00:00:00.000Z",
|
||||
toolResult: { content: [] },
|
||||
resource: { uri: "ui://circleback/meetings", html: "<p>cards</p>", csp: {}, permissions: {}, prefersBorder: true },
|
||||
};
|
||||
|
||||
async function render() {
|
||||
const container = document.createElement("div");
|
||||
const root = createRoot(container);
|
||||
await act(async () => root.render(
|
||||
<McpAppViewContent detail={detail} status="ready" callTool={async () => ({ content: [] })} displayName="Display meetings" />,
|
||||
));
|
||||
return { container, root };
|
||||
}
|
||||
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
describe("McpAppViewContent", () => {
|
||||
it("does not mount a view where the navigation guard cannot work", async () => {
|
||||
expect(mcpAppNavigationGuardSupported()).toBe(false);
|
||||
const { container, root } = await render();
|
||||
expect(container.querySelector("iframe")).toBeNull();
|
||||
expect(container.textContent).toContain("This browser can't show this app's widget safely.");
|
||||
await act(async () => root.unmount());
|
||||
});
|
||||
|
||||
it("mounts the view where the Navigation API is available", async () => {
|
||||
vi.stubGlobal("navigation", { addEventListener: () => undefined });
|
||||
const { container, root } = await render();
|
||||
expect(container.querySelector("iframe")).not.toBeNull();
|
||||
await act(async () => root.unmount());
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
import { useCallback } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import type { McpAppCallToolResult, McpAppViewDetail, McpAppViewSummary } from "@paperclipai/shared";
|
||||
import { mcpAppsApi } from "@/api/mcpApps";
|
||||
import { ApiError } from "@/api/client";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { McpAppFrame } from "./McpAppFrame";
|
||||
import { mcpAppNavigationGuardSupported } from "./mcp-app-host";
|
||||
|
||||
const UNSUPPORTED_BROWSER_MESSAGE = "This browser can't show this app's widget safely. The tool result is still in the activity.";
|
||||
|
||||
export interface McpAppViewContentProps {
|
||||
detail: McpAppViewDetail | undefined;
|
||||
status: "loading" | "error" | "ready";
|
||||
errorMessage?: string | null;
|
||||
callTool: (name: string, args: Record<string, unknown>) => Promise<McpAppCallToolResult>;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
/** Presentational shell, shared by the live view and its stories. */
|
||||
export function McpAppViewContent({ detail, status, errorMessage, callTool, displayName }: McpAppViewContentProps) {
|
||||
const unsupported = !mcpAppNavigationGuardSupported();
|
||||
if (status === "error" || unsupported) {
|
||||
return (
|
||||
<div role="status" data-testid="mcp-app-view-error" className="ml-1.5 mt-0.5 border-l-2 border-border py-1 pl-2.5 text-(length:--text-micro) text-muted-foreground">
|
||||
{unsupported ? UNSUPPORTED_BROWSER_MESSAGE : errorMessage ?? "This app's view could not be shown."}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div
|
||||
data-testid="mcp-app-view"
|
||||
className={cn(
|
||||
"min-w-0 max-w-full overflow-hidden",
|
||||
detail?.resource.prefersBorder !== false && "rounded-lg border border-border bg-card p-3",
|
||||
)}
|
||||
>
|
||||
{status === "loading" || !detail ? (
|
||||
<div role="status" aria-label={`Loading ${detail?.applicationName ?? "app"} view`} className="h-24 animate-pulse bg-muted/40" />
|
||||
) : (
|
||||
<McpAppFrame
|
||||
title={`${detail.applicationName}: ${displayName}`}
|
||||
viewId={detail.id}
|
||||
toolName={detail.upstreamToolName}
|
||||
resource={detail.resource}
|
||||
toolInput={detail.toolInput}
|
||||
toolResult={detail.toolResult}
|
||||
callTool={callTool}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function viewErrorMessage(error: unknown, applicationName: string): string {
|
||||
if (error instanceof ApiError && error.status === 404) return `This ${applicationName} view is no longer available.`;
|
||||
return `${applicationName} could not show this view. The tool result is still in the row above.`;
|
||||
}
|
||||
|
||||
/** Loads a recorded view and renders it under its tool row. */
|
||||
export function McpAppView({ issueId, view, displayName }: { issueId: string; view: McpAppViewSummary; displayName: string }) {
|
||||
const query = useQuery({
|
||||
queryKey: queryKeys.mcpApps.detail(issueId, view.id),
|
||||
queryFn: ({ signal }) => mcpAppsApi.detail(issueId, view.id, signal),
|
||||
// No document download where the view cannot be shown safely.
|
||||
enabled: mcpAppNavigationGuardSupported(),
|
||||
staleTime: 5 * 60_000,
|
||||
retry: 1,
|
||||
});
|
||||
const callTool = useCallback(
|
||||
(name: string, args: Record<string, unknown>) => mcpAppsApi.callTool(issueId, view.id, name, args),
|
||||
[issueId, view.id],
|
||||
);
|
||||
return (
|
||||
<McpAppViewContent
|
||||
detail={query.data}
|
||||
status={query.data ? "ready" : query.error ? "error" : "loading"}
|
||||
errorMessage={!query.data && query.error ? viewErrorMessage(query.error, view.applicationName) : null}
|
||||
callTool={callTool}
|
||||
displayName={displayName}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createMcpAppHost, MCP_APP_NAVIGATION_GUARD, mcpAppDocument, safeExternalUrl, type McpAppHostContext } from "./mcp-app-host";
|
||||
|
||||
const hostContext: McpAppHostContext = {
|
||||
theme: "dark",
|
||||
displayMode: "inline",
|
||||
availableDisplayModes: ["inline"],
|
||||
containerDimensions: { maxHeight: 640 },
|
||||
locale: "en-US",
|
||||
timeZone: "UTC",
|
||||
platform: "web",
|
||||
toolInfo: { id: "view-1", tool: { name: "DisplayMeetings", inputSchema: { type: "object" } } },
|
||||
};
|
||||
|
||||
function setup(overrides: Partial<Parameters<typeof createMcpAppHost>[0]> = {}) {
|
||||
const posted: any[] = [];
|
||||
const options = {
|
||||
post: (message: unknown) => posted.push(message),
|
||||
hostContext: () => hostContext,
|
||||
toolInput: { meetingIds: ["m1"] },
|
||||
toolResult: { content: [{ type: "text", text: "ok" }], structuredContent: { meetings: [{ id: "m1" }] } },
|
||||
callTool: vi.fn(async () => ({ content: [{ type: "text", text: "called" }] })),
|
||||
openLink: vi.fn(),
|
||||
onSizeChanged: vi.fn(),
|
||||
...overrides,
|
||||
};
|
||||
return { host: createMcpAppHost(options), posted, options };
|
||||
}
|
||||
|
||||
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
describe("createMcpAppHost", () => {
|
||||
it("answers ui/initialize with the host context and sends nothing before initialized", async () => {
|
||||
const { host, posted } = setup();
|
||||
host.receive({ jsonrpc: "2.0", id: 1, method: "ui/initialize", params: { protocolVersion: "2026-01-26" } });
|
||||
await flush();
|
||||
expect(posted).toHaveLength(1);
|
||||
expect(posted[0]).toMatchObject({ id: 1, result: { protocolVersion: "2026-01-26", hostInfo: { name: "Paperclip" }, hostContext: { theme: "dark" } } });
|
||||
host.hostContextChanged({ theme: "light" });
|
||||
expect(posted).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("sends tool-input then tool-result once the view is initialized", () => {
|
||||
const { host, posted } = setup();
|
||||
host.receive({ jsonrpc: "2.0", method: "ui/notifications/initialized" });
|
||||
host.receive({ jsonrpc: "2.0", method: "ui/notifications/initialized" });
|
||||
expect(posted.map((message) => message.method)).toEqual(["ui/notifications/tool-input", "ui/notifications/tool-result"]);
|
||||
expect(posted[0].params).toEqual({ arguments: { meetingIds: ["m1"] } });
|
||||
expect(posted[1].params.structuredContent).toEqual({ meetings: [{ id: "m1" }] });
|
||||
});
|
||||
|
||||
it("proxies tools/call and reports failures as JSON-RPC errors", async () => {
|
||||
const callTool = vi.fn()
|
||||
.mockResolvedValueOnce({ content: [{ type: "text", text: "called" }] })
|
||||
.mockRejectedValueOnce(new Error("denied"));
|
||||
const { host, posted } = setup({ callTool });
|
||||
host.receive({ jsonrpc: "2.0", id: "init", method: "ui/initialize", params: {} });
|
||||
host.receive({ jsonrpc: "2.0", id: "a", method: "tools/call", params: { name: "ReadMeetings", arguments: { ids: ["m1"] } } });
|
||||
host.receive({ jsonrpc: "2.0", id: "b", method: "tools/call", params: { name: "DeleteTag" } });
|
||||
await flush();
|
||||
expect(callTool).toHaveBeenCalledWith("ReadMeetings", { ids: ["m1"] });
|
||||
expect(posted.find((message) => message.id === "a")).toMatchObject({ result: { content: [{ text: "called" }] } });
|
||||
expect(posted.find((message) => message.id === "b")).toMatchObject({ error: { code: -32000, message: "denied" } });
|
||||
});
|
||||
|
||||
it("opens only http(s) links and rejects unknown methods", async () => {
|
||||
const { host, posted, options } = setup();
|
||||
host.receive({ jsonrpc: "2.0", id: 0, method: "ui/initialize", params: {} });
|
||||
host.receive({ jsonrpc: "2.0", id: 1, method: "ui/open-link", params: { url: "https://app.circleback.ai/meetings/m1" } });
|
||||
host.receive({ jsonrpc: "2.0", id: 2, method: "ui/open-link", params: { url: "javascript:alert(1)" } });
|
||||
host.receive({ jsonrpc: "2.0", id: 3, method: "ui/message", params: { role: "user", content: { type: "text", text: "hi" } } });
|
||||
await flush();
|
||||
expect(options.openLink).toHaveBeenCalledTimes(1);
|
||||
expect(options.openLink).toHaveBeenCalledWith("https://app.circleback.ai/meetings/m1");
|
||||
expect(posted.find((message) => message.id === 2)).toMatchObject({ error: { code: -32000 } });
|
||||
expect(posted.find((message) => message.id === 3)).toMatchObject({ error: { code: -32601 } });
|
||||
});
|
||||
|
||||
it("refuses tool calls and links before the view's ui/initialize", async () => {
|
||||
const callTool = vi.fn(async () => ({ content: [] }));
|
||||
const { host, posted, options } = setup({ callTool });
|
||||
host.receive({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "DeleteTag", arguments: {} } });
|
||||
host.receive({ jsonrpc: "2.0", id: 2, method: "ui/open-link", params: { url: "https://evil.example" } });
|
||||
host.receive({ jsonrpc: "2.0", id: 3, method: "ping" });
|
||||
await flush();
|
||||
expect(callTool).not.toHaveBeenCalled();
|
||||
expect(options.openLink).not.toHaveBeenCalled();
|
||||
expect(posted.find((message) => message.id === 1)).toMatchObject({ error: { code: -32000 } });
|
||||
expect(posted.find((message) => message.id === 2)).toMatchObject({ error: { code: -32000 } });
|
||||
expect(posted.find((message) => message.id === 3)).toMatchObject({ result: {} });
|
||||
});
|
||||
|
||||
it("reports size changes, ignores malformed messages and stops after teardown", () => {
|
||||
const { host, posted, options } = setup();
|
||||
host.receive({ method: "ui/notifications/size-changed", params: { height: 200 } });
|
||||
host.receive("not json-rpc");
|
||||
expect(options.onSizeChanged).not.toHaveBeenCalled();
|
||||
host.receive({ jsonrpc: "2.0", method: "ui/notifications/size-changed", params: { height: 200 } });
|
||||
expect(options.onSizeChanged).toHaveBeenCalledWith({ height: 200, width: undefined });
|
||||
host.receive({ jsonrpc: "2.0", method: "ui/notifications/initialized" });
|
||||
host.teardown();
|
||||
expect(posted.at(-1)).toMatchObject({ method: "ui/resource-teardown" });
|
||||
const count = posted.length;
|
||||
host.receive({ jsonrpc: "2.0", id: 9, method: "ping" });
|
||||
expect(posted).toHaveLength(count);
|
||||
});
|
||||
});
|
||||
|
||||
describe("mcpAppDocument", () => {
|
||||
it("installs the CSP before the view's markup and keeps one doctype", () => {
|
||||
const doc = mcpAppDocument("<!DOCTYPE html><html><head><script>1</script></head></html>", { connectDomains: ["https://api.circleback.ai"] });
|
||||
expect(doc.startsWith("<!doctype html><meta http-equiv=\"Content-Security-Policy\"")).toBe(true);
|
||||
expect(doc.indexOf("Content-Security-Policy")).toBeLessThan(doc.indexOf("<script>"));
|
||||
expect(doc.match(/<!doctype/gi)).toHaveLength(1);
|
||||
expect(doc).toContain("connect-src https://api.circleback.ai");
|
||||
});
|
||||
|
||||
it("runs the navigation guard before any of the view's scripts", () => {
|
||||
const doc = mcpAppDocument("<html><head><script>window.viewStarted = true</script></head></html>", {});
|
||||
expect(doc.indexOf(MCP_APP_NAVIGATION_GUARD)).toBeGreaterThan(doc.indexOf("Content-Security-Policy"));
|
||||
expect(doc.indexOf(MCP_APP_NAVIGATION_GUARD)).toBeLessThan(doc.indexOf("window.viewStarted"));
|
||||
});
|
||||
|
||||
it("routes links of any target and window.open through ui/open-link", () => {
|
||||
const posted: unknown[] = [];
|
||||
const parentWindow = { postMessage: (message: unknown) => posted.push(message) };
|
||||
const anchors: Array<{ href: string; attrs: Record<string, string> }> = [
|
||||
{ href: "https://app.circleback.ai/meetings/m1", attrs: { href: "https://app.circleback.ai/meetings/m1", target: "_blank" } },
|
||||
{ href: "https://app.circleback.ai/meetings/m2", attrs: { href: "https://app.circleback.ai/meetings/m2" } },
|
||||
{ href: "about:srcdoc#top", attrs: { href: "#top" } },
|
||||
{ href: "javascript:alert(1)", attrs: { href: "javascript:alert(1)" } },
|
||||
];
|
||||
let clickHandler: ((event: unknown) => void) | null = null;
|
||||
const fakeWindow: Record<string, unknown> = { open: () => "real window" };
|
||||
const fakeDocument = {
|
||||
baseURI: "about:srcdoc",
|
||||
addEventListener: (type: string, handler: (event: unknown) => void) => { if (type === "click") clickHandler = handler; },
|
||||
};
|
||||
new Function("window", "document", "parent", MCP_APP_NAVIGATION_GUARD)(fakeWindow, fakeDocument, parentWindow);
|
||||
const prevented: boolean[] = [];
|
||||
for (const anchor of anchors) {
|
||||
let defaultPrevented = false;
|
||||
clickHandler!({
|
||||
defaultPrevented: false,
|
||||
preventDefault: () => { defaultPrevented = true; },
|
||||
target: { closest: () => ({ href: anchor.href, getAttribute: (name: string) => anchor.attrs[name] ?? null }) },
|
||||
});
|
||||
prevented.push(defaultPrevented);
|
||||
}
|
||||
expect((fakeWindow.open as (url: string) => unknown)("https://circleback.ai/meetings/m3")).toBeNull();
|
||||
expect(prevented).toEqual([true, true, false, true]);
|
||||
expect(posted.map((message) => (message as { params: { url: string } }).params.url)).toEqual([
|
||||
"https://app.circleback.ai/meetings/m1",
|
||||
"https://app.circleback.ai/meetings/m2",
|
||||
"https://circleback.ai/meetings/m3",
|
||||
]);
|
||||
});
|
||||
|
||||
it("allows only http(s) external urls", () => {
|
||||
expect(safeExternalUrl("https://circleback.ai")).toBe("https://circleback.ai/");
|
||||
expect(safeExternalUrl("data:text/html,x")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,241 @@
|
||||
import {
|
||||
buildMcpAppCsp,
|
||||
MCP_APPS_PROTOCOL_VERSION,
|
||||
type McpAppCallToolResult,
|
||||
type McpAppResourceCsp,
|
||||
} from "@paperclipai/shared";
|
||||
|
||||
/**
|
||||
* Host side of the MCP Apps postMessage protocol (spec 2026-01-26). Pure and
|
||||
* transport-agnostic: the iframe component feeds it messages from the view and
|
||||
* it answers through `post`.
|
||||
*/
|
||||
|
||||
export interface McpAppHostContext {
|
||||
theme: "light" | "dark";
|
||||
displayMode: "inline";
|
||||
availableDisplayModes: ["inline"];
|
||||
containerDimensions: { maxHeight: number; width?: number };
|
||||
locale: string;
|
||||
timeZone: string;
|
||||
platform: "web";
|
||||
userAgent?: string;
|
||||
toolInfo: { id: string; tool: { name: string; inputSchema: Record<string, unknown> } };
|
||||
styles?: { variables: Record<string, string> };
|
||||
}
|
||||
|
||||
export interface McpAppHostOptions {
|
||||
post: (message: unknown) => void;
|
||||
hostContext: () => McpAppHostContext;
|
||||
toolInput: Record<string, unknown>;
|
||||
toolResult: McpAppCallToolResult;
|
||||
callTool: (name: string, args: Record<string, unknown>) => Promise<McpAppCallToolResult>;
|
||||
openLink: (url: string) => void;
|
||||
onSizeChanged: (size: { width?: number; height?: number }) => void;
|
||||
onLog?: (entry: unknown) => void;
|
||||
}
|
||||
|
||||
type JsonRpcId = string | number;
|
||||
interface JsonRpcMessage {
|
||||
jsonrpc: "2.0";
|
||||
id?: JsonRpcId;
|
||||
method?: string;
|
||||
params?: unknown;
|
||||
result?: unknown;
|
||||
error?: unknown;
|
||||
}
|
||||
|
||||
const METHOD_NOT_FOUND = -32601;
|
||||
const INVALID_PARAMS = -32602;
|
||||
const SERVER_ERROR = -32000;
|
||||
|
||||
function record(value: unknown): Record<string, unknown> | null {
|
||||
return value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : null;
|
||||
}
|
||||
|
||||
export function isJsonRpcMessage(value: unknown): value is JsonRpcMessage {
|
||||
const message = record(value);
|
||||
return message?.jsonrpc === "2.0" && (typeof message.method === "string" || "id" in message);
|
||||
}
|
||||
|
||||
/** Only http(s) links leave the sandbox, and always into a new browsing context. */
|
||||
export function safeExternalUrl(value: unknown): string | null {
|
||||
if (typeof value !== "string") return null;
|
||||
try {
|
||||
const url = new URL(value);
|
||||
return url.protocol === "https:" || url.protocol === "http:" ? url.toString() : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function createMcpAppHost(options: McpAppHostOptions) {
|
||||
let initialized = false;
|
||||
// Set once this document has sent `ui/initialize`. Requests that act on the
|
||||
// user's behalf are refused before it.
|
||||
let handshakeStarted = false;
|
||||
let toolDataSent = false;
|
||||
let nextRequestId = 1;
|
||||
let disposed = false;
|
||||
|
||||
const respond = (id: JsonRpcId, result: unknown) => options.post({ jsonrpc: "2.0", id, result });
|
||||
const fail = (id: JsonRpcId, code: number, message: string) => options.post({ jsonrpc: "2.0", id, error: { code, message } });
|
||||
const notify = (method: string, params: unknown) => {
|
||||
// The host must not send anything before the view reports it is initialized.
|
||||
if (initialized && !disposed) options.post({ jsonrpc: "2.0", method, params });
|
||||
};
|
||||
|
||||
function sendToolData() {
|
||||
if (toolDataSent) return;
|
||||
toolDataSent = true;
|
||||
notify("ui/notifications/tool-input", { arguments: options.toolInput });
|
||||
notify("ui/notifications/tool-result", options.toolResult);
|
||||
}
|
||||
|
||||
async function handleRequest(message: JsonRpcMessage & { id: JsonRpcId; method: string }) {
|
||||
const params = record(message.params) ?? {};
|
||||
if (!handshakeStarted && message.method !== "ui/initialize" && message.method !== "ping") {
|
||||
fail(message.id, SERVER_ERROR, "The view must call ui/initialize first");
|
||||
return;
|
||||
}
|
||||
switch (message.method) {
|
||||
case "ui/initialize":
|
||||
handshakeStarted = true;
|
||||
respond(message.id, {
|
||||
protocolVersion: MCP_APPS_PROTOCOL_VERSION,
|
||||
hostInfo: { name: "Paperclip", version: "1.0.0" },
|
||||
hostCapabilities: {
|
||||
openLinks: {},
|
||||
serverTools: {},
|
||||
logging: {},
|
||||
sandbox: { permissions: {}, csp: {} },
|
||||
},
|
||||
hostContext: options.hostContext(),
|
||||
});
|
||||
return;
|
||||
case "ping":
|
||||
respond(message.id, {});
|
||||
return;
|
||||
case "tools/call": {
|
||||
const name = typeof params.name === "string" ? params.name : "";
|
||||
const args = record(params.arguments) ?? {};
|
||||
if (!name) {
|
||||
fail(message.id, INVALID_PARAMS, "params.name is required");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
respond(message.id, await options.callTool(name, args));
|
||||
} catch (error) {
|
||||
fail(message.id, SERVER_ERROR, error instanceof Error ? error.message : "Tool call failed");
|
||||
}
|
||||
return;
|
||||
}
|
||||
case "ui/open-link": {
|
||||
const url = safeExternalUrl(params.url);
|
||||
if (!url) {
|
||||
fail(message.id, SERVER_ERROR, "Only http and https links can be opened");
|
||||
return;
|
||||
}
|
||||
options.openLink(url);
|
||||
respond(message.id, {});
|
||||
return;
|
||||
}
|
||||
case "ui/request-display-mode":
|
||||
respond(message.id, { mode: "inline" });
|
||||
return;
|
||||
case "ui/update-model-context":
|
||||
// Accepted; Paperclip does not yet feed view context back to the agent.
|
||||
respond(message.id, {});
|
||||
return;
|
||||
default:
|
||||
fail(message.id, METHOD_NOT_FOUND, `${message.method} is not supported by Paperclip`);
|
||||
}
|
||||
}
|
||||
|
||||
function handleNotification(message: JsonRpcMessage & { method: string }) {
|
||||
const params = record(message.params) ?? {};
|
||||
switch (message.method) {
|
||||
case "ui/notifications/initialized":
|
||||
initialized = true;
|
||||
sendToolData();
|
||||
return;
|
||||
case "ui/notifications/size-changed":
|
||||
options.onSizeChanged({
|
||||
width: typeof params.width === "number" ? params.width : undefined,
|
||||
height: typeof params.height === "number" ? params.height : undefined,
|
||||
});
|
||||
return;
|
||||
case "notifications/message":
|
||||
options.onLog?.(params);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
/** Feed one message received from the view. Malformed messages are ignored. */
|
||||
receive(data: unknown) {
|
||||
if (disposed || !isJsonRpcMessage(data)) return;
|
||||
if (typeof data.method === "string" && data.id !== undefined) {
|
||||
void handleRequest(data as JsonRpcMessage & { id: JsonRpcId; method: string });
|
||||
} else if (typeof data.method === "string") {
|
||||
handleNotification(data as JsonRpcMessage & { method: string });
|
||||
}
|
||||
// Responses to host requests (teardown) need no handling.
|
||||
},
|
||||
hostContextChanged(partial: Partial<McpAppHostContext>) {
|
||||
notify("ui/notifications/host-context-changed", partial);
|
||||
},
|
||||
/** Sends `ui/resource-teardown` and stops handling messages. */
|
||||
teardown(reason = "The view was closed") {
|
||||
if (initialized && !disposed) {
|
||||
options.post({ jsonrpc: "2.0", id: `teardown-${nextRequestId++}`, method: "ui/resource-teardown", params: { reason } });
|
||||
}
|
||||
disposed = true;
|
||||
},
|
||||
get initialized() {
|
||||
return initialized;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The view document with its CSP installed before any of its markup is parsed.
|
||||
* The meta tag goes right after the doctype; the parser hoists it into the
|
||||
* implicit head, so the view's own `<html>`/`<head>` merge after it and the
|
||||
* document keeps standards mode.
|
||||
*/
|
||||
export function mcpAppDocument(html: string, csp: McpAppResourceCsp): string {
|
||||
const policy = buildMcpAppCsp(csp).replace(/"/g, """);
|
||||
const body = html.replace(/^?\s*<!doctype[^>]*>/i, "");
|
||||
return `<!doctype html><meta http-equiv="Content-Security-Policy" content="${policy}"><meta name="referrer" content="no-referrer"><script>${MCP_APP_NAVIGATION_GUARD}</script>${body}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Views render only where the navigation guard can cancel script-driven
|
||||
* navigations of the frame (location assignment, meta refresh), which needs the
|
||||
* Navigation API. The parent and the sandboxed frame run in the same engine.
|
||||
*/
|
||||
export function mcpAppNavigationGuardSupported(target: unknown = typeof window === "undefined" ? undefined : window): boolean {
|
||||
const navigation = (target as { navigation?: { addEventListener?: unknown } } | undefined)?.navigation;
|
||||
return typeof navigation?.addEventListener === "function";
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs before the view's own scripts. The view's frame must never load another
|
||||
* document: that document would inherit the frame's message channel. The
|
||||
* sandbox allows no popups, so every way out goes through the host's
|
||||
* `ui/open-link` (http and https only, opened in a new tab with noopener):
|
||||
* - cross-document navigations of the frame are cancelled (Navigation API);
|
||||
* - link clicks, whatever their target, are routed to the host;
|
||||
* - `window.open` posts to the host and returns null.
|
||||
* Same-document navigations (pushState, hashes) still work.
|
||||
*/
|
||||
export const MCP_APP_NAVIGATION_GUARD = `(function(){
|
||||
var n=0;function open(u){try{u=String(new URL(String(u),document.baseURI))}catch(_){return;}if(/^https?:/i.test(u))parent.postMessage({jsonrpc:"2.0",id:"paperclip-link-"+(++n),method:"ui/open-link",params:{url:u}},"*");}
|
||||
window.open=function(u){if(u!=null&&u!=="")open(u);return null;};
|
||||
var nav=window.navigation;
|
||||
if(nav&&nav.addEventListener)nav.addEventListener("navigate",function(e){var d=e.destination;if(!d||d.sameDocument||e.downloadRequest||!e.cancelable)return;e.preventDefault();open(d.url);});
|
||||
document.addEventListener("click",function(e){var t=e.target,a=t&&t.closest?t.closest("a[href]"):null;if(!a||e.defaultPrevented)return;if((a.getAttribute("href")||"").charAt(0)==="#")return;e.preventDefault();open(a.href);},true);
|
||||
})();`;
|
||||
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { McpAppViewSummary } from "@paperclipai/shared";
|
||||
import { createMcpAppViewIndex, mcpAppViewIndexFor } from "./mcp-app-matching";
|
||||
import { mcpAppToolDisplayName } from "./McpAppTurnViews";
|
||||
|
||||
function view(id: string, overrides: Partial<McpAppViewSummary> = {}): McpAppViewSummary {
|
||||
return {
|
||||
id,
|
||||
issueId: "issue-1",
|
||||
runId: "run-1",
|
||||
connectionId: "conn-1",
|
||||
applicationName: "Circleback",
|
||||
toolName: "mcp.circleback-1a2b3c4d:displaymeetings",
|
||||
upstreamToolName: "DisplayMeetings",
|
||||
resourceUri: "ui://circleback/meetings",
|
||||
toolInput: { meetingIds: ["a"] },
|
||||
createdAt: "2026-11-12T00:00:00.000Z",
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("mcp app view index", () => {
|
||||
it("groups views by run in call order and ignores views without a run", () => {
|
||||
const index = createMcpAppViewIndex([view("a"), view("b", { runId: "run-2" }), view("c"), view("d", { runId: null })]);
|
||||
expect(index.forRun("run-1").map((v) => v.id)).toEqual(["a", "c"]);
|
||||
expect(index.forRun("run-2").map((v) => v.id)).toEqual(["b"]);
|
||||
expect(index.forRun("run-3")).toEqual([]);
|
||||
});
|
||||
|
||||
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}` }));
|
||||
const index = mcpAppViewIndexFor(views);
|
||||
expect(mcpAppViewIndexFor(views)).toBe(index);
|
||||
const started = performance.now();
|
||||
const counts = Array.from({ length: 2000 }, (_, reply) => index.forRun(`run-${reply % 100}`).length);
|
||||
expect(performance.now() - started).toBeLessThan(50);
|
||||
expect(counts.every((count) => count === 2)).toBe(true);
|
||||
});
|
||||
|
||||
it("names tools for people", () => {
|
||||
expect(mcpAppToolDisplayName("DisplayMeetings")).toBe("Display meetings");
|
||||
expect(mcpAppToolDisplayName("display_calendar_events")).toBe("Display calendar events");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { McpAppViewSummary } from "@paperclipai/shared";
|
||||
|
||||
export interface McpAppViewIndex {
|
||||
/** The views a run recorded, oldest first. */
|
||||
forRun(runId: string): McpAppViewSummary[];
|
||||
}
|
||||
|
||||
const EMPTY: McpAppViewSummary[] = [];
|
||||
|
||||
/** Groups a task's views by run once; each reply then reads only its own run. */
|
||||
export function createMcpAppViewIndex(views: readonly McpAppViewSummary[]): McpAppViewIndex {
|
||||
const byRun = new Map<string, McpAppViewSummary[]>();
|
||||
for (const view of views) {
|
||||
if (!view.runId) continue;
|
||||
const list = byRun.get(view.runId);
|
||||
if (list) list.push(view);
|
||||
else byRun.set(view.runId, [view]);
|
||||
}
|
||||
return { forRun: (runId) => byRun.get(runId) ?? EMPTY };
|
||||
}
|
||||
|
||||
const indexCache = new WeakMap<readonly McpAppViewSummary[], McpAppViewIndex>();
|
||||
|
||||
/** One index per loaded view list, shared by every reply of the task. */
|
||||
export function mcpAppViewIndexFor(views: readonly McpAppViewSummary[]): McpAppViewIndex {
|
||||
let index = indexCache.get(views);
|
||||
if (!index) {
|
||||
index = createMcpAppViewIndex(views);
|
||||
indexCache.set(views, index);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { groupImageResources } from "./image-resources";
|
||||
import { McpAppTurnViews, mcpAppRunRefreshKey } from "@/components/mcp-app/McpAppTurnViews";
|
||||
import { useRef, type ReactNode } from "react";
|
||||
import type { ExecutionProjection } from "@paperclipai/shared";
|
||||
import { useSecondTick } from "@/hooks/useSecondTick";
|
||||
@@ -307,6 +308,7 @@ export function TaskChatRunnerTurn({
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
<McpAppTurnViews runId={runId} refreshKey={mcpAppRunRefreshKey(turnItems, status)} />
|
||||
{final ? (
|
||||
<div
|
||||
className="w-full"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { groupImageResources } from "./image-resources";
|
||||
import { McpAppTurnViews } from "@/components/mcp-app/McpAppTurnViews";
|
||||
import { TaskBrowserActivity } from "../task-side-panel/TaskBrowserActivity";
|
||||
import { TaskChatProjectCreatedCard } from "./TaskChatProjectCreatedCard";
|
||||
import { TaskChatSkillCreatedCard } from "./TaskChatSkillCreatedCard";
|
||||
@@ -159,7 +160,11 @@ function renderItem(
|
||||
}
|
||||
/>
|
||||
) : undefined;
|
||||
return (
|
||||
// MCP Apps views ride with the reply, outside the folded tool history.
|
||||
const appViews = item.author === "agent" && item.sourceRunId
|
||||
? <McpAppTurnViews runId={item.sourceRunId} notBeforeMs={item.createdAtIso ? Date.parse(item.createdAtIso) : undefined} />
|
||||
: null;
|
||||
const bubble = (
|
||||
<TaskChatBubble
|
||||
item={item}
|
||||
// Hydration and live-to-durable reconciliation may move a logical
|
||||
@@ -173,7 +178,7 @@ function renderItem(
|
||||
: actions
|
||||
}
|
||||
queuedAction={renderQueuedAction?.(item)}
|
||||
beforeTurn={item.attachedTurn?.standaloneHeader ? turn : undefined}
|
||||
beforeTurn={item.attachedTurn?.standaloneHeader ? <>{turn}{appViews}</> : undefined}
|
||||
attachedTurn={item.attachedTurn?.standaloneHeader ? undefined : turn}
|
||||
hideAgentIdentity={Boolean(item.attachedTurn?.standaloneHeader)}
|
||||
onTryAgainNoLiveExecutionPath={onTryAgainNoLiveExecutionPath}
|
||||
@@ -183,6 +188,7 @@ function renderItem(
|
||||
attachments={attachments}
|
||||
/>
|
||||
);
|
||||
return appViews && !item.attachedTurn?.standaloneHeader ? <>{appViews}{bubble}</> : bubble;
|
||||
}
|
||||
case "marker":
|
||||
return (
|
||||
|
||||
@@ -146,6 +146,7 @@ export function commentsToTaskChatItems(
|
||||
: undefined,
|
||||
agentIcon,
|
||||
onBehalfOfUserName,
|
||||
...(kind === "agent" && sourceRunId ? { sourceRunId } : {}),
|
||||
// System notices carry their structured hints through to the render
|
||||
// layer (PAP-443); other authors keep the item lean.
|
||||
presentation: kind === "system" ? comment.presentation ?? null : undefined,
|
||||
|
||||
@@ -146,6 +146,8 @@ export interface TaskChatMessageItem {
|
||||
optimistic?: "pending" | "queued";
|
||||
/** Live run this queued message is waiting behind. */
|
||||
queueTargetRunId?: string | null;
|
||||
/** Run that wrote this agent reply; its MCP Apps views show with the reply. */
|
||||
sourceRunId?: string;
|
||||
/** Non-blocking verification limitations attached to the run's durable reply. */
|
||||
verificationCaveats?: Array<{
|
||||
commandOrCheck: string;
|
||||
|
||||
@@ -465,6 +465,11 @@ function recommendedManagedConnectorMethod(
|
||||
);
|
||||
}
|
||||
|
||||
// One-method sign-in skips the access step. These providers' warnings (Railway
|
||||
// project scope, Circleback sharing outside the workspace) must still be read
|
||||
// before authorizing, so the sign-in screen repeats them.
|
||||
const SIGN_IN_GUIDANCE_SLUGS = new Set(["railway", "circleback"]);
|
||||
|
||||
function canUseAutomaticOAuthFastPath(entry: AppDefinition | null | undefined): boolean {
|
||||
if (!entry) return false;
|
||||
const methods = availableToolConnectionMethods(entry);
|
||||
@@ -2337,7 +2342,7 @@ function StandardConnectionSetupFlow({
|
||||
} : undefined}
|
||||
authorizationHost={authorizationHost}
|
||||
authorizationUrl={authorizationFallbackUrl}
|
||||
guidance={entry?.slug === "railway" && accessStepMethod ? (
|
||||
guidance={entry && SIGN_IN_GUIDANCE_SLUGS.has(entry.slug) && accessStepMethod ? (
|
||||
<div className="space-y-3 text-sm text-muted-foreground">
|
||||
<p>{accessStepMethod.guidanceMd}</p>
|
||||
<ul className="list-disc space-y-2 pl-5">
|
||||
|
||||
@@ -78,6 +78,10 @@ const APP_COPY: Record<string, AppCopy> = {
|
||||
tagline: "Reuse approved product copy and follow your style guide.",
|
||||
short: "Sign in with Ditto. API keys are optional.",
|
||||
},
|
||||
circleback: {
|
||||
tagline: "Search meeting notes, transcripts, and action items.",
|
||||
short: "Sign in with Circleback. Meetings appear as cards in chat.",
|
||||
},
|
||||
gauge: {
|
||||
tagline: "Track your brand in AI answers and run content workflows.",
|
||||
short: "Sign in with Gauge and pick an organization. API keys are optional.",
|
||||
|
||||
@@ -309,6 +309,10 @@ export const queryKeys = {
|
||||
["status-cards", "detail", id, "summary-revisions"] as const,
|
||||
dryRun: (id: string) => ["status-cards", "detail", id, "dry-run"] as const,
|
||||
},
|
||||
mcpApps: {
|
||||
views: (issueId: string) => ["mcp-app-views", issueId] as const,
|
||||
detail: (issueId: string, viewId: string) => ["mcp-app-views", issueId, "detail", viewId] as const,
|
||||
},
|
||||
issues: {
|
||||
recoveryActions: (id: string, actionId: string | null, runId: string | null) =>
|
||||
["issues", id, "recovery-actions", actionId, runId] as const,
|
||||
|
||||
@@ -72,6 +72,7 @@ const POSTHOG = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "posthog"
|
||||
const NEON = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "neon")!;
|
||||
const SUPERAGENT = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "superagent")!;
|
||||
const GAUGE = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "gauge")!;
|
||||
const CIRCLEBACK = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "circleback")!;
|
||||
const DITTO = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "ditto")!;
|
||||
const BRAINTRUST = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "braintrust")!;
|
||||
const POSTMAN = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "postman")!;
|
||||
@@ -2438,6 +2439,24 @@ describe("AppsConnect — Connect with a link (M4 frame)", () => {
|
||||
}));
|
||||
});
|
||||
|
||||
it("connects Circleback with direct browser sign-in and shows the share warning first", async () => {
|
||||
mockParams.appKey = "circleback";
|
||||
listGalleryMock.mockResolvedValueOnce({ apps: [CIRCLEBACK] });
|
||||
await render();
|
||||
// Share and delete advice must be visible before sign-in on the only path.
|
||||
expect(container.textContent).toContain("anyone with the link");
|
||||
expect(container.textContent).toContain("Set share and delete actions to Ask first");
|
||||
expect(container.querySelector('input[type="password"]')).toBeNull();
|
||||
expect(container.textContent).not.toContain("API key");
|
||||
const primary = buttonByText("Continue to Circleback");
|
||||
expect(primary?.disabled).toBe(false);
|
||||
await act(async () => primary!.click());
|
||||
await vi.waitFor(() => expect(connectAppMock).toHaveBeenCalledWith("company-1", expect.objectContaining({
|
||||
galleryKey: "circleback",
|
||||
connectionMethodKey: "mcp-oauth",
|
||||
})));
|
||||
});
|
||||
|
||||
it("enables Neon's Connect button only once the API key is entered, with pin and read-only optional", async () => {
|
||||
mockParams.appKey = "neon";
|
||||
listGalleryMock.mockResolvedValueOnce({ apps: [NEON] });
|
||||
|
||||
@@ -387,11 +387,11 @@ describe("Connectors landing page", () => {
|
||||
}
|
||||
|
||||
function composioFixture() {
|
||||
aggregatorCatalogMock.push(indexedApp("Circleback"));
|
||||
aggregatorCatalogMock.push(indexedApp("Fathom"));
|
||||
listGalleryMock.mockResolvedValue({ apps: [getAppStoreDefinition("composio")] });
|
||||
listApplicationsMock.mockResolvedValue({ applications: [application({ id: "gateway-app", name: "Composio", metadata: { sourceTemplateKey: "composio" } })] });
|
||||
listConnectionsMock.mockResolvedValue({ connections: [connection({ applicationId: "gateway-app", name: "Composio account", transport: "mcp_remote", config: { sourceTemplateKey: "composio" } })] });
|
||||
const snapshot = { connectionId: "conn-notion", toolkit: "circleback", status: "connected", checkedAt: new Date().toISOString(), accounts: [{ id: "ca-work", alias: "Meeting notes", status: "ACTIVE", isDefault: true }] };
|
||||
const snapshot = { connectionId: "conn-notion", toolkit: "fathom", status: "connected", checkedAt: new Date().toISOString(), accounts: [{ id: "ca-work", alias: "Meeting notes", status: "ACTIVE", isDefault: true }] };
|
||||
listComposioAppsMock.mockResolvedValue({ apps: [snapshot] });
|
||||
refreshComposioAppsMock.mockResolvedValue({ apps: [snapshot] });
|
||||
return snapshot;
|
||||
@@ -414,7 +414,7 @@ describe("Connectors landing page", () => {
|
||||
}
|
||||
|
||||
async function connectionMenu(name = "Meeting notes") {
|
||||
const trigger = container.querySelector<HTMLButtonElement>(`[data-app-slug="circleback"] button[aria-label="Manage ${name} connection"]`)!;
|
||||
const trigger = container.querySelector<HTMLButtonElement>(`[data-app-slug="fathom"] button[aria-label="Manage ${name} connection"]`)!;
|
||||
expect(trigger).toBeTruthy();
|
||||
await act(() => { trigger.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true })); });
|
||||
await flushReact();
|
||||
@@ -533,19 +533,19 @@ describe("Connectors landing page", () => {
|
||||
listUserDirectoryMock.mockResolvedValue({ users: [{ principalId: "user-1", status: "active", user: { id: "user-1", name: "Dotta", email: "dotta@example.com", image: null } }] });
|
||||
aggregatorCatalogMock.push(...Array.from({ length: 60 }, (_, index) => indexedApp(`Indexed App ${index}`)));
|
||||
await renderBrowse();
|
||||
const circleback = container.querySelector('[data-app-slug="circleback"]')!;
|
||||
expect(circleback.getAttribute("data-connected")).toBe("true");
|
||||
expect(circleback.textContent).toContain("Accounts managed in Composio.");
|
||||
expect(circleback.textContent).toContain("Managed by Composio ·“Composio account”");
|
||||
expect(circleback.textContent).not.toContain("Connected by");
|
||||
expect(circleback.textContent).not.toContain("Dotta");
|
||||
expect(circleback.querySelector('[title="Connected"]')).toBeTruthy();
|
||||
expect(circleback.querySelector('button[aria-label="Manage Meeting notes"]')).toBeTruthy();
|
||||
expect(circleback.querySelector('button[aria-label="Connect Circleback"]')).toBeNull();
|
||||
const fathom = container.querySelector('[data-app-slug="fathom"]')!;
|
||||
expect(fathom.getAttribute("data-connected")).toBe("true");
|
||||
expect(fathom.textContent).toContain("Accounts managed in Composio.");
|
||||
expect(fathom.textContent).toContain("Managed by Composio ·“Composio account”");
|
||||
expect(fathom.textContent).not.toContain("Connected by");
|
||||
expect(fathom.textContent).not.toContain("Dotta");
|
||||
expect(fathom.querySelector('[title="Connected"]')).toBeTruthy();
|
||||
expect(fathom.querySelector('button[aria-label="Manage Meeting notes"]')).toBeTruthy();
|
||||
expect(fathom.querySelector('button[aria-label="Connect Fathom"]')).toBeNull();
|
||||
await clickButton("Next", container);
|
||||
expect(container.querySelector('[data-app-slug="circleback"] button[aria-label="Manage Circleback"]')).toBeTruthy();
|
||||
expect(container.querySelector('[data-app-slug="fathom"] button[aria-label="Manage Fathom"]')).toBeTruthy();
|
||||
await search("Meeting notes");
|
||||
expect(container.querySelectorAll('[data-app-slug="circleback"]')).toHaveLength(1);
|
||||
expect(container.querySelectorAll('[data-app-slug="fathom"]')).toHaveLength(1);
|
||||
await clickButton("Manage", container);
|
||||
expect(document.querySelector('[role="dialog"]')?.textContent).toContain("Meeting notes");
|
||||
expect(document.querySelector('[role="dialog"]')?.textContent).toContain('“Composio account”');
|
||||
@@ -560,12 +560,12 @@ describe("Connectors landing page", () => {
|
||||
listComposioAppsMock.mockResolvedValue({ apps: [pending] });
|
||||
refreshComposioAppsMock.mockResolvedValue({ apps: [pending] });
|
||||
await renderBrowse();
|
||||
const circleback = container.querySelector('[data-app-slug="circleback"]')!;
|
||||
expect(circleback.textContent).toContain("Waiting for sign-in");
|
||||
expect(circleback.textContent).toContain("Finish connecting this account.");
|
||||
expect(circleback.querySelector('[title="Connected"]')).toBeNull();
|
||||
await act(() => circleback.querySelector<HTMLButtonElement>('button[aria-label="Manage Meeting notes"]')!.click());
|
||||
expect(document.querySelector('[role="dialog"]')?.textContent).toContain("Manage Circleback");
|
||||
const fathom = container.querySelector('[data-app-slug="fathom"]')!;
|
||||
expect(fathom.textContent).toContain("Waiting for sign-in");
|
||||
expect(fathom.textContent).toContain("Finish connecting this account.");
|
||||
expect(fathom.querySelector('[title="Connected"]')).toBeNull();
|
||||
await act(() => fathom.querySelector<HTMLButtonElement>('button[aria-label="Manage Meeting notes"]')!.click());
|
||||
expect(document.querySelector('[role="dialog"]')?.textContent).toContain("Manage Fathom");
|
||||
});
|
||||
|
||||
it("discovers app authorization on refresh and reflects a disconnection when returning from Composio", async () => {
|
||||
@@ -574,12 +574,12 @@ describe("Connectors landing page", () => {
|
||||
listComposioAppsMock.mockResolvedValue({ apps: [] });
|
||||
syncComposioAppsMock.mockResolvedValue(response);
|
||||
await renderBrowse();
|
||||
await vi.waitFor(() => expect(container.querySelector('[data-app-slug="circleback"]')?.getAttribute("data-connected")).toBe("true"));
|
||||
await vi.waitFor(() => expect(container.querySelector('[data-app-slug="fathom"]')?.getAttribute("data-connected")).toBe("true"));
|
||||
listComposioAppsMock.mockResolvedValue({ apps: [] });
|
||||
syncComposioAppsMock.mockResolvedValue({ apps: [] });
|
||||
await act(() => focusManager.setFocused(false));
|
||||
await act(() => focusManager.setFocused(true));
|
||||
await vi.waitFor(() => expect(container.querySelector('button[aria-label="Connect Circleback"]')).toBeTruthy());
|
||||
await vi.waitFor(() => expect(container.querySelector('button[aria-label="Connect Fathom"]')).toBeTruthy());
|
||||
focusManager.setFocused(undefined);
|
||||
expect(setupComposioAppMock).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -596,8 +596,8 @@ describe("Connectors landing page", () => {
|
||||
const disconnected = { ...snapshot, status: "not_connected", accounts: [] };
|
||||
refreshComposioAppsMock.mockResolvedValue({ apps: [disconnected] });
|
||||
await clickButton("Refresh", dialog);
|
||||
expect(refreshComposioAppsMock).toHaveBeenCalledWith("conn-notion", ["circleback"]);
|
||||
expect(dialog.textContent).toContain("No connected Circleback accounts.");
|
||||
expect(refreshComposioAppsMock).toHaveBeenCalledWith("conn-notion", ["fathom"]);
|
||||
expect(dialog.textContent).toContain("No connected Fathom accounts.");
|
||||
expect(manageComposioAppAccountMock).not.toHaveBeenCalled();
|
||||
expect(setupComposioAppMock).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -606,8 +606,8 @@ describe("Connectors landing page", () => {
|
||||
const snapshot = composioFixture();
|
||||
listComposioAppsMock.mockResolvedValue({ apps: [{ ...snapshot, errorAt: new Date().toISOString() }], sync: { status: "error", error: "Unavailable" } });
|
||||
await renderBrowse();
|
||||
expect(container.querySelector('button[aria-label="Manage Circleback"]')).toBeTruthy();
|
||||
expect(container.querySelector('[data-app-slug="circleback"] [title="Connected"]')).toBeNull();
|
||||
expect(container.querySelector('button[aria-label="Manage Fathom"]')).toBeTruthy();
|
||||
expect(container.querySelector('[data-app-slug="fathom"] [title="Connected"]')).toBeNull();
|
||||
expect(container.textContent).toContain("Last known account · Refresh to verify");
|
||||
expect(container.textContent).toContain("Unavailable");
|
||||
const menu = await openComposioAccountMenu();
|
||||
@@ -619,16 +619,16 @@ describe("Connectors landing page", () => {
|
||||
it("keeps the last known aggregator accounts without a load-error notice when a refetch fails transiently", async () => {
|
||||
composioFixture();
|
||||
const client = await renderBrowse();
|
||||
const circleback = () => container.querySelector('[data-app-slug="circleback"]');
|
||||
expect(circleback()?.textContent).toContain("Meeting notes");
|
||||
expect(circleback()?.querySelector('[title="Connected"]')).toBeTruthy();
|
||||
const fathom = () => container.querySelector('[data-app-slug="fathom"]');
|
||||
expect(fathom()?.textContent).toContain("Meeting notes");
|
||||
expect(fathom()?.querySelector('[title="Connected"]')).toBeTruthy();
|
||||
|
||||
listComposioAppsMock.mockRejectedValue(new ApiError("Paperclip is restarting.", 503, { error: "tenant_app_unavailable" }));
|
||||
await act(async () => { await client.invalidateQueries({ queryKey: ["tools", "aggregator-apps"] }); });
|
||||
await flushReact();
|
||||
|
||||
expect(circleback()?.textContent).toContain("Meeting notes");
|
||||
expect(circleback()?.querySelector('[title="Connected"]')).toBeTruthy();
|
||||
expect(fathom()?.textContent).toContain("Meeting notes");
|
||||
expect(fathom()?.querySelector('[title="Connected"]')).toBeTruthy();
|
||||
expect(container.textContent).not.toContain("Last known account · Refresh to verify");
|
||||
expect(container.textContent).not.toContain("Couldn’t load Composio accounts");
|
||||
expect(container.querySelector('[data-query-view="error"]')).toBeNull();
|
||||
@@ -638,13 +638,13 @@ describe("Connectors landing page", () => {
|
||||
it("reports a real aggregator account failure while keeping the last known accounts", async () => {
|
||||
composioFixture();
|
||||
const client = await renderBrowse();
|
||||
expect(container.querySelector('[data-app-slug="circleback"]')?.textContent).toContain("Meeting notes");
|
||||
expect(container.querySelector('[data-app-slug="fathom"]')?.textContent).toContain("Meeting notes");
|
||||
|
||||
listComposioAppsMock.mockRejectedValue(new ApiError("Boom", 500, { error: "Boom" }));
|
||||
await act(async () => { await client.invalidateQueries({ queryKey: ["tools", "aggregator-apps"] }); });
|
||||
await flushReact();
|
||||
|
||||
expect(container.querySelector('[data-app-slug="circleback"]')?.textContent).toContain("Meeting notes");
|
||||
expect(container.querySelector('[data-app-slug="fathom"]')?.textContent).toContain("Meeting notes");
|
||||
expect(container.textContent).toContain("Couldn’t load Composio accounts. Use Refresh in the connection’s menu to try again.");
|
||||
expect(container.textContent).toContain("Last known account · Refresh to verify");
|
||||
});
|
||||
@@ -716,6 +716,22 @@ describe("Connectors landing page", () => {
|
||||
expect(document.querySelector('[role="dialog"]')?.textContent).toContain("Which service would you like to use?");
|
||||
});
|
||||
|
||||
it.each([true, false])("keeps native Circleback in place of its Composio listing (cloud: %s)", async (cloud) => {
|
||||
// Composio publishes it as "Circleback MCP" (slug circleback-mcp).
|
||||
aggregatorCatalogMock.push({ name: "Circleback", slug: "circleback-mcp", aliases: ["circleback_mcp"], routes: [{
|
||||
provider: "composio", toolkit: "circleback_mcp", logoUrl: "https://logos.composio.dev/api/circleback_mcp", docsUrl: "https://docs.composio.dev/toolkits/circleback_mcp",
|
||||
}] });
|
||||
listGalleryMock.mockResolvedValue({ apps: [getAppStoreDefinition("circleback")] });
|
||||
await renderBrowse(true, { cloud });
|
||||
|
||||
expect(container.querySelector('[data-app-slug="circleback-mcp"]')).toBeNull();
|
||||
const rows = container.querySelectorAll('[data-app-slug="circleback"]');
|
||||
expect(rows).toHaveLength(1);
|
||||
expect(rows[0]!.textContent).not.toContain("Connect through Composio");
|
||||
await clickButton("Connect", rows[0]!);
|
||||
expect(navigateMock).toHaveBeenCalledWith("/apps/connect?source=circleback");
|
||||
});
|
||||
|
||||
it.each([
|
||||
["Chat connectors offer its setup path", { enableChatConnectors: true }, true],
|
||||
["the instance is self-hosted", {}, false],
|
||||
@@ -836,28 +852,28 @@ describe("Connectors landing page", () => {
|
||||
});
|
||||
|
||||
it.each(["composio", "arcade"] as const)("skips provider selection and opens setup for a sole %s provider", async (provider) => {
|
||||
const app = indexedApp("Circleback", [provider]);
|
||||
const app = indexedApp("Fathom", [provider]);
|
||||
app.routes[0].toolkit = "circle_back";
|
||||
aggregatorCatalogMock.push(app);
|
||||
await renderBrowse();
|
||||
await act(() => container.querySelector<HTMLButtonElement>('button[aria-label="Connect Circleback"]')!.click());
|
||||
await act(() => container.querySelector<HTMLButtonElement>('button[aria-label="Connect Fathom"]')!.click());
|
||||
expect(navigateMock).toHaveBeenCalledWith(`/apps/connect?source=${provider}&targetToolkit=circle_back`);
|
||||
expect(document.querySelector('[role="dialog"]')).toBeNull();
|
||||
});
|
||||
|
||||
it("opens the saved gateway flow directly for a sole provider and allows cancellation", async () => {
|
||||
aggregatorCatalogMock.push(indexedApp("Circleback"));
|
||||
aggregatorCatalogMock.push(indexedApp("Fathom"));
|
||||
listGalleryMock.mockResolvedValue({ apps: [getAppStoreDefinition("composio")] });
|
||||
listApplicationsMock.mockResolvedValue({ applications: [application({ id: "gateway-app", name: "Composio", metadata: { sourceTemplateKey: "composio" } })] });
|
||||
listConnectionsMock.mockResolvedValue({ connections: [connection({ applicationId: "gateway-app", name: "Composio account", config: { sourceTemplateKey: "composio" } })] });
|
||||
await renderBrowse();
|
||||
await act(() => container.querySelector<HTMLButtonElement>('button[aria-label="Connect Circleback"]')!.click());
|
||||
await act(() => container.querySelector<HTMLButtonElement>('button[aria-label="Connect Fathom"]')!.click());
|
||||
const dialog = document.querySelector('[role="dialog"]')!;
|
||||
expect(dialog.textContent).toContain("Connect Circleback through Composio");
|
||||
expect(dialog.textContent).toContain("Connect Fathom through Composio");
|
||||
expect(dialog.textContent).not.toContain("Which service would you like to use?");
|
||||
expect(dialog.textContent).not.toContain("Back");
|
||||
expect(dialog.textContent).not.toContain("Connection settings");
|
||||
expect(dialog.textContent).not.toContain("An agent can check Circleback in Composio");
|
||||
expect(dialog.textContent).not.toContain("An agent can check Fathom in Composio");
|
||||
expect(dialog.querySelector('[data-slot="badge"]')).toBeNull();
|
||||
expect(dialog.querySelector<HTMLSelectElement>('#composio-app-account')?.value).toBe("conn-notion");
|
||||
expect(dialog.querySelector('#composio-app-agent')).toBeNull();
|
||||
@@ -911,19 +927,19 @@ describe("Connectors landing page", () => {
|
||||
listAgentsMock.mockRejectedValue(new Error("Agents are unavailable"));
|
||||
setupComposioAppMock.mockReset().mockResolvedValueOnce({ status: "authorization_required", authorizationUrl: "https://connect.composio.dev/link/personal" }).mockResolvedValueOnce({ status: "connected" });
|
||||
await renderBrowse();
|
||||
await act(() => container.querySelector<HTMLButtonElement>('button[aria-label="Connect Circleback"]')!.click());
|
||||
await act(() => container.querySelector<HTMLButtonElement>('button[aria-label="Connect Fathom"]')!.click());
|
||||
const select = document.querySelector<HTMLSelectElement>('#composio-app-account')!;
|
||||
expect(Array.from(select.options).map(option => option.textContent)).toEqual(["Work Composio", "Personal Composio", "Connect a new account…"]);
|
||||
await act(() => { select.value = "conn-personal"; select.dispatchEvent(new Event("change", { bubbles: true })); });
|
||||
await flushReact();
|
||||
await clickButton("Continue", document.querySelector('[role="dialog"]')!);
|
||||
expect(setupComposioAppMock).toHaveBeenCalledWith("conn-personal", "circleback", { action: "start" });
|
||||
expect(setupComposioAppMock).toHaveBeenCalledWith("conn-personal", "fathom", { action: "start" });
|
||||
expect(document.querySelector('a[href="https://connect.composio.dev/link/personal"]')).toBeTruthy();
|
||||
await act(() => { select.value = "conn-notion"; select.dispatchEvent(new Event("change", { bubbles: true })); });
|
||||
await flushReact();
|
||||
expect(document.querySelector('a[href="https://connect.composio.dev/link/personal"]')).toBeNull();
|
||||
await clickButton("Continue", document.querySelector('[role="dialog"]')!);
|
||||
expect(setupComposioAppMock).toHaveBeenLastCalledWith("conn-notion", "circleback", { action: "start" });
|
||||
expect(setupComposioAppMock).toHaveBeenLastCalledWith("conn-notion", "fathom", { action: "start" });
|
||||
expect(document.querySelector('[role="dialog"]')).toBeNull();
|
||||
expect(listAgentsMock).not.toHaveBeenCalled();
|
||||
expect(openNewIssueMock).not.toHaveBeenCalled();
|
||||
@@ -936,13 +952,13 @@ describe("Connectors landing page", () => {
|
||||
refreshComposioAppsMock.mockResolvedValue({ apps: [] });
|
||||
setupComposioAppMock.mockReset();
|
||||
await renderBrowse();
|
||||
await act(() => container.querySelector<HTMLButtonElement>('button[aria-label="Connect Circleback"]')!.click());
|
||||
await act(() => container.querySelector<HTMLButtonElement>('button[aria-label="Connect Fathom"]')!.click());
|
||||
const select = document.querySelector<HTMLSelectElement>('#composio-app-account')!;
|
||||
await act(() => { select.value = "__new__"; select.dispatchEvent(new Event("change", { bubbles: true })); });
|
||||
await flushReact();
|
||||
expect(navigateMock).not.toHaveBeenCalled();
|
||||
await clickButton("Connect new account", document.querySelector('[role="dialog"]')!);
|
||||
expect(navigateMock).toHaveBeenCalledWith("/apps/connect?source=composio&targetToolkit=circleback&new=1");
|
||||
expect(navigateMock).toHaveBeenCalledWith("/apps/connect?source=composio&targetToolkit=fathom&new=1");
|
||||
expect(document.querySelector('[role="dialog"]')).toBeNull();
|
||||
expect(setupComposioAppMock).not.toHaveBeenCalled();
|
||||
expect(listAgentsMock).not.toHaveBeenCalled();
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import { useState, type ReactNode } from "react";
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import type { McpAppCallToolResult } from "@paperclipai/shared";
|
||||
import { McpAppIssueProvider } from "@/components/mcp-app/McpAppIssueContext";
|
||||
import { McpAppTurnViews } from "@/components/mcp-app/McpAppTurnViews";
|
||||
import { McpAppViewContent } from "@/components/mcp-app/McpAppView";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import {
|
||||
ISSUE_ID,
|
||||
MEETINGS,
|
||||
MEETINGS_VIEW_DETAIL,
|
||||
MEETINGS_VIEW_SUMMARY,
|
||||
RUN_ID,
|
||||
} from "../../support/mcp-app/fixtures";
|
||||
|
||||
function Frame({ children }: { children: ReactNode }) {
|
||||
return <div className="mx-auto w-full max-w-(--tc-shell-max-w) p-6">{children}</div>;
|
||||
}
|
||||
|
||||
/** The production reply-level block with the run's recorded view in the query cache. */
|
||||
function SeededRunViews() {
|
||||
const queryClient = useQueryClient();
|
||||
const [seeded] = useState(() => {
|
||||
queryClient.setQueryData(queryKeys.mcpApps.views(ISSUE_ID), [MEETINGS_VIEW_SUMMARY]);
|
||||
queryClient.setQueryData(queryKeys.mcpApps.detail(ISSUE_ID, MEETINGS_VIEW_SUMMARY.id), MEETINGS_VIEW_DETAIL);
|
||||
return true;
|
||||
});
|
||||
if (!seeded) return null;
|
||||
return (
|
||||
<McpAppIssueProvider issueId={ISSUE_ID}>
|
||||
<Frame>
|
||||
<McpAppTurnViews runId={RUN_ID} />
|
||||
<p className="mt-3 text-sm text-foreground">Your most recent meetings are shown above.</p>
|
||||
</Frame>
|
||||
</McpAppIssueProvider>
|
||||
);
|
||||
}
|
||||
|
||||
const refreshedResult: McpAppCallToolResult = {
|
||||
content: [{ type: "text", text: "Refreshed" }],
|
||||
structuredContent: { meetings: [...MEETINGS, { ...MEETINGS[0]!, id: "m3", name: "Weekly product sync", tag: "Product Meeting", when: "Today" }] },
|
||||
};
|
||||
|
||||
function ViewState({ state }: { state: "ready" | "loading" | "error" | "tool-call-denied" }) {
|
||||
const callTool = async (): Promise<McpAppCallToolResult> => state === "tool-call-denied"
|
||||
? { content: [{ type: "text", text: "This action needs approval first. It was sent for review." }], isError: true }
|
||||
: refreshedResult;
|
||||
return (
|
||||
<Frame>
|
||||
<McpAppViewContent
|
||||
detail={state === "loading" ? undefined : MEETINGS_VIEW_DETAIL}
|
||||
status={state === "tool-call-denied" ? "ready" : state}
|
||||
errorMessage={state === "error" ? "Circleback could not show this view. The tool result is still in the row above." : null}
|
||||
callTool={callTool}
|
||||
displayName="Display meetings"
|
||||
/>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
|
||||
const meta = {
|
||||
id: "tasks-task-chat-mcp-app",
|
||||
title: "Tasks and conversations/Task creation and lifecycle/Tasks/MCP App views",
|
||||
component: ViewState,
|
||||
parameters: {
|
||||
layout: "fullscreen",
|
||||
docs: {
|
||||
description: {
|
||||
component:
|
||||
"MCP Apps (io.modelcontextprotocol/ui) views shown with the agent's reply, such as Circleback meeting cards. The view runs in an opaque-origin sandboxed iframe and talks to Paperclip only through the MCP Apps postMessage protocol: initialize, tool input and result, size changes, tool calls and opening links.",
|
||||
},
|
||||
},
|
||||
paperclip: {
|
||||
"capabilities": [
|
||||
"tasks/discussion",
|
||||
"runs-adapters/runs"
|
||||
],
|
||||
"status": "current",
|
||||
"implementation": "production",
|
||||
"boundary": "fixtures",
|
||||
"notes": "The view document is an original fixture that follows the 2026-01-26 MCP Apps protocol. Provider HTML comes from the connection at runtime.",
|
||||
},
|
||||
},
|
||||
} satisfies Meta<typeof ViewState>;
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const WithReply: Story = { name: "01 · Meeting cards with the agent's reply", render: () => <SeededRunViews />, args: { state: "ready" } };
|
||||
export const Ready: Story = { name: "02 · View (Refresh calls a tool)", args: { state: "ready" } };
|
||||
export const Loading: Story = { name: "03 · Loading", args: { state: "loading" } };
|
||||
export const ErrorFallback: Story = { name: "04 · View unavailable", args: { state: "error" } };
|
||||
export const ToolCallNeedsApproval: Story = { name: "05 · Tool call needs approval", args: { state: "tool-call-denied" } };
|
||||
@@ -0,0 +1,133 @@
|
||||
import type { McpAppViewDetail, McpAppViewSummary } from "@paperclipai/shared";
|
||||
|
||||
/**
|
||||
* A self-contained MCP Apps view that follows the 2026-01-26 protocol by hand:
|
||||
* ui/initialize → ui/notifications/initialized → tool-input/tool-result, then
|
||||
* size-changed, tools/call and ui/open-link. It stands in for a provider's
|
||||
* meeting-card view; the markup is original fixture content.
|
||||
*/
|
||||
export const MEETING_CARDS_VIEW_HTML = String.raw`<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
:root { color-scheme: light dark; font-family: var(--font-sans, system-ui, sans-serif); }
|
||||
body { margin: 0; padding: 8px 12px; background: transparent; color: var(--color-text-primary, CanvasText); }
|
||||
.row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 8px; cursor: pointer; }
|
||||
.row:hover { background: var(--color-background-secondary, rgba(127,127,127,.12)); }
|
||||
.avatar { width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: #fff; background: #b9655a; flex: none; }
|
||||
.text { min-width: 0; flex: 1; }
|
||||
.name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.who { font-size: 12px; color: var(--color-text-secondary, GrayText); }
|
||||
.tag { font-size: 12px; padding: 2px 8px; border: 1px solid var(--color-border-primary, rgba(127,127,127,.4)); border-radius: 999px; white-space: nowrap; }
|
||||
.date { font-size: 12px; color: var(--color-text-secondary, GrayText); width: 64px; text-align: right; }
|
||||
.actions { padding: 6px 4px 2px; }
|
||||
button { font: inherit; font-size: 12px; background: none; border: 1px solid var(--color-border-primary, rgba(127,127,127,.4)); color: inherit; border-radius: 6px; padding: 2px 8px; cursor: pointer; }
|
||||
.status { font-size: 12px; color: var(--color-text-secondary, GrayText); margin-left: 8px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="list"><div class="who">Waiting for the meeting list…</div></div>
|
||||
<div class="actions"><button id="refresh" type="button">Refresh</button><span class="status" id="status"></span></div>
|
||||
<script>
|
||||
let nextId = 1;
|
||||
const pending = new Map();
|
||||
function request(method, params) {
|
||||
const id = nextId++;
|
||||
parent.postMessage({ jsonrpc: "2.0", id, method, params }, "*");
|
||||
return new Promise((resolve, reject) => pending.set(id, { resolve, reject }));
|
||||
}
|
||||
function notify(method, params) { parent.postMessage({ jsonrpc: "2.0", method, params }, "*"); }
|
||||
function applyContext(context) {
|
||||
if (!context) return;
|
||||
if (context.theme) document.documentElement.style.colorScheme = context.theme;
|
||||
const vars = context.styles && context.styles.variables;
|
||||
if (vars) for (const key of Object.keys(vars)) document.documentElement.style.setProperty(key, vars[key]);
|
||||
}
|
||||
function initials(name) { return name.split(/\s+/).map((part) => part[0]).join("").slice(0, 2).toUpperCase(); }
|
||||
function render(result) {
|
||||
const meetings = (result && result.structuredContent && result.structuredContent.meetings) || [];
|
||||
const list = document.getElementById("list");
|
||||
list.innerHTML = "";
|
||||
for (const meeting of meetings) {
|
||||
const row = document.createElement("div");
|
||||
row.className = "row";
|
||||
row.innerHTML = '<div class="avatar"></div><div class="text"><div class="name"></div><div class="who"></div></div><span class="tag"></span><span class="date"></span>';
|
||||
row.querySelector(".avatar").textContent = initials(meeting.organizer);
|
||||
row.querySelector(".name").textContent = meeting.name;
|
||||
row.querySelector(".who").textContent = meeting.attendees;
|
||||
row.querySelector(".tag").textContent = meeting.tag;
|
||||
row.querySelector(".date").textContent = meeting.when;
|
||||
row.addEventListener("click", () => request("ui/open-link", { url: meeting.url }));
|
||||
list.appendChild(row);
|
||||
}
|
||||
if (!meetings.length) list.innerHTML = '<div class="who">No meetings</div>';
|
||||
reportSize();
|
||||
}
|
||||
function reportSize() { notify("ui/notifications/size-changed", { height: Math.ceil(document.body.getBoundingClientRect().height) }); }
|
||||
window.addEventListener("message", (event) => {
|
||||
const message = event.data;
|
||||
if (!message || message.jsonrpc !== "2.0") return;
|
||||
if (message.id !== undefined && pending.has(message.id)) {
|
||||
const entry = pending.get(message.id); pending.delete(message.id);
|
||||
message.error ? entry.reject(message.error) : entry.resolve(message.result);
|
||||
return;
|
||||
}
|
||||
if (message.method === "ui/notifications/tool-result") render(message.params);
|
||||
if (message.method === "ui/notifications/host-context-changed") applyContext(message.params);
|
||||
if (message.method === "ui/resource-teardown") parent.postMessage({ jsonrpc: "2.0", id: message.id, result: {} }, "*");
|
||||
});
|
||||
document.getElementById("refresh").addEventListener("click", async () => {
|
||||
const status = document.getElementById("status");
|
||||
status.textContent = "Refreshing…";
|
||||
try {
|
||||
const result = await request("tools/call", { name: "RefreshMeetingCards", arguments: {} });
|
||||
render(result);
|
||||
status.textContent = result.isError ? "Refresh failed" : "Updated";
|
||||
} catch (error) {
|
||||
status.textContent = (error && error.message) || "Refresh failed";
|
||||
}
|
||||
reportSize();
|
||||
});
|
||||
request("ui/initialize", { protocolVersion: "2026-01-26", appCapabilities: { availableDisplayModes: ["inline"] }, clientInfo: { name: "meeting-cards-fixture", version: "1" } })
|
||||
.then((result) => { applyContext(result.hostContext); notify("ui/notifications/initialized", {}); reportSize(); });
|
||||
</script>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
export const MEETINGS = [
|
||||
{ id: "m1", name: "Paperclip/Tom", organizer: "Tom Drummond", attendees: "Tom Drummond, you, and 2 others", tag: "External / Vendor", when: "Yesterday", url: "https://app.circleback.ai/meetings/m1" },
|
||||
{ id: "m2", name: "Paperclip <> Heavybit, Partner Meeting", organizer: "Tom Drummond", attendees: "Tom Drummond, you, and 2 others", tag: "3 tags", when: "Tue", url: "https://app.circleback.ai/meetings/m2" },
|
||||
];
|
||||
|
||||
export const ISSUE_ID = "11111111-1111-4111-8111-111111111111";
|
||||
export const RUN_ID = "22222222-2222-4222-8222-222222222222";
|
||||
|
||||
export const MEETINGS_VIEW_SUMMARY: McpAppViewSummary = {
|
||||
id: "33333333-3333-4333-8333-333333333333",
|
||||
issueId: ISSUE_ID,
|
||||
runId: RUN_ID,
|
||||
connectionId: "44444444-4444-4444-8444-444444444444",
|
||||
applicationName: "Circleback",
|
||||
toolName: "mcp.circleback-44444444:displaymeetings",
|
||||
upstreamToolName: "DisplayMeetings",
|
||||
resourceUri: "ui://circleback/meetings.html",
|
||||
toolInput: { meetingIds: ["m1", "m2"] },
|
||||
createdAt: "2026-11-12T15:00:00.000Z",
|
||||
};
|
||||
|
||||
export const MEETINGS_VIEW_DETAIL: McpAppViewDetail = {
|
||||
...MEETINGS_VIEW_SUMMARY,
|
||||
toolResult: {
|
||||
content: [{ type: "text", text: "Showing 2 meetings as cards." }],
|
||||
structuredContent: { meetings: MEETINGS },
|
||||
},
|
||||
resource: {
|
||||
uri: "ui://circleback/meetings.html",
|
||||
html: MEETING_CARDS_VIEW_HTML,
|
||||
csp: {},
|
||||
permissions: {},
|
||||
prefersBorder: true,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user