create-ailk 0.35.1 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +1 -1
  2. package/component-catalog.json +51 -1
  3. package/component-catalog.md +8 -5
  4. package/dist/lib/env-catalog.js +8 -0
  5. package/dist/surfaces.js +66 -22
  6. package/dist/topology.d.ts +4 -4
  7. package/dist/topology.js +104 -60
  8. package/dist/update.d.ts +19 -1
  9. package/dist/update.js +293 -35
  10. package/package.json +3 -3
  11. package/templates/.env.example +38 -0
  12. package/templates/apps/api/.env.example +45 -0
  13. package/templates/apps/api/CLAUDE.md +12 -4
  14. package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
  15. package/templates/apps/mcp/CLAUDE.md +4 -2
  16. package/templates/apps/web/.env.example +16 -0
  17. package/templates/apps/web/CLAUDE.md +73 -5
  18. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
  19. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
  20. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
  21. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
  22. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
  23. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
  24. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
  25. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
  26. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
  27. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
  28. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
  29. package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
  30. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +241 -66
  31. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
  32. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +377 -151
  33. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
  34. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
  35. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
  36. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
  37. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
  38. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
  39. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
  40. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
  41. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
  42. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
  43. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
  44. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
  45. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
  46. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +20 -4
  47. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
  48. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
  49. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
  51. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
  52. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
  53. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
  54. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
  55. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
  56. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
  57. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
  58. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
  59. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
  60. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +323 -73
  61. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +199 -43
  62. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
  63. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
  64. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
  65. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
  66. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
  67. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
  68. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
  69. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
  70. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +97 -53
  71. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
  72. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +215 -0
  73. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
  74. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
  75. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
  76. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
  77. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
  78. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
  79. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
  80. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
  81. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
  82. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
  83. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
  84. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
  85. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
  86. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +9 -6
  87. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
  88. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
  89. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
  90. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
  91. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
  92. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
  93. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
  94. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
  95. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
  96. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +21 -22
  97. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
  98. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
  99. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
  100. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
  101. package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
  102. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
  103. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
  104. package/templates/apps/web/app/[locale]/layout.tsx +24 -75
  105. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
  106. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
  107. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
  108. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +166 -7
  109. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +96 -30
  110. package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
  111. package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
  112. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
  113. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
  114. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
  115. package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
  116. package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
  117. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
  118. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
  119. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
  120. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
  121. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +738 -7
  122. package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
  123. package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
  124. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
  125. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
  126. package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
  127. package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
  128. package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
  129. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
  130. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
  131. package/templates/apps/web/auth.ts +133 -6
  132. package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
  133. package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
  134. package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
  135. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
  136. package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
  137. package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
  138. package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
  139. package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
  140. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
  141. package/templates/apps/web/lib/account-config.ts +132 -8
  142. package/templates/apps/web/lib/auth-email.ts +62 -6
  143. package/templates/apps/web/lib/auth-env.ts +13 -0
  144. package/templates/apps/web/lib/auth-routes.ts +11 -6
  145. package/templates/apps/web/lib/auth-sms.ts +180 -0
  146. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
  147. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
  148. package/templates/apps/web/lib/hub-session/config.ts +7 -1
  149. package/templates/apps/web/lib/hub-session/entry.ts +238 -0
  150. package/templates/apps/web/lib/hub-session/index.ts +1 -4
  151. package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
  152. package/templates/apps/web/lib/hub-session/session.ts +120 -2
  153. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
  154. package/templates/apps/web/lib/offerings-pricing.ts +4 -1
  155. package/templates/apps/web/lib/site-header.ts +14 -1
  156. package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
  157. package/templates/apps/web/lib/topology.generated.ts +39 -0
  158. package/templates/apps/web/messages/en.json +264 -96
  159. package/templates/apps/web/middleware.ts +34 -2
  160. package/templates/apps/web/security-headers.config.ts +21 -0
  161. package/versions.json +48 -48
  162. package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
  163. package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
  164. package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
  165. package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
  166. package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
  167. package/templates/apps/web/components/signed-in-nav.tsx +0 -79
  168. package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
  169. package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
@@ -3,7 +3,7 @@
3
3
  // Theme 1.9 — SSR theme + flash-prevention + CSS vars + meta + JSON-LD (#1322)
4
4
  // Chrome extract — Nav + Footer from @working-theory/ui (#1451)
5
5
  // Shell/Chrome composition — Nav + Footer wrap via @working-theory/templates MarketingShell (#2820)
6
- // Session-aware Nav actions — Sign in / Account + Sign out from the server-read session (#4984)
6
+ // Session-aware Nav actions — Sign in signed out, one "Your account" link signed in (#4984, #11095 D6)
7
7
  // Auth route group — the marketing chrome is dropped on the five (auth) paths (#5963)
8
8
  // Account area — the marketing chrome AND the consent Banner are dropped on /account paths (#7430)
9
9
  // Site-declared theme — `_site.mdx` `theme:` block → token overlay → CSS vars
@@ -43,7 +43,7 @@ import {
43
43
  Footer,
44
44
  Nav,
45
45
  type NavAction,
46
- type NavActionFlow,
46
+ type NavProps,
47
47
  } from "@working-theory/ui/chrome";
48
48
  import {
49
49
  cookiePurpose,
@@ -66,10 +66,6 @@ import type { ReactElement, ReactNode } from "react";
66
66
  import { parse as parseYaml } from "yaml";
67
67
 
68
68
  import { GoogleAnalytics } from "../../components/google-analytics";
69
- import {
70
- SignedInNav,
71
- type SignedInNavProps,
72
- } from "../../components/signed-in-nav";
73
69
  import { isAccountPath, isAuthPath, isBookingPath } from "../../lib/auth-routes";
74
70
  import { BOT_CLIENT_PROTECT, botCheckOn } from "../../lib/bot-check";
75
71
  import { isClosingFooterPath } from "../../lib/closing-footer-path";
@@ -115,8 +111,10 @@ import {
115
111
  } from "../../lib/site-brand";
116
112
  import { siteChrome, type SiteChrome } from "../../lib/site-chrome";
117
113
  import {
114
+ ACCOUNT_LABEL_KEY,
118
115
  HEADER_CTA_LABEL_KEY,
119
116
  readSiteHeader,
117
+ signedInHeaderActions,
120
118
  signedOutHeaderActions,
121
119
  } from "../../lib/site-header";
122
120
  import { SITE_LISTING } from "../../lib/site-listing";
@@ -131,7 +129,6 @@ import "../../lib/listings";
131
129
  import { siteThemeHead } from "../../lib/site-theme-head";
132
130
  import {
133
131
  SIGN_IN_PATH,
134
- SIGN_OUT_ENDPOINT,
135
132
  SIGN_UP_PATH,
136
133
  readSession,
137
134
  } from "../../lib/topology.generated";
@@ -167,26 +164,6 @@ const CONSENT_COOKIE_NAME = "ailk-consent";
167
164
 
168
165
  type ThemeMode = "light" | "dark";
169
166
 
170
- /**
171
- * Placeholder flow for the signed-in Nav actions (#4984).
172
- *
173
- * `NavAction` has no client-handler kind — its shapes are `link` (navigate)
174
- * and `flow` (open a StepFlow lightbox). The `flow` kind + Nav's
175
- * `renderFlowTrigger` composer is Nav's ONE caller-composed seam (#4341): the
176
- * caller receives the rendered trigger `<Button>` and decides what wraps it.
177
- * The layout uses that seam WITHOUT a lightbox — `SignedInNav`'s
178
- * `renderFlowTrigger` replaces both signed-in triggers (Account → a
179
- * non-navigating name label, Sign out → `SignOutTrigger`), so this flow config
180
- * is NEVER rendered. It only has to satisfy the type: one minimal fields-step
181
- * and a dead `action`.
182
- */
183
- const NAV_CLIENT_ACTION_FLOW: NavActionFlow["flow"] = {
184
- steps: [
185
- { id: "noop", fields: [{ name: "noop", label: "noop", type: "text" }] },
186
- ],
187
- action: "#",
188
- };
189
-
190
167
  // The member account shell's token reset (#8337 D3) — a package constant
191
168
  // (no site, request or user input), computed once at module scope and
192
169
  // emitted only on account routes, after `theme-vars`, below.
@@ -447,15 +424,13 @@ export default async function LocaleLayout({
447
424
  const navItemLabels: Record<string, string> = Object.fromEntries(
448
425
  [...navLabelKeys].map((key) => [key, navText(key)]),
449
426
  );
450
- // Session-aware action labels (#4984). `account` carries the signed-in
451
- // user's display name (name, else email) so the Nav shows WHO is signed
452
- // in; it keeps the generic label when there is no session.
453
- if (session?.user) {
454
- navItemLabels["account"] = session.user.name ?? session.user.email;
455
- }
427
+ // The signed-in action's label (#11095 D6): "Your account", from the
428
+ // `account` namespace, beside the nav keys.
429
+ const tAccount = await getTranslations({ locale, namespace: "account" });
430
+ navItemLabels[ACCOUNT_LABEL_KEY] = tAccount("yourAccount");
456
431
  // The site's own signed-out header button (#10046) — `_site.mdx`'s
457
- // `header.cta`. Its label is site content, written straight into the map
458
- // as `account` is; the composition is `signedOutHeaderActions` below.
432
+ // `header.cta`. Its label is site content, written straight into the map;
433
+ // the composition is `signedOutHeaderActions` below.
459
434
  const siteHeader = readSiteHeader();
460
435
  if (siteHeader?.cta) {
461
436
  navItemLabels[HEADER_CTA_LABEL_KEY] = siteHeader.cta.label;
@@ -486,11 +461,9 @@ export default async function LocaleLayout({
486
461
  // route group, so both routes exist in every scaffold; whether the header
487
462
  // shows them is the design's nav setting (#6797 — an earlier revision of
488
463
  // this comment said the Free site had no sign-up flow; it renders both and
489
- // the service shapes now roster both). Signed in → the user's name (a
490
- // non-navigating label) + an outline-strong "Sign out"; both authored as
491
- // `kind: "flow"` so Nav hands their triggers back through
492
- // `renderFlowTrigger`, which `SignedInNav` owns (see NAV_CLIENT_ACTION_FLOW
493
- // above).
464
+ // the service shapes now roster both). Signed in → one outline-strong
465
+ // "Your account" link to /account, where the account shell's Log out
466
+ // lives (#11095 D6) — a link action, so the Nav stays a Server Component.
494
467
  // The signed-out auth pair, shared by the header (every page but the deck
495
468
  // home) and the deck home's closing footer slide (#7718 D4).
496
469
  // The pair comes from the generated seam (#7894 D10): a hub's /sign-in and
@@ -510,15 +483,7 @@ export default async function LocaleLayout({
510
483
  : []),
511
484
  ];
512
485
  const navActions: NavAction[] = session
513
- ? [
514
- { labelKey: "account", kind: "flow", flow: NAV_CLIENT_ACTION_FLOW },
515
- {
516
- labelKey: "signOut",
517
- kind: "flow",
518
- flow: NAV_CLIENT_ACTION_FLOW,
519
- variant: "outline-strong",
520
- },
521
- ]
486
+ ? signedInHeaderActions()
522
487
  : signedOutHeaderActions(siteHeader, authActions);
523
488
 
524
489
  // The announcement bar is HOME-ONLY (#5469 D5): its route gate matches the
@@ -563,13 +528,10 @@ export default async function LocaleLayout({
563
528
  const headerIsFull = pageChrome.header === "full";
564
529
 
565
530
  // Only a full header carries actions (#7718 D1, #10049). Under a bare or no
566
- // header the auth links move to the footer — the auth pair signed out, an
567
- // Account link signed in (the route where Sign out lives; its label is the
568
- // user's name, `navLabels.items.account`).
531
+ // header the auth links move to the footer — the auth pair signed out,
532
+ // "Your account" signed in (the route where Sign out lives).
569
533
  const headerActions: NavAction[] = headerIsFull ? navActions : [];
570
- const deckFooterActions = session
571
- ? [{ labelKey: "account", path: "/account", variant: "outline-strong" as const }]
572
- : [...authActions];
534
+ const deckFooterActions = session ? signedInHeaderActions() : [...authActions];
573
535
  // #10550 D4 — the closing footer's site settings: its locality line, its
574
536
  // actions (the primary, then the secondary — they replace the auth links
575
537
  // on the closing footer in every header state) and its legal bar. The
@@ -603,19 +565,6 @@ export default async function LocaleLayout({
603
565
  : []),
604
566
  ];
605
567
 
606
- // A flow action needs `renderFlowTrigger`, a function — and this layout is a
607
- // Server Component. Nav forwards that function into NavMobileMenu ("use
608
- // client"), and React cannot serialize a function across the RSC boundary:
609
- // passing it from here crashed EVERY signed-in page with "Functions cannot be
610
- // passed directly to Client Components" (#7402). Nav's own
611
- // `{...(renderFlowTrigger ? … : {})}` guard only skips the forward when the
612
- // function is undefined; it never makes passing one legal. So a flow action
613
- // routes the whole Nav through `SignedInNav` ("use client"), which defines
614
- // `renderFlowTrigger` and imports `navItems` (icon components are functions
615
- // too) on the client side. Without one, Nav stays a Server Component and
616
- // nothing callable crosses.
617
- const hasFlowAction = headerActions.some((action) => action.kind === "flow");
618
-
619
568
  // Shared brand mark injected into both Nav and Footer chrome slots. The
620
569
  // mark comes from site-logo.tsx (the mark the /sign-in card also renders);
621
570
  // both add the shipped wordmark beside it — the Nav composes mark + wordmark
@@ -684,10 +633,10 @@ export default async function LocaleLayout({
684
633
  !isMagnetWalkRoute &&
685
634
  (await pageOptsIntoDeck({ pathname, locale }));
686
635
 
687
- // Every Nav prop that is safe to serialize — shared verbatim by the
688
- // server-rendered Nav (signed out) and `SignedInNav` (signed in), which adds
689
- // `navItems` and `renderFlowTrigger` on its own side of the RSC boundary.
690
- const navProps: SignedInNavProps = {
636
+ // Every Nav prop but `navItems`, shared by the bare and the full Nav. No
637
+ // header action is a flow (#11095 D6), so nothing callable crosses the RSC
638
+ // boundary (#7402) and the Nav stays a Server Component in both states.
639
+ const navProps: Omit<NavProps, "navItems"> = {
691
640
  locale,
692
641
  labels: navLabels,
693
642
  // Deck home (#5697): the two forwards that join #5426 D4 to a real deck.
@@ -987,14 +936,14 @@ export default async function LocaleLayout({
987
936
  label: tNav("home"),
988
937
  }}
989
938
  />
990
- ) : hasFlowAction ? (
991
- <SignedInNav {...navProps} signOutEndpoint={SIGN_OUT_ENDPOINT} />
992
939
  ) : (
993
940
  <Nav
994
941
  {...navProps}
995
942
  navItems={
996
943
  siteChrome.nav === "mark-only" &&
997
- (pageChrome.header === "bare" || pageChrome.headerFromTemplate)
944
+ (session !== null ||
945
+ pageChrome.header === "bare" ||
946
+ pageChrome.headerFromTemplate)
998
947
  ? []
999
948
  : publicNavItems
1000
949
  }
@@ -85,6 +85,7 @@ jest.mock("../../../../src/lib/commerce-sections", () => ({
85
85
  import { checkout } from "@working-theory/api-client";
86
86
  import { notFound } from "next/navigation";
87
87
 
88
+ import { accountInviteHref } from "../../../../lib/account-invite";
88
89
  import Page, { generateMetadata } from "../success/page";
89
90
 
90
91
  const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
@@ -318,6 +319,55 @@ describe("/purchase/success", () => {
318
319
  expect(metadata.robots).toEqual({ index: false, follow: true });
319
320
  });
320
321
 
322
+ // ── #11095 D9, AC-7 — "Open your account" for the paid email ─────────────
323
+
324
+ it("a paid read with customerEmail renders Open your account at accountInviteHref, inside a data-sentry-block (AC-7)", async () => {
325
+ mockGetSession.mockResolvedValue({
326
+ ok: true,
327
+ body: { ...PAID_SESSION, customerEmail: "buyer@example.com" },
328
+ });
329
+ const { getByTestId } = await renderPage("cs_test_abc123");
330
+ const link = getByTestId("purchase-success-account");
331
+ expect(link.textContent).toBe("copy:success.openAccount");
332
+ const expected = accountInviteHref("en", "buyer@example.com");
333
+ expect(expected).not.toBeNull();
334
+ expect(link.getAttribute("href")).toBe(expected);
335
+ expect(link.closest("[data-sentry-block]")).not.toBeNull();
336
+ // The sections are unchanged in every state.
337
+ expect(sectionTypes()).toEqual(["payment-receipt", "items", "cta"]);
338
+ });
339
+
340
+ it.each([
341
+ ["a paid read without customerEmail", { ok: true, body: PAID_SESSION }],
342
+ [
343
+ "an unpaid read, even with customerEmail",
344
+ {
345
+ ok: true,
346
+ body: { ...PAID_SESSION, paymentStatus: "unpaid", customerEmail: "buyer@example.com" },
347
+ },
348
+ ],
349
+ ["a 404 read", { ok: false, status: 404, body: { error: "unknown-session" } }],
350
+ ])("%s renders no Open your account link (AC-7)", async (_label, response) => {
351
+ mockGetSession.mockResolvedValue(response);
352
+ const { queryByTestId, queryByText } = await renderPage("cs_test_abc123");
353
+ expect(queryByTestId("purchase-success-account")).toBeNull();
354
+ expect(queryByText("copy:success.openAccount")).toBeNull();
355
+ });
356
+
357
+ it("a rejected read renders no Open your account link (AC-7)", async () => {
358
+ mockGetSession.mockRejectedValue(new Error("network"));
359
+ const { queryByTestId, queryByText } = await renderPage("cs_test_abc123");
360
+ expect(queryByTestId("purchase-success-account")).toBeNull();
361
+ expect(queryByText("copy:success.openAccount")).toBeNull();
362
+ });
363
+
364
+ it("sends no referrer (SEC-11095-5)", async () => {
365
+ const metadata = await generateMetadata({
366
+ params: Promise.resolve({ locale: "en" }),
367
+ });
368
+ expect(metadata.referrer).toBe("no-referrer");
369
+ });
370
+
321
371
  // ── T-16 / D12 — the request-time commerce-claim gate ───────────────────
322
372
 
323
373
  it("answers notFound() when the commerce claim is NOT held, before any API call (D12)", async () => {
@@ -52,9 +52,16 @@
52
52
  *
53
53
  * `noindex`: reachable only by finishing (or trying) a Checkout, never a
54
54
  * page a crawler should list.
55
+ *
56
+ * #11095 D9 — "Open your account". A paid read whose answer carries
57
+ * `customerEmail` (the hub serves it only for a paid Offerings session of
58
+ * the caller's own workspace, under 24 h old) adds one link built by
59
+ * `accountInviteHref`. Session Replay records `href`s, so the link sits in a
60
+ * `data-sentry-block` wrapper, and the page sends no referrer (SEC-11095-5).
55
61
  */
56
62
  import { checkout } from "@working-theory/api-client";
57
63
  import type { CheckoutSessionReadResponse } from "@working-theory/api-client";
64
+ import { Button, Container, Link } from "@working-theory/ui";
58
65
  import { SectionRenderer } from "@working-theory/ui/sections";
59
66
  import type { PageSection } from "@working-theory/validation";
60
67
  import { formatMoney } from "@working-theory/web-i18n";
@@ -64,6 +71,7 @@ import { notFound } from "next/navigation";
64
71
  import { getTranslations } from "next-intl/server";
65
72
  import type { ReactElement } from "react";
66
73
 
74
+ import { accountInviteHref } from "../../../../lib/account-invite";
67
75
  import { resolveCommerceClaim } from "../../../../src/lib/commerce-claim";
68
76
  import { ensureCommerceSectionsRegistered } from "../../../../src/lib/commerce-sections";
69
77
 
@@ -240,13 +248,23 @@ async function paidSections(
240
248
  return [receipt, itemsSection(session.lineItems, t, locale), ctaSection(t)];
241
249
  }
242
250
 
251
+ /** What the page renders: D6's sections, plus the paid read's account link (#11095 D9). */
252
+ interface SuccessView {
253
+ sections: PageSection[];
254
+ accountHref: string | null;
255
+ }
256
+
243
257
  /** D6's five-row table, collapsed to the three code paths that produce distinct output. */
244
258
  async function sectionsFor(
245
259
  sessionId: string | undefined,
246
260
  t: PurchaseT,
247
261
  locale: string,
248
- ): Promise<PageSection[]> {
249
- if (!sessionId) return unknownSections(t);
262
+ ): Promise<SuccessView> {
263
+ const none = (sections: PageSection[]): SuccessView => ({
264
+ sections,
265
+ accountHref: null,
266
+ });
267
+ if (!sessionId) return none(unknownSections(t));
250
268
 
251
269
  // A malformed/oversized id (D8's shape gate) or an unknown session both
252
270
  // answer non-2xx here — the API's failure is logged server-side and never
@@ -261,15 +279,21 @@ async function sectionsFor(
261
279
  try {
262
280
  res = await checkout.getSession(sessionId, await resolveVisitorIpInit());
263
281
  } catch {
264
- return unknownSections(t);
282
+ return none(unknownSections(t));
265
283
  }
266
- if (!res.ok) return unknownSections(t);
284
+ if (!res.ok) return none(unknownSections(t));
267
285
 
268
286
  if (res.body.paymentStatus !== "paid") {
269
- return pendingSections(res.body, t, locale);
287
+ return none(pendingSections(res.body, t, locale));
270
288
  }
271
289
 
272
- return await paidSections(res.body, t, locale);
290
+ const { customerEmail } = res.body;
291
+ return {
292
+ sections: await paidSections(res.body, t, locale),
293
+ accountHref: customerEmail
294
+ ? accountInviteHref(locale, customerEmail)
295
+ : null,
296
+ };
273
297
  }
274
298
 
275
299
  export async function generateMetadata({ params }: Props): Promise<Metadata> {
@@ -279,6 +303,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
279
303
  title: t("success.title"),
280
304
  description: t("success.message"),
281
305
  robots: { index: false, follow: true },
306
+ referrer: "no-referrer",
282
307
  };
283
308
  }
284
309
 
@@ -297,11 +322,27 @@ export default async function Page({
297
322
  const query = searchParams ? await searchParams : {};
298
323
  const sessionId = firstValue(query.session_id);
299
324
 
300
- const sections = await sectionsFor(sessionId, t, locale);
325
+ const { sections, accountHref } = await sectionsFor(sessionId, t, locale);
301
326
 
302
327
  return (
303
328
  <main>
304
329
  <SectionRenderer sections={sections} locale={locale} />
330
+ {accountHref !== null && (
331
+ // Session Replay records the DOM, so the link (it carries the email) is blocked from it.
332
+ <Container className="pb-section">
333
+ <div data-sentry-block>
334
+ <Button asChild size="big">
335
+ <Link
336
+ href={accountHref}
337
+ variant="bare"
338
+ data-testid="purchase-success-account"
339
+ >
340
+ {t("success.openAccount")}
341
+ </Link>
342
+ </Button>
343
+ </div>
344
+ </Container>
345
+ )}
305
346
  </main>
306
347
  );
307
348
  }