Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+85
@@ -0,0 +1,85 @@
|
||||
// Official brand marks of the AI clients HiveGrid connects to, inlined so the
|
||||
// app never pulls a logo from a third-party CDN and the marks stay crisp at the
|
||||
// 16px the topbar pill and the setup dialog render them at.
|
||||
//
|
||||
// Gradient ids are namespaced per mark (`hg-<client>-…`): two marks on the same
|
||||
// page would otherwise share an id and one would silently take the other's
|
||||
// colours.
|
||||
|
||||
export type AiClientMarkProps = { className?: string };
|
||||
|
||||
/** ChatGPT. */
|
||||
export function ChatGptMark({ className }: AiClientMarkProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 320 320" className={className} aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m297.06 130.97c7.26-21.79 4.76-45.66-6.85-65.48-17.46-30.4-52.56-46.04-86.84-38.68-15.25-17.18-37.16-26.95-60.13-26.81-35.04-.08-66.13 22.48-76.91 55.82-22.51 4.61-41.94 18.7-53.31 38.67-17.59 30.32-13.58 68.54 9.92 94.54-7.26 21.79-4.76 45.66 6.85 65.48 17.46 30.4 52.56 46.04 86.84 38.68 15.24 17.18 37.16 26.95 60.13 26.8 35.06.09 66.16-22.49 76.94-55.86 22.51-4.61 41.94-18.7 53.31-38.67 17.57-30.32 13.55-68.51-9.94-94.51zm-120.28 168.11c-14.03.02-27.62-4.89-38.39-13.88.49-.26 1.34-.73 1.89-1.07l63.72-36.8c3.26-1.85 5.26-5.32 5.24-9.07v-89.83l26.93 15.55c.29.14.48.42.52.74v74.39c-.04 33.08-26.83 59.9-59.91 59.97zm-128.84-55.03c-7.03-12.14-9.56-26.37-7.15-40.18.47.28 1.3.79 1.89 1.13l63.72 36.8c3.23 1.89 7.23 1.89 10.47 0l77.79-44.92v31.1c.02.32-.13.63-.38.83l-64.41 37.19c-28.69 16.52-65.33 6.7-81.92-21.95zm-16.77-139.09c7-12.16 18.05-21.46 31.21-26.29 0 .55-.03 1.52-.03 2.2v73.61c-.02 3.74 1.98 7.21 5.23 9.06l77.79 44.91-26.93 15.55c-.27.18-.61.21-.91.08l-64.42-37.22c-28.63-16.58-38.45-53.21-21.95-81.89zm221.26 51.49-77.79-44.92 26.93-15.54c.27-.18.61-.21.91-.08l64.42 37.19c28.68 16.57 38.51 53.26 21.94 81.94-7.01 12.14-18.05 21.44-31.2 26.28v-75.81c.03-3.74-1.96-7.2-5.2-9.06zm26.8-40.34c-.47-.29-1.3-.79-1.89-1.13l-63.72-36.8c-3.23-1.89-7.23-1.89-10.47 0l-77.79 44.92v-31.1c-.02-.32.13-.63.38-.83l64.41-37.16c28.69-16.55 65.37-6.7 81.91 22 6.99 12.12 9.52 26.31 7.15 40.1zm-168.51 55.43-26.94-15.55c-.29-.14-.48-.42-.52-.74v-74.39c.02-33.12 26.89-59.96 60.01-59.94 14.01 0 27.57 4.92 38.34 13.88-.49.26-1.33.73-1.89 1.07l-63.72 36.8c-3.26 1.85-5.26 5.31-5.24 9.06l-.04 89.79zm14.63-31.54 34.65-20.01 34.65 20v40.01l-34.65 20-34.65-20z" fill="currentColor" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/** Claude. */
|
||||
export function ClaudeMark({ className }: AiClientMarkProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" className={className} aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z" fill="#D97757" fillRule="nonzero" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/** Claude Code — the CLI mark, distinct from the Claude app mark above. */
|
||||
export function ClaudeCodeMark({ className }: AiClientMarkProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" className={className} aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
clipRule="evenodd"
|
||||
d="M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z"
|
||||
fill="#D97757"
|
||||
fillRule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenAI Codex. The glyph is inset in its 24-unit box because the upstream mark
|
||||
* centres it on a plate; without that plate it reads 20% smaller than the other
|
||||
* marks, so the viewBox is tightened by exactly that factor around the centre.
|
||||
*/
|
||||
export function CodexMark({ className }: AiClientMarkProps) {
|
||||
return (
|
||||
<svg viewBox="2 2 20 20" className={className} aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
|
||||
{/* The upstream mark ships a white rounded-square plate behind the glyph.
|
||||
Dropped: on the app surfaces this sits on, the plate reads as a stray
|
||||
white tile rather than part of the logo. */}
|
||||
<path
|
||||
d="M9.064 3.344a4.578 4.578 0 012.285-.312c1 .115 1.891.54 2.673 1.275.01.01.024.017.037.021a.09.09 0 00.043 0 4.55 4.55 0 013.046.275l.047.022.116.057a4.581 4.581 0 012.188 2.399c.209.51.313 1.041.315 1.595a4.24 4.24 0 01-.134 1.223.123.123 0 00.03.115c.594.607.988 1.33 1.183 2.17.289 1.425-.007 2.71-.887 3.854l-.136.166a4.548 4.548 0 01-2.201 1.388.123.123 0 00-.081.076c-.191.551-.383 1.023-.74 1.494-.9 1.187-2.222 1.846-3.711 1.838-1.187-.006-2.239-.44-3.157-1.302a.107.107 0 00-.105-.024c-.388.125-.78.143-1.204.138a4.441 4.441 0 01-1.945-.466 4.544 4.544 0 01-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81 5.81 0 01-.37-.961 4.582 4.582 0 01-.014-2.298.124.124 0 00.006-.056.085.085 0 00-.027-.048 4.467 4.467 0 01-1.034-1.651 3.896 3.896 0 01-.251-1.192 5.189 5.189 0 01.141-1.6c.337-1.112.982-1.985 1.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098 0 00.065-.066 4.51 4.51 0 01.829-1.615 4.535 4.535 0 011.837-1.388zm3.482 10.565a.637.637 0 000 1.272h3.636a.637.637 0 100-1.272h-3.636zM8.462 9.23a.637.637 0 00-1.106.631l1.272 2.224-1.266 2.136a.636.636 0 101.095.649l1.454-2.455a.636.636 0 00.005-.64L8.462 9.23z"
|
||||
fill="url(#hg-codex-0)"
|
||||
/>
|
||||
<defs>
|
||||
<linearGradient gradientUnits="userSpaceOnUse" id="hg-codex-0" x1="12" x2="12" y1="3" y2="21">
|
||||
<stop stopColor="#B1A7FF" />
|
||||
<stop offset=".5" stopColor="#7A9DFF" />
|
||||
<stop offset="1" stopColor="#3941FF" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/** GitHub Copilot. */
|
||||
export function CopilotMark({ className }: AiClientMarkProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" className={className} aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17.533 1.829A2.528 2.528 0 0015.11 0h-.737a2.531 2.531 0 00-2.484 2.087l-1.263 6.937.314-1.08a2.528 2.528 0 012.424-1.833h4.284l1.797.706 1.731-.706h-.505a2.528 2.528 0 01-2.423-1.829l-.715-2.453z" fill="url(#hg-copilot-0)" transform="translate(0 1)" /><path d="M6.726 20.16A2.528 2.528 0 009.152 22h1.566c1.37 0 2.49-1.1 2.525-2.48l.17-6.69-.357 1.228a2.528 2.528 0 01-2.423 1.83h-4.32l-1.54-.842-1.667.843h.497c1.124 0 2.113.75 2.426 1.84l.697 2.432z" fill="url(#hg-copilot-1)" transform="translate(0 1)" /><path d="M15 0H6.252c-2.5 0-4 3.331-5 6.662-1.184 3.947-2.734 9.225 1.75 9.225H6.78c1.13 0 2.12-.753 2.43-1.847.657-2.317 1.809-6.359 2.713-9.436.46-1.563.842-2.906 1.43-3.742A1.97 1.97 0 0115 0" fill="url(#hg-copilot-2)" transform="translate(0 1)" /><path d="M15 0H6.252c-2.5 0-4 3.331-5 6.662-1.184 3.947-2.734 9.225 1.75 9.225H6.78c1.13 0 2.12-.753 2.43-1.847.657-2.317 1.809-6.359 2.713-9.436.46-1.563.842-2.906 1.43-3.742A1.97 1.97 0 0115 0" fill="url(#hg-copilot-3)" transform="translate(0 1)" /><path d="M9 22h8.749c2.5 0 4-3.332 5-6.663 1.184-3.948 2.734-9.227-1.75-9.227H17.22c-1.129 0-2.12.754-2.43 1.848a1149.2 1149.2 0 01-2.713 9.437c-.46 1.564-.842 2.907-1.43 3.743A1.97 1.97 0 019 22" fill="url(#hg-copilot-4)" transform="translate(0 1)" /><path d="M9 22h8.749c2.5 0 4-3.332 5-6.663 1.184-3.948 2.734-9.227-1.75-9.227H17.22c-1.129 0-2.12.754-2.43 1.848a1149.2 1149.2 0 01-2.713 9.437c-.46 1.564-.842 2.907-1.43 3.743A1.97 1.97 0 019 22" fill="url(#hg-copilot-5)" transform="translate(0 1)" /><defs><radialGradient cx="85.44%" cy="100.653%" fx="85.44%" fy="100.653%" gradientTransform="scale(-.8553 -1) rotate(50.927 2.041 -1.946)" id="hg-copilot-0" r="105.116%"><stop offset="9.6%" stopColor="#00AEFF" /><stop offset="77.3%" stopColor="#2253CE" /><stop offset="100%" stopColor="#0736C4" /></radialGradient><radialGradient cx="18.143%" cy="32.928%" fx="18.143%" fy="32.928%" gradientTransform="scale(.8897 1) rotate(52.069 .193 .352)" id="hg-copilot-1" r="95.612%"><stop offset="0%" stopColor="#FFB657" /><stop offset="63.4%" stopColor="#FF5F3D" /><stop offset="92.3%" stopColor="#C02B3C" /></radialGradient><radialGradient cx="82.987%" cy="-9.792%" fx="82.987%" fy="-9.792%" gradientTransform="scale(-1 -.9441) rotate(-70.872 .142 1.17)" id="hg-copilot-4" r="140.622%"><stop offset="6.6%" stopColor="#8C48FF" /><stop offset="50%" stopColor="#F2598A" /><stop offset="89.6%" stopColor="#FFB152" /></radialGradient><linearGradient id="hg-copilot-2" x1="39.465%" x2="46.884%" y1="12.117%" y2="103.774%"><stop offset="15.6%" stopColor="#0D91E1" /><stop offset="48.7%" stopColor="#52B471" /><stop offset="65.2%" stopColor="#98BD42" /><stop offset="93.7%" stopColor="#FFC800" /></linearGradient><linearGradient id="hg-copilot-3" x1="45.949%" x2="50%" y1="0%" y2="100%"><stop offset="0%" stopColor="#3DCBFF" /><stop offset="24.7%" stopColor="#0588F7" stopOpacity="0" /></linearGradient><linearGradient id="hg-copilot-5" x1="83.507%" x2="83.453%" y1="-6.106%" y2="21.131%"><stop offset="5.8%" stopColor="#F8ADFA" /><stop offset="70.8%" stopColor="#A86EDD" stopOpacity="0" /></linearGradient></defs>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/** Gemini. */
|
||||
export function GeminiMark({ className }: AiClientMarkProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" className={className} aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="#3186FF" /><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#hg-gemini-0)" /><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#hg-gemini-1)" /><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#hg-gemini-2)" /><defs><linearGradient gradientUnits="userSpaceOnUse" id="hg-gemini-0" x1="7" x2="11" y1="15.5" y2="12"><stop stopColor="#08B962" /><stop offset="1" stopColor="#08B962" stopOpacity="0" /></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="hg-gemini-1" x1="8" x2="11.5" y1="5.5" y2="11"><stop stopColor="#F94543" /><stop offset="1" stopColor="#F94543" stopOpacity="0" /></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="hg-gemini-2" x1="3.5" x2="17.5" y1="13.5" y2="12"><stop stopColor="#FABC12" /><stop offset=".46" stopColor="#FABC12" stopOpacity="0" /></linearGradient></defs>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Shared mark lookup for everything that names an AI client: the connect
|
||||
// dialog's setup guides and connection rows, and the OAuth consent screen.
|
||||
// The icon id itself is decided in the view-model (`resolveMcpClientIcon`), so
|
||||
// this module only maps an id to a glyph.
|
||||
|
||||
import { FeatherCode, FeatherLink } from "@subframe/core";
|
||||
|
||||
import { ChatGptMark, ClaudeCodeMark, ClaudeMark, CodexMark, CopilotMark, GeminiMark } from "./AiClientMarks";
|
||||
|
||||
// Brand marks where a client has one, generic icons for the catch-all rows.
|
||||
export const CLIENT_ICONS: Record<string, React.ReactNode> = {
|
||||
claude: <ClaudeMark className="h-full w-full" />,
|
||||
"claude-code": <ClaudeCodeMark className="h-full w-full" />,
|
||||
chatgpt: <ChatGptMark className="text-icon-neutral-primary h-full w-full" />,
|
||||
codex: <CodexMark className="h-full w-full" />,
|
||||
copilot: <CopilotMark className="h-full w-full" />,
|
||||
gemini: <GeminiMark className="h-full w-full" />,
|
||||
code: <FeatherCode />,
|
||||
link: <FeatherLink />,
|
||||
};
|
||||
|
||||
/** Square, currentColor-tinted slot for one client's mark. */
|
||||
export function ClientIcon({ icon, className = "h-4 w-4" }: { icon: string; className?: string }) {
|
||||
return (
|
||||
<span
|
||||
className={`text-icon-neutral-secondary flex shrink-0 items-center justify-center [&>svg]:h-full [&>svg]:w-full ${className}`}
|
||||
>
|
||||
{CLIENT_ICONS[icon] ?? <FeatherLink />}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import "@testing-library/jest-dom";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { buildMcpConnectVM, type McpConnectVM } from "@hivegrid/view-models";
|
||||
|
||||
import { McpConnectDialog } from "./McpConnectDialog";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key, i18n: { language: "de" } }),
|
||||
}));
|
||||
|
||||
function readyVM(tokens: Parameters<typeof buildMcpConnectVM>[0]["tokens"] = []): McpConnectVM {
|
||||
return buildMcpConnectVM({
|
||||
connectorUrl: "https://staging-mcp.hivegrid.de",
|
||||
tenantName: "Acme",
|
||||
appName: "HiveGrid",
|
||||
tokens,
|
||||
canRevoke: true,
|
||||
nowIso: "2026-07-28T12:00:00.000Z",
|
||||
});
|
||||
}
|
||||
|
||||
describe("McpConnectDialog", () => {
|
||||
it("shows the connector URL a client has to be pointed at", () => {
|
||||
render(<McpConnectDialog open vm={readyVM()} onOpenChange={() => {}} onRevoke={() => {}} />);
|
||||
|
||||
expect(screen.getByText("https://staging-mcp.hivegrid.de")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("offers a setup guide per supported client", () => {
|
||||
render(<McpConnectDialog open vm={readyVM()} onOpenChange={() => {}} onRevoke={() => {}} />);
|
||||
|
||||
for (const guide of ["claude-code", "claude-desktop", "chatgpt", "copilot", "codex", "gemini", "editors", "manual"]) {
|
||||
expect(document.querySelector(`[data-ui-id="ui.mcp.connect.guide.${guide}"]`)).not.toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
it("explains the empty state instead of showing a bare list", () => {
|
||||
render(<McpConnectDialog open vm={readyVM()} onOpenChange={() => {}} onRevoke={() => {}} />);
|
||||
|
||||
expect(screen.getByText("mcp.connect.connections.empty")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("hands the client id to the revoke callback", () => {
|
||||
const onRevoke = vi.fn();
|
||||
const vm = readyVM([
|
||||
{
|
||||
clientId: "client-1",
|
||||
clientName: "Claude",
|
||||
scopes: ["mcp:read"],
|
||||
createdAtIso: "2026-07-20T08:00:00.000Z",
|
||||
expiresAtIso: "2026-07-28T18:00:00.000Z",
|
||||
revoked: false,
|
||||
},
|
||||
]);
|
||||
render(<McpConnectDialog open vm={vm} onOpenChange={() => {}} onRevoke={onRevoke} />);
|
||||
|
||||
fireEvent.click(screen.getByText("mcp.connect.connections.revoke"));
|
||||
|
||||
expect(onRevoke).toHaveBeenCalledWith("client-1");
|
||||
});
|
||||
|
||||
it("says what is happening while the data is still loading", () => {
|
||||
render(<McpConnectDialog open vm={{ status: "loading" }} onOpenChange={() => {}} onRevoke={() => {}} />);
|
||||
|
||||
expect(screen.getByText("mcp.connect.loading")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows plain-text error copy instead of an endless spinner", () => {
|
||||
render(
|
||||
<McpConnectDialog
|
||||
open
|
||||
vm={{ status: "error", error: { messageKey: "mcp.connect.error" } }}
|
||||
onOpenChange={() => {}}
|
||||
onRevoke={() => {}}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText("mcp.connect.error")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
// VD-MCP Interim-UI (AD-28) — "Mit KI verbinden" as a shell dialog, modelled on
|
||||
// the Subframe "Connect to code" modal: one accordion per client, each step a
|
||||
// copyable command or URL. Presentational only: the shell injects the VM and the
|
||||
// revoke callback, so there is no useLoaderData/useFetcher in here (DoD A.5).
|
||||
// Final Subframe optics land as a tracked design-nachzug.
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherX } from "@subframe/core";
|
||||
import type { McpClientGuideVM, McpConnectionVM, McpConnectVM } from "@hivegrid/view-models";
|
||||
|
||||
import { Accordion } from "~/ui/components/Accordion";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { CopyToClipboardButton } from "~/ui/components/CopyToClipboardButton";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { IconButton } from "~/ui/components/IconButton";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { ClientIcon } from "./ClientIcon";
|
||||
|
||||
export type McpConnectDialogProps = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
vm: McpConnectVM;
|
||||
/** Cuts one client's tokens; the shell reloads the VM afterwards. */
|
||||
onRevoke: (clientId: string) => void;
|
||||
/** Client id currently being revoked, for the pending button state. */
|
||||
revokingClientId?: string | null;
|
||||
};
|
||||
|
||||
export function McpConnectDialog({ open, onOpenChange, vm, onRevoke, revokingClientId = null }: McpConnectDialogProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog.Content className="w-[620px] max-w-[94vw] p-0" data-ui-id="ui.mcp.connect.dialog">
|
||||
<div className="flex w-full flex-col gap-6 p-6">
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex flex-col items-start gap-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-heading- font-heading- text-text-neutral-primary">{t("mcp.connect.title")}</span>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{vm.status === "ready"
|
||||
? t("mcp.connect.subtitle", { tenantName: vm.data.tenantName, appName: vm.data.appName })
|
||||
: t("mcp.connect.subtitleFallback")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<IconButton variant="ghost" size="small" icon={<FeatherX />} aria-label={t("shared.close")} onClick={() => onOpenChange(false)} />
|
||||
</div>
|
||||
|
||||
{vm.status === "loading" || vm.status === "idle" ? (
|
||||
<p className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary" data-ui-id="ui.mcp.connect.loading">
|
||||
{t("mcp.connect.loading")}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{vm.status === "error" ? (
|
||||
<p className="text-body-default-regular-0 font-body-default-regular-0 text-text-feedback-negative" data-ui-id="ui.mcp.connect.error">
|
||||
{t(vm.error.messageKey, { defaultValue: t("mcp.connect.error") })}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{vm.status === "ready" ? (
|
||||
<>
|
||||
<section className="flex w-full flex-col gap-2">
|
||||
<span className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary">{t("mcp.connect.connectorHeading")}</span>
|
||||
<CopyRow value={vm.data.connectorUrl} label={t("mcp.connect.connectorCopy")} uiId="ui.mcp.connect.connectorUrl" />
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("mcp.connect.connectorHint")}</span>
|
||||
</section>
|
||||
|
||||
<section className="flex w-full flex-col gap-2">
|
||||
<span className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary">{t("mcp.connect.setupHeading")}</span>
|
||||
{vm.data.guides.map((guide) => (
|
||||
<GuideAccordion key={guide.id} guide={guide} />
|
||||
))}
|
||||
</section>
|
||||
|
||||
<section className="flex w-full flex-col gap-2">
|
||||
<span className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary">
|
||||
{t("mcp.connect.connectionsHeading")}
|
||||
</span>
|
||||
{vm.data.connections.length === 0 ? (
|
||||
<p
|
||||
className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary"
|
||||
data-ui-id="ui.mcp.connect.connections.empty"
|
||||
>
|
||||
{t("mcp.connect.connections.empty")}
|
||||
</p>
|
||||
) : (
|
||||
<ul className="flex w-full list-none flex-col gap-2 p-0">
|
||||
{vm.data.connections.map((connection) => (
|
||||
<ConnectionRow
|
||||
key={connection.id}
|
||||
connection={connection}
|
||||
canRevoke={vm.data.canRevoke}
|
||||
pending={revokingClientId === connection.id}
|
||||
onRevoke={onRevoke}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function GuideAccordion({ guide }: { guide: McpClientGuideVM }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Accordion
|
||||
data-ui-id={`ui.mcp.connect.guide.${guide.id}`}
|
||||
trigger={
|
||||
<div className="flex w-full items-center gap-2 px-3 py-2.5">
|
||||
<ClientIcon icon={guide.icon} />
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary grow">{t(guide.labelKey)}</span>
|
||||
<Accordion.Chevron />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="flex w-full flex-col gap-3 px-3 pb-3">
|
||||
{guide.steps.map((step) => (
|
||||
<div key={step.id} className="flex w-full flex-col gap-1">
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">{t(step.titleKey)}</span>
|
||||
{step.hintKey ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t(step.hintKey)}</span>
|
||||
) : null}
|
||||
{step.copyText ? <CopyRow value={step.copyText} label={t("mcp.connect.copy")} uiId={`ui.mcp.connect.guide.${guide.id}.${step.id}`} /> : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Accordion>
|
||||
);
|
||||
}
|
||||
|
||||
function CopyRow({ value, label, uiId }: { value: string; label: string; uiId: string }) {
|
||||
return (
|
||||
<div
|
||||
className="border-border-default bg-surface-neutral-secondary flex w-full items-start gap-2 rounded-md border border-solid px-3 py-2"
|
||||
data-ui-id={uiId}
|
||||
>
|
||||
<code className="text-body-small-regular-0 text-text-neutral-primary min-w-0 grow font-mono break-all whitespace-pre-wrap">{value}</code>
|
||||
<CopyToClipboardButton clipboardText={value} tooltipText={label} aria-label={label} successKey="mcp.connect.toast.configurationCopied" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ConnectionRow({
|
||||
connection,
|
||||
canRevoke,
|
||||
pending,
|
||||
onRevoke,
|
||||
}: {
|
||||
connection: McpConnectionVM;
|
||||
canRevoke: boolean;
|
||||
pending: boolean;
|
||||
onRevoke: (clientId: string) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<li
|
||||
className="border-border-default flex w-full items-center gap-3 rounded-md border border-solid px-3 py-2"
|
||||
data-ui-id={`ui.mcp.connect.connection.${connection.id}`}
|
||||
>
|
||||
{/* The client's own mark identifies the row; the live/expired state moved
|
||||
into the meta line so the icon slot can carry the brand. */}
|
||||
<ClientIcon icon={connection.icon} />
|
||||
<div className="flex min-w-0 grow flex-col">
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary truncate">
|
||||
{connection.clientName || t("mcp.connect.connections.unnamedClient")}
|
||||
</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
<span className={connection.expired ? "text-text-neutral-tertiary" : "text-text-feedback-positive"}>
|
||||
{t(connection.expired ? "mcp.connect.connections.statusExpired" : "mcp.connect.connections.statusActive")}
|
||||
</span>{" "}
|
||||
· {t(connection.accessKey)} · {t("mcp.connect.connections.connectedAt", { date: formatters.date(connection.connectedAtIso) })}
|
||||
</span>
|
||||
</div>
|
||||
{canRevoke ? (
|
||||
<Button variant="destructive" size="small" loading={pending} onClick={() => onRevoke(connection.id)}>
|
||||
{t("mcp.connect.connections.revoke")}
|
||||
</Button>
|
||||
) : null}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
// VD-MCP — topbar entry point for the MCP connector: the pill left of the
|
||||
// global search plus the dialog it opens. Container half of the pair; it owns
|
||||
// the fetchers and the `?connect=mcp` deep link, the dialog stays purely
|
||||
// presentational.
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useFetcher, useSearchParams } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { McpConnectVM } from "@hivegrid/view-models";
|
||||
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { appPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { ChatGptMark, ClaudeCodeMark, ClaudeMark, CodexMark, CopilotMark, GeminiMark } from "./AiClientMarks";
|
||||
import { McpConnectDialog } from "./McpConnectDialog";
|
||||
|
||||
// Every client the connect dialog has a guide for. At rest the first three sit
|
||||
// in the pill; on hover the whole set rides past (see `.hg-mcp-*` in globals.css).
|
||||
const PILL_MARKS = [
|
||||
<ClaudeMark className="h-3.5 w-3.5" />,
|
||||
<ChatGptMark className="text-icon-neutral-primary h-3.5 w-3.5" />,
|
||||
<CopilotMark className="h-3.5 w-3.5" />,
|
||||
<ClaudeCodeMark className="h-3.5 w-3.5" />,
|
||||
<CodexMark className="h-3.5 w-3.5" />,
|
||||
<GeminiMark className="h-3.5 w-3.5" />,
|
||||
];
|
||||
|
||||
/** Query param that opens the dialog from a link (docs, onboarding mail). */
|
||||
export const MCP_CONNECT_SEARCH_PARAM = "connect";
|
||||
export const MCP_CONNECT_SEARCH_VALUE = "mcp";
|
||||
|
||||
type FetcherPayload = McpConnectVM | { error: string } | undefined;
|
||||
|
||||
function asVM(payload: FetcherPayload): McpConnectVM | null {
|
||||
return payload && "status" in payload ? payload : null;
|
||||
}
|
||||
|
||||
export function McpConnectLauncher({ tenantSlug }: { tenantSlug: string }) {
|
||||
const { t } = useTranslation();
|
||||
const rootData = useRootData();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const loadFetcher = useFetcher<McpConnectVM>();
|
||||
const revokeFetcher = useFetcher<FetcherPayload>();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [revokingClientId, setRevokingClientId] = useState<string | null>(null);
|
||||
|
||||
const href = appPath({ tenantSlug, path: "mcp/connect", mode: "host-aware" });
|
||||
const deepLinked = searchParams.get(MCP_CONNECT_SEARCH_PARAM) === MCP_CONNECT_SEARCH_VALUE;
|
||||
|
||||
useEffect(() => {
|
||||
if (deepLinked) setOpen(true);
|
||||
}, [deepLinked]);
|
||||
|
||||
// Load once per opening; the revoke action returns a fresh VM, so there is no
|
||||
// second round-trip after cutting a connection.
|
||||
useEffect(() => {
|
||||
if (open && loadFetcher.state === "idle" && loadFetcher.data === undefined) {
|
||||
loadFetcher.load(href);
|
||||
}
|
||||
}, [open, href, loadFetcher]);
|
||||
|
||||
useEffect(() => {
|
||||
if (revokeFetcher.state === "idle") setRevokingClientId(null);
|
||||
}, [revokeFetcher.state]);
|
||||
|
||||
function onOpenChange(next: boolean) {
|
||||
setOpen(next);
|
||||
if (!next && deepLinked) {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
params.delete(MCP_CONNECT_SEARCH_PARAM);
|
||||
setSearchParams(params, { replace: true, preventScrollReset: true });
|
||||
}
|
||||
}
|
||||
|
||||
function onRevoke(clientId: string) {
|
||||
const form = new FormData();
|
||||
form.set("intent", "revoke");
|
||||
form.set("clientId", clientId);
|
||||
if (rootData?.csrf) form.set("csrf", rootData.csrf);
|
||||
setRevokingClientId(clientId);
|
||||
revokeFetcher.submit(form, { method: "post", action: href, preventScrollReset: true });
|
||||
}
|
||||
|
||||
const loaded = asVM(revokeFetcher.data) ?? asVM(loadFetcher.data);
|
||||
// A payload that arrived but is not a VM means the route answered with an
|
||||
// error envelope — show plain text instead of an endless spinner (DoD E.24).
|
||||
const failed = loadFetcher.state === "idle" && loadFetcher.data !== undefined && asVM(loadFetcher.data) === null;
|
||||
const vm: McpConnectVM = loaded ?? (failed ? { status: "error", error: { messageKey: "mcp.connect.error" } } : { status: "loading" });
|
||||
|
||||
return (
|
||||
<>
|
||||
{/*
|
||||
Box instead of a bare icon: the client marks say what this connects to
|
||||
faster than any label, and the label says what it is. Under md the label
|
||||
drops and the marks carry the button on their own.
|
||||
*/}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpen(true)}
|
||||
// No `title`: the native tooltip would cover the hover animation with a
|
||||
// grey box repeating the label that is already next to the marks.
|
||||
aria-label={t("mcp.connect.open")}
|
||||
className="hg-mcp-pill border-border-default bg-surface-neutral-primary hover:bg-surface-neutral-secondary focus-visible:shadow-focus text-text-neutral-secondary flex h-8 shrink-0 cursor-pointer items-center gap-2 rounded-md border border-solid pr-3 pl-2.5 outline-none"
|
||||
data-ui-id="ui.mcp.connect.trigger"
|
||||
>
|
||||
<span className="hg-mcp-marks shrink-0" aria-hidden="true">
|
||||
{/* Doubled so the conveyor loops seamlessly at -50%. */}
|
||||
<span className="hg-mcp-marks-track">
|
||||
{[...PILL_MARKS, ...PILL_MARKS].map((mark, index) => (
|
||||
<span key={index} className="flex h-3.5 w-3.5 items-center justify-center">
|
||||
{mark}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
</span>
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 hidden md:inline">{t("mcp.connect.open")}</span>
|
||||
</button>
|
||||
<McpConnectDialog open={open} onOpenChange={onOpenChange} vm={vm} onRevoke={onRevoke} revokingClientId={revokingClientId} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
import { buildMcpConnectVM } from "@hivegrid/view-models";
|
||||
|
||||
import { McpConnectDialog } from "./McpConnectDialog";
|
||||
|
||||
/**
|
||||
* Deterministic real-component fixture for the VD-MCP interim pixel baseline
|
||||
* (AD-28). Every input is frozen — connector host, product name, token
|
||||
* timestamps — so a diff means the UI moved, not the environment.
|
||||
*/
|
||||
const VM = buildMcpConnectVM({
|
||||
connectorUrl: "https://mcp.hivegrid.example",
|
||||
tenantName: "HiveGrid Demo",
|
||||
appName: "HiveGrid",
|
||||
canRevoke: true,
|
||||
nowIso: "2026-07-28T12:00:00.000Z",
|
||||
tokens: [
|
||||
{
|
||||
clientId: "client-claude",
|
||||
clientName: "Claude",
|
||||
scopes: ["mcp:read", "mcp:write"],
|
||||
createdAtIso: "2026-07-20T08:00:00.000Z",
|
||||
expiresAtIso: "2026-07-28T18:00:00.000Z",
|
||||
revoked: false,
|
||||
},
|
||||
{
|
||||
clientId: "client-cursor",
|
||||
clientName: "Cursor",
|
||||
scopes: ["mcp:read"],
|
||||
// Deliberately in the past: pins the expired state next to the live one.
|
||||
createdAtIso: "2026-07-02T08:00:00.000Z",
|
||||
expiresAtIso: "2026-07-03T08:00:00.000Z",
|
||||
revoked: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export function McpConnectVisualFixture() {
|
||||
return <McpConnectDialog open vm={VM} onOpenChange={() => {}} onRevoke={() => {}} />;
|
||||
}
|
||||
|
||||
/** Empty state is its own baseline — it is what every new tenant sees first. */
|
||||
export function McpConnectEmptyVisualFixture() {
|
||||
const vm = buildMcpConnectVM({
|
||||
connectorUrl: "https://mcp.hivegrid.example",
|
||||
tenantName: "HiveGrid Demo",
|
||||
appName: "HiveGrid",
|
||||
canRevoke: true,
|
||||
nowIso: "2026-07-28T12:00:00.000Z",
|
||||
tokens: [],
|
||||
});
|
||||
return <McpConnectDialog open vm={vm} onOpenChange={() => {}} onRevoke={() => {}} />;
|
||||
}
|
||||
Reference in new issue
Block a user