Open-source SEO, GEO, and marketing skills for AI agents.
feat(notfair): per-workspace account selection for multi-account MCPs
Yuting Zhongb28be147ca84
diff --git a/notfair/CHANGELOG.md b/notfair/CHANGELOG.mdindex ed557bc2..64442f32 100644--- a/notfair/CHANGELOG.md+++ b/notfair/CHANGELOG.md@@ -1,5 +1,9 @@# NotFair+## Unreleased++**Pick which account each connection targets — right where you connect.** Multi-account MCPs (Google Ads, Meta Ads, Search Console) now resolve their workspace account/property on the Connections page, not just in onboarding. Finishing OAuth auto-keeps a still-valid selection, silently persists the only reachable account, and otherwise opens a picker dialog listing what the new token can reach. Each card carries one action tracking its setup state — **Connect** → **Choose account/property** → a quiet **Switch account/property** — with the persisted selection shown on the card (`Search Console property: sc-domain:example.com`) and Disconnect / Remove tucked into the ⋯ menu, so switching accounts never requires reconnecting. Selections persist on the workspace row and feed every goal agent's identity, keeping each workspace's agents on exactly one account per platform. Onboarding's connect step now renders the same `McpCard` rows and picker dialog as the Connections page — its bespoke connector tiles and three full-page picker steps are gone, so the Connect → Choose → Switch lifecycle is identical on both surfaces, and the picker's rows use the design system's elevated surfaces instead of borders. The account-selection layer is covered by the repo's first vitest suite (`pnpm test`).+## 0.9.0 — 2026-07-10**Renamed: notfair-cmo is now just NotFair — and the CMO is gone.** The product pivoted from "a CMO delegating to platform specialists" to **agent = goal**: you mint an agent per goal, define the goal by chatting with it, and it runs a disciplined improvement loop until the number says done. npm package `notfair-cmo` → `notfair` (bin: `notfair`), data dir `~/.notfair-cmo` → `~/.notfair` (auto-migrated on first start, merging safely with any plugin config already there), env vars `NOTFAIR_CMO_*` → `NOTFAIR_*`.diff --git a/notfair/CLAUDE.md b/notfair/CLAUDE.mdindex 65c9e818..d731031d 100644--- a/notfair/CLAUDE.md+++ b/notfair/CLAUDE.md@@ -11,14 +11,20 @@ heartbeat loop ("checks") measures the metric and lets the agent act — withobservation windows, a spend envelope, and per-goal memory as the controls.No approvals, no tasks, no orchestration layer: goals are the only unit.-## Verification (no test suite by design)+## Verification-This repo intentionally carries no unit tests, migrations, or legacy/compat-code. Verification is:+This repo carries no migrations or legacy/compat code. Verification is:1. `pnpm typecheck` — must be clean.-2. `pnpm build` — must be clean.-3. Live smoke: `pnpm dev` (port 3326), then walk the affected flow in the+2. `pnpm test` — vitest; must be clean. Tests live next to the code they+ cover (`src/lib/foo.ts` → `src/lib/foo.test.ts`). Default environment is+ node; component tests opt into a DOM with a leading+ `// @vitest-environment jsdom` pragma and use `@testing-library/react`.+ Mock at the server-action / db-module boundary (`vi.mock`), not deeper.+ Test pure logic and user-visible component behavior — don't unit-test+ Next.js pages or route handlers; the live smoke covers those.+3. `pnpm build` — must be clean.+4. Live smoke: `pnpm dev` (port 3326), then walk the affected flow in thebrowser (goal index → goal page → chat / START / checks).Prompt-affecting changes (`src/server/goals/identity.ts`, tick briefs indiff --git a/notfair/package.json b/notfair/package.jsonindex d393f2ef..39ad4bf5 100644--- a/notfair/package.json+++ b/notfair/package.json@@ -17,7 +17,9 @@"build": "next build && node scripts/copy-standalone-assets.mjs","start": "next start","cli": "tsx bin/cli.ts",- "typecheck": "tsc --noEmit"+ "typecheck": "tsc --noEmit",+ "test": "vitest run",+ "test:watch": "vitest"},"dependencies": {"@next/env": "16.2.6",@@ -48,6 +50,8 @@},"devDependencies": {"@tailwindcss/postcss": "^4.0.0",+ "@testing-library/jest-dom": "^6.9.1",+ "@testing-library/react": "^16.3.2","@types/better-sqlite3": "^7.6.0","@types/node": "^22.0.0","@types/react": "^19.0.0",@@ -56,10 +60,12 @@"@vitejs/plugin-react": "^6.0.2","eslint": "^9.0.0","eslint-config-next": "^16.2.6",+ "jsdom": "^29.1.1","postcss": "^8.4.0","tailwindcss": "^4.0.0","tsx": "^4.19.0",- "typescript": "^5.6.0"+ "typescript": "^5.6.0",+ "vitest": "^4.1.10"},"engines": {"node": ">=20"diff --git a/notfair/pnpm-lock.yaml b/notfair/pnpm-lock.yamlindex bd9ba264..d4ab89f2 100644--- a/notfair/pnpm-lock.yaml+++ b/notfair/pnpm-lock.yaml@@ -87,6 +87,12 @@ importers:'@tailwindcss/postcss':specifier: ^4.0.0version: 4.3.0+ '@testing-library/jest-dom':+ specifier: ^6.9.1+ version: 6.9.1+ '@testing-library/react':+ specifier: ^16.3.2+ version: 16.3.2(@testing-library/[email protected])(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@types/better-sqlite3':specifier: ^7.6.0version: 7.6.13@@ -111,6 +117,9 @@ importers:eslint-config-next:specifier: ^16.2.6version: 16.2.6(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])+ jsdom:+ specifier: ^29.1.1+ version: 29.1.1postcss:specifier: ^8.4.0version: 8.5.14@@ -123,13 +132,34 @@ importers:typescript:specifier: ^5.6.0version: 5.9.3+ vitest:+ specifier: ^4.1.10+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))packages:+ '@adobe/[email protected]':+ resolution: {integrity: sha512-6OzddxPio9UiWTCemp4N8cYLV2ZN1ncRnV1cVGtve7dhPOtRkleRyx32GQCYSwDYgaHU3USMm84tNsvKzRCa1Q==}+'@alloc/[email protected]':resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}engines: {node: '>=10'}+ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-KVw6qIiCTUQhByfTd78h2yD1/00waTmm9uy/R7Ck/ctUyAPj+AEDLkQIdJW0T8+qGgj3j5bpNKK7Q3G+LedJWg==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}++ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-67RZDnYRc8H/8MLDgQCDE//zoqVFwajkepHZgmXrbwybzXOEwOWGPYGmALYl9J2DOLfFPPs6kKCqmbzV895hTQ==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}++ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-wajfB8KqzMCN2KGNFdLkReeHncd0AslUSrvHVvvYWuU8ghncRJoA50kT3zP9MVL0+9g4/67H+cdvBskj9THPzg==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}++ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==}+'@babel/[email protected]':resolution: {integrity: sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==}engines: {node: '>=6.9.0'}@@ -185,6 +215,10 @@ packages:engines: {node: '>=6.0.0'}hasBin: true+ '@babel/[email protected]':+ resolution: {integrity: sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==}+ engines: {node: '>=6.9.0'}+'@babel/[email protected]':resolution: {integrity: sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==}engines: {node: '>=6.9.0'}@@ -197,6 +231,46 @@ packages:resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==}engines: {node: '>=6.9.0'}+ '@bramus/[email protected]':+ resolution: {integrity: sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==}+ hasBin: true++ '@csstools/[email protected]':+ resolution: {integrity: sha512-064IFJdjTfUqnjpCVpMOdbr8FLQBhinbZj6yRv2An2E41O/pLEXqfFRWqGq/SxlE5PEUYTlvWsG2r8MswAVvkg==}+ engines: {node: '>=20.19.0'}++ '@csstools/[email protected]':+ resolution: {integrity: sha512-DtdHlgXh5ZkA43cwBcAm+huzgJiwx3ZTWVjBs94kwz2xKqSimDA3lBgCjphYgwgVUMWatSM0pDd8TILB1yrVVg==}+ engines: {node: '>=20.19.0'}+ peerDependencies:+ '@csstools/css-parser-algorithms': ^4.0.0+ '@csstools/css-tokenizer': ^4.0.0++ '@csstools/[email protected]':+ resolution: {integrity: sha512-paQcIaOO53Rk5+YrBaBjm/SgrV4INImjo2BT1DtQRYr+XeTRbeAYlS+jxXp9drqvKmtFnWRJKIalDLhZZDu42A==}+ engines: {node: '>=20.19.0'}+ peerDependencies:+ '@csstools/css-parser-algorithms': ^4.0.0+ '@csstools/css-tokenizer': ^4.0.0++ '@csstools/[email protected]':+ resolution: {integrity: sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==}+ engines: {node: '>=20.19.0'}+ peerDependencies:+ '@csstools/css-tokenizer': ^4.0.0++ '@csstools/[email protected]':+ resolution: {integrity: sha512-TcJCWFbXLPpJYq6z7bfOyjWYJDiDg2/I4gyUC9pqPNqHFRIey0EB0q0L5cSnQDfWJg8Jd6VadakxdIez/3zkqQ==}+ peerDependencies:+ css-tree: ^3.2.1+ peerDependenciesMeta:+ css-tree:+ optional: true++ '@csstools/[email protected]':+ resolution: {integrity: sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==}+ engines: {node: '>=20.19.0'}+'@emnapi/[email protected]':resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==}@@ -400,6 +474,15 @@ packages:resolution: {integrity: sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==}engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}+ '@exodus/[email protected]':+ resolution: {integrity: sha512-S6mL0yNB/Abt9Ei4tq8gDhcczc4S3+vQ4ra7vxnAf+YHC02srtqxKKZghx2Dq6p0e66THKwR6r8N6P95wEty7Q==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+ peerDependencies:+ '@noble/hashes': ^1.8.0 || ^2.0.0+ peerDependenciesMeta:+ '@noble/hashes':+ optional: true+'@floating-ui/[email protected]':resolution: {integrity: sha512-1Ih4WTWyw0+lKyFMcBHGbb5U5FtuHJuujoyyr5zTaWS5EYMeT6Jb2AuDeftsCsEuchO+mM2ij5+q9crhydzLhQ==}@@ -1494,6 +1577,9 @@ packages:'@rtsao/[email protected]':resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==}+ '@standard-schema/[email protected]':+ resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==}+'@swc/[email protected]':resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}@@ -1592,15 +1678,47 @@ packages:'@tailwindcss/[email protected]':resolution: {integrity: sha512-Jm05Tjx+9yCLGv5qw1c+84Psds8MnyrEQYCB+FFk2lgGiUjlRqdxke4mVTuYrj2xnVZqKim2Apr5ySuQRYAw/w==}+ '@testing-library/[email protected]':+ resolution: {integrity: sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==}+ engines: {node: '>=18'}++ '@testing-library/[email protected]':+ resolution: {integrity: sha512-zIcONa+hVtVSSep9UT3jZ5rizo2BsxgyDYU7WFD5eICBE7no3881HGeb/QkGfsJs6JTkY1aQhT7rIPC7e+0nnA==}+ engines: {node: '>=14', npm: '>=6', yarn: '>=1'}++ '@testing-library/[email protected]':+ resolution: {integrity: sha512-XU5/SytQM+ykqMnAnvB2umaJNIOsLF3PVv//1Ew4CTcpz0/BRyy/af40qqrt7SjKpDdT1saBMc42CUok5gaw+g==}+ engines: {node: '>=18'}+ peerDependencies:+ '@testing-library/dom': ^10.0.0+ '@types/react': ^18.0.0 || ^19.0.0+ '@types/react-dom': ^18.0.0 || ^19.0.0+ react: ^18.0.0 || ^19.0.0+ react-dom: ^18.0.0 || ^19.0.0+ peerDependenciesMeta:+ '@types/react':+ optional: true+ '@types/react-dom':+ optional: true+'@tybys/[email protected]':resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==}+ '@types/[email protected]':+ resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==}+'@types/[email protected]':resolution: {integrity: sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==}+ '@types/[email protected]':+ resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==}+'@types/[email protected]':resolution: {integrity: sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==}+ '@types/[email protected]':+ resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}+'@types/[email protected]':resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==}@@ -1820,6 +1938,35 @@ packages:babel-plugin-react-compiler:optional: true+ '@vitest/[email protected]':+ resolution: {integrity: sha512-YsCn+qAk1GWjQOWFEsEcL2gNQ0zmVmQu3T03qP6UyjhtmdtwtbuI+DASn/7iQB3HGTXkdBwGddzxPlmiql5vlA==}++ '@vitest/[email protected]':+ resolution: {integrity: sha512-v0xaezt+DKEmKfaxg133ldzADrwLGd7Ze1MfQQTYfvs8OqZIwbxyxaYURivwV7sWy5fqn3rH5uOrSp07bp44Ow==}+ peerDependencies:+ msw: ^2.4.9+ vite: ^6.0.0 || ^7.0.0 || ^8.0.0+ peerDependenciesMeta:+ msw:+ optional: true+ vite:+ optional: true++ '@vitest/[email protected]':+ resolution: {integrity: sha512-W1HsjSH4MXQ9YfmmhLAoIYf1HRfekQCGngeIgcei6MP5QQGWUe0gkopdZQaVCFO+JDJMrAJGwa5pRpNpvy4P8Q==}++ '@vitest/[email protected]':+ resolution: {integrity: sha512-IKI6kpIH+LmpROplyLwBBaCfMgOZOMsygVa6BARD6ahA04VRuJSa6OaVG7kRvSEMD870Vd91rSSw0eegtWyLGg==}++ '@vitest/[email protected]':+ resolution: {integrity: sha512-xRkfOT1qpTAi/Ti4Y1LtfRc3kEuqxGw59eN2jN9pRWMtS/XDevekhcFSqvQqjUNGksfjMJu3Y+oJ+4Ypn2OaJw==}++ '@vitest/[email protected]':+ resolution: {integrity: sha512-PLf/Ugvoq5wO/b4rwYCR1h2PSIdXz7wnkQFMiUpLdtM7l6pqVFcQIBEHyT1+l+cj7mNwAfZHzqXqDyjvOuwbDw==}++ '@vitest/[email protected]':+ resolution: {integrity: sha512-fy9am/HWxbaGt/Sawrp90vt6Y6jQwf1RX77cz3uwoJwJVMli/e1IEwRPnMNJ7vKfPTwo0diXifkpPvwH9v7nGA==}+resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}peerDependencies:@@ -1833,10 +1980,18 @@ packages:resolution: {integrity: sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==}+ resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}+ engines: {node: '>=8'}+resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}engines: {node: '>=8'}+ resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==}+ engines: {node: '>=10'}+resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}@@ -1844,6 +1999,9 @@ packages:resolution: {integrity: sha512-ik3ZgC9dY/lYVVM++OISsaYDeg1tb0VtP5uL3ouh1koGOaUMDPpbFIei4JkFimWUFPn90sbMNMXQAIVOlnYKJA==}engines: {node: '>=10'}+ resolution: {integrity: sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==}+resolution: {integrity: sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==}engines: {node: '>= 0.4'}@@ -1880,6 +2038,10 @@ packages:resolution: {integrity: sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}+ engines: {node: '>=12'}+resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==}@@ -1921,6 +2083,9 @@ packages:resolution: {integrity: sha512-CyzaZRQKyHkB2ZInfTTl2nvT33EbDpjkLEbE8/Zck3Ll6O0qqvuGdrJ45HgtH+HykRg88ITY3AdreBGN70aBSQ==}engines: {node: 20.x || 22.x || 23.x || 24.x || 25.x || 26.x}+ resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==}+resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}@@ -1972,6 +2137,10 @@ packages:resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}+ resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==}+ engines: {node: '>=18'}+resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}engines: {node: '>=10'}@@ -2029,12 +2198,23 @@ packages:resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}engines: {node: '>= 8'}+ resolution: {integrity: sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==}+ engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}++ resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==}+resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==}+ resolution: {integrity: sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+resolution: {integrity: sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==}engines: {node: '>= 0.4'}@@ -2064,6 +2244,9 @@ packages:supports-color:optional: true+ resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==}+resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==}@@ -2116,6 +2299,12 @@ packages:resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==}engines: {node: '>=0.10.0'}+ resolution: {integrity: sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==}++ resolution: {integrity: sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==}+resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}engines: {node: '>= 0.4'}@@ -2133,6 +2322,10 @@ packages:resolution: {integrity: sha512-QyL119InA+XXEkNLNTPCXPugSvOfhwv0JOlGNzvxs0hZaiHLNvXSpudUWsOlsXGWJh8G6ckCScEkVHfX3kw/2Q==}engines: {node: '>=10.13.0'}+ resolution: {integrity: sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==}+ engines: {node: '>=20.19.0'}+resolution: {integrity: sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==}engines: {node: '>= 0.4'}@@ -2149,6 +2342,9 @@ packages:resolution: {integrity: sha512-HVLACW1TppGYjJ8H6/jqH/pqOtKRw6wMlrB23xfExmFWxFquAIWCmwoLsOyN96K4a5KbmOf5At9ZUO3GZbetAw==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-shc1dbU90Yl/xq1QrC7QRtfcwURZuVRfPhZbDoldJ1cn1gzDvBaBWlv0eFolj5+0znnPJz5TXLxsN77X/12KTA==}+resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==}engines: {node: '>= 0.4'}@@ -2301,6 +2497,9 @@ packages:resolution: {integrity: sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==}+ resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}+resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}engines: {node: '>=0.10.0'}@@ -2309,6 +2508,10 @@ packages:resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}engines: {node: '>=6'}+ resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==}+ engines: {node: '>=12.0.0'}+resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==}@@ -2477,6 +2680,10 @@ packages:resolution: {integrity: sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==}+ resolution: {integrity: sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+resolution: {integrity: sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ==}@@ -2499,6 +2706,10 @@ packages:resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==}engines: {node: '>=0.8.19'}+ resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==}+ engines: {node: '>=8'}+resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}@@ -2605,6 +2816,9 @@ packages:resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==}engines: {node: '>=12'}+ resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==}+resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==}engines: {node: '>= 0.4'}@@ -2666,6 +2880,15 @@ packages:resolution: {integrity: sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==}hasBin: true+ resolution: {integrity: sha512-ECi4Fi2f7BdJtUKTflYRTiaMxIB0O6zfR1fX0GXpUrf6flp8QIYn1UT20YQqdSOfk2dfkCwS8LAFoJDEppNK5Q==}+ engines: {node: ^20.19.0 || ^22.13.0 || >=24.0.0}+ peerDependencies:+ canvas: ^3.0.0+ peerDependenciesMeta:+ canvas:+ optional: true+resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==}engines: {node: '>=6'}@@ -2798,6 +3021,10 @@ packages:resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}hasBin: true+ resolution: {integrity: sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==}+ engines: {node: 20 || >=22}+resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}@@ -2810,6 +3037,10 @@ packages:resolution: {integrity: sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==}engines: {node: '>=12'}+ resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==}+ hasBin: true+resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}@@ -2865,6 +3096,9 @@ packages:resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==}+ resolution: {integrity: sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==}+resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}engines: {node: '>= 8'}@@ -2961,6 +3195,10 @@ packages:resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}engines: {node: '>=10'}+ resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==}+ engines: {node: '>=4'}+resolution: {integrity: sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==}engines: {node: 18 || 20 || >=22}@@ -3066,6 +3304,10 @@ packages:resolution: {integrity: sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-9miFgM2OFba7hB+pRgvtV84pYTBaoTHohvmIgiRt6dRIzbwEOIaNaP+dIlGs2fNFoB0SeISs0Jz5WFVRid6Xyg==}+ engines: {node: '>=12.20.0'}+resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}@@ -3096,6 +3338,9 @@ packages:resolution: {integrity: sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw==}+ resolution: {integrity: sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==}+resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}engines: {node: '>=8'}@@ -3107,6 +3352,9 @@ packages:resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}+ resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}+resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}@@ -3145,6 +3393,10 @@ packages:resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}engines: {node: '>= 0.8.0'}+ resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}+ engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}+resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}@@ -3186,6 +3438,9 @@ packages:resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}+ resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}+resolution: {integrity: sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==}peerDependencies:@@ -3230,6 +3485,10 @@ packages:resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}engines: {node: '>= 6'}+ resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==}+ engines: {node: '>=8'}+resolution: {integrity: sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==}engines: {node: '>= 0.4'}@@ -3250,6 +3509,10 @@ packages:resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==}+ resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}+ engines: {node: '>=0.10.0'}+resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}engines: {node: '>=4'}@@ -3293,6 +3556,10 @@ packages:resolution: {integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==}+ engines: {node: '>=v12.22.7'}+resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==}@@ -3345,6 +3612,9 @@ packages:resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}+resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}@@ -3367,6 +3637,12 @@ packages:resolution: {integrity: sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA==}+ resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}++ resolution: {integrity: sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==}+resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==}engines: {node: '>= 0.4'}@@ -3404,6 +3680,10 @@ packages:resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==}engines: {node: '>=4'}+ resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==}+ engines: {node: '>=8'}+resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==}engines: {node: '>=0.10.0'}@@ -3439,6 +3719,9 @@ packages:resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}+resolution: {integrity: sha512-Oo6tHdpZsGpkKG88HJ8RR1rg/RdnEkQEfMoEk2x1XRI3F1AxeU+ijRXpiVUF4UbLfcxxRGw6TbUINKYdWVsQTQ==}@@ -3456,14 +3739,40 @@ packages:resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}engines: {node: '>=6'}+ resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}++ resolution: {integrity: sha512-SHf/r48b7vOrjve9PxJo3MN5v5yuyjHvdUcrQffT3WXMUfnGmHDVbC4k3sHJaJTgZCwpUplIaAo5ANtMyp3YHg==}+ engines: {node: '>=18'}+resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==}engines: {node: '>=12.0.0'}+ resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==}+ engines: {node: '>=14.0.0'}++ resolution: {integrity: sha512-c1P7u0EhACHj7lPy4MJm8iTFEU8+nB0LCtddH0fhP7noaVoXAqafMtOOeX+ulpuPBqnrRgRhw494RICT3mbhnw==}++ resolution: {integrity: sha512-htwgN/8KRB3z3vnC0BOETVh2m499g5GmyTK9Wq5JBLX3FNz6tSBveAd+fQhzy9hkjif8vy2jwDMR1sGhLtZl2A==}+ hasBin: true+resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}engines: {node: '>=8.0'}+ resolution: {integrity: sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==}+ engines: {node: '>=16'}++ resolution: {integrity: sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==}+ engines: {node: '>=20'}+resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==}@@ -3529,6 +3838,10 @@ packages:resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}+ resolution: {integrity: sha512-cRZYrTDwWznlnRiPjggAGxZXanty6M8RV1ff8Wm4LWXBp7/IG8v5DnOm74DtUBp9OONpK75YlPnIjQqX0dBDtA==}+ engines: {node: '>=20.18.1'}+resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==}@@ -3636,6 +3949,63 @@ packages:yaml:optional: true+ resolution: {integrity: sha512-R9jUTe5S4Qb0HCd4TNqpC7oGcrMssMRGXLW80ubjWsW9VH5GF8y1Y0SFLY9AbqSk6nt0PnOx4H4WNJYZ13GUPw==}+ engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0}+ hasBin: true+ peerDependencies:+ '@edge-runtime/vm': '*'+ '@opentelemetry/api': ^1.9.0+ '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0+ '@vitest/browser-playwright': 4.1.10+ '@vitest/browser-preview': 4.1.10+ '@vitest/browser-webdriverio': 4.1.10+ '@vitest/coverage-istanbul': 4.1.10+ '@vitest/coverage-v8': 4.1.10+ '@vitest/ui': 4.1.10+ happy-dom: '*'+ jsdom: '*'+ vite: ^6.0.0 || ^7.0.0 || ^8.0.0+ peerDependenciesMeta:+ '@edge-runtime/vm':+ optional: true+ '@opentelemetry/api':+ optional: true+ '@types/node':+ optional: true+ '@vitest/browser-playwright':+ optional: true+ '@vitest/browser-preview':+ optional: true+ '@vitest/browser-webdriverio':+ optional: true+ '@vitest/coverage-istanbul':+ optional: true+ '@vitest/coverage-v8':+ optional: true+ '@vitest/ui':+ optional: true+ happy-dom:+ optional: true+ jsdom:+ optional: true++ resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==}+ engines: {node: '>=18'}++ resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==}+ engines: {node: '>=20'}++ resolution: {integrity: sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==}+ engines: {node: '>=20'}++ resolution: {integrity: sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==}engines: {node: '>= 0.4'}@@ -3657,6 +4027,11 @@ packages:engines: {node: '>= 8'}hasBin: true+ resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}+ engines: {node: '>=8'}+ hasBin: true+resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}engines: {node: '>=0.10.0'}@@ -3680,6 +4055,13 @@ packages:resolution: {integrity: sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==}engines: {node: '>=18'}+ resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==}+ engines: {node: '>=18'}++ resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}+resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}@@ -3701,8 +4083,30 @@ packages:snapshots:+ '@adobe/[email protected]': {}+'@alloc/[email protected]': {}+ '@asamuzakjp/[email protected]':+ dependencies:+ '@asamuzakjp/generational-cache': 1.0.1+ '@csstools/css-calc': 3.2.1(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])+ '@csstools/css-color-parser': 4.1.9(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])+ '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])+ '@csstools/css-tokenizer': 4.0.0++ '@asamuzakjp/[email protected]':+ dependencies:+ '@asamuzakjp/generational-cache': 1.0.1+ '@asamuzakjp/nwsapi': 2.3.9+ bidi-js: 1.0.3+ css-tree: 3.2.1+ is-potential-custom-element-name: 1.0.1++ '@asamuzakjp/[email protected]': {}++ '@asamuzakjp/[email protected]': {}+'@babel/[email protected]':dependencies:'@babel/helper-validator-identifier': 7.28.5@@ -3780,6 +4184,8 @@ snapshots:dependencies:'@babel/types': 7.29.0+ '@babel/[email protected]': {}+'@babel/[email protected]':dependencies:'@babel/code-frame': 7.29.0@@ -3803,6 +4209,34 @@ snapshots:'@babel/helper-string-parser': 7.27.1'@babel/helper-validator-identifier': 7.28.5+ '@bramus/[email protected]':+ dependencies:+ css-tree: 3.2.1++ '@csstools/[email protected]': {}++ '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':+ dependencies:+ '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])+ '@csstools/css-tokenizer': 4.0.0++ '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':+ dependencies:+ '@csstools/color-helpers': 6.1.0+ '@csstools/css-calc': 3.2.1(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])+ '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])+ '@csstools/css-tokenizer': 4.0.0++ '@csstools/[email protected](@csstools/[email protected])':+ dependencies:+ '@csstools/css-tokenizer': 4.0.0++ '@csstools/[email protected]([email protected])':+ optionalDependencies:+ css-tree: 3.2.1++ '@csstools/[email protected]': {}+'@emnapi/[email protected]':dependencies:'@emnapi/wasi-threads': 1.2.1@@ -3943,6 +4377,8 @@ snapshots:'@eslint/core': 0.17.0levn: 0.4.1+ '@exodus/[email protected]': {}+'@floating-ui/[email protected]':dependencies:'@floating-ui/utils': 0.2.11@@ -4962,6 +5398,8 @@ snapshots:'@rtsao/[email protected]': {}+ '@standard-schema/[email protected]': {}+'@swc/[email protected]':dependencies:tslib: 2.8.1@@ -5039,19 +5477,58 @@ snapshots:postcss: 8.5.14tailwindcss: 4.3.0+ '@testing-library/[email protected]':+ dependencies:+ '@babel/code-frame': 7.29.0+ '@babel/runtime': 7.29.7+ '@types/aria-query': 5.0.4+ aria-query: 5.3.0+ dom-accessibility-api: 0.5.16+ lz-string: 1.5.0+ picocolors: 1.1.1+ pretty-format: 27.5.1++ '@testing-library/[email protected]':+ dependencies:+ '@adobe/css-tools': 4.5.0+ aria-query: 5.3.2+ css.escape: 1.5.1+ dom-accessibility-api: 0.6.3+ picocolors: 1.1.1+ redent: 3.0.0++ '@testing-library/[email protected](@testing-library/[email protected])(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':+ dependencies:+ '@babel/runtime': 7.29.7+ '@testing-library/dom': 10.4.1+ react: 19.2.6+ react-dom: 19.2.6([email protected])+ optionalDependencies:+ '@types/react': 19.2.14+ '@types/react-dom': 19.2.3(@types/[email protected])+'@tybys/[email protected]':dependencies:tslib: 2.8.1optional: true+ '@types/[email protected]': {}+'@types/[email protected]':dependencies:'@types/node': 22.19.19+ '@types/[email protected]':+ dependencies:+ '@types/deep-eql': 4.0.2+ assertion-error: 2.0.1+'@types/[email protected]':dependencies:'@types/ms': 2.1.0+ '@types/[email protected]': {}+'@types/[email protected]':dependencies:'@types/estree': 1.0.9@@ -5249,6 +5726,47 @@ snapshots:'@rolldown/pluginutils': 1.0.1+ '@vitest/[email protected]':+ dependencies:+ '@standard-schema/spec': 1.1.0+ '@types/chai': 5.2.3+ '@vitest/spy': 4.1.10+ '@vitest/utils': 4.1.10+ chai: 6.2.2+ tinyrainbow: 3.1.0++ '@vitest/[email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':+ dependencies:+ '@vitest/spy': 4.1.10+ estree-walker: 3.0.3+ magic-string: 0.30.21+ optionalDependencies:++ '@vitest/[email protected]':+ dependencies:+ tinyrainbow: 3.1.0++ '@vitest/[email protected]':+ dependencies:+ '@vitest/utils': 4.1.10+ pathe: 2.0.3++ '@vitest/[email protected]':+ dependencies:+ '@vitest/pretty-format': 4.1.10+ '@vitest/utils': 4.1.10+ magic-string: 0.30.21+ pathe: 2.0.3++ '@vitest/[email protected]': {}++ '@vitest/[email protected]':+ dependencies:+ '@vitest/pretty-format': 4.1.10+ convert-source-map: 2.0.0+ tinyrainbow: 3.1.0+dependencies:acorn: 8.16.0@@ -5262,16 +5780,24 @@ snapshots:json-schema-traverse: 0.4.1uri-js: 4.4.1+ [email protected]: {}+dependencies:color-convert: 2.0.1+ [email protected]: {}+dependencies:tslib: 2.8.1+ dependencies:+ dequal: 2.0.3+@@ -5341,6 +5867,8 @@ snapshots:get-intrinsic: 1.3.0is-array-buffer: 3.0.5+ [email protected]: {}+@@ -5368,6 +5896,10 @@ snapshots:bindings: 1.5.0prebuild-install: 7.1.3+ dependencies:+ require-from-string: 2.0.2+dependencies:file-uri-to-path: 1.0.0@@ -5431,6 +5963,8 @@ snapshots:+ [email protected]: {}+dependencies:ansi-styles: 4.3.0@@ -5478,10 +6012,24 @@ snapshots:shebang-command: 2.0.0which: 2.0.2+ dependencies:+ mdn-data: 2.27.1+ source-map-js: 1.2.1++ [email protected]: {}++ dependencies:+ whatwg-mimetype: 5.0.0+ whatwg-url: 16.0.1+ transitivePeerDependencies:+ - '@noble/hashes'+dependencies:call-bound: 1.0.4@@ -5508,6 +6056,8 @@ snapshots:dependencies:ms: 2.1.3+ [email protected]: {}+dependencies:character-entities: 2.0.2@@ -5555,6 +6105,10 @@ snapshots:dependencies:esutils: 2.0.3+ [email protected]: {}++ [email protected]: {}+dependencies:call-bind-apply-helpers: 1.0.2@@ -5574,6 +6128,8 @@ snapshots:graceful-fs: 4.2.11tapable: 2.3.3+ [email protected]: {}+dependencies:array-buffer-byte-length: 1.0.2@@ -5654,6 +6210,8 @@ snapshots:iterator.prototype: 1.1.5math-intrinsics: 1.1.0+ [email protected]: {}+dependencies:es-errors: 1.3.0@@ -5915,10 +6473,16 @@ snapshots:+ dependencies:+ '@types/estree': 1.0.9++ [email protected]: {}+@@ -6096,6 +6660,12 @@ snapshots:dependencies:hermes-estree: 0.25.1+ dependencies:+ '@exodus/bytes': 1.15.1+ transitivePeerDependencies:+ - '@noble/hashes'+@@ -6111,6 +6681,8 @@ snapshots:+ [email protected]: {}+@@ -6215,6 +6787,8 @@ snapshots:+ [email protected]: {}+dependencies:call-bound: 1.0.4@@ -6279,6 +6853,32 @@ snapshots:dependencies:argparse: 2.0.1+ dependencies:+ '@asamuzakjp/css-color': 5.1.11+ '@asamuzakjp/dom-selector': 7.1.1+ '@bramus/specificity': 2.4.2+ '@csstools/css-syntax-patches-for-csstree': 1.1.6([email protected])+ '@exodus/bytes': 1.15.1+ css-tree: 3.2.1+ data-urls: 7.0.0+ decimal.js: 10.6.0+ html-encoding-sniffer: 6.0.0+ is-potential-custom-element-name: 1.0.1+ lru-cache: 11.5.2+ parse5: 8.0.1+ saxes: 6.0.0+ symbol-tree: 3.2.4+ tough-cookie: 6.0.2+ undici: 7.28.0+ w3c-xmlserializer: 5.0.0+ webidl-conversions: 8.0.1+ whatwg-mimetype: 5.0.0+ whatwg-url: 16.0.1+ xml-name-validator: 5.0.0+ transitivePeerDependencies:+ - '@noble/hashes'+@@ -6381,6 +6981,8 @@ snapshots:dependencies:js-tokens: 4.0.0+ [email protected]: {}+dependencies:yallist: 3.1.1@@ -6391,6 +6993,8 @@ snapshots:+ [email protected]: {}+dependencies:'@jridgewell/sourcemap-codec': 1.5.5@@ -6552,6 +7156,8 @@ snapshots:dependencies:'@types/mdast': 4.0.4+ [email protected]: {}+@@ -6752,6 +7358,8 @@ snapshots:+ [email protected]: {}+dependencies:brace-expansion: 5.0.6@@ -6861,6 +7469,8 @@ snapshots:define-properties: 1.2.1es-object-atoms: 1.1.1+ [email protected]: {}+dependencies:wrappy: 1.0.2@@ -6909,12 +7519,18 @@ snapshots:is-decimal: 2.0.1is-hexadecimal: 2.0.1+ dependencies:+ entities: 8.0.0++ [email protected]: {}+@@ -6954,6 +7570,12 @@ snapshots:+ dependencies:+ ansi-regex: 5.0.1+ ansi-styles: 5.2.0+ react-is: 17.0.2+dependencies:loose-envify: 1.4.0@@ -7048,6 +7670,8 @@ snapshots:+ [email protected]: {}+dependencies:'@types/hast': 3.0.4@@ -7101,6 +7725,11 @@ snapshots:string_decoder: 1.3.0util-deprecate: 1.0.2+ dependencies:+ indent-string: 4.0.0+ strip-indent: 3.0.0+dependencies:call-bind: 1.0.9@@ -7155,6 +7784,8 @@ snapshots:mdast-util-to-markdown: 2.1.2unified: 11.0.5+ [email protected]: {}+@@ -7218,6 +7849,10 @@ snapshots:es-errors: 1.3.0is-regex: 1.2.1+ dependencies:+ xmlchars: 2.2.0+@@ -7312,6 +7947,8 @@ snapshots:side-channel-map: 1.0.1side-channel-weakmap: 1.0.2+ [email protected]: {}+@@ -7331,6 +7968,10 @@ snapshots:+ [email protected]: {}++ [email protected]: {}+dependencies:es-errors: 1.3.0@@ -7397,6 +8038,10 @@ snapshots:+ dependencies:+ min-indent: 1.0.1+@@ -7422,6 +8067,8 @@ snapshots:+ [email protected]: {}+@@ -7443,15 +8090,35 @@ snapshots:inherits: 2.0.4readable-stream: 3.6.2+ [email protected]: {}++ [email protected]: {}+dependencies:fdir: 6.5.0([email protected])picomatch: 4.0.4+ [email protected]: {}++ [email protected]: {}++ dependencies:+ tldts-core: 7.4.8+dependencies:is-number: 7.0.0+ dependencies:+ tldts: 7.4.8++ dependencies:+ punycode: 2.3.1+@@ -7538,6 +8205,8 @@ snapshots:+ [email protected]: {}+dependencies:'@types/unist': 3.0.3@@ -7650,6 +8319,51 @@ snapshots:jiti: 2.7.0tsx: 4.22.1+ [email protected](@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):+ dependencies:+ '@vitest/expect': 4.1.10+ '@vitest/mocker': 4.1.10([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ '@vitest/pretty-format': 4.1.10+ '@vitest/runner': 4.1.10+ '@vitest/snapshot': 4.1.10+ '@vitest/spy': 4.1.10+ '@vitest/utils': 4.1.10+ es-module-lexer: 2.3.1+ expect-type: 1.4.0+ magic-string: 0.30.21+ obug: 2.1.3+ pathe: 2.0.3+ picomatch: 4.0.4+ std-env: 4.2.0+ tinybench: 2.9.0+ tinyexec: 1.2.4+ tinyglobby: 0.2.16+ tinyrainbow: 3.1.0+ why-is-node-running: 2.3.0+ optionalDependencies:+ '@opentelemetry/api': 1.9.0+ '@types/node': 22.19.19+ jsdom: 29.1.1+ transitivePeerDependencies:+ - msw++ dependencies:+ xml-name-validator: 5.0.0++ [email protected]: {}++ [email protected]: {}++ dependencies:+ '@exodus/bytes': 1.15.1+ tr46: 6.0.0+ webidl-conversions: 8.0.1+ transitivePeerDependencies:+ - '@noble/hashes'+dependencies:is-bigint: 1.1.0@@ -7695,6 +8409,11 @@ snapshots:dependencies:isexe: 2.0.0+ dependencies:+ siginfo: 2.0.0+ stackback: 0.0.2+@@ -7705,6 +8424,10 @@ snapshots:dependencies:is-wsl: 3.1.1+ [email protected]: {}++ [email protected]: {}+diff --git a/notfair/src/app/(app)/[project]/connections/page.tsx b/notfair/src/app/(app)/[project]/connections/page.tsxindex decc6abe..fc6bf081 100644--- a/notfair/src/app/(app)/[project]/connections/page.tsx+++ b/notfair/src/app/(app)/[project]/connections/page.tsx@@ -9,8 +9,17 @@ import { McpFlashBanner } from "@/components/mcp-flash-banner";import { AddMcpServerMenu } from "@/components/add-mcp-server-card";import { normalizeResourceUrl } from "@/server/mcp/discovery-url";import { projectHref } from "@/lib/project-href";+import { accountPickerFor } from "@/lib/mcp-account-pickers";+import { prefetchAccountChoice } from "@/server/mcp/account-selection";-type Search = { mcp_connected?: string; mcp_error?: string; mcp_analyzing?: string };+type Search = {+ mcp_connected?: string;+ mcp_error?: string;+ mcp_analyzing?: string;+ /** Catalog key of the MCP that just finished OAuth — drives the+ * post-connect account/property picker on the matching card. */+ mcp_key?: string;+};export default async function ConnectionsPage({searchParams,@@ -21,7 +30,8 @@ export default async function ConnectionsPage({}) {const { project: slug } = await params;const project = getProject(slug);- const { mcp_connected, mcp_error, mcp_analyzing } = await searchParams;+ const { mcp_connected, mcp_error, mcp_analyzing, mcp_key } =+ await searchParams;if (!project || project.archived_at) notFound();const catalog = getMcpCatalog(project.slug);@@ -29,6 +39,14 @@ export default async function ConnectionsPage({catalog.map((s) => getMcpStatus(project.slug, s.key)),);+ // Post-OAuth account/property picker: when the callback flagged a+ // multi-account MCP (`?mcp_key=`), prefetch its list here on the server+ // and hand it to the card, which auto-opens the picker dialog with it.+ const pendingChoice = mcp_key+ ? await prefetchAccountChoice(project, mcp_key)+ : null;+ const autoOpenPickerKey = pendingChoice ? mcp_key : null;+const builtinTools = summarizeBuiltinTools();const connectedCount = statuses.filter((s) => s.state === "connected").length;const connectedSpecs = catalog.filter(@@ -99,7 +117,19 @@ export default async function ConnectionsPage({<ol className="ns-group">{catalog.map((spec, i) => (<li key={spec.key}>- <McpCard spec={spec} status={statuses[i]} />+ <McpCard+ spec={spec}+ status={statuses[i]}+ projectSlug={project.slug}+ selectedAccountId={+ accountPickerFor(spec.key)?.selectedId(project) ?? null+ }+ pickerPrefetch={+ spec.key === autoOpenPickerKey+ ? (pendingChoice?.prefetch ?? null)+ : null+ }+ /></li>))}</ol>diff --git a/notfair/src/app/api/mcp-oauth/callback/route.ts b/notfair/src/app/api/mcp-oauth/callback/route.tsindex 3dc30be2..533ab310 100644--- a/notfair/src/app/api/mcp-oauth/callback/route.ts+++ b/notfair/src/app/api/mcp-oauth/callback/route.ts@@ -186,6 +186,30 @@ export async function GET(request: Request) {console.error("[mcp-oauth] suggestion generation kickoff failed:", err);}+ // Multi-account MCPs (Google Ads, Meta Ads, GSC): resolve the workspace's+ // account/property selection now, server-side. A still-valid existing+ // selection is kept, a bearer with exactly one account is persisted+ // silently, and only a genuine choice appends `mcp_key` — which makes the+ // Connections page open the picker dialog on the matching card.+ try {+ const { resolvePostConnectSelection } = await import(+ "@/server/mcp/account-selection"+ );+ const selection = await resolvePostConnectSelection(+ pending.project_slug,+ pending.catalog_key,+ );+ if (selection.kind === "choice_required") {+ back.searchParams.set("mcp_key", pending.catalog_key);+ }+ } catch (err) {+ console.error("[mcp-oauth] post-connect account resolution threw:", err);+ const { accountPickerFor } = await import("@/lib/mcp-account-pickers");+ if (accountPickerFor(pending.catalog_key)) {+ back.searchParams.set("mcp_key", pending.catalog_key);+ }+ }+// Flash banner uses the catalog name (what the user recognizes), not the// project-prefixed server key.back.searchParams.set("mcp_connected", pending.display_name);diff --git a/notfair/src/app/onboarding/page.tsx b/notfair/src/app/onboarding/page.tsxindex 226086dc..864bd512 100644--- a/notfair/src/app/onboarding/page.tsx+++ b/notfair/src/app/onboarding/page.tsx@@ -1,12 +1,33 @@import { Suspense } from "react";import { OnboardingFlow } from "@/components/onboarding-flow";+import { getProject } from "@/server/db/projects";+import { prefetchAccountChoice } from "@/server/mcp/account-selection";export const dynamic = "force-dynamic";-export default function OnboardingPage() {+type Search = { slug?: string; mcp_key?: string };++export default async function OnboardingPage({+ searchParams,+}: {+ searchParams: Promise<Search>;+}) {+ const { slug, mcp_key } = await searchParams;++ // Same post-OAuth picker flow as the Connections page: when the callback+ // flagged a multi-account MCP (`?mcp_key=`), prefetch the account list+ // server-side so the connect step opens the picker dialog with data —+ // never a client fetch racing the flash banner's URL cleanup.+ const project = slug ? getProject(slug) : null;+ const pendingChoice =+ project && mcp_key ? await prefetchAccountChoice(project, mcp_key) : null;+return (<Suspense fallback={null}>- <OnboardingFlow />+ <OnboardingFlow+ pickerMcpKey={pendingChoice && mcp_key ? mcp_key : null}+ pickerPrefetch={pendingChoice?.prefetch ?? null}+ /></Suspense>);}diff --git a/notfair/src/components/mcp-account-picker-dialog.test.tsx b/notfair/src/components/mcp-account-picker-dialog.test.tsxnew file mode 100644index 00000000..d6f75eb4--- /dev/null+++ b/notfair/src/components/mcp-account-picker-dialog.test.tsx@@ -0,0 +1,153 @@+// @vitest-environment jsdom+import { beforeEach, describe, expect, it, vi } from "vitest";+import { render, screen, waitFor, fireEvent } from "@testing-library/react";++import { McpAccountPickerDialog } from "@/components/mcp-account-picker-dialog";+import {+ listGscProperties,+ setOnboardingGscPropertyAction,+} from "@/server/onboarding/accounts";++vi.mock("@/server/onboarding/accounts", () => ({+ listGoogleAdsAccounts: vi.fn(),+ setOnboardingAccountAction: vi.fn(),+ listMetaAdsAccounts: vi.fn(),+ setOnboardingMetaAdsAccountAction: vi.fn(),+ listGscProperties: vi.fn(),+ setOnboardingGscPropertyAction: vi.fn(),+}));++const GSC = "notfair-googlesearchconsole";++function renderDialog(+ props: Partial<React.ComponentProps<typeof McpAccountPickerDialog>> = {},+) {+ const onOpenChange = vi.fn();+ const onPicked = vi.fn();+ const utils = render(+ <McpAccountPickerDialog+ projectSlug="proj"+ mcpKey={GSC}+ selectedId={null}+ open+ onOpenChange={onOpenChange}+ onPicked={onPicked}+ {...props}+ />,+ );+ return { ...utils, onOpenChange, onPicked };+}++beforeEach(() => {+ vi.clearAllMocks();+});++describe("McpAccountPickerDialog", () => {+ it("renders prefetched items without calling the list action", async () => {+ renderDialog({+ prefetch: {+ ok: true,+ items: [+ { id: "sc-domain:a.com", name: "a.com", is_default: false },+ { id: "sc-domain:b.com", name: "b.com", is_default: true },+ ],+ },+ });+ expect(+ await screen.findByRole("button", { name: /Use a\.com/ }),+ ).toBeInTheDocument();+ expect(screen.getByText("default")).toBeInTheDocument();+ expect(listGscProperties).not.toHaveBeenCalled();+ });++ it("marks the persisted selection as current", async () => {+ renderDialog({+ selectedId: "sc-domain:b.com",+ prefetch: {+ ok: true,+ items: [+ { id: "sc-domain:a.com", name: "a.com", is_default: false },+ { id: "sc-domain:b.com", name: "b.com", is_default: false },+ ],+ },+ });+ expect(await screen.findByText("current")).toBeInTheDocument();+ });++ it("shows a prefetched error with no retry fetch on mount", async () => {+ renderDialog({ prefetch: { ok: false, error: "HTTP 502" } });+ expect(await screen.findByRole("alert")).toHaveTextContent("HTTP 502");+ expect(listGscProperties).not.toHaveBeenCalled();+ });++ it("fetches from the MCP when opened without a prefetch (manual open)", async () => {+ vi.mocked(listGscProperties).mockResolvedValue({+ ok: true,+ properties: [{ id: "sc-domain:a.com", name: "a.com" }],+ default_property_id: null,+ });+ renderDialog();+ expect(+ await screen.findByRole("button", { name: /Use a\.com/ }),+ ).toBeInTheDocument();+ expect(listGscProperties).toHaveBeenCalledWith("proj");+ });++ it("shows the empty state when the bearer reaches nothing", async () => {+ vi.mocked(listGscProperties).mockResolvedValue({+ ok: true,+ properties: [],+ default_property_id: null,+ });+ renderDialog();+ expect(+ await screen.findByText(/no Search Console property/i),+ ).toBeInTheDocument();+ });++ it("persists a pick, then notifies and closes", async () => {+ vi.mocked(setOnboardingGscPropertyAction).mockResolvedValue({+ ok: true,+ project: {} as never,+ });+ const { onOpenChange, onPicked } = renderDialog({+ prefetch: {+ ok: true,+ items: [{ id: "sc-domain:a.com", name: "a.com", is_default: false }],+ },+ });+ fireEvent.click(await screen.findByRole("button", { name: /Use a\.com/ }));+ await waitFor(() => {+ expect(setOnboardingGscPropertyAction).toHaveBeenCalledWith(+ "proj",+ "sc-domain:a.com",+ );+ expect(onPicked).toHaveBeenCalled();+ expect(onOpenChange).toHaveBeenCalledWith(false);+ });+ });++ it("stays open and does not notify when persisting fails", async () => {+ vi.mocked(setOnboardingGscPropertyAction).mockResolvedValue({+ ok: false,+ error: "not reachable",+ });+ const { onOpenChange, onPicked } = renderDialog({+ prefetch: {+ ok: true,+ items: [{ id: "sc-domain:a.com", name: "a.com", is_default: false }],+ },+ });+ fireEvent.click(await screen.findByRole("button", { name: /Use a\.com/ }));+ await waitFor(() =>+ expect(setOnboardingGscPropertyAction).toHaveBeenCalled(),+ );+ expect(onPicked).not.toHaveBeenCalled();+ expect(onOpenChange).not.toHaveBeenCalledWith(false);+ });++ it("renders nothing for MCPs without a picker", () => {+ const { container } = renderDialog({ mcpKey: "notfair-xads" });+ expect(container).toBeEmptyDOMElement();+ });+});\ No newline at end of filediff --git a/notfair/src/components/mcp-account-picker-dialog.tsx b/notfair/src/components/mcp-account-picker-dialog.tsxnew file mode 100644index 00000000..8dc7dfd4--- /dev/null+++ b/notfair/src/components/mcp-account-picker-dialog.tsx@@ -0,0 +1,233 @@+"use client";++import { useEffect, useRef, useState } from "react";+import { AlertCircle, ChevronRight, Loader2 } from "lucide-react";+import { toast } from "sonner";++import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogHeader,+ DialogTitle,+} from "@/components/ui/dialog";+import { cn } from "@/lib/utils";+import {+ accountPickerFor,+ type AccountPickerItem,+} from "@/lib/mcp-account-pickers";++/**+ * Result of the server-side list prefetch the Connections page runs when+ * a multi-account MCP just finished OAuth (`?mcp_key=`). Passing data in+ * (instead of fetching on mount) matters: a mount-time server-action call+ * races the flash banner's URL-cleanup navigation, which can strand the+ * action's promise and leave the dialog stuck on "loading".+ */+export type AccountPickerPrefetch =+ | { ok: true; items: AccountPickerItem[] }+ | { ok: false; error: string };++type Phase =+ | { phase: "loading" }+ | { phase: "error"; message: string }+ | { phase: "empty" }+ | { phase: "list"; items: AccountPickerItem[] };++/**+ * Account/property picker for multi-account MCPs (Google Ads, Meta Ads,+ * Search Console) on the Connections page. Opens automatically right+ * after OAuth when the bearer offers a real choice (fed by `prefetch`),+ * and manually from the card's "Choose …" / "Change …" affordances+ * (fetches on open — no navigation in flight then).+ *+ * Persisting goes through the same validated server actions onboarding+ * uses, so the choice lands on the `projects` row goal agents read.+ */+export function McpAccountPickerDialog({+ projectSlug,+ mcpKey,+ selectedId,+ open,+ prefetch,+ onOpenChange,+ onPicked,+}: {+ projectSlug: string;+ mcpKey: string;+ /** Currently persisted selection on the project row, if any. */+ selectedId: string | null;+ open: boolean;+ /** Server-prefetched list for the post-OAuth auto-open; consumed once. */+ prefetch?: AccountPickerPrefetch | null;+ onOpenChange: (open: boolean) => void;+ /** Fired after a selection was persisted. */+ onPicked: () => void;+}) {+ const picker = accountPickerFor(mcpKey);+ const [state, setState] = useState<Phase>({ phase: "loading" });+ const [pickingId, setPickingId] = useState<string | null>(null);+ // The prefetch belongs to the auto-open right after OAuth. Later manual+ // opens re-fetch so the list (and any transient error) is fresh.+ const prefetchConsumedRef = useRef(false);++ useEffect(() => {+ if (!open || !picker) return;+ setPickingId(null);+ if (prefetch && !prefetchConsumedRef.current) {+ prefetchConsumedRef.current = true;+ setState(+ !prefetch.ok+ ? { phase: "error", message: prefetch.error }+ : prefetch.items.length === 0+ ? { phase: "empty" }+ : { phase: "list", items: prefetch.items },+ );+ return;+ }+ setState({ phase: "loading" });+ let cancelled = false;+ (async () => {+ const r = await picker.list(projectSlug);+ if (cancelled) return;+ if (!r.ok) {+ setState({ phase: "error", message: r.error });+ return;+ }+ setState(+ r.items.length === 0+ ? { phase: "empty" }+ : { phase: "list", items: r.items },+ );+ })();+ return () => {+ cancelled = true;+ };+ // Reload only when the dialog (re)opens or targets a different MCP —+ // parent re-renders must not refetch mid-flight.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [open, mcpKey, projectSlug]);++ if (!picker) return null;++ async function onPick(item: AccountPickerItem) {+ if (!picker) return;+ setPickingId(item.id);+ try {+ const r = await picker.set(projectSlug, item.id);+ if (!r.ok) {+ toast.error(r.error);+ setPickingId(null);+ return;+ }+ toast.success(`${picker.noun} set: ${item.name}`);+ onPicked();+ onOpenChange(false);+ } catch (err) {+ toast.error(err instanceof Error ? err.message : String(err));+ setPickingId(null);+ }+ }++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="sm:max-w-md">+ <DialogHeader>+ <DialogTitle>Which {picker.noun}?</DialogTitle>+ <DialogDescription>+ This workspace’s goal agents operate on exactly one — pick+ it here. You can change it any time from this card.+ </DialogDescription>+ </DialogHeader>++ {state.phase === "loading" && (+ <div className="flex items-center gap-3 py-4 text-sm text-muted-foreground">+ <Loader2 className="size-4 animate-spin" aria-hidden />+ <span>Loading from the MCP…</span>+ </div>+ )}++ {state.phase === "error" && (+ <div role="alert" className="space-y-2 py-2">+ <div className="flex items-center gap-2 text-sm font-medium">+ <AlertCircle+ className="size-4 text-[hsl(var(--notfair-warn))]"+ aria-hidden+ />+ <span>Couldn’t load the list.</span>+ </div>+ <p className="text-xs text-muted-foreground">{state.message}</p>+ </div>+ )}++ {state.phase === "empty" && (+ <p className="py-2 text-sm text-muted-foreground">+ The connected user has no {picker.noun} the token can reach. Try+ reconnecting with a different account.+ </p>+ )}++ {state.phase === "list" && (+ <ul className="max-h-80 space-y-2 overflow-y-auto list-none p-0">+ {state.items.map((item) => {+ const isSelected = item.id === selectedId;+ const isPicking = pickingId === item.id;+ const isOtherPicking = pickingId !== null && !isPicking;+ return (+ <li key={item.id}>+ <button+ type="button"+ onClick={() => onPick(item)}+ disabled={pickingId !== null}+ aria-label={`Use ${item.name} (${item.id})`}+ className={cn(+ // Elevation over borders, per the design system: an+ // inset surface + soft shadow reads as a card without+ // drawing an outline.+ "block w-full rounded-[10px] bg-[hsl(var(--notfair-surface-2)/0.5)] p-3 text-left shadow-[var(--notfair-shadow-sm)] transition-colors hover:bg-[hsl(var(--notfair-surface-2))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/30 disabled:cursor-not-allowed",+ isOtherPicking && "opacity-50",+ )}+ >+ <div className="flex items-center justify-between gap-3">+ <div className="min-w-0 flex-1">+ <div className="flex items-center gap-2">+ <span className="truncate text-sm font-medium">+ {item.name}+ </span>+ {isSelected && (+ <span className="ns-tag-accent rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide">+ current+ </span>+ )}+ {item.is_default && !isSelected && (+ <span className="rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground">+ default+ </span>+ )}+ </div>+ <p className="truncate text-xs text-muted-foreground tabular-nums">+ {picker.id_label} {item.id}+ </p>+ </div>+ {isPicking ? (+ <Loader2+ className="size-4 shrink-0 animate-spin text-muted-foreground"+ aria-hidden+ />+ ) : (+ <ChevronRight+ className="size-4 shrink-0 text-muted-foreground"+ aria-hidden+ />+ )}+ </div>+ </button>+ </li>+ );+ })}+ </ul>+ )}+ </DialogContent>+ </Dialog>+ );+}diff --git a/notfair/src/components/mcp-card.test.tsx b/notfair/src/components/mcp-card.test.tsxnew file mode 100644index 00000000..f14725c9--- /dev/null+++ b/notfair/src/components/mcp-card.test.tsx@@ -0,0 +1,109 @@+// @vitest-environment jsdom+import { beforeEach, describe, expect, it, vi } from "vitest";+import { render, screen } from "@testing-library/react";++import { McpCard } from "@/components/mcp-card";+import type { McpSpec } from "@/server/mcp-catalog";+import type { McpRuntimeStatus } from "@/server/mcp/state";++vi.mock("next/navigation", () => ({+ useRouter: () => ({ refresh: vi.fn(), replace: vi.fn(), push: vi.fn() }),+}));+vi.mock("@/server/actions/mcp", () => ({+ startMcpConnect: vi.fn(),+ disconnectMcpAction: vi.fn(),+ listMcpToolsAction: vi.fn(),+ removeUserMcpServerAction: vi.fn(),+}));+vi.mock("@/server/onboarding/accounts", () => ({+ listGoogleAdsAccounts: vi.fn(),+ setOnboardingAccountAction: vi.fn(),+ listMetaAdsAccounts: vi.fn(),+ setOnboardingMetaAdsAccountAction: vi.fn(),+ listGscProperties: vi.fn(),+ setOnboardingGscPropertyAction: vi.fn(),+}));++const gscSpec: McpSpec = {+ key: "notfair-googlesearchconsole",+ display_name: "NotFair Google Search Console",+ description: "Organic search performance.",+ resource_url: "https://notfair.co/api/mcp/google_search_console",+ discovery_url:+ "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/google_search_console",+ source: "preset",+};++const xadsSpec: McpSpec = {+ ...gscSpec,+ key: "notfair-xads",+ display_name: "NotFair X Ads",+ resource_url: "https://notfair.co/api/mcp/x_ads",+};++const connected: McpRuntimeStatus = { state: "connected" } as McpRuntimeStatus;+const notConfigured: McpRuntimeStatus = {+ state: "not_configured",+} as McpRuntimeStatus;++beforeEach(() => {+ vi.clearAllMocks();+});++describe("McpCard primary action per setup state", () => {+ it("offers Connect when there is no token", () => {+ render(+ <McpCard spec={gscSpec} status={notConfigured} projectSlug="proj" />,+ );+ expect(screen.getByRole("button", { name: "Connect" })).toBeInTheDocument();+ expect(screen.queryByText(/Choose property/)).not.toBeInTheDocument();+ });++ it("offers Choose property when connected with nothing selected", () => {+ render(+ <McpCard+ spec={gscSpec}+ status={connected}+ projectSlug="proj"+ selectedAccountId={null}+ />,+ );+ expect(+ screen.getByRole("button", { name: "Choose property" }),+ ).toBeInTheDocument();+ expect(+ screen.queryByRole("button", { name: "Connect" }),+ ).not.toBeInTheDocument();+ // Disconnect lives in the ⋯ menu now, never on the card face.+ expect(+ screen.queryByRole("button", { name: "Disconnect" }),+ ).not.toBeInTheDocument();+ });++ it("offers a quiet Switch property once configured, and shows the selection", () => {+ render(+ <McpCard+ spec={gscSpec}+ status={connected}+ projectSlug="proj"+ selectedAccountId="sc-domain:notfair.co"+ />,+ );+ expect(+ screen.getByRole("button", { name: "Switch property" }),+ ).toBeInTheDocument();+ expect(screen.getByText("sc-domain:notfair.co")).toBeInTheDocument();+ expect(+ screen.queryByRole("button", { name: "Choose property" }),+ ).not.toBeInTheDocument();+ });++ it("shows no account action for MCPs without a picker", () => {+ render(<McpCard spec={xadsSpec} status={connected} projectSlug="proj" />);+ expect(screen.queryByText(/Choose|Switch/)).not.toBeInTheDocument();+ // The ⋯ menu is still there for Disconnect / Remove.+ expect(+ screen.getByRole("button", { name: /More options/ }),+ ).toBeInTheDocument();+ });+});\ No newline at end of filediff --git a/notfair/src/components/mcp-card.tsx b/notfair/src/components/mcp-card.tsxindex 6ed69e16..4bb7d0e5 100644--- a/notfair/src/components/mcp-card.tsx+++ b/notfair/src/components/mcp-card.tsx@@ -1,8 +1,14 @@"use client";-import { useState, useTransition } from "react";+import { useEffect, useRef, useState, useTransition } from "react";import { useRouter } from "next/navigation";-import { Loader2, BookOpenText, Trash2, MoreHorizontal } from "lucide-react";+import {+ Loader2,+ BookOpenText,+ Trash2,+ MoreHorizontal,+ Unplug,+} from "lucide-react";import { toast } from "sonner";import {startMcpConnect,@@ -13,7 +19,12 @@ import {import type { McpSpec } from "@/server/mcp-catalog";import type { McpRuntimeStatus } from "@/server/mcp/state";import { McpToolsDialog } from "@/components/mcp-tools-dialog";+import {+ McpAccountPickerDialog,+ type AccountPickerPrefetch,+} from "@/components/mcp-account-picker-dialog";import { McpIcon } from "@/components/mcp-icon";+import { accountPickerFor } from "@/lib/mcp-account-pickers";import {DropdownMenu,DropdownMenuContent,@@ -24,20 +35,66 @@ import {type Props = {spec: McpSpec;status: McpRuntimeStatus;+ /** Needed by the account picker's list/set server actions. */+ projectSlug: string;+ /**+ * Persisted account/property selection for pickable MCPs (Google Ads,+ * Meta Ads, Search Console) — null when unset or not pickable.+ */+ selectedAccountId?: string | null;+ /**+ * Set when this card's MCP just finished OAuth (`?mcp_key=` matches) and+ * the bearer offers a real account/property choice: the page prefetched+ * the list server-side, and the card auto-opens the picker with it.+ */+ pickerPrefetch?: AccountPickerPrefetch | null;+ /**+ * Fired after any mutation (disconnect, remove, account picked), on top+ * of the router.refresh() the card always does. Hosts whose data comes+ * from a client-side action (onboarding's connect step) pass their+ * reload here; server-rendered hosts (Connections page) omit it.+ */+ onMutated?: () => void;};/**- * One row in the Connections list — Apple-style settings row with- * brand glyph, name + status, and a primary connect/disconnect button.+ * One row in the Connections list — Apple-style settings row with brand+ * glyph, name + status, and a single primary action that tracks setup+ * state: **Connect** when there's no token, **Choose account/property**+ * when the token spans multiple accounts and none is picked yet, and a+ * quiet **Switch account/property** once configured (the ⋯ menu holds+ * Disconnect / Remove).*/-export function McpCard({ spec, status }: Props) {+export function McpCard({+ spec,+ status,+ projectSlug,+ selectedAccountId = null,+ pickerPrefetch = null,+ onMutated,+}: Props) {const [pending, startTransition] = useTransition();const [busy, setBusy] = useState<"connect" | "disconnect" | "remove" | null>(null,);const [toolsOpen, setToolsOpen] = useState(false);+ const [pickerOpen, setPickerOpen] = useState(false);+ const autoOpenedRef = useRef(false);const router = useRouter();+ const picker = accountPickerFor(spec.key);+ const isConnected = status.state === "connected";++ // Post-OAuth landing: open the picker exactly once with the prefetched+ // list. The flash banner strips ?mcp_key from the URL right after mount,+ // so the intent is captured in state before the prop disappears.+ useEffect(() => {+ if (!pickerPrefetch || !picker || !isConnected) return;+ if (autoOpenedRef.current) return;+ autoOpenedRef.current = true;+ setPickerOpen(true);+ }, [pickerPrefetch, picker, isConnected]);+async function onConnect() {setBusy("connect");try {@@ -64,6 +121,7 @@ export function McpCard({ spec, status }: Props) {} else {toast.success(`${spec.display_name} disconnected`);router.refresh();+ onMutated?.();}setBusy(null);});@@ -78,13 +136,13 @@ export function McpCard({ spec, status }: Props) {} else {toast.success(`${spec.display_name} removed`);router.refresh();+ onMutated?.();}setBusy(null);});}const isBusy = busy !== null || pending;- const isConnected = status.state === "connected";return (<>@@ -102,34 +160,41 @@ export function McpCard({ spec, status }: Props) {</div><p className="ns-row-desc line-clamp-1">{spec.description}</p><StatusLine status={status} resourceUrl={spec.resource_url} />+ {picker && isConnected && selectedAccountId && (+ <p className="mt-1.5 flex items-center gap-1.5 text-[11.5px] text-[hsl(var(--notfair-ink-4))]">+ <span>{picker.noun}:</span>+ <span className="ns-tag-mono">{selectedAccountId}</span>+ </p>+ )}</div><div className="ns-row-meta">- {isConnected ? (+ {/* One primary action per setup state; a fully configured row+ has none — its remaining actions live in the ⋯ menu. */}+ {!isConnected ? (<buttontype="button"- className="ns-btn ns-btn-outline ns-btn-sm"+ className="ns-btn ns-btn-primary ns-btn-sm"disabled={isBusy}- onClick={onDisconnect}+ onClick={onConnect}>- {busy === "disconnect" ? (+ {busy === "connect" ? (<Loader2 className="size-3.5 animate-spin" />) : null}- Disconnect+ {status.state === "stale_token" ? "Reconnect" : "Connect"}</button>- ) : (+ ) : picker ? (+ // Unset gets the loud primary style (setup isn't done);+ // switching an already-chosen account is a quiet outline.<buttontype="button"- className="ns-btn ns-btn-primary ns-btn-sm"+ className={`ns-btn ns-btn-sm ${selectedAccountId ? "ns-btn-outline" : "ns-btn-primary"}`}disabled={isBusy}- onClick={onConnect}+ onClick={() => setPickerOpen(true)}>- {busy === "connect" ? (- <Loader2 className="size-3.5 animate-spin" />- ) : null}- {status.state === "stale_token" ? "Reconnect" : "Connect"}+ {selectedAccountId ? "Switch" : "Choose"} {picker.short_noun}</button>- )}+ ) : null}<DropdownMenu><DropdownMenuTrigger asChild>@@ -151,6 +216,20 @@ export function McpCard({ spec, status }: Props) {View tools</DropdownMenuItem>)}+ {isConnected && (+ <DropdownMenuItem+ onSelect={onDisconnect}+ disabled={isBusy}+ className="gap-2 rounded-md px-2 py-1.5 text-[13px]"+ >+ {busy === "disconnect" ? (+ <Loader2 className="size-3.5 animate-spin" />+ ) : (+ <Unplug className="size-3.5 text-muted-foreground" />+ )}+ Disconnect+ </DropdownMenuItem>+ )}<DropdownMenuItemonSelect={onRemove}disabled={isBusy}@@ -175,6 +254,21 @@ export function McpCard({ spec, status }: Props) {mcpDescription={spec.description}loadTools={() => listMcpToolsAction({ mcp_key: spec.key })}/>++ {picker && (+ <McpAccountPickerDialog+ projectSlug={projectSlug}+ mcpKey={spec.key}+ selectedId={selectedAccountId}+ open={pickerOpen}+ prefetch={pickerPrefetch}+ onOpenChange={setPickerOpen}+ onPicked={() => {+ router.refresh();+ onMutated?.();+ }}+ />+ )}</>);}diff --git a/notfair/src/components/mcp-flash-banner.tsx b/notfair/src/components/mcp-flash-banner.tsxindex 412f696e..41fddd4b 100644--- a/notfair/src/components/mcp-flash-banner.tsx+++ b/notfair/src/components/mcp-flash-banner.tsx@@ -43,6 +43,7 @@ export function McpFlashBanner({url.searchParams.delete("mcp_connected");url.searchParams.delete("mcp_error");url.searchParams.delete("mcp_analyzing");+ url.searchParams.delete("mcp_key");router.replace(url.pathname + (url.search ? url.search : ""));}, [connected, error, analyzing, goalsHref, router]);diff --git a/notfair/src/components/onboarding-flow.tsx b/notfair/src/components/onboarding-flow.tsxindex 19de337b..deb331dc 100644--- a/notfair/src/components/onboarding-flow.tsx+++ b/notfair/src/components/onboarding-flow.tsx@@ -1,52 +1,64 @@"use client";-import { Suspense, useActionState, useEffect, useRef, useState } from "react";+import { Suspense, useActionState, useCallback, useEffect, useState } from "react";import { useRouter, useSearchParams } from "next/navigation";import Link from "next/link";-import { AlertCircle, ChevronRight, FolderOpen, Loader2, Plug } from "lucide-react";+import { AlertCircle, FolderOpen, Loader2 } from "lucide-react";import { toast } from "sonner";import { Button } from "@/components/ui/button";import { McpFlashBanner } from "@/components/mcp-flash-banner";-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";import { cn } from "@/lib/utils";import { projectHref } from "@/lib/project-href";-import { startMcpConnect } from "@/server/actions/mcp";import { createProjectForOnboardingAction } from "@/server/actions/projects";import {- listGoogleAdsAccounts,- setOnboardingAccountAction,- getConnectStepStateAction,- listMetaAdsAccounts,- setOnboardingMetaAdsAccountAction,- listGscProperties,- setOnboardingGscPropertyAction,- type GoogleAdsAccount,- type MetaAdsAccount,- type GscProperty,- type ConnectStepState,+ getOnboardingConnectCardsAction,+ type ConnectCard,} from "@/server/onboarding/accounts";import { AddMcpServerMenu } from "@/components/add-mcp-server-card";-import { McpIcon } from "@/components/mcp-icon";+import { McpCard } from "@/components/mcp-card";+import type { AccountPickerPrefetch } from "@/components/mcp-account-picker-dialog";-type Step =- | "name"- | "connect"- | "account"- | "meta-account"- | "gsc-property";+type Step = "name" | "connect";-export function OnboardingFlow() {+/**+ * The post-OAuth account/property choice for a multi-account MCP, as+ * prefetched by the onboarding server page (`?mcp_key=`). Same shape and+ * flow as the Connections page: the matching `McpCard` auto-opens the+ * shared picker dialog with this data.+ */+type PendingAccountChoice = {+ mcp_key: string;+ prefetch: AccountPickerPrefetch | null;+};++export function OnboardingFlow({+ pickerMcpKey = null,+ pickerPrefetch = null,+}: {+ pickerMcpKey?: string | null;+ pickerPrefetch?: AccountPickerPrefetch | null;+}) {return (<Suspense fallback={null}>- <OnboardingFlowInner />+ <OnboardingFlowInner+ autoPicker={+ pickerMcpKey+ ? { mcp_key: pickerMcpKey, prefetch: pickerPrefetch }+ : null+ }+ /></Suspense>);}-function OnboardingFlowInner() {+function OnboardingFlowInner({+ autoPicker,+}: {+ autoPicker: PendingAccountChoice | null;+}) {const router = useRouter();const params = useSearchParams();const stepParam = params.get("step");@@ -54,18 +66,8 @@ function OnboardingFlowInner() {const mcpConnected = params.get("mcp_connected") ?? undefined;const mcpError = params.get("mcp_error") ?? undefined;const mcpAnalyzing = params.get("mcp_analyzing") === "1";- const step: Step =- stepParam === "connect" ||- stepParam === "account" ||- stepParam === "meta-account" ||- stepParam === "gsc-property"- ? stepParam- : "name";-- // Step → progress-pip state mapping. The pickers (account, meta-account,- // gsc-property) all roll up under "Connect" because they're sub-flows- // launched from the connect step and return to it.- const phase: "name" | "connect" = step === "name" ? "name" : "connect";+ const step: Step = stepParam === "connect" ? "connect" : "name";+ const phase: "name" | "connect" = step;return (<div className="ns-page">@@ -111,15 +113,10 @@ function OnboardingFlowInner() {}/>)}- {step === "connect" && slug && <ConnectStep slug={slug} />}- {step === "account" && slug && <AccountStep slug={slug} />}- {step === "meta-account" && slug && <MetaAccountStep slug={slug} />}- {step === "gsc-property" && slug && <GscPropertyStep slug={slug} />}- {(step === "connect" ||- step === "account" ||- step === "meta-account" ||- step === "gsc-property") &&- !slug && <MissingSlug />}+ {step === "connect" && slug && (+ <ConnectStep slug={slug} autoPicker={autoPicker} />+ )}+ {step === "connect" && !slug && <MissingSlug />}</main></div>);@@ -388,144 +385,77 @@ function HarnessPicker({ disabled }: { disabled: boolean }) {}// ── Step 2: Connect ────────────────────────────────────────────────--/**- * Spec for one of the recommended-MCP tiles in the connect step. The core- * ad/search platforms get first-class tiles because they are what goal- * agents measure and act on; everything else lives in the "More tools"- * browse dialog.- */-type RecommendedTile = {- mcp_key: string;- /** Primary row title — the MCP name, e.g. "Google Ads MCP". Doubles- * as the tile's aria-label so existing tests that match by platform- * prefix (`/^Google Ads/`) still resolve. */- mcp_display_name: string;- /** What the user gets — phrased as "Gives the <X> agent the ability- * to …" so the MCP↔agent dependency reads in plain language instead- * of a badge. */- description: string;- /** Resource URL the OAuth flow targets — also feeds <McpIcon>'s icon- * lookup so each tile shows the brand mark the connections page uses. */- resource_url: string;- /** Sub-step the OAuth callback should land on so the user can pick an- * account/property when their token covers more than one. Absent when- * the MCP has no picker — OAuth returns straight to the connect step. */- account_step?: "account" | "meta-account" | "gsc-property";- /** Label for the "Select X" sub-action when connected but not selected. */- account_action_label?: string;-};--const RECOMMENDED_TILES: RecommendedTile[] = [- {- mcp_key: "notfair-googleads",- mcp_display_name: "Google Ads MCP",- description:- "Google Ads campaigns, spend, conversions — the richest ground for CAC and wasted-spend goals.",- resource_url: "https://notfair.co/api/mcp/google_ads",- account_step: "account",- account_action_label: "Select Google Ads account",- },- {- mcp_key: "notfair-metaads",- mcp_display_name: "Meta Ads MCP",- description:- "Meta (Facebook + Instagram) ad sets, ROAS, creative performance — for paid-social goals.",- resource_url: "https://notfair.co/api/mcp/meta_ads",- account_step: "meta-account",- account_action_label: "Select Meta ad account",- },- {- mcp_key: "notfair-googlesearchconsole",- mcp_display_name: "Google Search Console MCP",- // SEO agent owns Search Console — there's no dedicated GSC agent.- description:- "Organic search performance — queries, pages, indexing. Lets a goal agent measure and grow organic traffic.",- resource_url: "https://notfair.co/api/mcp/google_search_console",- account_step: "gsc-property",- account_action_label: "Select GSC property",- },- // Google Analytics deliberately lives under "More tools".- {- mcp_key: "notfair-xads",- mcp_display_name: "X Ads MCP",- description:- "X (Twitter) Ads campaigns, line items, spend and engagement — measurable ground for a goal agent.",- resource_url: "https://notfair.co/api/mcp/x_ads",- },+//+// Renders the exact `McpCard` rows the Connections page uses — one shared+// component, one lifecycle (Connect → Choose account → Switch account),+// zero drift between onboarding and the app. The wizard only curates the+// list (via `getOnboardingConnectCardsAction`): recommended MCPs always+// show; everything else appears once connected and otherwise lives in+// the "More tools" browse menu.++const RECOMMENDED_MCP_KEYS = [+ "notfair-googleads",+ "notfair-metaads",+ "notfair-googlesearchconsole",+ "notfair-xads",];-type ConnectStepStateView =+type ConnectCardsView =| { phase: "loading" }- | { phase: "loaded"; state: ConnectStepState }+ | { phase: "loaded"; cards: ConnectCard[]; any_connected: boolean }| { phase: "error"; message: string };-function ConnectStep({ slug }: { slug: string }) {+function ConnectStep({+ slug,+ autoPicker,+}: {+ slug: string;+ autoPicker: PendingAccountChoice | null;+}) {const router = useRouter();- const [view, setView] = useState<ConnectStepStateView>({ phase: "loading" });- const [tileBusy, setTileBusy] = useState<string | null>(null);+ const [view, setView] = useState<ConnectCardsView>({ phase: "loading" });const [advancing, setAdvancing] = useState(false);- const connectionsHref = projectHref(slug, "/connections");++ const loadCards = useCallback(async () => {+ const result = await getOnboardingConnectCardsAction(slug);+ if (!result.ok) {+ setView({ phase: "error", message: result.error });+ return;+ }+ setView({+ phase: "loaded",+ cards: result.cards,+ any_connected: result.any_connected,+ });+ }, [slug]);useEffect(() => {let cancelled = false;(async () => {- const result = await getConnectStepStateAction(slug);+ const result = await getOnboardingConnectCardsAction(slug);if (cancelled) return;if (!result.ok) {setView({ phase: "error", message: result.error });return;}- setView({ phase: "loaded", state: result.state });+ setView({+ phase: "loaded",+ cards: result.cards,+ any_connected: result.any_connected,+ });})();return () => {cancelled = true;};}, [slug]);- async function onConnectTile(tile: RecommendedTile) {- setTileBusy(tile.mcp_key);- try {- const result = await startMcpConnect({- mcp_key: tile.mcp_key,- // After OAuth lands, route through the matching account-picker- // step. That step auto-skips if the bearer covers a single- // account/property; otherwise it shows a picker. Both paths- // ultimately redirect back to /onboarding?step=connect so the- // user can continue adding tools. MCPs without a picker return- // straight to the connect step.- return_to: `/onboarding?step=${tile.account_step ?? "connect"}&slug=${encodeURIComponent(slug)}`,- });- if (!result.ok) {- toast.error(result.error);- setTileBusy(null);- return;- }- window.location.href = result.authorize_url;- } catch (err) {- toast.error(err instanceof Error ? err.message : String(err));- setTileBusy(null);- }- }-- function onPickAccount(tile: RecommendedTile) {- if (!tile.account_step) return;- router.push(- `/onboarding?step=${tile.account_step}&slug=${encodeURIComponent(slug)}`,- );- }-- async function onDone() {+ function onDone() {setAdvancing(true);// Straight to the workspace: the user mints their first goal agent// there and defines the goal in its chat. Nothing to provision here.router.replace(projectHref(slug, ""));}- function onSkip() {- router.replace(projectHref(slug, ""));- }-if (view.phase === "loading") {return (<div className="flex items-center gap-3 text-sm text-muted-foreground py-8">@@ -552,19 +482,7 @@ function ConnectStep({ slug }: { slug: string }) {);}- const { state } = view;- const tileStateByKey = {- "notfair-googleads": state.googleads,- "notfair-metaads": state.metaads,- "notfair-googlesearchconsole": state.gsc,- "notfair-xads": state.xads,- } as const;- const anyConnected =- state.googleads.connected ||- state.metaads.connected ||- state.gsc.connected ||- state.xads.connected ||- state.extra_connected_count > 0;+ const { cards, any_connected } = view;return (<>@@ -577,23 +495,19 @@ function ConnectStep({ slug }: { slug: string }) {</header><ol className="ns-list">- {RECOMMENDED_TILES.map((tile) => (- <RecommendedConnectorTile- key={tile.mcp_key}- tile={tile}- state={tileStateByKey[tile.mcp_key as keyof typeof tileStateByKey]}- busy={tileBusy === tile.mcp_key}- disabled={tileBusy !== null && tileBusy !== tile.mcp_key}- onConnect={() => onConnectTile(tile)}- onPickAccount={() => onPickAccount(tile)}- />- ))}- {/* Connected extras (Stripe, Supabase, …) added via the "More tools"- dialog land here, between the recommended trio and the More row,- so the list stays in the user's mental order: top tier first,- extras next, the door to add more last. */}- {state.extras.map((extra) => (- <ExtraConnectorTile key={extra.key} extra={extra} />+ {cards.map(({ spec, status, selected_id }) => (+ <li key={spec.key}>+ <McpCard+ spec={spec}+ status={status}+ projectSlug={slug}+ selectedAccountId={selected_id}+ pickerPrefetch={+ autoPicker?.mcp_key === spec.key ? autoPicker.prefetch : null+ }+ onMutated={loadCards}+ />+ </li>))}<li>{/* Reuse the connections-page Add-MCP menu so onboarding gets the@@ -602,21 +516,12 @@ function ConnectStep({ slug }: { slug: string }) {list; the dropdown opens from there. */}<AddMcpServerMenualign="start"- // Hide the three recommended MCPs from Browse — they each have- // their own row above already, no point re-listing them.- hideKeys={RECOMMENDED_TILES.map((t) => t.mcp_key)}- // Filter already-connected entries from Browse. The dialog- // already filters via connectedKeys; the recommended trio is- // also in hideKeys above for belt-and-suspenders.- connectedKeys={[- ...(state.googleads.connected ? ["notfair-googleads"] : []),- ...(state.metaads.connected ? ["notfair-metaads"] : []),- ...(state.gsc.connected ? ["notfair-googlesearchconsole"] : []),- ...(state.xads.connected ? ["notfair-xads"] : []),- // Google Analytics + Stripe/Supabase/etc. arrive here — a- // connected GA is an extras row, which also hides it in Browse.- ...state.extras.map((e) => e.key),- ]}+ // Hide the always-visible recommended MCPs from Browse — they+ // each have their own row above already.+ hideKeys={RECOMMENDED_MCP_KEYS}+ connectedKeys={cards+ .filter((c) => c.status.state === "connected")+ .map((c) => c.spec.key)}trigger={<buttontype="button"@@ -636,13 +541,9 @@ function ConnectStep({ slug }: { slug: string }) {</span></span><span className="ns-tile-status">- {state.extra_connected_count > 0 ? (- <span>{state.extra_connected_count} connected</span>- ) : (- <span className="arrow" aria-hidden>- ›- </span>- )}+ <span className="arrow" aria-hidden>+ ›+ </span></span></button>}@@ -652,7 +553,7 @@ function ConnectStep({ slug }: { slug: string }) {<div className="ns-foot"><p className="ns-footnote">You can set up MCPs later in the app.</p>- {anyConnected ? (+ {any_connected ? (<buttontype="button"onClick={onDone}@@ -668,7 +569,7 @@ function ConnectStep({ slug }: { slug: string }) {) : (<buttontype="button"- onClick={onSkip}+ onClick={onDone}disabled={advancing}className="ns-btn ns-btn-ghost">@@ -676,710 +577,6 @@ function ConnectStep({ slug }: { slug: string }) {</button>)}</div>-- </>- );-}--function RecommendedConnectorTile({- tile,- state,- busy,- disabled,- onConnect,- onPickAccount,-}: {- tile: RecommendedTile;- state: { connected: boolean; account_selected: boolean };- busy: boolean;- disabled: boolean;- onConnect: () => void;- onPickAccount: () => void;-}) {- // The row can't be a real <button>: the "Select account" sub-action- // below is a button too, and HTML forbids nested interactive elements- // (React 19 surfaces it as a hydration error). div[role=button] keeps- // the accessible name + role (so `getByRole('button', { name: /…/ })`- // still resolves) while making the nesting legal.- const inert = state.connected || busy || disabled;- const activate = () => {- if (!inert) onConnect();- };- return (- <li>- <div- role="button"- tabIndex={inert ? -1 : 0}- onClick={activate}- onKeyDown={(e) => {- if (e.key === "Enter" || e.key === " ") {- e.preventDefault();- activate();- }- }}- aria-disabled={busy || disabled ? true : undefined}- aria-label={tile.mcp_display_name}- className={`ns-tile w-full ${state.connected ? "is-connected" : ""}`}- // When already connected, the row itself is non-actionable; the- // sub-action below handles "pick account" and the row would- // navigate nowhere otherwise.- style={state.connected ? { cursor: "default" } : undefined}- >- <McpIcon resourceUrl={tile.resource_url} alt={tile.mcp_display_name} size="lg" />- <span className="ns-tile-body">- <span className="ns-tile-name-row">- <span className="ns-tile-name">{tile.mcp_display_name}</span>- </span>- <span className="ns-tile-desc block">{tile.description}</span>- {tile.account_step && state.connected && !state.account_selected && (- <button- type="button"- onClick={(e) => {- e.stopPropagation();- onPickAccount();- }}- disabled={disabled}- className="ns-subaction"- >- {tile.account_action_label}- </button>- )}- </span>- <span className="ns-tile-status">- {busy ? (- <Loader2 className="size-4 animate-spin" aria-hidden />- ) : state.connected ? (- <span className="ns-status-connected">Connected</span>- ) : (- // Visual pill — the surrounding row IS the actual click target,- // so this is intentionally a span (not nested <button>) to keep- // HTML valid. The pill is the affordance saying "click this row- // to connect this MCP."- <span className="ns-btn ns-btn-primary ns-btn-sm">- Connect{" "}- <span className="arrow" aria-hidden style={{ fontWeight: 400 }}>- ›- </span>- </span>- )}- </span>- </div>- </li>- );-}--function ExtraConnectorTile({- extra,-}: {- extra: {- key: string;- display_name: string;- description?: string;- resource_url: string;- };-}) {- return (- <li>- <div- className="ns-tile is-connected"- style={{ cursor: "default", width: "100%" }}- aria-label={extra.display_name}- >- <McpIcon resourceUrl={extra.resource_url} alt={extra.display_name} size="lg" />- <span className="ns-tile-body">- <span className="ns-tile-name block">{extra.display_name}</span>- {extra.description && (- <span className="ns-tile-desc block">{extra.description}</span>- )}- </span>- <span className="ns-tile-status">- <span className="ns-status-connected">Connected</span>- </span>- </div>- </li>- );-}---// ── Step 3: Pick Google Ads account (auto-skipped if only 1) ───────--type AccountListState =- | { phase: "loading" }- | { phase: "loaded"; accounts: GoogleAdsAccount[]; default_account_id: string | null }- | { phase: "error"; message: string };--function AccountStep({ slug }: { slug: string }) {- const router = useRouter();- const [state, setState] = useState<AccountListState>({ phase: "loading" });- const [pickingId, setPickingId] = useState<string | null>(null);- // Guard against StrictMode double-mount auto-selecting twice.- const autoSelectedRef = useRef(false);-- useEffect(() => {- let cancelled = false;- (async () => {- const result = await listGoogleAdsAccounts(slug);- if (cancelled) return;- if (!result.ok) {- setState({- phase: "error",- message: result.error,- });- return;- }- setState({- phase: "loaded",- accounts: result.accounts,- default_account_id: result.default_account_id,- });- })();- return () => {- cancelled = true;- };- }, [slug]);-- // Auto-skip when there's exactly one account — no point making the user- // pick from a list of one. We still call the server action so the project- // row gets the id persisted, then forward to the audit step.- useEffect(() => {- if (state.phase !== "loaded") return;- if (state.accounts.length !== 1) return;- if (autoSelectedRef.current) return;- autoSelectedRef.current = true;- (async () => {- const only = state.accounts[0]!;- const result = await setOnboardingAccountAction(slug, only.id);- if (!result.ok) {- toast.error(result.error);- setState({ phase: "error", message: result.error });- return;- }- // Back to the connect step so the user can wire up the rest of- // their tools.- // setOnboardingAccountAction and stays blocked behind the- // project-onboarding task until the user clicks "Done — next step".- router.replace(- `/onboarding?step=connect&slug=${encodeURIComponent(slug)}`,- );- })();- }, [state, slug, router]);-- async function onPick(account: GoogleAdsAccount) {- setPickingId(account.id);- try {- const result = await setOnboardingAccountAction(slug, account.id);- if (!result.ok) {- toast.error(result.error);- setPickingId(null);- return;- }- router.replace(- `/onboarding?step=connect&slug=${encodeURIComponent(slug)}`,- );- } catch (err) {- toast.error(err instanceof Error ? err.message : String(err));- setPickingId(null);- }- }-- if (state.phase === "loading") {- return (- <Card>- <CardContent className="space-y-2 pt-6 pb-6">- <div className="flex items-center gap-3 text-sm">- <Loader2 className="size-4 animate-spin text-muted-foreground" aria-hidden />- <span className="font-medium">Loading your Google Ads accounts…</span>- </div>- </CardContent>- </Card>- );- }-- if (state.phase === "error") {- return (- <Card role="alert">- <CardContent className="space-y-3 pt-6 pb-6">- <div className="flex items-center gap-2">- <AlertCircle className="size-4 text-[hsl(var(--notfair-warn))]" aria-hidden />- <span className="font-medium text-sm">- Couldn’t load your Google Ads accounts.- </span>- </div>- <p className="text-xs text-muted-foreground">{state.message}</p>- <div className="flex gap-2">- <Button asChild>- <Link href="/onboarding">Retry from start</Link>- </Button>- <Button variant="outline" asChild>- <Link href={projectHref(slug, "")}>Skip to project</Link>- </Button>- </div>- </CardContent>- </Card>- );- }-- if (state.accounts.length === 0) {- return (- <Card role="alert">- <CardContent className="space-y-3 pt-6 pb-6">- <div className="flex items-center gap-2">- <AlertCircle className="size-4 text-[hsl(var(--notfair-warn))]" aria-hidden />- <span className="font-medium text-sm">- No Google Ads accounts found on this connection.- </span>- </div>- <p className="text-xs text-muted-foreground">- The connected user has no Google Ads customer accounts. Connect a- different account or skip for now.- </p>- <div className="flex gap-2">- <Button asChild>- <Link href={`/onboarding?step=connect&slug=${encodeURIComponent(slug)}`}>- Reconnect- </Link>- </Button>- <Button variant="outline" asChild>- <Link href={projectHref(slug, "")}>Skip to project</Link>- </Button>- </div>- </CardContent>- </Card>- );- }-- // length === 1 → auto-selecting via effect above; render the same loading- // card so there's no flash of the picker UI.- if (state.accounts.length === 1) {- return (- <Card>- <CardContent className="space-y-2 pt-6 pb-6">- <div className="flex items-center gap-3 text-sm">- <Loader2 className="size-4 animate-spin text-muted-foreground" aria-hidden />- <span className="font-medium">- Using your only Google Ads account…- </span>- </div>- </CardContent>- </Card>- );- }-- // length > 1 → picker.- return (- <>- <header className="space-y-2">- <h1 className="text-3xl font-semibold tracking-tight text-foreground">- Which Google Ads account?- </h1>- <p className="text-sm text-muted-foreground">- Your connection has {state.accounts.length} accounts. Pick the one- you want me to audit for this workspace. You can switch later in- Settings.- </p>- </header>-- <ul className="space-y-2 list-none p-0">- {state.accounts.map((account) => {- const isDefault = account.id === state.default_account_id;- const isPicking = pickingId === account.id;- const isOtherPicking = pickingId !== null && !isPicking;- return (- <li key={account.id}>- <button- type="button"- onClick={() => onPick(account)}- disabled={pickingId !== null}- aria-label={`Audit ${account.name} (${account.id})`}- className={cn(- "block w-full rounded-md border bg-card p-4 text-left transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/30 disabled:cursor-not-allowed",- isOtherPicking && "opacity-50",- )}- >- <div className="flex items-center justify-between gap-3">- <div className="min-w-0 flex-1">- <div className="flex items-center gap-2">- <span className="font-medium text-sm">{account.name}</span>- {isDefault && (- <span className="rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground">- default- </span>- )}- </div>- <p className="text-xs text-muted-foreground tabular-nums">- Customer ID {account.id}- </p>- </div>- {isPicking ? (- <Loader2- className="size-4 animate-spin text-muted-foreground"- aria-hidden- />- ) : (- <ChevronRight className="size-4 text-muted-foreground" aria-hidden />- )}- </div>- </button>- </li>- );- })}- </ul>- </>- );-}--// ── Step 3b: Pick Meta Ads ad-account (auto-skipped if only 1) ─────-//-// Mirrors AccountStep but for the notfair-metaads MCP. Lands the user-// back on the connect step after picking so they can wire up another-// MCP or finish onboarding.--type MetaListState =- | { phase: "loading" }- | { phase: "loaded"; accounts: MetaAdsAccount[]; default_account_id: string | null }- | { phase: "error"; message: string };--function MetaAccountStep({ slug }: { slug: string }) {- const router = useRouter();- const [state, setState] = useState<MetaListState>({ phase: "loading" });- const [pickingId, setPickingId] = useState<string | null>(null);- const autoSelectedRef = useRef(false);-- useEffect(() => {- let cancelled = false;- (async () => {- const result = await listMetaAdsAccounts(slug);- if (cancelled) return;- if (!result.ok) {- setState({ phase: "error", message: result.error });- return;- }- setState({- phase: "loaded",- accounts: result.accounts,- default_account_id: result.default_account_id,- });- })();- return () => {- cancelled = true;- };- }, [slug]);-- useEffect(() => {- if (state.phase !== "loaded") return;- if (state.accounts.length !== 1) return;- if (autoSelectedRef.current) return;- autoSelectedRef.current = true;- (async () => {- const only = state.accounts[0]!;- const result = await setOnboardingMetaAdsAccountAction(slug, only.id);- if (!result.ok) {- toast.error(result.error);- setState({ phase: "error", message: result.error });- return;- }- router.replace(- `/onboarding?step=connect&slug=${encodeURIComponent(slug)}`,- );- })();- }, [state, slug, router]);-- async function onPick(account: MetaAdsAccount) {- setPickingId(account.id);- try {- const result = await setOnboardingMetaAdsAccountAction(slug, account.id);- if (!result.ok) {- toast.error(result.error);- setPickingId(null);- return;- }- router.replace(- `/onboarding?step=connect&slug=${encodeURIComponent(slug)}`,- );- } catch (err) {- toast.error(err instanceof Error ? err.message : String(err));- setPickingId(null);- }- }-- return (- <AccountPickerScaffold- slug={slug}- mcpDisplayName="Meta Ads"- idLabel="Ad account ID"- state={- state.phase === "loading"- ? { phase: "loading" }- : state.phase === "error"- ? { phase: "error", message: state.message }- : {- phase: "loaded",- items: state.accounts.map((a) => ({- id: a.id,- name: a.name,- isDefault: a.id === state.default_account_id,- isPicking: pickingId === a.id,- })),- anyPicking: pickingId !== null,- }- }- onPick={(id) => {- const a = state.phase === "loaded" ? state.accounts.find((x) => x.id === id) : null;- if (a) onPick(a);- }}- />- );-}--// ── Step 3c: Pick Google Search Console property (auto-skipped if only 1) ──--type GscListState =- | { phase: "loading" }- | { phase: "loaded"; properties: GscProperty[]; default_property_id: string | null }- | { phase: "error"; message: string };--function GscPropertyStep({ slug }: { slug: string }) {- const router = useRouter();- const [state, setState] = useState<GscListState>({ phase: "loading" });- const [pickingId, setPickingId] = useState<string | null>(null);- const autoSelectedRef = useRef(false);-- useEffect(() => {- let cancelled = false;- (async () => {- const result = await listGscProperties(slug);- if (cancelled) return;- if (!result.ok) {- setState({ phase: "error", message: result.error });- return;- }- setState({- phase: "loaded",- properties: result.properties,- default_property_id: result.default_property_id,- });- })();- return () => {- cancelled = true;- };- }, [slug]);-- useEffect(() => {- if (state.phase !== "loaded") return;- if (state.properties.length !== 1) return;- if (autoSelectedRef.current) return;- autoSelectedRef.current = true;- (async () => {- const only = state.properties[0]!;- const result = await setOnboardingGscPropertyAction(slug, only.id);- if (!result.ok) {- toast.error(result.error);- setState({ phase: "error", message: result.error });- return;- }- router.replace(- `/onboarding?step=connect&slug=${encodeURIComponent(slug)}`,- );- })();- }, [state, slug, router]);-- async function onPick(property: GscProperty) {- setPickingId(property.id);- try {- const result = await setOnboardingGscPropertyAction(slug, property.id);- if (!result.ok) {- toast.error(result.error);- setPickingId(null);- return;- }- router.replace(- `/onboarding?step=connect&slug=${encodeURIComponent(slug)}`,- );- } catch (err) {- toast.error(err instanceof Error ? err.message : String(err));- setPickingId(null);- }- }-- return (- <AccountPickerScaffold- slug={slug}- mcpDisplayName="Google Search Console"- idLabel="Property"- state={- state.phase === "loading"- ? { phase: "loading" }- : state.phase === "error"- ? { phase: "error", message: state.message }- : {- phase: "loaded",- items: state.properties.map((p) => ({- id: p.id,- name: p.name,- isDefault: p.id === state.default_property_id,- isPicking: pickingId === p.id,- })),- anyPicking: pickingId !== null,- }- }- onPick={(id) => {- const p = state.phase === "loaded" ? state.properties.find((x) => x.id === id) : null;- if (p) onPick(p);- }}- />- );-}--// ── Shared picker shell for Meta + GSC ─────────────────────────────-//-// Visually identical to the Google Ads picker but parameterized by the-// MCP display label and the id-label shown under each row. Used by-// MetaAccountStep + GscPropertyStep to avoid duplicating ~80 lines of-// loading / error / empty / single-item / picker JSX three times.--type AccountPickerScaffoldState =- | { phase: "loading" }- | { phase: "error"; message: string }- | {- phase: "loaded";- items: { id: string; name: string; isDefault: boolean; isPicking: boolean }[];- anyPicking: boolean;- };--function AccountPickerScaffold({- slug,- mcpDisplayName,- idLabel,- state,- onPick,-}: {- slug: string;- mcpDisplayName: string;- idLabel: string;- state: AccountPickerScaffoldState;- onPick: (id: string) => void;-}) {- if (state.phase === "loading") {- return (- <Card>- <CardContent className="space-y-2 pt-6 pb-6">- <div className="flex items-center gap-3 text-sm">- <Loader2 className="size-4 animate-spin text-muted-foreground" aria-hidden />- <span className="font-medium">- Loading your {mcpDisplayName} accounts…- </span>- </div>- </CardContent>- </Card>- );- }- if (state.phase === "error") {- return (- <Card role="alert">- <CardContent className="space-y-3 pt-6 pb-6">- <div className="flex items-center gap-2">- <AlertCircle className="size-4 text-[hsl(var(--notfair-warn))]" aria-hidden />- <span className="font-medium text-sm">- Couldn’t load your {mcpDisplayName} accounts.- </span>- </div>- <p className="text-xs text-muted-foreground">{state.message}</p>- <div className="flex gap-2">- <Button asChild>- <Link href={`/onboarding?step=connect&slug=${encodeURIComponent(slug)}`}>- Back to connect- </Link>- </Button>- </div>- </CardContent>- </Card>- );- }- if (state.items.length === 0) {- return (- <Card role="alert">- <CardContent className="space-y-3 pt-6 pb-6">- <p className="text-sm font-medium">- No {mcpDisplayName} accounts on this connection.- </p>- <p className="text-xs text-muted-foreground">- Try a different account or skip this connector for now.- </p>- <Button asChild>- <Link href={`/onboarding?step=connect&slug=${encodeURIComponent(slug)}`}>- Back to connect- </Link>- </Button>- </CardContent>- </Card>- );- }- if (state.items.length === 1) {- return (- <Card>- <CardContent className="space-y-2 pt-6 pb-6">- <div className="flex items-center gap-3 text-sm">- <Loader2 className="size-4 animate-spin text-muted-foreground" aria-hidden />- <span className="font-medium">- Using your only {mcpDisplayName} account…- </span>- </div>- </CardContent>- </Card>- );- }- return (- <>- <header className="space-y-2">- <h1 className="text-3xl font-semibold tracking-tight text-foreground">- Which {mcpDisplayName} account?- </h1>- <p className="text-sm text-muted-foreground">- Your connection has {state.items.length} accounts. Pick the one- you want me to use for this workspace. You can switch later in- Settings.- </p>- </header>- <ul className="space-y-2 list-none p-0">- {state.items.map((item) => {- const isOtherPicking = state.anyPicking && !item.isPicking;- return (- <li key={item.id}>- <button- type="button"- onClick={() => onPick(item.id)}- disabled={state.anyPicking}- aria-label={`Use ${item.name} (${item.id})`}- className={cn(- "block w-full rounded-md border bg-card p-4 text-left transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/30 disabled:cursor-not-allowed",- isOtherPicking && "opacity-50",- )}- >- <div className="flex items-center justify-between gap-3">- <div className="min-w-0 flex-1">- <div className="flex items-center gap-2">- <span className="font-medium text-sm">{item.name}</span>- {item.isDefault && (- <span className="rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground">- default- </span>- )}- </div>- <p className="text-xs text-muted-foreground tabular-nums">- {idLabel} {item.id}- </p>- </div>- {item.isPicking ? (- <Loader2 className="size-4 animate-spin text-muted-foreground" aria-hidden />- ) : (- <ChevronRight className="size-4 text-muted-foreground" aria-hidden />- )}- </div>- </button>- </li>- );- })}- </ul></>);}diff --git a/notfair/src/lib/mcp-account-pickers.test.ts b/notfair/src/lib/mcp-account-pickers.test.tsnew file mode 100644index 00000000..f6a528ac--- /dev/null+++ b/notfair/src/lib/mcp-account-pickers.test.ts@@ -0,0 +1,131 @@+import { beforeEach, describe, expect, it, vi } from "vitest";++import { accountPickerFor } from "@/lib/mcp-account-pickers";+import {+ listGoogleAdsAccounts,+ listMetaAdsAccounts,+ listGscProperties,+ setOnboardingAccountAction,+ setOnboardingGscPropertyAction,+} from "@/server/onboarding/accounts";+import type { Project } from "@/types";++vi.mock("@/server/onboarding/accounts", () => ({+ listGoogleAdsAccounts: vi.fn(),+ setOnboardingAccountAction: vi.fn(),+ listMetaAdsAccounts: vi.fn(),+ setOnboardingMetaAdsAccountAction: vi.fn(),+ listGscProperties: vi.fn(),+ setOnboardingGscPropertyAction: vi.fn(),+}));++const project = {+ google_ads_account_id: "111",+ meta_ads_account_id: "act_222",+ gsc_property_id: "sc-domain:example.com",+} as Project;++beforeEach(() => {+ vi.clearAllMocks();+});++describe("accountPickerFor", () => {+ it("returns null for MCPs without an account picker", () => {+ expect(accountPickerFor("notfair-xads")).toBeNull();+ expect(accountPickerFor("stripe")).toBeNull();+ expect(accountPickerFor("")).toBeNull();+ });++ it("covers exactly the three multi-account MCPs", () => {+ for (const key of [+ "notfair-googleads",+ "notfair-metaads",+ "notfair-googlesearchconsole",+ ]) {+ expect(accountPickerFor(key), key).not.toBeNull();+ }+ });++ it("reads the persisted selection off the matching project column", () => {+ expect(accountPickerFor("notfair-googleads")!.selectedId(project)).toBe(+ "111",+ );+ expect(accountPickerFor("notfair-metaads")!.selectedId(project)).toBe(+ "act_222",+ );+ expect(+ accountPickerFor("notfair-googlesearchconsole")!.selectedId(project),+ ).toBe("sc-domain:example.com");+ });+});++describe("list normalization", () => {+ it("maps Google Ads accounts and flags the MCP default", async () => {+ vi.mocked(listGoogleAdsAccounts).mockResolvedValue({+ ok: true,+ accounts: [+ { id: "111", name: "Acme" },+ { id: "222", name: "Beta" },+ ],+ default_account_id: "222",+ });+ const r = await accountPickerFor("notfair-googleads")!.list("proj");+ expect(r).toEqual({+ ok: true,+ items: [+ { id: "111", name: "Acme", is_default: false },+ { id: "222", name: "Beta", is_default: true },+ ],+ });+ expect(listGoogleAdsAccounts).toHaveBeenCalledWith("proj");+ });++ it("maps GSC properties through the same shape", async () => {+ vi.mocked(listGscProperties).mockResolvedValue({+ ok: true,+ properties: [+ { id: "sc-domain:a.com", name: "a.com", permission: "siteOwner" },+ ],+ default_property_id: null,+ });+ const r = await accountPickerFor("notfair-googlesearchconsole")!.list("p");+ expect(r).toEqual({+ ok: true,+ items: [{ id: "sc-domain:a.com", name: "a.com", is_default: false }],+ });+ });++ it("passes list failures through untouched", async () => {+ vi.mocked(listMetaAdsAccounts).mockResolvedValue({+ ok: false,+ kind: "rpc",+ error: "HTTP 500",+ });+ const r = await accountPickerFor("notfair-metaads")!.list("p");+ expect(r).toEqual({ ok: false, error: "HTTP 500" });+ });+});++describe("set normalization", () => {+ it("delegates to the platform set action and simplifies the result", async () => {+ vi.mocked(setOnboardingAccountAction).mockResolvedValue({+ ok: true,+ project,+ });+ const r = await accountPickerFor("notfair-googleads")!.set("proj", "111");+ expect(r).toEqual({ ok: true });+ expect(setOnboardingAccountAction).toHaveBeenCalledWith("proj", "111");+ });++ it("surfaces set failures as { ok: false, error }", async () => {+ vi.mocked(setOnboardingGscPropertyAction).mockResolvedValue({+ ok: false,+ error: "Property X isn't reachable.",+ });+ const r = await accountPickerFor("notfair-googlesearchconsole")!.set(+ "proj",+ "X",+ );+ expect(r).toEqual({ ok: false, error: "Property X isn't reachable." });+ });+});diff --git a/notfair/src/lib/mcp-account-pickers.ts b/notfair/src/lib/mcp-account-pickers.tsnew file mode 100644index 00000000..fe56f0fe--- /dev/null+++ b/notfair/src/lib/mcp-account-pickers.ts@@ -0,0 +1,128 @@+/**+ * Registry of MCPs whose bearer can span multiple accounts/properties and+ * therefore need a per-project selection (persisted on the `projects` row —+ * goal agents read it from their identity's "Workspace facts").+ *+ * One entry per pickable catalog key, normalizing the per-platform list/set+ * server actions from `@/server/onboarding/accounts` into a single shape so+ * the Connections-page picker dialog can drive any of them. The onboarding+ * wizard keeps its own step-based UI over the same actions.+ *+ * This module carries no directive on purpose: the server-rendered+ * Connections page uses `selectedId` to read the persisted choice off the+ * project row, and the client dialog uses `list`/`set` (which resolve to+ * server-action stubs on the client).+ */++import {+ listGoogleAdsAccounts,+ setOnboardingAccountAction,+ listMetaAdsAccounts,+ setOnboardingMetaAdsAccountAction,+ listGscProperties,+ setOnboardingGscPropertyAction,+} from "@/server/onboarding/accounts";+import type { Project } from "@/types";++export type AccountPickerItem = {+ id: string;+ name: string;+ /** True when the MCP flagged this entry as the bearer's default. */+ is_default: boolean;+};++export type AccountPickerListResult =+ | { ok: true; items: AccountPickerItem[] }+ | { ok: false; error: string };++export type AccountPickerSetResult =+ | { ok: true }+ | { ok: false; error: string };++export type AccountPickerSpec = {+ /** Human noun for the selectable unit, e.g. "Google Ads account". */+ noun: string;+ /** Bare unit for tight UI slots ("account" / "property") — the card's+ * primary button says "Choose account", not the full noun. */+ short_noun: string;+ /** Label shown before the raw id under each row, e.g. "Customer ID". */+ id_label: string;+ list: (project_slug: string) => Promise<AccountPickerListResult>;+ set: (project_slug: string, id: string) => Promise<AccountPickerSetResult>;+ /** Read the persisted selection off the project row. */+ selectedId: (project: Project) => string | null;+};++const PICKERS: Record<string, AccountPickerSpec> = {+ "notfair-googleads": {+ noun: "Google Ads account",+ short_noun: "account",+ id_label: "Customer ID",+ list: async (slug) => {+ const r = await listGoogleAdsAccounts(slug);+ if (!r.ok) return { ok: false, error: r.error };+ return {+ ok: true,+ items: r.accounts.map((a) => ({+ id: a.id,+ name: a.name,+ is_default: a.id === r.default_account_id,+ })),+ };+ },+ set: async (slug, id) => {+ const r = await setOnboardingAccountAction(slug, id);+ return r.ok ? { ok: true } : { ok: false, error: r.error };+ },+ selectedId: (p) => p.google_ads_account_id,+ },+ "notfair-metaads": {+ noun: "Meta ad account",+ short_noun: "account",+ id_label: "Ad account ID",+ list: async (slug) => {+ const r = await listMetaAdsAccounts(slug);+ if (!r.ok) return { ok: false, error: r.error };+ return {+ ok: true,+ items: r.accounts.map((a) => ({+ id: a.id,+ name: a.name,+ is_default: a.id === r.default_account_id,+ })),+ };+ },+ set: async (slug, id) => {+ const r = await setOnboardingMetaAdsAccountAction(slug, id);+ return r.ok ? { ok: true } : { ok: false, error: r.error };+ },+ selectedId: (p) => p.meta_ads_account_id,+ },+ "notfair-googlesearchconsole": {+ noun: "Search Console property",+ short_noun: "property",+ id_label: "Property",+ list: async (slug) => {+ const r = await listGscProperties(slug);+ if (!r.ok) return { ok: false, error: r.error };+ return {+ ok: true,+ items: r.properties.map((p) => ({+ id: p.id,+ name: p.name,+ is_default: p.id === r.default_property_id,+ })),+ };+ },+ set: async (slug, id) => {+ const r = await setOnboardingGscPropertyAction(slug, id);+ return r.ok ? { ok: true } : { ok: false, error: r.error };+ },+ selectedId: (p) => p.gsc_property_id,+ },+};++/** Picker spec for a catalog key, or null when the MCP has no account picker. */+export function accountPickerFor(mcp_key: string): AccountPickerSpec | null {+ return PICKERS[mcp_key] ?? null;+}diff --git a/notfair/src/server/mcp/account-selection.test.ts b/notfair/src/server/mcp/account-selection.test.tsnew file mode 100644index 00000000..1ec6de0e--- /dev/null+++ b/notfair/src/server/mcp/account-selection.test.ts@@ -0,0 +1,188 @@+import { beforeEach, describe, expect, it, vi } from "vitest";++import {+ resolvePostConnectSelection,+ prefetchAccountChoice,+} from "@/server/mcp/account-selection";+import {+ getProject,+ setProjectGscProperty,+ setProjectGoogleAdsAccount,+} from "@/server/db/projects";+import { listGscProperties } from "@/server/onboarding/accounts";+import type { Project } from "@/types";++// Mock at the platform-action + db layer so the real registry+// (mcp-account-pickers) is exercised as part of the resolution.+vi.mock("@/server/onboarding/accounts", () => ({+ listGoogleAdsAccounts: vi.fn(),+ setOnboardingAccountAction: vi.fn(),+ listMetaAdsAccounts: vi.fn(),+ setOnboardingMetaAdsAccountAction: vi.fn(),+ listGscProperties: vi.fn(),+ setOnboardingGscPropertyAction: vi.fn(),+}));+vi.mock("@/server/db/projects", () => ({+ getProject: vi.fn(),+ setProjectGoogleAdsAccount: vi.fn(),+ setProjectMetaAdsAccount: vi.fn(),+ setProjectGscProperty: vi.fn(),+}));++const GSC = "notfair-googlesearchconsole";++function makeProject(overrides: Partial<Project> = {}): Project {+ return {+ google_ads_account_id: null,+ meta_ads_account_id: null,+ gsc_property_id: null,+ ...overrides,+ } as Project;+}++function gscList(ids: string[]) {+ vi.mocked(listGscProperties).mockResolvedValue({+ ok: true,+ properties: ids.map((id) => ({ id, name: id })),+ default_property_id: null,+ });+}++beforeEach(() => {+ vi.clearAllMocks();+});++describe("resolvePostConnectSelection", () => {+ it("is not_pickable for MCPs without a picker (never lists)", async () => {+ const r = await resolvePostConnectSelection("proj", "notfair-xads");+ expect(r).toEqual({ kind: "not_pickable" });+ expect(listGscProperties).not.toHaveBeenCalled();+ });++ it("is not_pickable when the project row is gone", async () => {+ vi.mocked(getProject).mockReturnValue(null);+ const r = await resolvePostConnectSelection("proj", GSC);+ expect(r).toEqual({ kind: "not_pickable" });+ });++ it("keeps an existing selection the new bearer can still reach", async () => {+ vi.mocked(getProject).mockReturnValue(+ makeProject({ gsc_property_id: "sc-domain:a.com" }),+ );+ gscList(["sc-domain:a.com", "sc-domain:b.com"]);+ const r = await resolvePostConnectSelection("proj", GSC);+ expect(r).toEqual({ kind: "kept_existing" });+ expect(setProjectGscProperty).not.toHaveBeenCalled();+ });++ it("auto-persists the only reachable account", async () => {+ vi.mocked(getProject).mockReturnValue(makeProject());+ gscList(["sc-domain:only.com"]);+ const r = await resolvePostConnectSelection("proj", GSC);+ expect(r).toEqual({+ kind: "auto_selected",+ id: "sc-domain:only.com",+ name: "sc-domain:only.com",+ });+ expect(setProjectGscProperty).toHaveBeenCalledWith(+ "proj",+ "sc-domain:only.com",+ );+ });++ it("requires a choice when the bearer reaches several accounts", async () => {+ vi.mocked(getProject).mockReturnValue(makeProject());+ gscList(["sc-domain:a.com", "sc-domain:b.com"]);+ const r = await resolvePostConnectSelection("proj", GSC);+ expect(r).toEqual({ kind: "choice_required" });+ expect(setProjectGscProperty).not.toHaveBeenCalled();+ });++ it("requires a choice when the old selection is no longer reachable", async () => {+ vi.mocked(getProject).mockReturnValue(+ makeProject({ gsc_property_id: "sc-domain:gone.com" }),+ );+ gscList(["sc-domain:a.com", "sc-domain:b.com"]);+ const r = await resolvePostConnectSelection("proj", GSC);+ expect(r).toEqual({ kind: "choice_required" });+ });++ it("requires a choice (to surface the problem) when the list call fails", async () => {+ vi.mocked(getProject).mockReturnValue(makeProject());+ vi.mocked(listGscProperties).mockResolvedValue({+ ok: false,+ kind: "rpc",+ error: "timeout",+ });+ const r = await resolvePostConnectSelection("proj", GSC);+ expect(r).toEqual({ kind: "choice_required" });+ });++ it("routes each platform to its own project column", async () => {+ const { listGoogleAdsAccounts } = await import(+ "@/server/onboarding/accounts"+ );+ vi.mocked(getProject).mockReturnValue(makeProject());+ vi.mocked(listGoogleAdsAccounts).mockResolvedValue({+ ok: true,+ accounts: [{ id: "123", name: "Only" }],+ default_account_id: null,+ });+ await resolvePostConnectSelection("proj", "notfair-googleads");+ expect(setProjectGoogleAdsAccount).toHaveBeenCalledWith("proj", "123");+ expect(setProjectGscProperty).not.toHaveBeenCalled();+ });+});++describe("prefetchAccountChoice", () => {+ it("returns null for non-pickable MCPs", async () => {+ const r = await prefetchAccountChoice(makeProject(), "stripe");+ expect(r).toBeNull();+ });++ it("returns null when the persisted selection is still reachable", async () => {+ gscList(["sc-domain:a.com"]);+ const r = await prefetchAccountChoice(+ makeProject({ gsc_property_id: "sc-domain:a.com" }),+ GSC,+ );+ expect(r).toBeNull();+ });++ it("hands the list + current selection to the dialog when a choice is due", async () => {+ gscList(["sc-domain:a.com", "sc-domain:b.com"]);+ const r = await prefetchAccountChoice(+ makeProject({ gsc_property_id: "sc-domain:gone.com" }),+ GSC,+ );+ expect(r).toEqual({+ prefetch: {+ ok: true,+ items: [+ { id: "sc-domain:a.com", name: "sc-domain:a.com", is_default: false },+ { id: "sc-domain:b.com", name: "sc-domain:b.com", is_default: false },+ ],+ },+ selected_id: "sc-domain:gone.com",+ });+ });++ it("passes a list failure through so the dialog can show it", async () => {+ vi.mocked(listGscProperties).mockResolvedValue({+ ok: false,+ kind: "rpc",+ error: "HTTP 502",+ });+ const r = await prefetchAccountChoice(makeProject(), GSC);+ expect(r).toEqual({+ prefetch: { ok: false, error: "HTTP 502" },+ selected_id: null,+ });+ });++ it("never writes — auto-selection is the OAuth callback's job", async () => {+ gscList(["sc-domain:only.com"]);+ await prefetchAccountChoice(makeProject(), GSC);+ expect(setProjectGscProperty).not.toHaveBeenCalled();+ });+});diff --git a/notfair/src/server/mcp/account-selection.ts b/notfair/src/server/mcp/account-selection.tsnew file mode 100644index 00000000..c5064c0b--- /dev/null+++ b/notfair/src/server/mcp/account-selection.ts@@ -0,0 +1,95 @@+/**+ * Server-side post-connect account/property resolution for multi-account+ * MCPs (Google Ads, Meta Ads, Search Console).+ *+ * Runs inside the OAuth callback, before the redirect back to the app:+ *+ * - selection already set and still reachable by the new bearer → keep it;+ * - the bearer reaches exactly one account/property → persist it (there is+ * no real choice to offer);+ * - otherwise → `choice_required`, and the callback appends `?mcp_key=` so+ * the Connections page opens the picker dialog.+ *+ * Doing this server-side (rather than in a client effect after landing)+ * matters: a mount-time server-action fetch races the flash banner's+ * URL-cleanup navigation, which can strand the action's promise.+ */++import { accountPickerFor } from "@/lib/mcp-account-pickers";+import {+ getProject,+ setProjectGoogleAdsAccount,+ setProjectMetaAdsAccount,+ setProjectGscProperty,+} from "@/server/db/projects";+import type { AccountPickerPrefetch } from "@/components/mcp-account-picker-dialog";+import type { Project } from "@/types";++const SETTERS: Record<+ string,+ (slug: string, id: string | null) => Project | null+> = {+ "notfair-googleads": setProjectGoogleAdsAccount,+ "notfair-metaads": setProjectMetaAdsAccount,+ "notfair-googlesearchconsole": setProjectGscProperty,+};++export type PostConnectSelection =+ | { kind: "not_pickable" }+ | { kind: "kept_existing" }+ | { kind: "auto_selected"; id: string; name: string }+ | { kind: "choice_required" };++export async function resolvePostConnectSelection(+ project_slug: string,+ catalog_key: string,+): Promise<PostConnectSelection> {+ const picker = accountPickerFor(catalog_key);+ const setter = SETTERS[catalog_key];+ if (!picker || !setter) return { kind: "not_pickable" };+ const project = getProject(project_slug);+ if (!project) return { kind: "not_pickable" };++ const list = await picker.list(project_slug);+ // Can't reach the MCP right now — let the Connections page's picker+ // surface the problem (it retries the list on render).+ if (!list.ok) return { kind: "choice_required" };++ const selected = picker.selectedId(project);+ if (selected && list.items.some((i) => i.id === selected)) {+ return { kind: "kept_existing" };+ }+ if (list.items.length === 1) {+ const only = list.items[0]!;+ setter(project_slug, only.id);+ return { kind: "auto_selected", id: only.id, name: only.name };+ }+ // Zero or many — the user has to look at it either way.+ return { kind: "choice_required" };+}++/**+ * Server-render-time prefetch for the account picker dialog. Pages that+ * receive the post-OAuth `?mcp_key=` (Connections, onboarding connect+ * step) call this during render and hand the result to the client, so+ * the dialog opens with data instead of racing the flash banner's+ * URL-cleanup navigation with a mount-time fetch.+ *+ * Returns null when no picker should open: unknown/non-pickable key, or+ * the persisted selection is still reachable (covers stale URLs — the+ * OAuth callback normally filters that case before appending the param).+ * Read-only by design: auto-selecting a lone account is the callback's+ * job; a GET render must not write.+ */+export async function prefetchAccountChoice(+ project: Project,+ mcp_key: string,+): Promise<{ prefetch: AccountPickerPrefetch; selected_id: string | null } | null> {+ const picker = accountPickerFor(mcp_key);+ if (!picker) return null;+ const selected_id = picker.selectedId(project);+ const list = await picker.list(project.slug);+ if (!list.ok) return { prefetch: { ok: false, error: list.error }, selected_id };+ if (selected_id && list.items.some((i) => i.id === selected_id)) return null;+ return { prefetch: { ok: true, items: list.items }, selected_id };+}diff --git a/notfair/src/server/onboarding/accounts.ts b/notfair/src/server/onboarding/accounts.tsindex ec4c7af6..841b46be 100644--- a/notfair/src/server/onboarding/accounts.ts+++ b/notfair/src/server/onboarding/accounts.ts@@ -458,141 +458,64 @@ export async function setOnboardingGscPropertyAction(return { ok: true, project: updated };}-// ── Onboarding connect-step state ──────────────────────────────────+// ── Onboarding connect-step cards ──────────────────────────────────//-// The multi-MCP onboarding step renders one tile per recommended MCP-// (Google Ads, Meta Ads, GSC, X Ads — the ones that power a specialist-// agent) plus a "More" tile. Google Analytics lives under "More": it-// provisions no specialist, so a connected GA surfaces as an extras-// row instead of a first-class tile. Each tile needs:+// The connect step renders the exact `McpCard` rows the Connections page+// uses — one shared component, one lifecycle (Connect → Choose → Switch),+// zero drift between the two surfaces. This action assembles the card+// inputs client-side onboarding can't compute itself: the catalog spec,+// the live runtime status, and the persisted account/property selection.//-// - is the MCP connected? (token row exists)-// - is an account/property selected on the project row?-// - the display name to label the tile-//-// We also surface a count of additional non-recommended connectors the-// user has wired up via the "More" tile so the tile can show that-// number ("More · 2 connected").--export type ConnectedMcpState = {- /** True when an mcp_tokens row exists for this catalog_key. */- connected: boolean;- /**- * True when the user has picked a specific account/property for this MCP- * (i.e. the project column is non-null). Always false when not connected.- */- account_selected: boolean;-};--export type ConnectedExtraMcp = {- /** Catalog key (`stripe`, `supabase`, …) — what's stored on mcp_tokens. */- key: string;- /** Display label resolved from the catalog (`Stripe`, `Supabase`, …). */- display_name: string;- /** Short marketing line from the catalog. Optional. */- description?: string;- /** Resource URL — feeds the <McpIcon> favicon lookup so each extra row- * shows its brand mark the same way the Connections page does. */- resource_url: string;+// The list is curated for the wizard: the recommended MCPs (the ones+// goal agents most commonly measure) always show; anything else from the+// catalog (Google Analytics, Stripe, user-pasted servers) appears only+// once connected — until then it lives in the "More tools" browse menu.++const RECOMMENDED_MCP_KEYS = new Set([+ "notfair-googleads",+ "notfair-metaads",+ "notfair-googlesearchconsole",+ "notfair-xads",+]);++export type ConnectCard = {+ spec: import("@/server/mcp-catalog").McpSpec;+ status: import("@/server/mcp/state").McpRuntimeStatus;+ /** Persisted account/property selection — null when unset/not pickable. */+ selected_id: string | null;};-export type ConnectStepState = {- googleads: ConnectedMcpState;- metaads: ConnectedMcpState;- gsc: ConnectedMcpState;- /**- * X Ads has a first-class connect tile like the trio above, but no- * account/property picker sub-flow — `account_selected` simply- * mirrors `connected` so the tile shape stays uniform.- */- xads: ConnectedMcpState;- /**- * MCPs the user has connected via the "More tools" overflow dialog —- * anything outside the recommended trio (Stripe, Supabase, PostHog,- * plus any user-pasted custom servers). Rendered as additional rows in- * the connect-step list below the recommended tiles.- */- extras: ConnectedExtraMcp[];- /**- * Cached length of `extras`. Kept on the surface so existing test- * fixtures and any caller that only needs a badge count don't have- * to compute it themselves.- */- extra_connected_count: number;- /**- * Project's website_url — used by the connect step to pre-load context- * about what the user is connecting tools for. Optional in the schema;- * propagated here for the redirect-target builder.- */- website_url: string | null;-};--export type GetConnectStepStateResult =- | { ok: true; state: ConnectStepState }+export type GetConnectCardsResult =+ | { ok: true; cards: ConnectCard[]; any_connected: boolean }| { ok: false; error: string };-export async function getConnectStepStateAction(+export async function getOnboardingConnectCardsAction(project_slug: string,-): Promise<GetConnectStepStateResult> {+): Promise<GetConnectCardsResult> {if (!project_slug.trim()) return { ok: false, error: "Missing project slug." };const project = getProject(project_slug);if (!project) return { ok: false, error: "Project not found." };- const { findMcpToken, listProjectMcpTokens } = await import(- "@/server/mcp/tokens"- );const { getMcpCatalog } = await import("@/server/mcp-catalog");+ const { getMcpStatus } = await import("@/server/mcp/state");+ const { accountPickerFor } = await import("@/lib/mcp-account-pickers");- const RECOMMENDED_KEYS = new Set([- "notfair-googleads",- "notfair-metaads",- "notfair-googlesearchconsole",- "notfair-xads",- ]);- const allTokens = listProjectMcpTokens(project_slug);const catalog = getMcpCatalog(project_slug);-- // Build the extras list: for every connected non-recommended token,- // look up its display name + description in the catalog so the connect- // step can render real rows ("Stripe — Payments, …") instead of a bare- // catalog-key. Tokens whose catalog entry was removed (rare — manual- // db edit, or a preset we silently dropped) are skipped silently.- const extras: ConnectedExtraMcp[] = [];- for (const t of allTokens) {- if (RECOMMENDED_KEYS.has(t.server_name)) continue;- const entry = catalog.find((c) => c.key === t.server_name);- if (!entry) continue;- extras.push({- key: t.server_name,- display_name: entry.display_name,- description: entry.description,- resource_url: entry.resource_url,- });- }-+ const statuses = await Promise.all(+ catalog.map((s) => getMcpStatus(project_slug, s.key)),+ );+ const all = catalog.map((spec, i) => ({+ spec,+ status: statuses[i]!,+ selected_id: accountPickerFor(spec.key)?.selectedId(project) ?? null,+ }));return {ok: true,- state: {- googleads: {- connected: !!findMcpToken(project_slug, "notfair-googleads"),- account_selected: !!project.google_ads_account_id,- },- metaads: {- connected: !!findMcpToken(project_slug, "notfair-metaads"),- account_selected: !!project.meta_ads_account_id,- },- gsc: {- connected: !!findMcpToken(project_slug, "notfair-googlesearchconsole"),- account_selected: !!project.gsc_property_id,- },- xads: (() => {- const connected = !!findMcpToken(project_slug, "notfair-xads");- return { connected, account_selected: connected };- })(),- extras,- extra_connected_count: extras.length,- website_url: project.website_url,- },+ cards: all.filter(+ (c) =>+ RECOMMENDED_MCP_KEYS.has(c.spec.key) || c.status.state === "connected",+ ),+ any_connected: all.some((c) => c.status.state === "connected"),};}diff --git a/notfair/vitest.config.ts b/notfair/vitest.config.tsnew file mode 100644index 00000000..e776860a--- /dev/null+++ b/notfair/vitest.config.ts@@ -0,0 +1,22 @@+import path from "node:path";+import { defineConfig } from "vitest/config";+import react from "@vitejs/plugin-react";++export default defineConfig({+ plugins: [react()],+ resolve: {+ alias: { "@": path.resolve(__dirname, "src") },+ },+ test: {+ // Testing-library auto-cleanup registers on the global afterEach.+ globals: true,+ // Only first-party tests — `next build` copies src (tests included)+ // into .next/standalone, which vitest must not collect.+ include: ["src/**/*.test.{ts,tsx}"],+ setupFiles: ["./vitest.setup.ts"],+ // Server modules and libs run in node. Component tests opt into a DOM+ // per-file via `// @vitest-environment jsdom` (vitest 4 removed the+ // environmentMatchGlobs shorthand).+ environment: "node",+ },+});diff --git a/notfair/vitest.setup.ts b/notfair/vitest.setup.tsnew file mode 100644index 00000000..f149f27a--- /dev/null+++ b/notfair/vitest.setup.ts@@ -0,0 +1 @@+import "@testing-library/jest-dom/vitest";