@pantheon-systems/p1-next-sdk 0.24.0 → 0.25.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.
@@ -0,0 +1,11 @@
1
+ import "../styles.css";
2
+ import { HtmlShell } from "../../components/html-shell";
3
+
4
+ /** Root layout for the editor and its auth and API routes. */
5
+ export default function EditorRootLayout({
6
+ children,
7
+ }: {
8
+ children: React.ReactNode;
9
+ }) {
10
+ return <HtmlShell lang="en">{children}</HtmlShell>;
11
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The document around every route. The site and the editor are separate root
3
+ * layouts, and both render through this.
4
+ */
5
+
6
+ export function HtmlShell({
7
+ lang,
8
+ children,
9
+ }: {
10
+ lang: string;
11
+ children: React.ReactNode;
12
+ }) {
13
+ return (
14
+ <html lang={lang}>
15
+ {/* Puck's canvas-preview iframe copies this document's <body> attributes
16
+ onto its own iframe <body> (@puckeditor/core's CopyHostStyles
17
+ syncAttributes()), so a class/attribute placed directly on <body>
18
+ cannot be used to keep a rule out of the iframe. `.p1-app-shell` is
19
+ a child of <body> instead — Puck's canvas iframe never contains it
20
+ (the iframe only ever renders the Puck root/block tree into its own
21
+ #frame-root, not this layout). See styles.css for the scoped reset
22
+ this enables. */}
23
+ <body data-rm-theme="light">
24
+ <div className="p1-app-shell">{children}</div>
25
+ </body>
26
+ </html>
27
+ );
28
+ }
@@ -0,0 +1,74 @@
1
+ /* The saved-language prompt. Every colour, space, radius and shadow routes
2
+ through a `--p1-locale-prompt-*` property so a site can retheme it without
3
+ touching these rules; each resolves to the matching PDS token, then to a
4
+ literal for pages that don't load PDS. Type inherits from the site. */
5
+
6
+ .prompt {
7
+ --p1-locale-prompt-color-text: var(--pds-color-foreground-default, #111827);
8
+ --p1-locale-prompt-color-surface: var(--pds-color-surface-default, #ffffff);
9
+ --p1-locale-prompt-color-border: var(--pds-color-border-default, #e5e7eb);
10
+ --p1-locale-prompt-color-hover: var(--pds-color-surface-default-secondary, #f3f4f6);
11
+ --p1-locale-prompt-color-accept: var(--pds-color-foreground-default, #111827);
12
+ --p1-locale-prompt-color-accept-hover: #374151;
13
+ --p1-locale-prompt-color-accept-text: var(--pds-color-foreground-reverse, #ffffff);
14
+ --p1-locale-prompt-space-edge: var(--pds-spacing-m, 1rem);
15
+ --p1-locale-prompt-space-gap: var(--pds-spacing-s, 0.75rem);
16
+ --p1-locale-prompt-space-button-block: 0.375rem;
17
+ --p1-locale-prompt-space-button-inline: var(--pds-spacing-s, 0.75rem);
18
+ --p1-locale-prompt-radius: var(--pds-border-radius-card, 0.5rem);
19
+ --p1-locale-prompt-radius-button: var(--pds-border-radius-default, 0.25rem);
20
+ --p1-locale-prompt-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
21
+
22
+ position: fixed;
23
+ inset-inline: var(--p1-locale-prompt-space-edge);
24
+ bottom: var(--p1-locale-prompt-space-edge);
25
+ z-index: 50;
26
+ display: flex;
27
+ flex-wrap: wrap;
28
+ align-items: center;
29
+ gap: var(--p1-locale-prompt-space-gap);
30
+ max-width: 28rem;
31
+ margin-inline: auto;
32
+ padding: var(--p1-locale-prompt-space-edge);
33
+ border: 1px solid var(--p1-locale-prompt-color-border);
34
+ border-radius: var(--p1-locale-prompt-radius);
35
+ background: var(--p1-locale-prompt-color-surface);
36
+ color: var(--p1-locale-prompt-color-text);
37
+ box-shadow: var(--p1-locale-prompt-shadow);
38
+ font-size: 0.875rem;
39
+ line-height: 1.25rem;
40
+ }
41
+
42
+ .message {
43
+ flex: 1;
44
+ margin: 0;
45
+ }
46
+
47
+ .accept,
48
+ .dismiss {
49
+ padding: var(--p1-locale-prompt-space-button-block) var(--p1-locale-prompt-space-button-inline);
50
+ border-radius: var(--p1-locale-prompt-radius-button);
51
+ font: inherit;
52
+ font-weight: 500;
53
+ cursor: pointer;
54
+ }
55
+
56
+ .accept {
57
+ background: var(--p1-locale-prompt-color-accept);
58
+ color: var(--p1-locale-prompt-color-accept-text);
59
+ text-decoration: none;
60
+ }
61
+
62
+ .accept:hover {
63
+ background: var(--p1-locale-prompt-color-accept-hover);
64
+ }
65
+
66
+ .dismiss {
67
+ border: 1px solid var(--p1-locale-prompt-color-border);
68
+ background: transparent;
69
+ color: inherit;
70
+ }
71
+
72
+ .dismiss:hover {
73
+ background: var(--p1-locale-prompt-color-hover);
74
+ }
@@ -0,0 +1,94 @@
1
+ "use client";
2
+
3
+ /**
4
+ * Offers the page in the visitor's saved locale when it is in another one or
5
+ * has none. Either choice saves a locale, so the offer is not repeated; on a
6
+ * page with no locale, "Stay here" only closes it.
7
+ */
8
+
9
+ import { useState, useSyncExternalStore } from "react";
10
+ import { useP1Localization } from "@pantheon-systems/p1-next-sdk";
11
+ import {
12
+ getSavedLocale,
13
+ getSavedLocaleSuggestion,
14
+ saveLocale,
15
+ } from "@pantheon-systems/p1-next-sdk/localization";
16
+ import { localeName } from "../lib/locale-name";
17
+ import styles from "./locale-suggestion.module.css";
18
+
19
+ export function LocaleSuggestionPrompt({
20
+ locale,
21
+ path,
22
+ onAccept,
23
+ onDismiss,
24
+ }: {
25
+ locale: string;
26
+ path: string;
27
+ onAccept: () => void;
28
+ onDismiss: () => void;
29
+ }) {
30
+ return (
31
+ <aside
32
+ lang="en"
33
+ aria-label="Language"
34
+ className={styles.prompt}
35
+ >
36
+ <p className={styles.message}>
37
+ This page is available in <span lang={locale}>{localeName(locale)}</span>.
38
+ </p>
39
+ <a
40
+ href={path}
41
+ hrefLang={locale}
42
+ onClick={onAccept}
43
+ className={styles.accept}
44
+ >
45
+ <span lang={locale}>{localeName(locale)}</span>
46
+ </a>
47
+ <button
48
+ type="button"
49
+ onClick={onDismiss}
50
+ className={styles.dismiss}
51
+ >
52
+ Stay here
53
+ </button>
54
+ </aside>
55
+ );
56
+ }
57
+
58
+ const subscribe = () => () => {};
59
+
60
+ /** The visitor's saved locale, or `null` on the server and while hydrating. */
61
+ function useSavedLocale(): string | null {
62
+ return useSyncExternalStore(subscribe, getSavedLocale, () => null);
63
+ }
64
+
65
+ export function LocaleSuggestion() {
66
+ // The live region is rendered empty first, so screen readers announce the offer when it fills.
67
+ return (
68
+ <div aria-live="polite">
69
+ <LocaleOffer savedLocale={useSavedLocale()} />
70
+ </div>
71
+ );
72
+ }
73
+
74
+ export function LocaleOffer({ savedLocale }: { savedLocale: string | null }) {
75
+ const { locale, siteLocales, variants } = useP1Localization();
76
+ const [dismissed, setDismissed] = useState(false);
77
+
78
+ const suggestion = siteLocales
79
+ ? getSavedLocaleSuggestion({ variants, siteLocales, savedLocale })
80
+ : null;
81
+ if (!suggestion || dismissed) return null;
82
+
83
+ return (
84
+ <LocaleSuggestionPrompt
85
+ locale={suggestion.locale}
86
+ path={suggestion.path}
87
+ onAccept={() => saveLocale(suggestion.locale)}
88
+ onDismiss={() => {
89
+ if (locale) saveLocale(locale);
90
+ setDismissed(true);
91
+ }}
92
+ />
93
+ );
94
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Catch-all route that renders user-facing pages generated by Puck.
3
+ *
4
+ * The pipeline lives in the SDK — see createPublishedPage in
5
+ * app/published-pages.tsx for what this route is made of.
6
+ */
7
+
8
+ import { published } from "../published-pages";
9
+
10
+ /**
11
+ * Backstop only: publishing calls revalidatePath for the affected routes, so
12
+ * cached pages normally refresh the moment their content changes. This bounds
13
+ * how long an edit made outside that path (a direct API write, a restored
14
+ * branch) can stay stale.
15
+ *
16
+ * Must stay a literal here: Next.js statically analyzes segment-config exports,
17
+ * so a value re-exported from the factory would go undetected.
18
+ */
19
+ export const revalidate = 300;
20
+
21
+ export const generateStaticParams = published.generateStaticParams;
22
+ export const generateMetadata = published.generateMetadata;
23
+ export default published.Page;
@@ -0,0 +1,37 @@
1
+ import "./styles.css";
2
+ import type { Metadata } from "next";
3
+
4
+ const siteUrl = process.env.NEXT_PUBLIC_SITE_URL;
5
+
6
+ // A page-level openGraph replaces (not merges) this one, so buildPageMetadata
7
+ // re-declares og:type and the env site-name fallback; this covers routes that
8
+ // return no openGraph (e.g. not-found early returns).
9
+ export const metadata: Metadata = {
10
+ ...(siteUrl ? { metadataBase: new URL(siteUrl) } : {}),
11
+ openGraph: {
12
+ type: "website",
13
+ siteName: process.env.NEXT_PUBLIC_SITE_NAME,
14
+ },
15
+ };
16
+
17
+ export default function RootLayout({
18
+ children,
19
+ }: {
20
+ children: React.ReactNode;
21
+ }) {
22
+ return (
23
+ <html lang="en">
24
+ {/* Puck's canvas-preview iframe copies this document's <body> attributes
25
+ onto its own iframe <body> (@puckeditor/core's CopyHostStyles
26
+ syncAttributes()), so a class/attribute placed directly on <body>
27
+ cannot be used to keep a rule out of the iframe. `.p1-app-shell` is
28
+ a child of <body> instead — Puck's canvas iframe never contains it
29
+ (the iframe only ever renders the Puck root/block tree into its own
30
+ #frame-root, not this layout). See styles.css for the scoped reset
31
+ this enables. */}
32
+ <body data-rm-theme="light">
33
+ <div className="p1-app-shell">{children}</div>
34
+ </body>
35
+ </html>
36
+ );
37
+ }
@@ -0,0 +1,27 @@
1
+ import "./styles.css";
2
+ import type { Metadata } from "next";
3
+
4
+ const siteUrl = process.env.NEXT_PUBLIC_SITE_URL;
5
+
6
+ // A page-level openGraph replaces (not merges) this one, so buildPageMetadata
7
+ // re-declares og:type and the env site-name fallback; this covers routes that
8
+ // return no openGraph (e.g. not-found early returns).
9
+ export const metadata: Metadata = {
10
+ ...(siteUrl ? { metadataBase: new URL(siteUrl) } : {}),
11
+ openGraph: {
12
+ type: "website",
13
+ siteName: process.env.NEXT_PUBLIC_SITE_NAME,
14
+ },
15
+ };
16
+
17
+ export default function RootLayout({
18
+ children,
19
+ }: {
20
+ children: React.ReactNode;
21
+ }) {
22
+ return (
23
+ <html lang="en">
24
+ <body data-rm-theme="light">{children}</body>
25
+ </html>
26
+ );
27
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Home route. The pipeline lives in the SDK — see createPublishedPage in
3
+ * app/published-pages.tsx for what this route is made of.
4
+ */
5
+
6
+ import { published } from "./published-pages";
7
+
8
+ /**
9
+ * Backstop only: publishing calls revalidatePath("/"), so the home page
10
+ * normally refreshes the moment its content changes. This bounds how long an
11
+ * edit made outside that path can stay stale.
12
+ *
13
+ * Must stay a literal here: Next.js statically analyzes segment-config exports,
14
+ * so a value re-exported from the factory would go undetected.
15
+ */
16
+ export const revalidate = 300;
17
+
18
+ export const generateMetadata = published.generateHomeMetadata;
19
+ export default published.HomePage;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The name of a locale in its own language, such as "Français" for `fr`, for
3
+ * offering a visitor a language they read. Throws a `RangeError` for a value
4
+ * that is not a language tag.
5
+ */
6
+ export function localeName(locale: string): string {
7
+ const name = new Intl.DisplayNames([locale], { type: "language" }).of(locale) ?? locale;
8
+ return name.charAt(0).toLocaleUpperCase(locale) + name.slice(1);
9
+ }
@@ -25,8 +25,8 @@ export function createP1Pages(opts) {
25
25
  console.warn("[p1-next-sdk] The P1 editor now renders from pages.Layout, but this " +
26
26
  "app rendered pages.Page without it — the editor will be empty. Mount " +
27
27
  "it at app/p1/(editor)/layout.tsx, or run: " +
28
- "npx @pantheon-systems/p1-next-sdk migrate — see " +
29
- "docs/MIGRATION-EDITOR-LAYOUT.md");
28
+ "npx @pantheon-systems/p1-next-sdk migrate editor-layout — see " +
29
+ "node_modules/@pantheon-systems/p1-next-sdk/docs/migrations/editor-layout.md");
30
30
  }
31
31
  return null;
32
32
  }
@@ -0,0 +1,213 @@
1
+ # Migration Guide: Persistent Editor Layout
2
+
3
+ This guide covers upgrading to `@pantheon-systems/p1-next-sdk@0.8.x`, in which the P1 editor renders from a persistent **layout** instead of the catch-all **page**. This is what lets the editor survive navigation between documents without a full remount (no more teardown of providers, auth, and the Puck canvas iframe on every page switch).
4
+
5
+ New projects scaffolded with `create-p1-starter-kit@0.8.x` already have the new structure — this guide is only for **existing apps upgrading the SDK**.
6
+
7
+ ## Breaking: the editor moved from `pages.Page` to `pages.Layout`
8
+
9
+ `createP1Pages()` now returns a `Layout` that renders the editor, and `Page` is intentionally empty. The editor must be mounted from a static route segment — an `(editor)` route group — so it persists across route-param changes. `EditorClient` is now rendered with **no props** and derives the edited page from the URL.
10
+
11
+ > **This is a silent breaking change for JavaScript apps.** If you upgrade but keep only the old `app/p1/[[...p1]]/page.tsx` (`export default pages.Page`), `pages.Page` renders `null` and the editor is **blank with no build error**. TypeScript apps get a compile error first — the `EditorClient` prop type changed from `{ path: string }` to no props — but JS apps get no signal. In development the SDK logs a one-time warning pointing here.
12
+
13
+ ## Recommended: run the codemod
14
+
15
+ From your project root, on a clean git tree:
16
+
17
+ ```bash
18
+ npx @pantheon-systems/p1-next-sdk migrate editor-layout
19
+ ```
20
+
21
+ It restructures the routes for you and leaves sibling routes (`/p1/merge`, `/p1/api`, `/p1/auth`) untouched. It writes code that only newer P1 packages export, so it checks the suite you have installed first and tells you to upgrade before it touches anything. Step 6 below needs a newer suite than the route move does; against an older one the codemod says so, skips that step alone, and leaves your existing chatbot gate working. Preview first with `--dry-run`; the codemod refuses to run on a dirty tree unless you pass `--force`, is safe to re-run (idempotent), and **bails with a pointer back to this guide** if your files have diverged from the starter shape. If it bails, follow the manual steps below.
22
+
23
+ ```bash
24
+ npx @pantheon-systems/p1-next-sdk migrate editor-layout --dry-run # preview
25
+ npx @pantheon-systems/p1-next-sdk migrate editor-layout # apply
26
+ ```
27
+
28
+ Review the diff and commit it as its own change.
29
+
30
+ ## Manual steps
31
+
32
+ If you customized the editor route and the codemod bailed, apply the same transform by hand. The move adds one real on-disk directory (`(editor)/`) that the URL never sees, so **every relative import in a moved file gains one `../`**.
33
+
34
+ ### 1. Move the catch-all into an `(editor)` route group
35
+
36
+ ```
37
+ app/p1/[[...p1]]/page.tsx -> app/p1/(editor)/[[...p1]]/p1-pages.tsx (+ new page.tsx)
38
+ app/p1/[[...p1]]/editor-client.tsx -> app/p1/(editor)/[[...p1]]/editor-client.tsx
39
+ app/p1/(editor)/layout.tsx (new)
40
+ ```
41
+
42
+ Sibling routes stay **outside** the group so the editor never wraps them:
43
+
44
+ ```
45
+ app/p1/merge/… app/p1/api/… app/p1/auth/… (unchanged)
46
+ ```
47
+
48
+ ### 2. Split `page.tsx` into a shared factory module + a thin page
49
+
50
+ Extract the `createP1Pages(...)` call into `p1-pages.tsx` and **export** it, so both the layout and the page can import it. Deepen the `config` import by one level, and drop the `puck.css` side-effect import (it moves to the layout).
51
+
52
+ `app/p1/(editor)/[[...p1]]/p1-pages.tsx`:
53
+ ```diff
54
+ -import "@puckeditor/core/puck.css";
55
+ import { createP1Pages } from "@pantheon-systems/p1-next-sdk/server";
56
+ -import config from "../../../puck.config";
57
+ +import config from "../../../../puck.config";
58
+ import { EditorClientWrapper } from "./editor-client";
59
+
60
+ -const pages = createP1Pages({
61
+ +export const pages = createP1Pages({
62
+ config,
63
+ // …your existing options…
64
+ EditorClient: EditorClientWrapper,
65
+ });
66
+ -
67
+ -export default pages.Page;
68
+ -export const generateMetadata = pages.generateMetadata;
69
+ -export const dynamic = "force-dynamic";
70
+ ```
71
+
72
+ `app/p1/(editor)/[[...p1]]/page.tsx` (new, thin):
73
+ ```tsx
74
+ import { pages } from "./p1-pages";
75
+
76
+ export default pages.Page;
77
+ export const generateMetadata = pages.generateMetadata;
78
+ export const dynamic = "force-dynamic";
79
+ ```
80
+
81
+ ### 3. Add the `(editor)` layout
82
+
83
+ `app/p1/(editor)/layout.tsx` (new):
84
+ ```tsx
85
+ import "@puckeditor/core/puck.css";
86
+ import { pages } from "./[[...p1]]/p1-pages";
87
+
88
+ export default pages.Layout;
89
+ ```
90
+
91
+ The editor layout (the one rendering `pages.Layout`) must live at the `(editor)` group, **not** at `app/p1/layout.tsx` — a layout at `/p1` would wrap every sibling route (`/p1/merge`, …) and render the editor on top of them. A root layout at `app/p1/layout.tsx` that renders only the `<html>` and `<body>`, as the [localized published pages](./localized-pages.md) guide adds, is fine.
92
+
93
+ ### 4. Derive the edited path from the URL in `editor-client.tsx`
94
+
95
+ `EditorClient` is rendered by the layout with no props, so it reads the path from the URL instead of a prop. Add `usePathname` and `editorPagePathFromUrlPath`, and drop the `{ path }` parameter:
96
+
97
+ ```diff
98
+ -import { useRouter } from "next/navigation";
99
+ +import { usePathname, useRouter } from "next/navigation";
100
+ -import { P1NextRouterProvider } from "@pantheon-systems/p1-next-sdk";
101
+ +import { P1NextRouterProvider, editorPagePathFromUrlPath } from "@pantheon-systems/p1-next-sdk";
102
+ ```
103
+
104
+ ```diff
105
+ -export function EditorClientWrapper({ path }: { path: string }) {
106
+ +export function EditorClientWrapper() {
107
+ + const pathname = usePathname();
108
+ + const path = editorPagePathFromUrlPath(pathname);
109
+ // …rest of the component unchanged…
110
+ ```
111
+
112
+ Then deepen the remaining relative imports in this file by one level (`../../../…` → `../../../../…`).
113
+
114
+ ### 5. Remove any `NON_EDITOR_ROUTES` opt-out list
115
+
116
+ Earlier versions kept the editor off sibling routes with a hand-maintained `NON_EDITOR_ROUTES` array. The `(editor)` route group makes siblings editor-free by construction, so delete that list.
117
+
118
+ ### 6. Hand the AI chatbot's rollout gate to the SDK
119
+
120
+ Optional, and the one step with its own version requirement: it imports
121
+ `@pantheon-systems/p1-next-sdk/chatbot`, so skip it if your installed suite predates that
122
+ entry point. The app-level gate below keeps working until the rollout flag retires.
123
+
124
+ Earlier starters carried the chatbot's rollout plumbing themselves: a local
125
+ `ChatbotFlagProvider`, a hardcoded flag key, a `lib/chatbot-flag/` directory, and a
126
+ feature-flag SDK in the app's own `package.json`. Whether the chatbot is available to a
127
+ site is Pantheon's decision, not the application's, so it now lives behind
128
+ `@pantheon-systems/p1-next-sdk/chatbot` — and nothing in your project has to change when
129
+ the rollout ends.
130
+
131
+ ```diff
132
+ -import { createAIChatPlugin } from "@pantheon-systems/p1-ai-chat";
133
+ -import { useFlags } from "launchdarkly-react-client-sdk";
134
+ +import { P1ChatbotProvider, useP1Chatbot } from "@pantheon-systems/p1-next-sdk/chatbot";
135
+ -import { ChatbotFlagProvider } from "../../../../components/ChatbotFlagProvider";
136
+ -import { shouldShowChatbot, CHATBOT_FLAG_KEY } from "../../../../lib/chatbot-flag/feature-gate";
137
+ -import { createGenerateWithAIHandler } from "../../../../lib/chatbot-flag/ai-generate";
138
+ -import { getDraftRequestChannel } from "../../../../lib/chatbot-flag/draft-request-channel";
139
+ ```
140
+
141
+ Swap the provider:
142
+
143
+ ```diff
144
+ - <ChatbotFlagProvider>
145
+ + <P1ChatbotProvider>
146
+ <EditorContent path={path} />
147
+ - </ChatbotFlagProvider>
148
+ + </P1ChatbotProvider>
149
+ ```
150
+
151
+ There is nothing left to branch on — an unavailable chatbot contributes no plugins, no
152
+ handler and an unchanged remount key:
153
+
154
+ ```diff
155
+ - const flags = useFlags();
156
+ - const agentUrl = process.env.NEXT_PUBLIC_AGENT_URL;
157
+ - const chatbotEnabled = shouldShowChatbot(flags[CHATBOT_FLAG_KEY], agentUrl);
158
+ - const draftRequests = getDraftRequestChannel();
159
+ - const aiPlugin = React.useMemo(
160
+ - () =>
161
+ - chatbotEnabled && agentUrl
162
+ - ? createAIChatPlugin({ agentUrl, draftRequests, onPageCreated: handlePageCreated })
163
+ - : null,
164
+ - [chatbotEnabled, agentUrl, draftRequests, handlePageCreated],
165
+ - );
166
+ + const chatbot = useP1Chatbot({ onPageCreated: handlePageCreated });
167
+ const additionalPlugins = React.useMemo(
168
+ - () => (aiPlugin ? [...p1Plugins, mediaPlugin, aiPlugin] : [...p1Plugins, mediaPlugin]),
169
+ - [p1Plugins, mediaPlugin, aiPlugin],
170
+ + () => [...p1Plugins, mediaPlugin, ...chatbot.plugins],
171
+ + [p1Plugins, mediaPlugin, chatbot.plugins],
172
+ );
173
+ ```
174
+
175
+ ```diff
176
+ pluginOptions: {
177
+ onDocumentSelect: handleDocumentSelect,
178
+ - onGenerateWithAI: createGenerateWithAIHandler(draftRequests, chatbotEnabled),
179
+ - showAIPanelToggle: chatbotEnabled,
180
+ + ...chatbot.pluginOptions,
181
+ ```
182
+
183
+ ```diff
184
+ - <Puck key={`${puckKey}-${chatbotEnabled ? "ai" : "no-ai"}`} {...puckProps as any} _experimentalFullScreenCanvas={true} />
185
+ + <Puck key={`${puckKey}${chatbot.editorKeySuffix}`} {...puckProps as any} _experimentalFullScreenCanvas={true} />
186
+ ```
187
+
188
+ Nothing imports the old gate afterwards, so it can go — the codemod leaves these for you
189
+ rather than deleting files it was not asked to move:
190
+
191
+ - `lib/chatbot-flag/` and `components/ChatbotFlagProvider.tsx`, plus their test files
192
+ - `launchdarkly-react-client-sdk` and `@pantheon-systems/p1-ai-chat` in `package.json`
193
+ - `NEXT_PUBLIC_LD_CLIENT_ID` in `.env` / `.env.example`
194
+
195
+ `NEXT_PUBLIC_AGENT_URL` still applies, and still belongs to the environment rather than
196
+ to your source.
197
+
198
+ ## Minimum structure after migration
199
+
200
+ ```
201
+ app/p1/
202
+ (editor)/
203
+ layout.tsx # export default pages.Layout
204
+ [[...p1]]/
205
+ p1-pages.tsx # export const pages = createP1Pages({ … })
206
+ page.tsx # re-exports pages.Page / generateMetadata / dynamic
207
+ editor-client.tsx # EditorClientWrapper() — derives path from the URL
208
+ merge/ # siblings stay outside (editor)
209
+ api/
210
+ auth/
211
+ ```
212
+
213
+ The editor is mounted at `/p1`; the client derives the edited page via `editorPagePathFromUrlPath`, whose base path defaults to `/p1`. If you mount the editor somewhere else, pass the matching base path to `editorPagePathFromUrlPath`.