canopycms 0.2.0-int.121 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -5,18 +5,9 @@ packages release together, at one version.
5
5
 
6
6
  ## This build
7
7
 
8
- Version `0.2.0-int.121`, built from [`0a53107`](https://github.com/safeinsights/canopycms/tree/0a53107eda329ce0499edad3544a16fb130b5beb).
8
+ Version `0.2.0`, built from [`ecd004a`](https://github.com/safeinsights/canopycms/tree/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463).
9
9
 
10
- ### New since int.119
11
-
12
- - [Media-library thumbnails are stored at upload and cached by the browser — behaviour change](#media-library-thumbnails-are-stored-at-upload-and-cached-by-the-browser--behaviour-change)
13
- - [Image fields are bordered cards, and Crop explains itself and works without aspect](#image-fields-are-bordered-cards-and-crop-explains-itself-and-works-without-aspect)
14
- - [A locked branch shows a lock where a row's "…" menu would be](#a-locked-branch-shows-a-lock-where-a-rows--menu-would-be)
15
- - [Links clicked in the preview open their entry instead of leaving the editor — behaviour change](#links-clicked-in-the-preview-open-their-entry-instead-of-leaving-the-editor--behaviour-change)
16
-
17
- ### Revised since int.119
18
-
19
- - [Removing a file from the media library hides it, and an admin can restore it — breaking (assets.delete, AssetStore) / behaviour change; template first](#removing-a-file-from-the-media-library-hides-it-and-an-admin-can-restore-it--breaking-assetsdelete-assetstore--behaviour-change-template-first)
10
+ Its entries are [0.2.0](#020), under **Released**.
20
11
 
21
12
  If you upgraded from a build on another branch, compare the `<!-- changeset: … -->` slugs in your previous build's `CHANGELOG.md` (`npm pack canopycms@<old>` fetches it) with this one's: entries whose slug your old file lacks are new to you.
22
13
 
@@ -33,7 +24,7 @@ Each entry has up to three parts:
33
24
  `node_modules/canopycms/CHANGELOG.md`, assembled for that build: its **This build** section lists
34
25
  what is new since the previous int on the same branch, or on a stable release links its entries, and its links point at the commit the build
35
26
  came from. The copy in the repository holds released history and the entries from before changesets;
36
- every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/.changeset/README.md) until a stable release
27
+ every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/.changeset/README.md) until a stable release
37
28
  moves it here.
38
29
 
39
30
  **Find your starting point.** From a stable pin, start at the first version under **Released**
@@ -67,21 +58,13 @@ Nothing in this section is edited by hand: each entry is a `.changeset/` file, w
67
58
  assembles here and labels with the first int that carries it, and a stable release moves the
68
59
  entries under **Released**.
69
60
 
70
- | int | Area | Change | Action |
71
- | --- | --- | --- | --- |
72
- | 119 | Assets | [Library removal hides the file; deploy grants before the image](#removing-a-file-from-the-media-library-hides-it-and-an-admin-can-restore-it--breaking-assetsdelete-assetstore--behaviour-change-template-first) | Template first |
73
- | 119 | Editing | [Content panel docks when stacked; overlay slides; matched dividers](#stacked-layout-docks-the-content-panel-beside-the-form) | None |
74
- | 119 | Editing | [Editor opens the home page; singletons named by type](#the-editor-opens-the-home-page-and-names-single-entry-types-by-their-type--behaviour-change) | None |
75
- | 119 | Editing | [Drawers share the content panel's compact header](#compact-drawer-headers-jumpable-comment-headings-and-a-steadier-owner-chip) | None |
76
- | 119 | Editing | [Object Clear in a "…" menu; Undo stays inline](#an-objects-clear-moves-into-its--menu-with-an-inline-undo) | Editor UI tests |
77
- | 119 | Editing | [Top bar: one unsaved dot, no "Editing" label](#the-top-bar-shows-one-unsaved-mark-and-a-status-only-when-it-matters--behaviour-change) | None |
78
- | 119 | Preview | [createPreviewPage takes a layout for the site header and footer](#previews-can-show-the-site-header-and-footer-and-the-preview-stays-put-between-entries) | Optional |
79
- | 121 | Assets | [Editor thumbnails stored at upload; raw-route redirects cacheable](#media-library-thumbnails-are-stored-at-upload-and-cached-by-the-browser--behaviour-change) | None |
80
- | 121 | Editing | [Image field card; Crop disabled with reason; free-form crop](#image-fields-are-bordered-cards-and-crop-explains-itself-and-works-without-aspect) | None |
81
- | 121 | Editing | [Locked branch: tree rows show a lock](#a-locked-branch-shows-a-lock-where-a-rows--menu-would-be) | None |
82
- | 121 | Preview | [Preview links open their entry; others open a new tab](#links-clicked-in-the-preview-open-their-entry-instead-of-leaving-the-editor--behaviour-change) | None |
83
-
84
- ### Removing a file from the media library hides it, and an admin can restore it — **breaking (assets.delete, AssetStore) / behaviour change; template first**
61
+ ---
62
+
63
+ ## Released
64
+
65
+ ### 0.2.0
66
+
67
+ #### Removing a file from the media library hides it, and an admin can restore it — **breaking (assets.delete, AssetStore) / behaviour change; template first**
85
68
 
86
69
  <!-- changeset: ef-g-media -->
87
70
 
@@ -110,7 +93,7 @@ the media library and restore a file, and uploading the same file again restores
110
93
  - Files removed before this release lost their metadata. Uploading the same bytes again recreates
111
94
  it, recorded under the re-uploader's name.
112
95
 
113
- ### Stacked layout docks the content panel beside the form
96
+ #### Stacked layout docks the content panel beside the form
114
97
 
115
98
  <!-- changeset: ef-a-shell -->
116
99
 
@@ -118,7 +101,7 @@ _First in int.119._
118
101
 
119
102
  **What changed.** In a wide window the content panel docks beside the form row in the stacked layout too, keeping the preview full width; in a narrow window it slides in over the form, unless the user prefers reduced motion. Both pane dividers share one width, and a branch banner has a line beneath it.
120
103
 
121
- ### The editor opens the home page and names single-entry types by their type — **behaviour change**
104
+ #### The editor opens the home page and names single-entry types by their type — **behaviour change**
122
105
 
123
106
  <!-- changeset: ef-b-identity -->
124
107
 
@@ -126,7 +109,7 @@ _First in int.119._
126
109
 
127
110
  **What changed.** With no entry in the URL, the editor opens the entry routed at `/`, else the first with a preview. An entry type limited to one entry (`maxItems: 1`) with a label is named by that label, though entry links and search still use its title. Content tree rows show the type on a second line, quick open shows type and route, "Rename…" is "Change URL…" ("Change slug…" for an entry with no page), and the "All content" crumb, the form header's title and the rail's site button are gone.
128
111
 
129
- ### Compact drawer headers, jumpable comment headings and a steadier owner chip
112
+ #### Compact drawer headers, jumpable comment headings and a steadier owner chip
130
113
 
131
114
  <!-- changeset: ef-c-drawers -->
132
115
 
@@ -134,7 +117,7 @@ _First in int.119._
134
117
 
135
118
  **What changed.** The Branches, Comments, Media and staged-changes drawers take the content panel's compact header with no subtitle. In the Comments drawer, each thread's heading is the one control that jumps to it. The Branches drawer no longer offers "New branch comment" or "+ New", since new branch comments start in the Comments drawer. A person's chip keeps its avatar and a long name on one line.
136
119
 
137
- ### An object's Clear moves into its "…" menu, with an inline Undo
120
+ #### An object's Clear moves into its "…" menu, with an inline Undo
138
121
 
139
122
  <!-- changeset: ef-d-clear -->
140
123
 
@@ -150,7 +133,7 @@ theirs. Their Undo, and the inline one, now survive edits to other items in an e
150
133
  **To adopt.** A UI test that clicked an object's "Clear" button now opens the object's
151
134
  "Actions for …" menu and chooses the "Clear" item, then finds "Undo clear" in the label row instead of a toast.
152
135
 
153
- ### The top bar shows one unsaved mark and a status only when it matters — **behaviour change**
136
+ #### The top bar shows one unsaved mark and a status only when it matters — **behaviour change**
154
137
 
155
138
  <!-- changeset: ef-f-topbar -->
156
139
 
@@ -158,7 +141,7 @@ _First in int.119._
158
141
 
159
142
  **What changed.** The branch pill's unsaved count is the same dot as the entry's, with a number, in the brand colour the content tree also uses. "Unsaved · kept on this device" moved into Save's tooltip and description; the bar shows it only as a warning when drafts could not be stored. The pill drops the default "Editing" status and shows In review, Approved, Archived or Protected. The "Read-only" chip no longer repeats a branch-wide lock the banner already explains; it stays for an entry read-only for its own reason.
160
143
 
161
- ### Previews can show the site header and footer, and the preview stays put between entries
144
+ #### Previews can show the site header and footer, and the preview stays put between entries
162
145
 
163
146
  <!-- changeset: ef-e-preview -->
164
147
 
@@ -178,15 +161,17 @@ export default createPreviewPage({
178
161
 
179
162
  A preview page built on `useCanopyPreview` alone can pass `siteChrome: true` when it renders the header and footer for `?chrome=1`.
180
163
 
181
- ### Media-library thumbnails are stored at upload and cached by the browser — **behaviour change**
164
+ #### Media-library thumbnails are stored at upload and cached by the browser — **breaking (AssetStore.presignPublicObjectRead) / behaviour change**
182
165
 
183
166
  <!-- changeset: editor-thumbnails-cached -->
184
167
 
185
168
  _First in int.121._
186
169
 
187
- **What changed.** Finalizing a raster upload also stores the three widths the editor shows it at (`assets/t/w=80`, `w=160`, `w=320`), so the media library's first view reads stored objects instead of transforming in the request. Uploading a file that already exists stores any of those widths it lacks. Animated images are skipped, since re-encoding every frame would hold the upload too long; their first view transforms them as before. This adds roughly 0.1 s to a typical photo's upload and up to about 0.6 s for a 24-megapixel PNG, measured locally; a failure is logged and never fails the upload. On S3, the authenticated asset route's redirect to a presigned URL is now `private, max-age` until the end of the hour rather than `no-store`, and the URL stays the same for that hour, so reopening the media library fetches no thumbnails. A cached redirect can outlive a sign-out by at most that hour; it points only at a public-prefix object under an unguessable key.
170
+ **What changed.** Finalizing a raster upload also stores the three widths the editor shows it at (`assets/t/w=80`, `w=160`, `w=320`), so the media library's first view reads stored objects instead of transforming in the request. Uploading a file that already exists stores any of those widths it lacks. Animated images are skipped; their first view transforms them as before. This adds roughly 0.1 s to a typical photo's upload; a failure is logged and never fails the upload. On S3, the authenticated asset route's redirect to a presigned URL is now `private, max-age` until the end of the hour rather than `no-store`, and the URL stays the same for that hour, so reopening the media library fetches no thumbnails. A cached redirect can outlive a sign-out by at most that hour; it points only at a public-prefix object under an unguessable key. A streamed object stored without a `Cache-Control` is now sent as `private, max-age=31536000, immutable`, since every public-prefix key is content-addressed.
171
+
172
+ **To adopt.** Only a custom `AssetStore` that implements `presignPublicObjectRead` changes: it returns `PresignedRead` (`{ url, maxAgeSeconds }`, from `canopycms/server`) or `null`, instead of a URL string. `maxAgeSeconds` is how long a browser may reuse that URL; return `0` to keep the old `no-store` behaviour.
188
173
 
189
- ### Image fields are bordered cards, and Crop explains itself and works without `aspect`
174
+ #### Image fields are bordered cards, and Crop explains itself and works without `aspect`
190
175
 
191
176
  <!-- changeset: image-field-cards -->
192
177
 
@@ -196,7 +181,7 @@ _First in int.121._
196
181
 
197
182
  **To adopt.** Nothing. `canopycms/client` now imports `react-image-crop`'s stylesheet through the editor theme, so a bundler that handles the Mantine stylesheets handles it too.
198
183
 
199
- ### A locked branch shows a lock where a row's "…" menu would be
184
+ #### A locked branch shows a lock where a row's "…" menu would be
200
185
 
201
186
  <!-- changeset: locked-row-lock -->
202
187
 
@@ -204,7 +189,7 @@ _First in int.121._
204
189
 
205
190
  **What changed.** On a protected, in-review or approved branch the content tree no longer drops a row's "…" menu without a trace. Each row that would have had a menu shows a lock of the same size, and its tooltip gives the branch's reason ("This branch is in review. Withdraw it to make changes."), on hover, keyboard focus and touch. An entry a path rule locks keeps its own lock beside its title and gets none in the menu slot.
206
191
 
207
- ### Links clicked in the preview open their entry instead of leaving the editor — **behaviour change**
192
+ #### Links clicked in the preview open their entry instead of leaving the editor — **behaviour change**
208
193
 
209
194
  <!-- changeset: preview-links-stay-in-editor -->
210
195
 
@@ -212,9 +197,29 @@ _First in int.121._
212
197
 
213
198
  **What changed.** A plain click on a link in the editor's preview no longer navigates the frame off its preview route to a public page, which could refuse to be framed. A link to another page of the site opens that page's entry in the editor, keeping the draft of the one left, and focus follows into its page. A page no entry has, such as a listing, opens in a new tab, and a note naming it says so; a link to another site opens in a new tab. Cmd/Ctrl/Shift/Alt and middle clicks, links with `download` or a `target` other than `_self`, links to the same page and `mailto:`/`tel:` links behave as they do outside the editor. A click that follows a link no longer also focuses the field it sits in, except while fields are highlighted, when a click on a marked link picks its field instead. The preview takes over links only once the editor has connected, so a public page embedded elsewhere keeps its links. Pages using `useCanopyPreview` or `withCanopyPreview` get this with no change.
214
199
 
215
- ---
200
+ #### The browser's Back and Forward move between entries in the editor — **behaviour change**
216
201
 
217
- ## Released
202
+ <!-- changeset: editor-back-forward-entries -->
203
+
204
+ _First in 0.2.0._
205
+
206
+ **What changed.** Opening an entry in the editor adds a browser history entry, whether it is opened from the content panel, quick open, a comment, a preview link or a new entry's creation, and so does switching branch. Back and Forward then open the entry their URL names, without reloading the page; the preview follows, focus moves to the entry's menu in the top bar, and drafts are kept, as on any switch. Choosing the open entry again adds nothing, and the editor's own corrections, such as the home page it opens at load or the URL it fixes after a rename or delete, replace the URL instead. An entry since deleted or renamed opens the home page, with a note saying so. A Back onto another branch switches to it, asking first when there are unsaved changes; staying, or a branch no longer listed, returns to the entry the Back left.
207
+
208
+ #### A locked branch's row lock shows on the hovered, focused or selected row
209
+
210
+ <!-- changeset: row-lock-on-hover -->
211
+
212
+ _First in 0.2.0._
213
+
214
+ **What changed.** The lock in a content-tree row's menu slot was drawn on every row, repeating the branch pill and banner. It now appears on the row under the pointer, the focused row, the row with focus inside it, and the selected row, so a touch user sees the row they tapped. The slot stays reserved so rows do not shift, and the lock stays in the tab order and the accessibility tree on every row.
215
+
216
+ #### The dev content watcher waits for a save to finish before comparing
217
+
218
+ <!-- changeset: dev-watcher-waits-for-writes -->
219
+
220
+ _First in 0.2.0._
221
+
222
+ **What changed.** In `dev` mode, the watcher that warns when working-tree content has diverged from the served branch clone now acts on a new or changed file only once its size has held still for 100 ms. A save that truncates and then writes could reach the watcher as one event between the two steps. The check then read a half-written file and warned of a divergence that nothing later retracted. Now any warning about a half-finished save is retracted once the save completes.
218
223
 
219
224
  ### 0.1.0
220
225
 
@@ -267,7 +272,7 @@ URL.
267
272
  2. For a branch preview: wrap views with `withCanopyPreview` in a `'use client'` module, add
268
273
  `app/preview/[[...path]]/page.server.tsx`, set `editor.previewPrefix: '/preview'`, and serve that
269
274
  route with `frame-ancestors 'self'`, not `X-Frame-Options: DENY` (see
270
- [Live Preview](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#live-preview)).
275
+ [Live Preview](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#live-preview)).
271
276
  3. A test reading view content from the route's server HTML must load the page in a browser.
272
277
  Server output rendered during a preview request carries the signed-in asset prefix; keep it out
273
278
  of cross-request caches (`unstable_cache`, module memos).
@@ -282,7 +287,7 @@ kept site styles ahead of Mantine's in the preview.
282
287
  server components. A string path marks the form's spelling (`'a.0.b'` marks `a[0].b`), and an empty
283
288
  path marks nothing. The editor counts and logs marks naming no field. `createEntrySchemaRegistry`
284
289
  refuses a field name that is empty, all digits or contains `.`, `[` or `]`. See
285
- [Live Preview](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#live-preview).
290
+ [Live Preview](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#live-preview).
286
291
 
287
292
  **To adopt.** Fix each path that stops compiling; the error lists valid ones. Rewrite computed paths
288
293
  as literal segments, or type that component's prop as plain `FieldProps`. Pass `fieldProps` as
@@ -364,7 +369,7 @@ or a failed render) renders as its plain text, with no URL; any other form of th
364
369
  fields are nested or renamed, pass the AI config's `seo` the same object you pass
365
370
  `createNextCanopyContext({ seo })`, so the sitemap and AI content read the flag from the same
366
371
  place. A field that links to a hidden section by plain URL needs a field transform; the README
367
- shows [the recipe](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#ai-content-configuration).
372
+ shows [the recipe](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#ai-content-configuration).
368
373
 
369
374
  **Now deletable.** An `exclude.where` that re-read the `noindex` flag by hand.
370
375
 
@@ -386,7 +391,7 @@ A `markdown` field with `renderAs: 'mdx'` is checked as MDX, and `mdxAllow` narr
386
391
  field or site-wide. New: field options `renderAs`, `mdxAllow`; config key `mdxAllow`; type
387
392
  `MdxAllowlist`. (int.110) A component prop allowance can be `'string'` (or
388
393
  `{ type: 'string', maxLength }`): a quoted value only, never bare or `{…}`. See
389
- [MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#mdx-content-cannot-run-code).
394
+ [MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#mdx-content-cannot-run-code).
390
395
 
391
396
  **To adopt.** Set `renderAs: 'mdx'` on each `markdown` field your site compiles as MDX, and
392
397
  `mdxAllow` to what your renderer takes. Set `executable: true` only on a field whose editors you
@@ -523,7 +528,7 @@ a format check.
523
528
 
524
529
  - (int.93) Submit commits gain an `Edited-by: Name (id)` trailer; PR bodies gain a section that
525
530
  re-submits replace, keeping human text. Options: `gitEditedByTrailers`, `gitCoAuthoredByTrailers`
526
- ([reference](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#definecanopyconfig-options)).
531
+ ([reference](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#definecanopyconfig-options)).
527
532
  - (int.110) Submit-commit trailers name every user who saved since the last submit commit, and
528
533
  the PR-body section every user who edited the branch, not only the submitter; settings commits
529
534
  (permissions, groups) carry the acting user's trailer.
@@ -547,7 +552,7 @@ saves only push the branch, and no failing PR task lands in System health.
547
552
  that entry type goes unavailable: the editor says so, and its entries answer 503 with
548
553
  `code: 'SCHEMA_UNAVAILABLE'`. Builds, static deploys and `generate-ai-content` still fail. The
549
554
  worker holds the base branch for up to 30 minutes while that lasts; see
550
- [New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
555
+ [New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
551
556
  Public types gain optional `unavailable` on `EntryTypeConfig` and `FlatSchemaItem`, optional
552
557
  `ApiResponse.code`, and a required `SchemaResolutionResult.issues`.
553
558
 
@@ -585,7 +590,7 @@ hang until the drain heartbeat lets termination continue. Its in-flight task is
585
590
  new stack needs no steps.
586
591
 
587
592
  **What changed.** (int.109) Detailed in
588
- [The worker instance](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
593
+ [The worker instance](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
589
594
  bundle is one file whose sha256 user data checks, readable as that one object; a file-system policy
590
595
  refusing clients without TLS or IAM, replacing the worker's
591
596
  `AmazonElasticFileSystemClientReadWriteAccess`; an encrypted gp3 root volume; a boot-time upgrade to
@@ -639,10 +644,10 @@ failure and exits non-zero on `selfStopped`, with a code outside `RestartPrevent
639
644
  with its hash, as `worker/dist/index.js` and `index.js.sha256`. The default, `'asset'`, is
640
645
  unchanged.
641
646
  - `CanopyCmsService` alarms when the worker logs no git sync for 30 minutes. See
642
- [Worker-down alarm](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#worker-down-alarm).
647
+ [Worker-down alarm](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#worker-down-alarm).
643
648
 
644
649
  **To adopt.** Optional. For parameter-only change sets, see
645
- [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
650
+ [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
646
651
  `alarmTopic`.
647
652
 
648
653
  **Now deletable.** A manual `cdk deploy` after each canopycms bump whose only purpose is moving the
@@ -653,7 +658,7 @@ worker, and a hand-built alarm on the worker log group.
653
658
  **What changed.** (int.112) The boot's `dnf upgrade` could be OOM-killed on every retry. A 1 GiB
654
659
  swap file now goes on first; an upgrade that still fails starts the worker unpatched and notifies
655
660
  `alarmTopic` if set; a retried step names itself when it gives up. See
656
- [The worker instance](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#the-worker-instance).
661
+ [The worker instance](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#the-worker-instance).
657
662
 
658
663
  **To adopt.** Deploy, which replaces the worker instance. The bundle needs none of this, so it is
659
664
  not Template first and the worker contract stays at 1.
@@ -719,7 +724,7 @@ and operations may reuse GitHub fetches under 30 seconds old.
719
724
 
720
725
  **To adopt.** Nothing. Seeding `remote.git` stages a copy of the repository beside the gateway's
721
726
  mirror, so the root volume needs room for two
722
- ([details](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#the-worker-instance)).
727
+ ([details](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#the-worker-instance)).
723
728
 
724
729
  #### The worker follows a rebased or deleted GitHub branch
725
730
 
@@ -741,7 +746,7 @@ changes the template too (the fallback bundle's key and hash), so only the contr
741
746
  bundle-only roll is safe.
742
747
 
743
748
  **To adopt.** Parameter mode: gate bundle-only rolls on the contract
744
- ([recipe](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
749
+ ([recipe](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
745
750
  `WorkerContract` output, so `cdk deploy` the template once, which adds it. A hand-installed unit
746
751
  copies its `Environment=CANOPYCMS_WORKER_CONTRACT=` line from `worker/canopy-worker.service`.
747
752
 
@@ -758,8 +763,8 @@ units from the bundle's contract: 2 gets the split, an older bundle the single u
758
763
  template, then roll the bundle; on an older template it stops with `template too old for this
759
764
  bundle`. Inspect EFS only through `sudo /opt/canopy-worker/canopy-inspect <command>`, never from a root shell. A hand install
760
765
  takes `worker/`'s three units and `gateway.env.example`
761
- ([steps](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
762
- [checklist](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#first-deploy-checklist).
766
+ ([steps](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
767
+ [checklist](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#first-deploy-checklist).
763
768
 
764
769
  #### `canopycms-cdk`: `CanopyCmsService.attachTo`, and editor response headers — **behaviour change if you frame the CMS**
765
770
 
@@ -770,7 +775,7 @@ response headers policy. `CanopyCmsDistribution` sends the same headers: `frame-
770
775
  `X-Frame-Options: SAMEORIGIN`, `nosniff`, HSTS and `X-Robots-Tag: noindex`. Unless your app sends
771
776
  its own framing headers, no other origin can frame the editor or any page the CMS domain serves. Every such page is
772
777
  marked `noindex`. The editor's default preview is same-origin and unaffected. See
773
- [Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
778
+ [Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
774
779
 
775
780
  **To adopt.** If you wired the Function URL into your own distribution by hand, delete those
776
781
  behaviors and call `attachTo`, passing your CMS build's `assetPrefix` as `editorAssetPrefix` and a
@@ -946,7 +951,7 @@ one the exclusions leave out. A throw or any other return is logged and treated
946
951
  **To adopt.** If your site's routes, sitemap or bylines decide that some entries have no page,
947
952
  apply the same rule here, for example `referenceLink: (target, { body }) =>
948
953
  !body?.trim() ? false : undefined` in `defineAIContentConfig` from `canopycms/ai`. See
949
- [AI Content Configuration](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#ai-content-configuration).
954
+ [AI Content Configuration](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#ai-content-configuration).
950
955
 
951
956
  **Now deletable.** A `fieldTransforms` entry that re-renders a reference field only to drop or
952
957
  change its link.
@@ -1021,7 +1026,7 @@ _First in int.115._
1021
1026
  entry the base branch also changed, the "updated on the base branch" notice and the branch's
1022
1027
  conflict count now stay until the branch merges, so a reviewer still sees which entries replaced a
1023
1028
  base change. They used to clear on the next sync, about five minutes later. README's new [Drafts
1024
- and Unpublishing](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#drafts-and-unpublishing) section covers long-lived branches and
1029
+ and Unpublishing](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#drafts-and-unpublishing) section covers long-lived branches and
1025
1030
  unpublishing.
1026
1031
 
1027
1032
  #### The editor calls the content drawer "All content"
@@ -1333,7 +1338,7 @@ editor carries an unsaved draft of a stamped entry onto its stamped version.
1333
1338
  The flag is refused off a top-level `datetime`, on `list: true`, and with `required: true`.
1334
1339
 
1335
1340
  **To adopt.** Add `stampOnPublish: true` to the date field your site sorts or labels by, such as
1336
- `{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#stamping-a-publication-date).
1341
+ `{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#stamping-a-publication-date).
1337
1342
 
1338
1343
  **Now deletable.** A build step or hook that writes a missing publication date into new entries.
1339
1344
 
@@ -1380,7 +1385,7 @@ preview/form divider is now keyboard-resizable within the same 15–85% the spli
1380
1385
  stored at, and `react-split-pane` is no longer a dependency.
1381
1386
  `EditorPanes`, `EditorPanesProps`, the `PaneLayout` type and the `SPLIT_PERCENT_*` and `DEFAULT_*_SPLIT_PERCENT` constants are
1382
1387
  no longer exported from `canopycms/client`. See
1383
- [Your root layout](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#editor-customization).
1388
+ [Your root layout](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#editor-customization).
1384
1389
 
1385
1390
  **To adopt.** Nothing, unless you import `EditorPanes` or those constants: render `CanopyEditor`
1386
1391
  instead, which lays out its own panes. Hiding your site chrome on the editor route is now
@@ -1491,7 +1496,7 @@ never ended. `canopycms-auth-clerk` skips it while the editor is mounted, and ex
1491
1496
  **To adopt.** Nothing for the editor, if your edit page uses `useClerkAuthConfig()` or
1492
1497
  `ClerkSignIn`. If your CMS build renders `<SignIn>`, `UserButton` or `OrganizationSwitcher` on your
1493
1498
  own pages, mount the hook as in
1494
- [Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
1499
+ [Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
1495
1500
  Your own Server Actions in the CMS build still 403 behind OAC.
1496
1501
 
1497
1502
  **Now deletable.** Any local patch of `window.__internal_onBeforeSetActive` (or 6.x's
@@ -1532,12 +1537,12 @@ fast naming the ARN, the field and the keys present, never a value.
1532
1537
  **To adopt.** Nothing, unless one of those secrets holds a JSON document: then set the matching
1533
1538
  prop. The scaffolded stack fills them from the repository _variables_
1534
1539
  `CANOPY_GITHUB_TOKEN_SECRET_JSON_FIELD` and `CLERK_SECRET_KEY_SECRET_JSON_FIELD`
1535
- ([why the prefix](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
1540
+ ([why the prefix](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
1536
1541
  adds the props to `infrastructure/bin/app.ts` and `infrastructure/lib/cms-stack.ts` and the two `env`
1537
1542
  lines to `.github/workflows/deploy-cms.yml`, or re-runs the generator and diffs. `cdk synth` refuses a `…JsonField` prop without its `…SecretArn`, and an ARN carrying the ECS `:KEY::` suffix
1538
1543
  (also in `secretsArns`). Don't use CDK's `secretValueFromJson`: it resolves the plaintext into the deployed
1539
1544
  resource's configuration, readable by anyone who can describe it. Only `CLERK_SECRET_KEY` goes through Secrets Manager; `CLERK_JWT_KEY` and the publishable
1540
- key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#security-model)).
1545
+ key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#security-model)).
1541
1546
 
1542
1547
  **Now deletable.** A wrapper that fetches the secret, parses it and re-exports one field into the
1543
1548
  worker's environment, such as a `jq` step in user data or a wrapper entrypoint around
@@ -1549,7 +1554,7 @@ worker's environment, such as a `jq` step in user data or a wrapper entrypoint a
1549
1554
  `githubToken` is not deprecated and stays the documented default; `canopycms` neither depends on
1550
1555
  nor imports `@octokit/auth-app`. Register one App per site, not one shared across repositories:
1551
1556
  anyone holding an App's key can mint a token for any of its installations
1552
- ([why](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
1557
+ ([why](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
1553
1558
 
1554
1559
  **To adopt with `canopycms-cdk`** (existing stacks need no edit). `CanopyCmsServiceProps` takes
1555
1560
  `githubAppId`, `githubAppInstallationId`, `githubAppPrivateKeySecretArn` and
@@ -1562,7 +1567,7 @@ anyone holding an App's key can mint a token for any of its installations
1562
1567
  `verify` checks an existing installation's permissions: run it, since an App missing a
1563
1568
  permission only shows up later, as `sync-failed`. `create` needs an interactive terminal and
1564
1569
  never edits an existing JSON secret (create one and point the JSON-field prop at it)
1565
- ([details](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
1570
+ ([details](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
1566
1571
  2. Set the three props and **remove `githubTokenSecretArn`** (with its JSON field). A partial set
1567
1572
  of the three is refused at synth, and so is an App alongside a token.
1568
1573
  3. In the generated workflow, store them as `CANOPY_GITHUB_APP_ID`,
@@ -1573,7 +1578,7 @@ anyone holding an App's key can mint a token for any of its installations
1573
1578
 
1574
1579
  The private key is ARN-only; passing the key itself is refused at synth. Its ARN joins the worker's
1575
1580
  IAM policy automatically, so you need not add it to `secretsArns`. See
1576
- [Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#authenticating-as-a-github-app).
1581
+ [Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#authenticating-as-a-github-app).
1577
1582
 
1578
1583
  ```bash
1579
1584
  canopycms init-github-app create -- \
@@ -1621,7 +1626,7 @@ downloads the `.pem` from the App's settings page.
1621
1626
 
1622
1627
  **What changed.** The worker re-reads a Secrets Manager secret (the GitHub token or the Clerk secret
1623
1628
  key) when the operation using it fails. Timings, costs and the store-before-revoke order are in
1624
- [Rotating a secret](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#rotating-a-secret).
1629
+ [Rotating a secret](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#rotating-a-secret).
1625
1630
 
1626
1631
  **To adopt.** Nothing for credentials from `*_SECRET_ARN`, which is every scaffolded deployment. A
1627
1632
  GitHub App private key is still read only at boot: store the new key, replace the instance, and
@@ -1675,12 +1680,12 @@ also check the bucket policy for its grant.
1675
1680
  5. `withCanopy()` adds sharp's libvips to Next's file tracing (not for a static export) and, on
1676
1681
  Next 16 and later, sets `turbopack: {}` when your config has neither `turbopack` nor your own
1677
1682
  `webpack` and it can read your Next version. A webpack build still fails its image transforms
1678
- ([Dual Build Support](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#dual-build-support)).
1683
+ ([Dual Build Support](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#dual-build-support)).
1679
1684
 
1680
1685
  **Breaking:** a stack setting `platform` on `fromImageAsset` without `architecture` gets an arm64
1681
1686
  function while `platform` still decides the image, so `Platform.LINUX_AMD64` builds an image the
1682
1687
  function cannot run. A stack setting neither moves to arm64 with a matching image, built under QEMU
1683
- on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#where-the-image-is-built)).
1688
+ on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#where-the-image-is-built)).
1684
1689
 
1685
1690
  **To adopt.**
1686
1691
 
@@ -1709,7 +1714,7 @@ reason; `platform` on `fromImageAsset`; and, with `withCanopy()`, a hand-written
1709
1714
 
1710
1715
  **What changed.** `media.uploadUrl` (s3 adapter; an absolute http(s) URL or a site-relative path)
1711
1716
  replaces the `url` that `beginUpload()` returns, leaving the presign's `fields` untouched, so
1712
- uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#media-configuration) for the
1717
+ uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#media-configuration) for the
1713
1718
  CloudFront behavior it expects.
1714
1719
 
1715
1720
  **To adopt.** Optional. Set it from an environment variable: a site-relative value works only where
@@ -1734,7 +1739,7 @@ needs `lazyPublicTransforms: true`) let you pass a deterministically named role,
1734
1739
  bucket's stack computes `arn:aws:iam::<account>:role/<name>` from literals instead of a
1735
1740
  `Fn::GetStackOutput` reference only the CDK CLI resolves. The constructs re-attach
1736
1741
  `AWSLambdaBasicExecutionRole` (and the VPC policy) that `lambda.Function` drops from a role you
1737
- pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#cross-account-asset-bucket).
1742
+ pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#cross-account-asset-bucket).
1738
1743
 
1739
1744
  **To adopt.** Optional:
1740
1745
 
@@ -1844,7 +1849,7 @@ public JWKS PEM, used only to verify signatures.
1844
1849
  to variables (Settings → Secrets and variables → Actions → Variables); `bin/app.ts` refuses the
1845
1850
  deploy at synth while it is unset. Check that `bin/app.ts` passes `CLERK_SECRET_KEY` as
1846
1851
  `clerkSecretKeySecretArn` (read by the worker), never in the Lambda's `environment`, unless you keep
1847
- `clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/docs/deploying-to-aws.md#security-model)).
1852
+ `clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/docs/deploying-to-aws.md#security-model)).
1848
1853
 
1849
1854
  #### `readByUrlPath` answers only where `listEntries` publishes — **breaking (routing)**
1850
1855
 
@@ -1943,7 +1948,7 @@ basePath: process.env.NEXT_PUBLIC_BASE_PATH,
1943
1948
  Then pass `baseUrl` to `assetUrl` only if Next serves `/assets` (local adapter, `next dev`, S3 with
1944
1949
  no distribution): `assetUrl(image, { width: 960, baseUrl: BASE_PATH })`. Assets on CloudFront via
1945
1950
  `AssetSupport` stay at the distribution root; pass no `baseUrl` (mount table under "Where `/assets`
1946
- is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#media-configuration)). Two traps:
1951
+ is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#media-configuration)). Two traps:
1947
1952
 
1948
1953
  - Don't pass a deployment `basePath` to `contentStaticParams({ basePath })`; that option filters by
1949
1954
  a nested route prefix and emits zero params, building green.
@@ -2102,7 +2107,7 @@ Under `exactOptionalPropertyTypes: true`, omit keys instead of assigning `undefi
2102
2107
  `withTrailingSlash` and `isAbsoluteUrl` from `canopycms/server`; `defineSeoFieldGroup()` from
2103
2108
  `canopycms`; `generateContentSitemap` and `entryToMetadata` from `canopycms-next`, bound on
2104
2109
  `createNextCanopyContext`'s result. See
2105
- [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#sitemap-and-seo-metadata). Every routable entry type is in
2110
+ [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#sitemap-and-seo-metadata). Every routable entry type is in
2106
2111
  the sitemap unless `exclude`d or `noindex`; one `noindex` predicate drives both robots metadata and
2107
2112
  sitemap exclusion. `trailingSlash` is never inferred. `lastModified` defaults to `updatedAt`, a
2108
2113
  filesystem mtime. An empty SEO field counts as unset. `siteUrl` must be absolute, colliding URLs are
@@ -2159,7 +2164,7 @@ underscore-prefixed files are skipped.
2159
2164
 
2160
2165
  **What changed.** New scaffolds write `defaultBranchAccess: 'deny'` and
2161
2166
  `defaultPathAccess: { read: 'allow' }`
2162
- ([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#public-read-on-server-deployments)).
2167
+ ([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#public-read-on-server-deployments)).
2163
2168
 
2164
2169
  **To adopt.** An older scaffold's `defaultBranchAccess: 'allow'` is wider than recommended;
2165
2170
  consider `'deny'`. If you deleted `defaultPathAccess: { read: 'allow' }`, anonymous visitors get no content until you
@@ -2212,7 +2217,7 @@ re-checked an entry's type (a `switch` on `meta.entryType` can merge them into o
2212
2217
  **What changed.** `BlockComponentRegistry<Blocks>` (types only, from `canopycms`; `BlockValueOf<Blocks, 'hero'>`
2213
2218
  gives one template's value type) requires exactly
2214
2219
  one component per block template name when written as an object literal. See
2215
- [Block Component Registries](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#block-component-registries) and
2220
+ [Block Component Registries](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#block-component-registries) and
2216
2221
  `apps/example1/app/components/PostView.tsx`.
2217
2222
 
2218
2223
  ```ts
@@ -2234,7 +2239,7 @@ templates against the schema.
2234
2239
 
2235
2240
  **What changed.** Spreading a `const` field array into several schemas, and nesting
2236
2241
  `defineInlineFieldGroup()` inside a block template, are documented
2237
- ([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
2242
+ ([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
2238
2243
  identity helper for them.
2239
2244
 
2240
2245
  ```ts
@@ -2253,7 +2258,7 @@ field by composing from the same `const` field object.
2253
2258
  A block template holding a `reference` field is a shared block; `read()`/`readByUrlPath()` resolve
2254
2259
  it, and listings do with
2255
2260
  [`resolveReferences`](#listings-resolve-references-and-a-resolved-reference-carries-urlpath-and-optionally-its-body-16--breaking-type-level)
2256
- (0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#shared--referenced-blocks).
2261
+ (0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#shared--referenced-blocks).
2257
2262
 
2258
2263
  **Now deletable.** A second `read()` in page code to unwrap a shared block's reference.
2259
2264
 
@@ -2275,7 +2280,7 @@ Not retro-documented, apart from these:
2275
2280
 
2276
2281
  #### The registry is keyed by entry-type name (0.0.42)
2277
2282
 
2278
- **What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/0a53107eda329ce0499edad3544a16fb130b5beb/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
2283
+ **What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/ecd004a19d226d3b93e175eb8a2bd2c5a4ef2463/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
2279
2284
 
2280
2285
  **To adopt.**
2281
2286
 
@@ -194,7 +194,14 @@ export function startDevContentWatcher(services, options = {}) {
194
194
  }
195
195
  }
196
196
  };
197
- const watcher = chokidar.watch(workingTreeContentDir, { ignoreInitial: true });
197
+ // A save can truncate and then write. chokidar's 50 ms per-path throttle passes only the first
198
+ // `change`, which can land between the two steps: a check then reads a half-written file and
199
+ // reports a divergence nothing retracts. `awaitWriteFinish` emits only once the file's size has
200
+ // held still, and bypasses that throttle.
201
+ const watcher = chokidar.watch(workingTreeContentDir, {
202
+ ignoreInitial: true,
203
+ awaitWriteFinish: { stabilityThreshold: 100, pollInterval: 25 },
204
+ });
198
205
  watcher.on('add', () => void check());
199
206
  watcher.on('change', () => void check());
200
207
  watcher.on('unlink', () => void check());
@@ -62,6 +62,7 @@ import { findFieldTarget, focusFieldTarget } from './field-target.js';
62
62
  import { UndoToastMessage } from './components/UndoToastMessage.js';
63
63
  import { getNotificationDuration } from './utils/env.js';
64
64
  import { MayHaveLandedError } from './unanswered.js';
65
+ import { sanitizeBranchName } from '../paths/branch-name.js';
65
66
  // Stable fallbacks, so reference resolution's memo and effect don't re-run on every render
66
67
  // while no entry is open.
67
68
  const EMPTY_SCHEMA = [];
@@ -182,6 +183,8 @@ const EditorContent = ({ entries, title, siteTitle = title, branchName = '', col
182
183
  // A row's lock reason on an unanswered branch would be "details could not be loaded", which is
183
184
  // not yet true; once the fetch has failed it is, and the lock says so.
184
185
  const branchRowsPending = branchLoading && !branchesLoadFailed;
186
+ // Set once the branch actions below exist; they depend on the drafts, which depend on the entries.
187
+ const switchBranchRef = useRef(async () => { });
185
188
  // 2. Entry manager (depends on branchNameState, owns selectedPath)
186
189
  const { selectedPath, setSelectedPath, closeEntry, entries: entriesState, collections: collectionsFromApi, currentEntry, availableSchemas, entriesInitializing, entriesLoadFailed, navigatorOpen, setNavigatorOpen, refreshEntries, refreshContent, handleCreateEntry, renameEntry, loadEntry, readEntryValue, saveEntry, getEntryVersion, adoptEntryVersion, followMovedEntry, recreateEntry, createModalOpen, createModalCollection, createModalError, createModalCreating, createModalExistingSlugs, handleCreateModalSubmit, closeCreateModal, } = useEntryManager({
187
190
  initialEntries: entries,
@@ -197,6 +200,13 @@ const EditorContent = ({ entries, title, siteTitle = title, branchName = '', col
197
200
  }),
198
201
  resolvePreviewRoute: (entry) => buildPreviewRoute(entry, { previewBaseByCollection, contentRoot }),
199
202
  setBusy: setEntriesLoading,
203
+ switchBranch: (branch) => switchBranchRef.current(branch),
204
+ // To the entry menu, which names the entry opened; a dialog keeps focus.
205
+ onHistoryRestore: () => requestAnimationFrame(() => {
206
+ if (!document.activeElement?.closest('[role="dialog"]')) {
207
+ navigatorToggleRef.current?.focus({ preventScroll: true });
208
+ }
209
+ }),
200
210
  });
201
211
  // The content overlay and a maximized preview hide the form; `navigatorOpen` is only the
202
212
  // overlay's. Anything that focuses something in the form reveals it first. Opening an entry
@@ -296,6 +306,17 @@ const EditorContent = ({ entries, title, siteTitle = title, branchName = '', col
296
306
  onBranchCreated: addCreatedBranch,
297
307
  userId: userContext?.userId,
298
308
  });
309
+ switchBranchRef.current = async (branch) => {
310
+ const listed = (name) => name === branch || name === sanitizeBranchName(branch);
311
+ if (branchSummaries.length > 0 && !branchSummaries.some((b) => listed(b.name))) {
312
+ notifications.show({
313
+ message: `Branch “${branch}” no longer exists or you can no longer open it, so you're still on “${branchNameState}”.`,
314
+ color: 'yellow',
315
+ });
316
+ throw new Error(`Branch ${branch} is not listed`);
317
+ }
318
+ await handleBranchChange(branch);
319
+ };
299
320
  // 5. Comment system (depends on branchNameState)
300
321
  const { comments, getCommentUser, focusedFieldPath, highlightThreadId, commentsPanelOpen, setCommentsPanelOpen, handleAddComment, handleResolveThread, handleJumpToField, handleJumpToEntry, handleJumpToBranch, } = useCommentSystem({
301
322
  branchName: branchNameState,
@@ -885,8 +906,8 @@ const EditorContent = ({ entries, title, siteTitle = title, branchName = '', col
885
906
  setDeletingEntryReferencedBy(result.referencedBy);
886
907
  return;
887
908
  }
888
- if (result.ok && selectedPath === deletingEntryPath)
889
- closeEntry();
909
+ if (result.ok)
910
+ closeEntry(deletingEntryPath, branchNameState);
890
911
  closeDeleteEntryModal();
891
912
  }
892
913
  finally {
@@ -522,8 +522,9 @@ export const EntryNavigator = ({ items, collections, selectedPath, onSelect, onT
522
522
  !entryUnavailable &&
523
523
  !entryLocked &&
524
524
  (onDeleteEntry || onRenameEntry || onReorderEntry);
525
- // The lock stands where the menu would, on exactly the rows that would otherwise have one. It
526
- // is always shown: on hover alone, touch and keyboard users would see neither menu nor reason.
525
+ // The lock holds the slot where the menu would be, on exactly the rows that would otherwise have
526
+ // one, so rows never shift. The stylesheet reveals it on the hovered, focused or selected
527
+ // row (`data-nav-selected`), which keeps touch and keyboard users' route to the reason.
527
528
  const wouldHaveCollectionMenu = isCollection &&
528
529
  !!(rawOnAdd ||
529
530
  rawOnEdit ||
@@ -540,7 +541,7 @@ export const EntryNavigator = ({ items, collections, selectedPath, onSelect, onT
540
541
  const showCollectionDirtyDot = !isEntry && dirtyCollections.has(node.value);
541
542
  const adminItems = onAddSubCollection || onEdit || onDelete;
542
543
  const hasCollectionContentItems = onAdd || canReorder;
543
- return (_jsxs(Box, { ...elementProps, ref: selected ? selectedNodeRef : undefined, "data-nav-row": true, "data-testid": `entry-nav-item-${testIdSuffix}`, onClick: (event) => {
544
+ return (_jsxs(Box, { ...elementProps, ref: selected ? selectedNodeRef : undefined, "data-nav-row": true, "data-nav-selected": selected ? '' : undefined, "data-testid": `entry-nav-item-${testIdSuffix}`, onClick: (event) => {
544
545
  elementProps.onClick(event);
545
546
  if (isLeaf && isEntry) {
546
547
  onSelect(node.value);
@@ -585,7 +586,8 @@ export const EntryNavigator = ({ items, collections, selectedPath, onSelect, onT
585
586
  onDelete();
586
587
  }, children: "Delete collection" }))] })] })), showsLockSlot &&
587
588
  (readOnlyReason ? (_jsx(BranchRowLock, { label: isCollection ? 'Collection actions' : 'Entry actions', reason: readOnlyReason })) : (
588
- // The branch's state is still loading: hold the slot so rows do not shift.
589
+ // The branch's state is still loading: hold the slot so rows do not shift. It draws
590
+ // nothing, so it needs no reveal.
589
591
  _jsx(Box, { w: 18, h: 18, "aria-hidden": true, "data-testid": "branch-lock-pending" }))), hasEntryMenu && (_jsxs(Menu, { shadow: "md", width: 180, withinPortal: true, position: "bottom-end", children: [_jsx(Menu.Target, { children: _jsx(ActionIcon, { size: "xs", variant: "subtle", color: "gray", onClick: (event) => event.stopPropagation(), "aria-label": "Entry actions", "data-testid": `entry-menu-${testIdSuffix}`, children: _jsx(IconDots, { size: 14 }) }) }), _jsxs(Menu.Dropdown, { onKeyDown: stopTreeKeys, children: [onRenameEntry && (_jsxs(Menu.Item, { leftSection: _jsx(IconEdit, { size: 14 }), onClick: (event) => {
590
592
  event.stopPropagation();
591
593
  onRenameEntry(entryPath);
@@ -4,7 +4,9 @@ import React from 'react';
4
4
  * writes. It matches the menu button's footprint so rows do not shift between branches, and takes
5
5
  * the menu's name; the reason is its Tooltip and its description. It stays `aria-disabled` rather
6
6
  * than `disabled`, so the reason opens on keyboard focus and touch too. Space is stopped here: the
7
- * tree would read it as expand/collapse.
7
+ * tree would read it as expand/collapse. `data-row-lock` marks it for the theme stylesheet, which
8
+ * draws it only on the hovered, focused or selected row (opacity, never `display`, so
9
+ * focusing it reveals it); a touch user sees it on the row they tapped.
8
10
  */
9
11
  export declare const BranchRowLock: React.FC<{
10
12
  label: string;
@@ -8,11 +8,13 @@ import { IconLock } from '@tabler/icons-react';
8
8
  * writes. It matches the menu button's footprint so rows do not shift between branches, and takes
9
9
  * the menu's name; the reason is its Tooltip and its description. It stays `aria-disabled` rather
10
10
  * than `disabled`, so the reason opens on keyboard focus and touch too. Space is stopped here: the
11
- * tree would read it as expand/collapse.
11
+ * tree would read it as expand/collapse. `data-row-lock` marks it for the theme stylesheet, which
12
+ * draws it only on the hovered, focused or selected row (opacity, never `display`, so
13
+ * focusing it reveals it); a touch user sees it on the row they tapped.
12
14
  */
13
15
  export const BranchRowLock = ({ label, reason }) => {
14
16
  const reasonId = useId();
15
- return (_jsx(Tooltip, { label: reason, withinPortal: true, position: "bottom-end", multiline: true, w: 240, events: { hover: true, focus: true, touch: true }, children: _jsxs(ActionIcon, { size: "xs", variant: "transparent", c: "dimmed", "aria-disabled": true, "aria-label": label, "aria-describedby": reasonId, "data-testid": "branch-lock", style: { cursor: 'default' }, onClick: (event) => event.stopPropagation(), onKeyDown: (event) => {
17
+ return (_jsx(Tooltip, { label: reason, withinPortal: true, position: "bottom-end", multiline: true, w: 240, events: { hover: true, focus: true, touch: true }, children: _jsxs(ActionIcon, { size: "xs", variant: "transparent", c: "dimmed", "aria-disabled": true, "aria-label": label, "aria-describedby": reasonId, "data-testid": "branch-lock", "data-row-lock": true, style: { cursor: 'default' }, onClick: (event) => event.stopPropagation(), onKeyDown: (event) => {
16
18
  if (event.nativeEvent.code === 'Space')
17
19
  event.stopPropagation();
18
20
  }, children: [_jsx(IconLock, { size: 14, "aria-hidden": true }), _jsx(VisuallyHidden, { component: "span", id: reasonId, children: reason })] }) }));
@@ -0,0 +1,7 @@
1
+ /** Shows `url`, pushed, or replaced keeping the entry's other state; never rewrites the URL shown. */
2
+ export declare function writeEditorUrl(url: string, push: boolean): void;
3
+ /** Stamps the history entry the editor opened on, keeping Next.js's keys: the URL is unchanged. */
4
+ export declare function markEditorHistoryStart(): void;
5
+ /** On `popstate`: entries moved, undefined if an end is not this run's, null for an undo's. */
6
+ export declare function recordHistoryMove(): number | undefined | null;
7
+ export declare function undoHistoryMove(moved: number): void;
@@ -0,0 +1,80 @@
1
+ /** Session-history writes stamped with their position, so a refused Back can be undone. */
2
+ const STAMP_KEY = 'canopyHistory';
3
+ // Next.js's router keys: its patched history methods copy `__NA` and the tree back and record the
4
+ // URL, but do neither for state already holding `__NA` or `_N` (app-router.js, next 15.5).
5
+ const ROUTER_KEYS = ['__NA', '__PRIVATE_NEXTJS_INTERNALS_TREE', '_N'];
6
+ // A run restarts wherever the position is lost, so positions from two runs are never compared.
7
+ let run = '';
8
+ let position;
9
+ let undoTarget;
10
+ const newRun = () => {
11
+ run = Math.random().toString(36).slice(2);
12
+ position = undefined;
13
+ };
14
+ const currentState = () => {
15
+ const state = window.history.state;
16
+ return state !== null && typeof state === 'object' ? { ...state } : {};
17
+ };
18
+ const stampIn = (state) => {
19
+ const value = state[STAMP_KEY];
20
+ if (value === null || typeof value !== 'object')
21
+ return undefined;
22
+ const [stampRun, at] = [Reflect.get(value, 'run'), Reflect.get(value, 'position')];
23
+ return typeof stampRun === 'string' && typeof at === 'number'
24
+ ? { run: stampRun, position: at }
25
+ : undefined;
26
+ };
27
+ const samePage = (a, b) => {
28
+ const [x, y] = [new URL(a, window.location.href), new URL(b, window.location.href)];
29
+ const query = (u) => new URLSearchParams(u.search).toString();
30
+ return (x.origin === y.origin && x.pathname === y.pathname && query(x) === query(y) && x.hash === y.hash);
31
+ };
32
+ /** Shows `url`, pushed, or replaced keeping the entry's other state; never rewrites the URL shown. */
33
+ export function writeEditorUrl(url, push) {
34
+ if (samePage(url, window.location.href))
35
+ return;
36
+ if (!run)
37
+ newRun();
38
+ const at = (position ?? 0) + (push ? 1 : 0);
39
+ const kept = push ? {} : currentState();
40
+ for (const key of ROUTER_KEYS)
41
+ delete kept[key];
42
+ const method = push ? window.history.pushState : window.history.replaceState;
43
+ method.call(window.history, { ...kept, [STAMP_KEY]: { run, position: at } }, '', url);
44
+ position = at;
45
+ }
46
+ /** Stamps the history entry the editor opened on, keeping Next.js's keys: the URL is unchanged. */
47
+ export function markEditorHistoryStart() {
48
+ const state = currentState();
49
+ const stamp = stampIn(state);
50
+ if (stamp) {
51
+ run = stamp.run;
52
+ position = stamp.position;
53
+ return;
54
+ }
55
+ newRun();
56
+ position = 0;
57
+ window.history.replaceState({ ...state, [STAMP_KEY]: { run, position } }, '', window.location.href);
58
+ }
59
+ /** On `popstate`: entries moved, undefined if an end is not this run's, null for an undo's. */
60
+ export function recordHistoryMove() {
61
+ const arrived = stampIn(currentState());
62
+ const undone = undoTarget !== undefined &&
63
+ arrived?.run === undoTarget.run &&
64
+ arrived.position === undoTarget.position;
65
+ undoTarget = undefined;
66
+ const moved = arrived?.run === run && position !== undefined ? arrived.position - position : undefined;
67
+ if (arrived) {
68
+ run = arrived.run;
69
+ position = arrived.position;
70
+ }
71
+ else
72
+ newRun();
73
+ return undone ? null : moved;
74
+ }
75
+ export function undoHistoryMove(moved) {
76
+ if (position === undefined)
77
+ return;
78
+ undoTarget = { run, position: position - moved };
79
+ window.history.go(-moved);
80
+ }
@@ -5,6 +5,7 @@ import { notifications } from '@mantine/notifications';
5
5
  import { Text } from '@mantine/core';
6
6
  import { useApiClient } from '../context/index.js';
7
7
  import { requestBranchCreate } from './create-branch-request.js';
8
+ import { writeEditorUrl } from './editor-history.js';
8
9
  const MAX_LISTED_LABELS = 5;
9
10
  /** 'Unsaved changes in: "A", "B".' */
10
11
  export const describeUnsaved = ({ labels }) => {
@@ -25,10 +26,11 @@ export function useBranchActions(options) {
25
26
  const [confirmOpen, setConfirmOpen] = useState(false);
26
27
  const performBranchSwitch = (next) => {
27
28
  options.setBranchName(next);
29
+ // Its own history entry; a Back onto another branch already shows this URL, so writes nothing.
28
30
  if (typeof window !== 'undefined') {
29
31
  const url = new URL(window.location.href);
30
32
  url.searchParams.set('branch', next);
31
- window.history.replaceState({}, '', url.toString());
33
+ writeEditorUrl(url.toString(), true);
32
34
  }
33
35
  options.onBranchSwitch?.(next);
34
36
  };
@@ -18,6 +18,7 @@ import { RetryToastMessage } from '../components/RetryToastMessage.js';
18
18
  import { isNonApiResponse } from '../../api/client.js';
19
19
  import { isGatewayFailure, isUnanswered, UnansweredError } from '../unanswered.js';
20
20
  import { describeUnsaved } from './useBranchActions.js';
21
+ import { writeEditorUrl } from './editor-history.js';
21
22
  const BRANCHES_LOAD_FAILED_TOAST_ID = 'canopy-branches-load-failed';
22
23
  const BRANCH_OUTCOME_UNKNOWN_TOAST_ID = 'canopy-branch-outcome-unknown';
23
24
  /** The error a refused branch action throws; a gateway's 5xx says nothing of whether it ran. */
@@ -583,16 +584,18 @@ export function useBranchManager(options) {
583
584
  const handleReloadBranchData = async () => {
584
585
  await loadBranches();
585
586
  };
587
+ // The editor's own page; a Back off it to a page of the host leaves that page's URL alone.
588
+ const editorPathRef = useRef(typeof window === 'undefined' ? '' : window.location.pathname);
586
589
  useEffect(() => {
587
590
  if (typeof window === 'undefined')
588
591
  return;
589
- if (!branchName)
592
+ if (!branchName || window.location.pathname !== editorPathRef.current)
590
593
  return;
591
594
  const url = new URL(window.location.href);
592
595
  const current = url.searchParams.get('branch');
593
596
  if (current !== branchName) {
594
597
  url.searchParams.set('branch', branchName);
595
- window.history.replaceState({}, '', url.toString());
598
+ writeEditorUrl(url.toString(), false);
596
599
  }
597
600
  }, [branchName]);
598
601
  return {
@@ -4,6 +4,8 @@ import type { LogicalPath } from '../../paths/types.js';
4
4
  import type { FormValue } from '../FormRenderer.js';
5
5
  import type { EntryFieldError } from '../../validation/entry-validator.js';
6
6
  /** @internal Exported for tests. */
7
+ export declare const RESTORED_ENTRY_GONE_MESSAGE = "The entry you returned to is no longer on this branch, so the home page opened.";
8
+ /** @internal Exported for tests. */
7
9
  export { listAllEntries } from './useEntriesData.js';
8
10
  /**
9
11
  * Thrown by saveEntry when the API returns a non-200 response. Carries the
@@ -37,12 +39,17 @@ export interface UseEntryManagerOptions {
37
39
  /** An entry's route on the site (`buildPreviewRoute`), which picks the home page to open first. */
38
40
  resolvePreviewRoute?: (entry: EditorEntry) => string | undefined;
39
41
  setBusy: (busy: boolean) => void;
42
+ /** Switches to the branch a Back or Forward reached; rejects when the switch does not happen. */
43
+ switchBranch?: (branch: string) => Promise<void>;
44
+ /** Called when a Back or Forward has opened another entry. */
45
+ onHistoryRestore?: () => void;
40
46
  }
41
47
  export interface UseEntryManagerReturn {
42
48
  selectedPath: string;
49
+ /** Opens an entry the user chose, adding a history entry, so Back returns to the one before. */
43
50
  setSelectedPath: (path: string) => void;
44
- /** Leaves no entry open, as after deleting the open one, instead of opening the first. */
45
- closeEntry: () => void;
51
+ /** Leaves no entry open if `path` on `branch` is still open, as after deleting it. */
52
+ closeEntry: (path: string, branch: string) => void;
46
53
  entries: EditorEntry[];
47
54
  setEntries: (entries: EditorEntry[]) => void;
48
55
  collections: EditorCollection[];
@@ -10,7 +10,11 @@ import { SCHEMA_UNAVAILABLE_CODE } from '../unavailable-entry-type.js';
10
10
  import { entriesKey, fetchEntriesAndSchema } from './useEntriesData.js';
11
11
  import { RetryToastMessage } from '../components/RetryToastMessage.js';
12
12
  import { isGatewayFailure, isUnanswered, MayHaveLandedError, UnansweredError } from '../unanswered.js';
13
+ import { sanitizeBranchName } from '../../paths/branch-name.js';
14
+ import { markEditorHistoryStart, recordHistoryMove, undoHistoryMove, writeEditorUrl, } from './editor-history.js';
13
15
  const ENTRIES_LOAD_FAILED_TOAST_ID = 'canopy-entries-load-failed';
16
+ /** @internal Exported for tests. */
17
+ export const RESTORED_ENTRY_GONE_MESSAGE = 'The entry you returned to is no longer on this branch, so the home page opened.';
14
18
  // Re-exported so existing imports of `listAllEntries` from this module keep
15
19
  // working -- the implementation lives in useEntriesData.ts alongside the
16
20
  // other fetch/key/type pieces useEntryManager shares with the SWR layer.
@@ -56,6 +60,23 @@ const EMPTY_SCHEMAS = [];
56
60
  * from an entry that crashes the editor); null opens the home page (`resolveHomeEntry`).
57
61
  */
58
62
  const readUrlEntry = () => typeof window === 'undefined' ? null : new URLSearchParams(window.location.search).get('entry');
63
+ /** The current URL with `branch` and the `entry` that `selectedPath` shows, as `readUrlEntry` reads it. */
64
+ const entryUrl = (selectedPath, noEntry, branch) => {
65
+ const url = new URL(window.location.href);
66
+ if (branch)
67
+ url.searchParams.set('branch', branch);
68
+ if (selectedPath) {
69
+ url.searchParams.set('entry', selectedPath);
70
+ }
71
+ else if (noEntry) {
72
+ // Kept, so a reload still opens no entry.
73
+ url.searchParams.set('entry', '');
74
+ }
75
+ else {
76
+ url.searchParams.delete('entry');
77
+ }
78
+ return url.toString();
79
+ };
59
80
  /**
60
81
  * Custom hook for managing editor entries (CRUD operations).
61
82
  */
@@ -102,6 +123,18 @@ export function useEntryManager(options) {
102
123
  selectedPathRef.current = selectedPath;
103
124
  // Counts selections through the returned setter, not this hook's own fallbacks.
104
125
  const selectionsByCallerRef = useRef(0);
126
+ // The path the user chose, which the URL sync pushes; any other selection replaces the URL.
127
+ const pushTargetRef = useRef(null);
128
+ // The `entry` a Back onto another branch opens once that branch shows; a later move drops it.
129
+ const entryAfterBranchChangeRef = useRef(undefined);
130
+ // Counts Back and Forward moves, so a branch switch one asked for knows when another followed.
131
+ const historyMovesRef = useRef(0);
132
+ // The path a Back or Forward opened, until the entries show whether it is still there.
133
+ const restoredPathRef = useRef(null);
134
+ // The editor's own page: a Back off it to another page of the host is no move between entries.
135
+ const editorPathRef = useRef(typeof window === 'undefined' ? '' : window.location.pathname);
136
+ const onHistoryRestoreRef = useRef(options.onHistoryRestore);
137
+ onHistoryRestoreRef.current = options.onHistoryRestore;
105
138
  const [navigatorOpen, setNavigatorOpen] = useState(() => readUrlEntry() === '');
106
139
  const isInitialMount = useRef(true);
107
140
  const hasSyncedFromUrl = useRef(false);
@@ -188,13 +221,18 @@ export function useEntryManager(options) {
188
221
  const noEntryRequested = useRef(initialUrlEntry.current === '');
189
222
  const selectEntryPath = useCallback((path) => {
190
223
  selectionsByCallerRef.current += 1;
224
+ pushTargetRef.current = path;
191
225
  setSelectedPath(path);
192
226
  }, []);
193
227
  // No entry open, as the URL's empty `entry` asks, where a lost selection opens the home page.
194
- const closeEntry = useCallback(() => {
228
+ // Replaces the history entry: it follows a delete, which Back could not undo.
229
+ const closeEntry = useCallback((path, branch) => {
230
+ if (selectedPathRef.current !== path || currentBranchRef.current !== branch)
231
+ return;
195
232
  noEntryRequested.current = true;
196
- selectEntryPath('');
197
- }, [selectEntryPath]);
233
+ selectionsByCallerRef.current += 1;
234
+ setSelectedPath('');
235
+ }, []);
198
236
  const collectionByPath = useMemo(() => {
199
237
  const map = new Map();
200
238
  const walk = (collections) => {
@@ -470,6 +508,7 @@ export function useEntryManager(options) {
470
508
  // still empty when this function runs (slow server / cold start).
471
509
  const createdEntry = refreshed.find((e) => e.collectionPath === createModalCollection.path && e.slug === slug);
472
510
  if (createdEntry) {
511
+ pushTargetRef.current = createdEntry.path;
473
512
  setSelectedPath(createdEntry.path);
474
513
  }
475
514
  else {
@@ -566,8 +605,16 @@ export function useEntryManager(options) {
566
605
  isInitialMount.current = false;
567
606
  }
568
607
  else {
569
- noEntryRequested.current = false;
570
- setSelectedPath('');
608
+ const restored = entryAfterBranchChangeRef.current;
609
+ entryAfterBranchChangeRef.current = undefined;
610
+ const entry = restored?.branch === options.branchName ? restored.entry : undefined;
611
+ noEntryRequested.current = entry === '';
612
+ setSelectedPath(entry ?? '');
613
+ if (entry !== undefined) {
614
+ restoredPathRef.current = entry;
615
+ setNavigatorOpen(entry === '');
616
+ onHistoryRestoreRef.current?.();
617
+ }
571
618
  // Bound version-map growth across switches. Correctness no longer
572
619
  // depends on this clear: tokens are keyed by `${branch}:${contentId}`
573
620
  // (see entryVersionsRef), so a late response from the previous branch
@@ -703,33 +750,100 @@ export function useEntryManager(options) {
703
750
  return;
704
751
  }
705
752
  }
753
+ const restored = restoredPathRef.current === selectedPath;
754
+ if (restored)
755
+ restoredPathRef.current = null;
706
756
  // If the selected entry exists, keep it
707
757
  if (entriesState.find((e) => e.path === selectedPath))
708
758
  return;
709
759
  if (selectedPath === '' && noEntryRequested.current)
710
760
  return;
761
+ if (restored && selectedPath) {
762
+ notifications.show({ message: RESTORED_ENTRY_GONE_MESSAGE, color: 'blue' });
763
+ }
711
764
  setSelectedPath(resolveHomeEntry(entriesState, resolvePreviewRouteRef.current)?.path ?? '');
712
765
  }, [entriesState, selectedPath]);
713
766
  // Update URL when selection changes (skip until URL sync has happened)
714
767
  useEffect(() => {
715
768
  if (typeof window === 'undefined')
716
769
  return;
770
+ // Pushed only once listed: a path the check above replaces would leave a stale entry behind.
771
+ const push = pushTargetRef.current === selectedPath && entriesState.some((e) => e.path === selectedPath);
772
+ pushTargetRef.current = null;
717
773
  // Don't update URL until we've synced from it first
718
774
  if (!hasSyncedFromUrl.current)
719
775
  return;
720
- const url = new URL(window.location.href);
721
- if (selectedPath) {
722
- url.searchParams.set('entry', selectedPath);
723
- }
724
- else if (noEntryRequested.current) {
725
- // Kept, so a reload still opens no entry.
726
- url.searchParams.set('entry', '');
727
- }
728
- else {
729
- url.searchParams.delete('entry');
730
- }
731
- window.history.replaceState({}, '', url.toString());
776
+ if (window.location.pathname !== editorPathRef.current)
777
+ return;
778
+ writeEditorUrl(entryUrl(selectedPath, noEntryRequested.current, currentBranchRef.current), push);
732
779
  }, [selectedPath]);
780
+ const entriesRef = useRef(entriesState);
781
+ entriesRef.current = entriesState;
782
+ const switchBranchRef = useRef(options.switchBranch);
783
+ switchBranchRef.current = options.switchBranch;
784
+ // Back and Forward open the entry their URL names, without a reload.
785
+ useEffect(() => {
786
+ if (typeof window === 'undefined')
787
+ return;
788
+ markEditorHistoryStart();
789
+ const restore = () => {
790
+ const moved = recordHistoryMove();
791
+ if (moved === null || window.location.pathname !== editorPathRef.current)
792
+ return;
793
+ historyMovesRef.current += 1;
794
+ entryAfterBranchChangeRef.current = undefined;
795
+ const params = new URLSearchParams(window.location.search);
796
+ const entry = params.get('entry');
797
+ const branch = params.get('branch');
798
+ const current = currentBranchRef.current;
799
+ // A legacy name and its sanitized form are one branch; a switch would key drafts by the other.
800
+ if (branch && sanitizeBranchName(branch) !== sanitizeBranchName(current)) {
801
+ const move = historyMovesRef.current;
802
+ const stay = () => {
803
+ if (move !== historyMovesRef.current)
804
+ return;
805
+ if (moved)
806
+ undoHistoryMove(moved);
807
+ else {
808
+ const url = entryUrl(selectedPathRef.current, noEntryRequested.current, currentBranchRef.current);
809
+ writeEditorUrl(url, false);
810
+ }
811
+ };
812
+ const switchBranch = switchBranchRef.current;
813
+ if (!switchBranch) {
814
+ stay();
815
+ return;
816
+ }
817
+ entryAfterBranchChangeRef.current = { branch, entry };
818
+ if (!hasSyncedFromUrl.current)
819
+ initialUrlEntry.current = entry;
820
+ switchBranch(branch).catch(() => {
821
+ if (move === historyMovesRef.current)
822
+ entryAfterBranchChangeRef.current = undefined;
823
+ stay();
824
+ });
825
+ return;
826
+ }
827
+ // A Back is a selection, so a rename, move or re-create landing afterwards leaves it open.
828
+ selectionsByCallerRef.current += 1;
829
+ noEntryRequested.current = entry === '';
830
+ setNavigatorOpen(entry === '');
831
+ if (!hasSyncedFromUrl.current) {
832
+ initialUrlEntry.current = entry;
833
+ setSelectedPath(entry ?? '');
834
+ return;
835
+ }
836
+ const target = entry ?? resolveHomeEntry(entriesRef.current, resolvePreviewRouteRef.current)?.path ?? '';
837
+ if (target === selectedPathRef.current)
838
+ return;
839
+ restoredPathRef.current = target;
840
+ // A path no longer listed falls back to the home page, through the selection check above.
841
+ setSelectedPath(target);
842
+ onHistoryRestoreRef.current?.();
843
+ };
844
+ window.addEventListener('popstate', restore);
845
+ return () => window.removeEventListener('popstate', restore);
846
+ }, []);
733
847
  return {
734
848
  selectedPath,
735
849
  setSelectedPath: selectEntryPath,
@@ -320,7 +320,11 @@ const canopyCssVariablesResolver = (theme) => ({
320
320
  * Switch thumbs, white text on the primary colour (moved to the fill), and dimmed text Mantine
321
321
  * draws itself (a blocked menu item, a combobox's empty message, outside days). Outside days lose
322
322
  * Mantine's half opacity, under 4.5:1. The crop box and its handles sit on an arbitrary image, where
323
- * no single colour holds 3:1, so they take a white and black pair.
323
+ * no single colour holds 3:1, so they take a white and black pair. A navigator row's lock is
324
+ * drawn only while its row is hovered, focused (Mantine's Tree focuses the `li` around the row, on click and arrow keys), has focus
325
+ * within, or is selected. It hides by opacity alone, so it keeps its place and stays in the tab order
326
+ * and the accessibility tree; while hidden it takes no pointer events, so a tap on its slot reaches
327
+ * the row.
324
328
  */
325
329
  const CANOPY_STYLES = `
326
330
  .mantine-Checkbox-input:not(:checked, :disabled, [data-indeterminate], [data-error]),
@@ -353,6 +357,23 @@ const CANOPY_STYLES = `
353
357
  outline: 2px solid var(--mantine-color-white);
354
358
  box-shadow: 0 0 0 4px var(--mantine-color-black);
355
359
  }
360
+ [data-nav-row] [data-row-lock] {
361
+ opacity: 0;
362
+ pointer-events: none;
363
+ transition: opacity 120ms ease;
364
+ }
365
+ [data-nav-row]:hover [data-row-lock],
366
+ [data-nav-row]:focus-within [data-row-lock],
367
+ [role='treeitem']:focus > [data-nav-row] [data-row-lock],
368
+ [data-nav-row][data-nav-selected] [data-row-lock] {
369
+ opacity: 1;
370
+ pointer-events: auto;
371
+ }
372
+ @media (prefers-reduced-motion: reduce) {
373
+ [data-nav-row] [data-row-lock] {
374
+ transition: none;
375
+ }
376
+ }
356
377
  [data-combobox-selected] {
357
378
  --mantine-primary-color-filled: var(--canopy-primary-fill);
358
379
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const CANOPYCMS_VERSION = "0.2.0-int.121";
1
+ export declare const CANOPYCMS_VERSION = "0.2.0";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/bump-version.mjs, its only writer. The package builds with plain
2
2
  // tsc (rootDir: src), so src/ cannot import ../package.json; version.test.ts keeps the two equal.
3
- export const CANOPYCMS_VERSION = '0.2.0-int.121';
3
+ export const CANOPYCMS_VERSION = '0.2.0';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "//": "@codemirror/language, @lezer/highlight: workaround — @mdxeditor/editor uses cm6-theme-basic-light which peer-requires these but mdxeditor doesn't declare them as dependencies",
3
3
  "name": "canopycms",
4
- "version": "0.2.0-int.121",
4
+ "version": "0.2.0",
5
5
  "description": "CanopyCMS core package: schema-driven content, branch-aware editing, and editor UI for Next.js.",
6
6
  "license": "MIT",
7
7
  "repository": {