From 20ec1a65176c378f8dc9cd4acfccbb84b349c378 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sun, 8 Nov 2026 10:17:29 -0500 Subject: [PATCH] Figma card signs in with Coderhelm's app in one click; my own app and a key are the other choices --- dashboard/e2e/integrations-page.spec.ts | 36 +++++++++ dashboard/src/components/mcp-server-panel.tsx | 81 ++++++++++++++++++- dashboard/src/lib/api.ts | 6 ++ 3 files changed, 120 insertions(+), 3 deletions(-) diff --git a/dashboard/e2e/integrations-page.spec.ts b/dashboard/e2e/integrations-page.spec.ts index 4219e0d3..c5693f13 100644 --- a/dashboard/e2e/integrations-page.spec.ts +++ b/dashboard/e2e/integrations-page.spec.ts @@ -163,6 +163,14 @@ async function mockApi(page: Page, init: Partial = {}): Promise c.method === "POST" && c.path === "/api/mcp-servers/app-figma/connect")).toBe(true); await expect(page).toHaveURL(/\/settings\/integrations\/#integration-figma$/); }); + +test("Figma signs in with Coderhelm's app in one click; my own app and a key are the other choices", async ({ page }) => { + const db = await mockApi(page); + const figma = db.items.find((i) => i.id === "figma")!; + const detail = figma.detail as Record & { plugin: Record }; + detail.own_app_redirect_uri = "https://app.coderhelm.com/settings/integrations/mcp-callback/"; + detail.coderhelm_app = true; + detail.plugin.own_app = { + authorize: "https://www.figma.com/oauth", + token: "https://api.figma.com/v1/oauth/token", + refresh: "https://api.figma.com/v1/oauth/refresh", + scopes: ["current_user:read", "file_content:read"], + console: "https://www.figma.com/developers/apps", + guide: "https://developers.figma.com/docs/rest-api/oauth-apps/", + }; + await page.goto("/settings/integrations#integration-figma"); + const card = row(page, "figma"); + const ours = card.getByTestId("coderhelm-app"); + await expect(ours).toContainText("current_user:read, file_content:read"); + // The own app's steps and the key wait behind their disclosures. + await expect(card.getByText("Use my own Figma app", { exact: true }).first()).toBeVisible(); + await expect(card.getByText("Use a key instead", { exact: true })).toBeVisible(); + await expect(card.getByTestId("own-app")).toBeHidden(); + await ours.getByRole("button", { name: "Sign in with Figma" }).click(); + await expect.poll(() => db.calls.some((c) => c.path === "/api/mcp-servers/oauth/callback")).toBe(true); + expect(db.calls.some((c) => c.method === "POST" && c.path === "/api/mcp-servers/apps/figma/coderhelm")).toBe(true); + expect(db.calls.some((c) => c.method === "PUT" && c.path === "/api/mcp-servers/apps/figma")).toBe(false); +}); diff --git a/dashboard/src/components/mcp-server-panel.tsx b/dashboard/src/components/mcp-server-panel.tsx index a96483c6..caf13976 100644 --- a/dashboard/src/components/mcp-server-panel.tsx +++ b/dashboard/src/components/mcp-server-panel.tsx @@ -11,6 +11,7 @@ import { useToast } from "./toast"; import { inputClass, linkButton, primaryButton, secondaryButton } from "./ui"; import { connectCatalogServer, startMcpSignIn } from "./mcp-servers"; import { CopyButton } from "./copy-button"; +import { HybridAppChoice } from "./hybrid-app-choice"; // A catalog MCP server (Sentry, Linear, Notion…), opened in place on // Integrations and on Connections: signing in through the vendor's remote @@ -18,16 +19,45 @@ import { CopyButton } from "./copy-button"; /** An MCP server: credentials (entered here, never shown again), its test, its instructions, and turning it off. */ export function PluginPanel({ item, onChanged, onClose }: { item: Integration; onChanged: () => Promise; onClose: () => void }) { - const d = item.detail as { plugin: PluginDef; enabled: boolean; has_credentials: boolean; custom_prompt: string; remote?: McpServer | null; own_app?: OwnAppState | null; own_app_redirect_uri?: string | null }; + const d = item.detail as { + plugin: PluginDef; + enabled: boolean; + has_credentials: boolean; + custom_prompt: string; + remote?: McpServer | null; + own_app?: OwnAppState | null; + own_app_redirect_uri?: string | null; + coderhelm_app?: boolean; + }; const p = d.plugin; const keyForm = ; // The vendor's MCP server takes only apps it approved, but its API takes - // the team's own app: sign in with that, or use a key. + // Coderhelm's app or the team's own: sign in with one, or use a key. if (p.own_app) { const signedIn = d.own_app?.status === "connected"; + const mine = d.own_app && (d.own_app.source ?? "own") === "own" ? d.own_app : null; + const ownPanel = ; + if (d.coderhelm_app) { + // Coderhelm's app: one sign-in button; the team's own app and a key + // are the other choices, behind their disclosures. + const ours = d.own_app && d.own_app.source === "coderhelm" ? d.own_app : null; + return ( +
+ void onChanged()} /> + + + {ownPanel} + + + {keyForm} + +
+ ); + } return (
- + void onChanged()} /> + {ownPanel} {keyForm} @@ -141,6 +171,51 @@ function OAuthOffer({ plugin }: { plugin: PluginDef }) { ); } +/** Signing in with Coderhelm's own app with the vendor: nothing to create or paste. */ +function CoderhelmAppSignIn({ plugin, state }: { plugin: PluginDef; state: OwnAppState | null }) { + const [busy, setBusy] = useState(false); + const [error, setError] = useState(""); + const scopes = plugin.own_app?.scopes ?? []; + const go = async () => { + setBusy(true); + setError(""); + try { + const r = await api.connectCoderhelmApp(plugin.id); + window.location.assign(r.authorize_url); + } catch (e) { + setError(errorMessage(e, "Couldn't start the sign-in.")); + setBusy(false); + } + }; + return ( +
+ {state?.status === "connected" ? ( +

+ Signed in{state.connected_by ? ` by ${state.connected_by}` : ""} with Coderhelm's app. Agents read {plugin.name} with this sign-in. +

+ ) : state?.status_reason ? ( +

+ {state.status_reason} +

+ ) : ( +

+ You sign in at {plugin.name} and allow Coderhelm to read{scopes.length ? ` (${scopes.join(", ")})` : ""}. Nothing is changed in {plugin.name}. +

+ )} + {error && ( +

+ {error} +

+ )} +
+ +
+
+ ); +} + /** The team's own OAuth app with the vendor: where to create it, its client id and secret, and signing in with it. */ function OwnAppPanel({ plugin, state, redirectUri, onChanged }: { plugin: PluginDef; state: OwnAppState | null; redirectUri: string; onChanged: () => Promise }) { const app = plugin.own_app!; diff --git a/dashboard/src/lib/api.ts b/dashboard/src/lib/api.ts index e1de0983..0befe7d9 100644 --- a/dashboard/src/lib/api.ts +++ b/dashboard/src/lib/api.ts @@ -1470,6 +1470,9 @@ export const api = { method: "PUT", body: JSON.stringify({ client_id, client_secret }), }), + /** Signs in with Coderhelm's own app for a catalog server (Figma): replaces the team's own app, if one was saved, and answers where to send the browser. */ + connectCoderhelmApp: (catalogId: string) => + request<{ authorize_url: string; own_app: OwnAppState }>(`/api/mcp-servers/apps/${encodeURIComponent(catalogId)}/coderhelm`, { method: "POST" }), setMcpClient: (id: string, client_id: string, client_secret: string) => request<{ server: McpServer }>(`/api/mcp-servers/${encodeURIComponent(id)}/client`, { method: "PUT", @@ -3025,6 +3028,9 @@ export interface OwnAppDef { export interface OwnAppState { /** The connection's id, for connect, disconnect and remove. */ id: string; + /** Whose app it signs in with: Coderhelm's or the team's own. Missing from older gateways (own). */ + source?: "coderhelm" | "own"; + /** The team's own app's client id; empty for Coderhelm's app. */ client_id: string; has_secret: boolean; status: "connected" | "not_connected" | "needs_reconnect" | "failed";