Connect card: pin the MCP install URL to the URL's org (fix wrong-org flash) - #1011
Conversation
A multi-org user loading /<orgB> while their session cookie still points at
orgA saw orgA's slug flash into the copyable `npx add-mcp .../<slug>/mcp` box
before /account/me resolved. On first paint `auth.organization` comes from the
SSR auth-hint, which is scoped to the COOKIE's org — but the page is scoped to
the URL's org.
Seed OrganizationProvider's slug (which feeds the connect card via
useOrganizationSlug) from the URL's `{-$orgSlug}` param, falling back to the
session slug on a bare URL (which OrgSlugGate canonicalizes onto it anyway). The
URL slug is the actual request scope and is correct on the very first paint, so
the wrong slug never appears. OrgSlugGate keeps using the session slug for
canonicalization; only the install-URL context changes. useOrganizationSlug is
consumed solely by the connect card, so there's no other blast radius.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-cloud | 405e3c0 | Jun 13 2026, 09:22 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-marketing | 405e3c0 | Commit Preview URL Branch Preview URL |
Jun 13 2026, 09:21 PM |
Cloudflare previewTorn down — the PR is closed. |
Greptile SummarySeeds
Confidence Score: 5/5Safe to merge — the change is a single-line seed that only affects the copyable install URL in the connect card, with no impact on auth, access control, or other org-scoped consumers. The fix is minimal and well-bounded. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant SSR as SSR Gate
participant Root as __root.tsx (AuthGate)
participant OrgCtx as OrganizationProvider
participant Card as McpInstallCard
participant Me as /account/me
Note over Browser,Me: Multi-org user loads /<orgB> (cookie still has orgA)
Browser->>SSR: "GET /<orgB>/..."
SSR-->>Browser: "authHint = { org: orgA } (cookie scope), urlOrgSlug = orgB"
Note over Root: BEFORE fix: scopeSlug = activeSlug = orgA slug (wrong)
Note over Root: AFTER fix: scopeSlug = urlOrgSlug ?? activeSlug = orgB slug (correct)
Root->>OrgCtx: "organizationId=orgA.id, organizationSlug=scopeSlug"
OrgCtx->>Card: useOrganizationSlug() returns orgB slug
Card-->>Browser: "npx add-mcp .../<orgB>/mcp (correct on first paint)"
Browser->>Me: GET /account/me (URL-scoped to orgB)
Me-->>Root: "auth.organization = { id: orgB.id, slug: orgB slug }"
Root->>OrgCtx: "organizationId=orgB.id, organizationSlug=orgB slug (steady state)"
Reviews (1): Last reviewed commit: "Connect card: pin the MCP install URL to..." | Re-trigger Greptile |
@executor-js/cli
@executor-js/config
@executor-js/execution
@executor-js/sdk
@executor-js/codemode-core
@executor-js/runtime-quickjs
@executor-js/plugin-file-secrets
@executor-js/plugin-graphql
@executor-js/plugin-keychain
@executor-js/plugin-mcp
@executor-js/plugin-onepassword
@executor-js/plugin-openapi
executor
commit: |
A multi-org user loading
/<orgB>while their session cookie still points atorgA saw orgA's slug flash into the copyable
npx add-mcp .../<slug>/mcpURLbefore
/account/meresolved — a worse-than-cosmetic bug, since the wrongendpoint is copyable.
Cause
On first paint
auth.organizationcomes from the SSR auth-hint, which is scopedto the cookie's org (the gate deliberately doesn't do a WorkOS membership
lookup per document request). But the page is scoped to the URL's org. The
connect card reads
useOrganizationSlug(), which__root.tsxseeded fromauth.organization.slug— so until/account/me(URL-scoped) resolved, thecard rendered the cookie org's slug.
Fix
Seed
OrganizationProvider's slug from the URL's{-$orgSlug}param(
urlOrgSlug ?? activeSlug). The URL slug is the actual request scope and iscorrect on the very first paint (it's in the path during SSR too), so the wrong
slug never appears. Falls back to the session slug on a bare URL, which
OrgSlugGateis about to canonicalize onto it anyway.OrgSlugGatekeeps usingthe session slug for canonicalization; only the install-URL context changes.
useOrganizationSlugis consumed only by the connect card(
McpInstallCard), so there's no other blast radius — theorganizationIdconsumers are untouched.
Verification
Typecheck/lint/format clean. The fix is a one-line seed change; correctness
holds across steady-state, the multi-org flash, bare-URL canonicalize, and
foreign-slug 404 (verified by reasoning — a sub-second first-paint flash is too
timing/highlight-brittle to pin in e2e reliably). Happy to demo live on a
two-org dev instance.