diff --git a/app/(marketing)/templates/TemplatesPageClient.tsx b/app/(marketing)/templates/TemplatesPageClient.tsx index ced6626..40f3a4d 100644 --- a/app/(marketing)/templates/TemplatesPageClient.tsx +++ b/app/(marketing)/templates/TemplatesPageClient.tsx @@ -5,7 +5,6 @@ import { useSearchParams } from "next/navigation"; import HeaderLockup from "../../components/type/HeaderLockup"; import { GovernanceTemplateGrid } from "../../components/sections/GovernanceTemplateGrid"; import type { TemplateGridCardEntry } from "../../../lib/templates/templateGridPresentation"; -import { prepareFreshCreateFlowEntrySync } from "../../(app)/create/utils/prepareFreshCreateFlowEntry"; import { buildTemplateReviewHref } from "../../(app)/create/utils/flowSteps"; import { useTranslation } from "../../contexts/MessagesContext"; @@ -62,8 +61,7 @@ export default function TemplatesPageClient({ } /** - * - `fromFlow=1` — skip `prepareFreshCreateFlowEntry` on template click - * (draft preserved). Used by profile “Create from template”. + * - `fromFlow=1` — in-wizard catalog; community answers stay until apply. * Templates carry no recommendation; the grid stays in curated order. */ function TemplatesGridWithSearchParams({ @@ -91,13 +89,6 @@ function TemplatesGrid({ hrefForTemplate={(slug) => buildTemplateReviewHref(slug, { fromCreateWizard: fromFlow }) } - onTemplateClick={() => { - if (!fromFlow) { - // Marketing /templates has no session in hand; DELETE is - // best-effort and the sentinel blocks stale-draft hydration. - prepareFreshCreateFlowEntrySync({ signedIn: true }); - } - }} /> ); } diff --git a/app/components/sections/RuleStack/RuleStack.container.tsx b/app/components/sections/RuleStack/RuleStack.container.tsx index fc4b3ed..a4ca689 100644 --- a/app/components/sections/RuleStack/RuleStack.container.tsx +++ b/app/components/sections/RuleStack/RuleStack.container.tsx @@ -7,7 +7,6 @@ import { memo, useEffect, useState } from "react"; import { useTranslation } from "../../../contexts/MessagesContext"; import { logger } from "../../../../lib/logger"; -import { prepareFreshCreateFlowEntrySync } from "../../../(app)/create/utils/prepareFreshCreateFlowEntry"; import { buildTemplateReviewHref } from "../../../(app)/create/utils/flowSteps"; import { fetchTemplates, @@ -96,10 +95,6 @@ const RuleStackContainer = memo( } } logger.debug(`${slug} template clicked`); - // Marketing home “Popular templates”: same fresh start as Top “Create rule”. - // `signedIn: true` because this surface has no session in hand; DELETE is - // best-effort and the sentinel blocks stale-draft hydration. - prepareFreshCreateFlowEntrySync({ signedIn: true }); }; return ( diff --git a/docs/create-flow.md b/docs/create-flow.md index 04d76ce..b623328 100644 --- a/docs/create-flow.md +++ b/docs/create-flow.md @@ -66,9 +66,9 @@ The step persists **`stakeholderEmails`** on `CreateFlowState` (validated on `PU - **Create rule entry:** call [`createRuleEntryPath`](../app/(app)/create/utils/createRuleEntry.ts) and `router.push` that path. Do **not** call `prepareFreshCreateFlowEntry`. - **Continue saved draft** (profile): do **not** call `prepareFreshCreateFlowEntry`. Clear the same `localStorage` keys **only** (see [`ProfilePageClient`](../app/(app)/profile/ProfilePageClient.tsx) `handleContinueDraft`) so the client mirror is empty, then navigate to **`/create/{savedStep}`**. Hydration loads the server draft; the URL may be corrected to `currentStep` when it differs from the path. -- **Confirmed wipe:** [`prepareFreshCreateFlowEntry`](../app/(app)/create/utils/prepareFreshCreateFlowEntry.ts) still clears **`create-flow-anonymous`** and, when sync is on, **`DELETE`s `/api/drafts/me`**. Use it only after the person agrees to start over. Direct template picks still call it today; replacing a draft from a template is a separate confirm. +- **Confirmed wipe:** [`prepareFreshCreateFlowEntry`](../app/(app)/create/utils/prepareFreshCreateFlowEntry.ts) still clears **`create-flow-anonymous`** and, when sync is on, **`DELETE`s `/api/drafts/me`**. Use it only after the person agrees to start over, including when they confirm replacing a draft with a template. -Call sites for **`createRuleEntryPath`**: [`Top.container.tsx`](../app/components/navigation/Top/Top.container.tsx) (Create rule), Home hero, About, and profile **Create new custom Rule** ([`ProfilePageClient.tsx`](../app/(app)/profile/ProfilePageClient.tsx)). Template catalog clicks still use **`prepareFreshCreateFlowEntry`** until that confirm ships. +Call sites for **`createRuleEntryPath`**: [`Top.container.tsx`](../app/components/navigation/Top/Top.container.tsx) (Create rule), Home hero, About, and profile **Create new custom Rule** ([`ProfilePageClient.tsx`](../app/(app)/profile/ProfilePageClient.tsx)). Template catalog clicks do **not** wipe a draft; **Use without changes** / **Customize** ask first, then apply from an empty seed. --- @@ -91,15 +91,15 @@ From that page, **Customize** opens a dialog for name, optional logo, descriptio - **Use without changes (direct)** — home Popular templates, `/templates` without `fromFlow`, or a pasted review-template URL. Identity is collected on the final-review Rule card. Back returns to template review. - **Use without changes (in-flow)** — `/create/review` → `/create/templates` → template. Community identity is already collected. Back still returns to template review. -**Direct entry vs in-flow template pick.** The same `/create/review-template/[slug]` URL is reached from two different origins. We disambiguate at the *click site*, not on the review-template page. **Direct** picks call [`prepareFreshCreateFlowEntry`](../app/(app)/create/utils/prepareFreshCreateFlowEntry.ts) **before** navigation (local + server draft when sync is on — see **Fresh start vs continue draft** above). **In-flow** picks skip that call so the user’s community-stage state survives the detour. Because `CreateFlowProvider` reads `localStorage` in its `useState` initializer, clearing **before** `push` means a direct entry mounts without stale anonymous keys; signed-in users also avoid a stale server draft overwriting the empty mirror. +**Direct entry vs in-flow template pick.** The same `/create/review-template/[slug]` URL is reached from two different origins. **Direct** picks (home Popular templates, `/templates`) do not wipe a draft on click. **Use without changes** and **Customize** ask before replacing a draft, then seed from the template with no leftover logo or setup answers. **In-flow** picks (`/create/templates?fromFlow=1`) keep the community name, description, and place already given. A hydration latch stops a saved server draft from overwriting the template after apply. | Origin | Click-site behavior | URL the user lands on | | --- | --- | --- | -| Home marketing "Popular templates" ([`RuleStack.container.tsx`](../app/components/sections/RuleStack/RuleStack.container.tsx)) | always `await prepareFreshCreateFlowEntry()` then navigate | `/create/review-template/[slug]` | -| `/templates` index ([`TemplatesPageClient.tsx`](../app/(marketing)/templates/TemplatesPageClient.tsx)) visited directly / via pasted URL | `fromFlow` absent → `await prepareFreshCreateFlowEntry()` then navigate | `/create/review-template/[slug]` | +| Home marketing "Popular templates" ([`RuleStack.container.tsx`](../app/components/sections/RuleStack/RuleStack.container.tsx)) | navigate only; apply asks before replacing a draft | `/create/review-template/[slug]` | +| `/templates` index ([`TemplatesPageClient.tsx`](../app/(marketing)/templates/TemplatesPageClient.tsx)) visited directly / via pasted URL | `fromFlow` absent → navigate only | `/create/review-template/[slug]` | | In-flow: `/create/review` footer "Create from template" → `/create/templates` → template click | no fresh-entry prep; cards are `?fromFlow=1` links | `/create/review-template/[slug]?fromFlow=1` | -Only one `?fromFlow=1` marker exists on template-review URLs. In-flow catalog clicks on `/create/templates` always include it so **Use without changes** can keep in-flow identity instead of clearing it. Profile still uses marketing `/templates?fromFlow=1`. Templates on `/templates` and `/create/templates` show in curated order with no RECOMMENDED tag; facet scoring is unused. +Only one `?fromFlow=1` marker exists on template-review URLs. In-flow catalog clicks on `/create/templates` always include it so **Use without changes** can keep in-flow identity instead of clearing it. Profile **Create from template** uses marketing `/templates` without that marker, so a saved draft is not treated as this community’s name. Templates on `/templates` and `/create/templates` show in curated order with no RECOMMENDED tag; facet scoring is unused. **Resume from profile** remains explicit-only: **Continue** clears local mirrors then opens `/create/{step}` so [`SignedInDraftHydration`](../app/(app)/create/SignedInDraftHydration.tsx) can load `/api/drafts/me` when the client buffer is empty. There is no automatic “pick template from marketing → silently merge server draft” path.