smoodly 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +24 -1611
  2. package/dist/admin/drift.js +3 -2
  3. package/dist/admin/editor/SeoSettings.d.ts +7 -1
  4. package/dist/admin/editor/SeoSettings.js +2 -2
  5. package/dist/admin/field-label.d.ts +2 -0
  6. package/dist/admin/field-label.js +2 -0
  7. package/dist/admin/forms/FieldWidget.js +2 -2
  8. package/dist/admin/next/create-admin.d.ts +4 -4
  9. package/dist/admin/next/create-admin.js +5 -5
  10. package/dist/admin/next/index.d.ts +1 -1
  11. package/dist/admin/serialize.d.ts +8 -1
  12. package/dist/admin/serialize.js +23 -7
  13. package/dist/admin/shell/AdminApp.d.ts +3 -3
  14. package/dist/admin/shell/AdminApp.js +2 -2
  15. package/dist/admin/shell/EntryForm.js +8 -1
  16. package/dist/admin/shell/presence-realtime.d.ts +2 -2
  17. package/dist/cli/space-io.js +1 -1
  18. package/dist/collections.d.ts +4 -0
  19. package/dist/collections.js +9 -1
  20. package/dist/entry-page.d.ts +12 -10
  21. package/dist/entry-store.d.ts +30 -1
  22. package/dist/entry-store.js +54 -1
  23. package/dist/env.d.ts +5 -5
  24. package/dist/env.js +2 -2
  25. package/dist/fields.d.ts +13 -7
  26. package/dist/fields.js +2 -2
  27. package/dist/global.d.ts +4 -7
  28. package/dist/index.d.ts +10 -39
  29. package/dist/index.js +1 -1
  30. package/dist/migrations.js +1 -1
  31. package/dist/next/index.d.ts +1 -1
  32. package/dist/next/index.js +1 -1
  33. package/dist/next/meta.d.ts +6 -4
  34. package/dist/next/meta.js +14 -17
  35. package/dist/next/page-renderer.js +6 -3
  36. package/dist/next/queries.d.ts +10 -11
  37. package/dist/next/queries.js +7 -2
  38. package/dist/page.d.ts +5 -2
  39. package/dist/page.js +3 -1
  40. package/dist/pairing.d.ts +10 -10
  41. package/dist/path-index.d.ts +3 -0
  42. package/dist/path-index.js +7 -0
  43. package/dist/read-shapes.d.ts +64 -0
  44. package/dist/read-shapes.js +52 -0
  45. package/dist/render.d.ts +3 -3
  46. package/dist/resolve.d.ts +12 -0
  47. package/dist/resolve.js +29 -7
  48. package/dist/schema-version.d.ts +1 -1
  49. package/dist/schema-version.js +1 -1
  50. package/dist/schema.d.ts +22 -1
  51. package/dist/seo.d.ts +18 -0
  52. package/dist/seo.js +53 -0
  53. package/dist/site.d.ts +15 -16
  54. package/dist/site.js +64 -58
  55. package/dist/sql-space.d.ts +6 -5
  56. package/dist/sql-space.js +11 -24
  57. package/dist/sql.d.ts +6 -1
  58. package/dist/sql.js +60 -23
  59. package/dist/supabase-entry-store.d.ts +3 -1
  60. package/dist/supabase-entry-store.js +39 -0
  61. package/dist/supabase-path-index.d.ts +1 -0
  62. package/dist/supabase-path-index.js +16 -0
  63. package/migrations/20260930040956_smoodly_v7.sql +84 -0
  64. package/package.json +1 -1
package/README.md CHANGED
@@ -1,1623 +1,36 @@
1
- # smoodly (core package)
1
+ # smoodly
2
2
 
3
- Define a component once in code — it's instantly a typed, editable,
4
- AI-addressable building block your editors can compose, within the rails you
5
- set. Content lives in Supabase; the admin mounts into your own Next.js app.
3
+ A code-first CMS for Next.js. Define a component once in code and it
4
+ becomes a typed, editable building block your editors compose, within
5
+ the rails you set. Content lives in Supabase; the admin mounts into
6
+ your own app at `/admin`.
6
7
 
7
- npx create-smoodly-app my-site
8
-
9
- A self-hosted app needs three environment variables: `SMOODLY_URL`,
10
- `SMOODLY_SECRET_KEY` and `SMOODLY_PUBLISHABLE_KEY`.
11
- Source and docs: https://github.com/laniakea-studio/smoodly-cms
12
-
13
- The registration runtime — the real implementation of the API designed in
14
- Phase 0 (`sketches/phase0/` remains the readable spec; `docs/DESIGN.md`
15
- holds the decisions). Test-driven; run with `npm test`.
16
-
17
- Implemented:
18
-
19
- - `f.*` field builders — inert, immutable, JSON-serializable descriptors
20
- (ref thunks excepted); validation lives server/admin-side by design rule
21
- - `smoodly.schema.section/element` — descriptor capture + the
22
- fields-only-`localized()` rule enforced at construction
23
- - `smoodly.section/element(schema, View)` — the typed pairing: returns a
24
- real component carrying `.schema`; drift between schema and view is a
25
- compile error at the pairing; style select defaults apply in hard-coded
26
- JSX use; `Props<typeof schema>` infers required/optional/select types
27
- - `z.sections([...]).max(n)` / `z.freeform({ sections, custom? })` / `z.locked` — component
28
- references in, names stored; `custom: true` lets editors add a custom section there
29
- - `smoodly.toolset` — plain values, element refs serialized to names
30
- - `smoodly.collection` — descriptors + admin hints; ref thunks resolve
31
- post-evaluation and infer the target entry shape
32
- - `defineConfig` — registry name-uniqueness, the `styles` CSS values
33
- behind Smoodly's styles set (`spacing.sm/md/lg`, `width.narrow/wide/full`;
34
- package fallbacks fill the rest) and the `css: true` gate for the
35
- custom-CSS box (spec 2026-09-14)
36
- - `<smoodly.Section>` — the root wrapper every section renders through:
37
- `as`, Smoodly's `styles` steps rendered INLINE (`padding-top`,
38
- `padding-bottom`, `text-align`, `--smd-width`; Default renders nothing),
39
- the node's scoped `<style>` child (`[data-smd-node="…"]{…}`),
40
- `data-smd-node` always, every other prop spread onto the root; settings
41
- are never turned into attributes — the view writes its own
42
- - Four namespaces on a node (spec 2026-09-14, plan A): `fields`
43
- (content), `settings` (the developer's knobs — any builder, never
44
- localized, interpreted by the view; `meta` is gone), `styles`
45
- (Smoodly's set: `spacingTop`, `spacingBottom`, `width`, `align`, each
46
- an optional radio — `styles: false | { omit }` on a schema opts out),
47
- `css` (the snippet; `css: false` on a schema removes the box).
48
- `styles.ts` holds the descriptors and `inlineStyles`; `css.ts` refuses
49
- `@import`, `url(`, `expression(`, `behavior:`, `</`, more than 4000
50
- characters and unbalanced braces — on the escape-decoded snippet too —
51
- and `safeCss`/`scopedCss` strip and scope at render. Publish validates
52
- settings and css (`validateNode`); saves stay lenient.
53
- - Conditional fields (spec 2026-09-14 §12): every builder takes
54
- `.hidden(f.when(path).is(v))` (`isNot`, `in`, `isEmpty`, `isNotEmpty`);
55
- a bare path is a sibling, `fields.`/`settings.` crosses namespaces, an
56
- unknown path throws at registration (`assertConditions`). One
57
- `isHidden` in `conditions.ts` drives the form and the validator; a
58
- hidden field's stored value is kept.
59
- - The custom section (spec 2026-09-14 §6, plan B, 2026-09-15): the
60
- editor's own block, `Custom section` at the bottom of the "+" picker in
61
- a `z.freeform({ custom: true })` zone. One flat node `{ type: "custom",
62
- fields: { rows: [{ spans, gap, align, reverse, columns: [richtext…] }] },
63
- styles, css? }` — the shape is ordinary descriptors (`custom/schema.ts`,
64
- the list carries `widget: "rows"`), so `descriptorAt`, the media walk,
65
- the validator and inline editing understand it with no special case.
66
- `custom/rows.ts` is the pure reconcile: `renormalize` (integers ≥ 1
67
- summing to 12, largest remainder), `setColumnCount` (a new column takes
68
- the last span; a removed column folds into the last survivor, blank
69
- paragraphs dropped — never silent deletion), `setSpan`, `spanAtX`,
70
- `presetsFor`, `rowsProblems` (`Spans must sum to 12.`, `Between 1 and 6
71
- columns.`, `One span per column.`), `columnsLabel`. `custom/css.ts`
72
- emits the scoped layout CSS from the stored numbers and whitelisted
73
- keywords only — one grid per row by `data-row`, gap `1rem · 2rem ·
74
- 3rem`, one `@media (max-width: <breakpoint>)` that stacks every row
75
- (`.smd-row--reverse` flips the stack); `createCustomSection` renders
76
- through `<smoodly.Section>` with `data-custom`, `.smd-row` /
77
- `.smd-col` marked `rows.<i>` / `columns.<j>`, richtext through the
78
- project's bound `RichText` or the root renderer over `elements`, the
79
- layout `<style>` before the editor's css so the box wins.
80
- `config.custom: { breakpoint?, toolset?, RichText? }` (default `48rem`
81
- and the richtext default toolset plus `image`; the breakpoint must be a
82
- length) resolves onto `config.custom` / `site.custom`; `renderPage`
83
- registers the renderer under the `custom` type; the resolver and both
84
- page stores carry the custom schema (`withCustomSchema`,
85
- `PageStoreOptions.custom`) so column images resolve and count as usage;
86
- publish runs `validateCustomNode` (structure through `rowsProblems`,
87
- the columns' richtext, the css). In the admin: `AdminRegistry.custom`
88
- (one synthetic section), `admin/custom-section.ts`, the picker entry
89
- `Custom section · Your own rows of columns`, `RowsWidget` (a card per
90
- row: `Columns` stepper, `Widths` bar with `1/2 · 1/2`-style presets,
91
- `Gap`, `Vertical align`, `Reverse on mobile`, `Column N` editors,
92
- `+ Add row`) over `SpanBar` (pointer drag in twelfths, arrow keys),
93
- `Custom section · N columns` labels, deep-copy on duplicate.
94
-
95
- - `smoodly.schema.page` / `smoodly.page` / `<Zone>` / `renderPage` — the
96
- pages runtime: policies normalized to plain data, tree nodes mapped to
97
- registered components, fail-soft on unknown types
98
- - `collectionSQL` / `coreTablesSQL` — the stable schema (DESIGN.md §3):
99
- `coreTablesSQL` emits the once-ever core tables including `entries`,
100
- `entry_locales` and `entry_versions` (shared fields on the node,
101
- localized fields, slug and status per locale row, merged snapshots
102
- per locale for versioned collections; `space_id` multi-tenancy with
103
- a default space for self-hosted, `sort` for manual ordering, and no
104
- sibling-slug index at all — sibling uniqueness is the primary key of
105
- `paths` plus a pre-check the stores make per locale, for entries and
106
- pages alike);
107
- `collectionSQL` emits only the disposable per-collection guardrails —
108
- a published-only read view joining `entries` and `entry_locales` (one
109
- row per published locale, a `locale` column; a versioned collection
110
- reads the published snapshot; typed casts, snake_case aliases, refs as
111
- plain id values) and partial btree indexes for the declared `order.by`
112
- field, on the jsonb VALUE (`("fields"->'x')`)
113
- - `PageStore` contract + `MemoryPageStore` — id-keyed page persistence
114
- over pages/page_locales/page_versions/paths — one node, one row per
115
- locale, each locale with its own tree, draft, publish and history
116
- (spec 2026-09-06). Every read and write takes the record's `id`, and
117
- the URL is derived from the tree, never stored on the record. Pages
118
- form a tree (`parentId`, sibling `sort`, a null `template` = folder,
119
- `pages.tree.depth` capping how deep editors may nest), and expose
120
- `rename` (a locale's slug/title), `move`, `setTemplate`, `addLocale`,
121
- `removeLocale`, `resolvePath(locale, path)` and `pathsOf(id)` alongside
122
- the draft/publish semantics (one version row per publish plus the live
123
- draft, rewritten in place; publish moves that locale's pointer and
124
- freezes the row; discard deletes the abandoned draft; `restore` writes
125
- an old version as the draft; drafts never leak into published reads). The contract
126
- is a reusable suite (`test/page-store-contract.ts`); every adapter runs
127
- the same tests.
128
- - `SupabasePageStore` — the same id-keyed contract over
129
- pages/page_locales/page_versions/paths (a server-side client from
130
- `createSmoodlyClient`: the service role in self-host, a write key in
131
- the cloud). Contract-tested against a real local stack: `supabase
132
- start` at the repo root (the generated DDL is its one migration), then
133
- `npm run test:supabase`; plain `npm test` skips it and never needs
134
- Docker.
135
- - `paths.ts` — the ONE place a URL is derived: pure, framework-free
136
- functions (`segmentFor` — a locale's own segment, no fallback —
137
- `chainOf`, `pagePath`, `pagePathIn` (nullable, for the admin),
138
- `pagePathRows`, `entryPathRows`, `entrySegment` (a locale's own slug,
139
- no fallback), `assertSupportedLocale` (both stores), `buildPageTree`,
140
- segment and depth assertions) that both adapters and the tree query call, so the index
141
- and every derived `path` agree by construction. `pagePath` is the
142
- single page-path derivation — `pagePathRows`, `buildPageTree` and the
143
- site layer all go through it.
144
- - `PathIndex` — the derived URL index, `MemoryPathIndex` and
145
- `SupabasePathIndex` over the `paths` table ((space, locale, path) → page
146
- or entry). Pages and entries share ONE instance, so a page and an entry
147
- can never claim the same URL; the Supabase adapter rewrites a whole
148
- subtree in one statement through the `smoodly_rewrite_paths` SQL
149
- function, and a collision surfaces as "the path … is already taken".
150
- - Collections declare their own URL shape: `path` (the code-owned base
151
- segment, per locale — absent = the collection has no URLs), `tree`
152
- (entries nest under entries up to a depth), and `order` (`"manual"` or
153
- `{ by, direction }`, replacing `admin.orderBy` and driving both the
154
- store's list order and the generated index). A declared field orders by
155
- its jsonb VALUE, so numbers sort numerically and strings — ISO dates
156
- included — alphabetically, the same in Supabase as in memory.
157
- - `smoodly.entryPage(collection, View)` — a paired component registered
158
- like a page (`kind: "entryPage"`, name `entry:<collection>`), served for
159
- every entry of the collection by the catch-all through
160
- `renderSmoodlyPath`.
161
- - `resolveTree` — the batched ref-resolution pass: one fetch per
162
- collection per round, ref-site depth modes (bare ref = entry only,
163
- `.resolve(names)` = named refs one level, bare `.resolve()` = whole
164
- chain), per-path cycle cutting with shallow copies, optional `maxDepth`
165
- safety valve (default unlimited)
166
- - `resolveFields` — the same pass over ONE entry's fields against its
167
- collection's descriptors, for the entry-page route: the shared task
168
- collection and batched rounds are factored out, so a ref site behaves
169
- identically whether it sits in a page tree or in an entry.
170
- - `localize.ts` — `fixedPathFor` (the path a fixed page registration
171
- is served at in one locale — the escape hatch's addressing; a slug map
172
- that omits a locale means "the same segment", since a registration is
173
- code, not a record). Pages themselves have no fallback: title and slug
174
- live on `page_locales`, and slugs stay `paths.ts`'s business.
175
-
176
- - `collectEntryRefs` / `collectTreeRefs` — the refs-index feeders: walk
177
- an entry or a page tree against its schemas and list every outgoing
178
- reference edge (derived, rebuildable, never the source of truth)
179
- - Page saves feed the refs index — a page's rows are the UNION of its
180
- draft and published trees' edges (source kind `page`), rewritten on
181
- every `saveDraft`/`publish`, so cross-kind safe-delete holds while
182
- either tree shows an entry. Publish integrity: `publish` walks the
183
- draft tree directly and blocks on missing/unpublished entries.
184
- Revalidation fan-out: `affectedTargets` — reverse BFS over refs
185
- (entry ← entry ← page, cycle-safe, optional `maxDepth`) returning
186
- `{ pageIds, entryIds }`: every PUBLISHED page whose tree reaches the
187
- changed entry, and the entry itself plus every entry that references it.
188
- Ids, not slugs — `pageTag(id)`/`entryTag(id)` name the cache tags, and
189
- the op handler's `revalidate` effect passes each to Next's `updateTag`,
190
- so a rename never orphans a tag. All wired via
191
- store constructor options (`sections`, `entries`, shared
192
- `MemoryRefIndex` in memory); the cross-store contract
193
- (`test/page-refs-contract.ts`) runs against memory AND Supabase.
194
- - Media (spec 2026-09-08): `f.image({ aspect? })` / `f.video()` / `f.file()`
195
- store `{ asset, alt?, crop?, hotspot?, aspect? }`; `AssetStore` (memory +
196
- `SupabaseAssetStore`: rows in `assets`, bytes in the public `media`
197
- bucket, two-op signed uploads); the refs index carries `asset` edges
198
- through lists, objects and styles, so delete is guarded and usage is
199
- listed; `resolveTree`/`resolveFields`/the site layer resolve media to
200
- `{ url, width, height, mime, alt, crop?, hotspot?, aspect? }` with one
201
- fetch per page; `smoodly/image` ships `<SmoodlyImage>` (a box at the
202
- aspect, the image framed by crop and hotspot over `next/image`),
203
- `<SmoodlyVideo>`, `imageUrl` behind the loader seam (v1: the Next
204
- loader only) and `smoodlyImages()` for next.config's `images`. Admin: the media
205
- widget in every form, the library picker, the crop-and-hotspot editor,
206
- the Media screen with metadata, usage links and guarded delete.
207
- - `EntryStore` contract + `MemoryEntryStore` + `SupabaseEntryStore` —
208
- collection-entry persistence over entries/entry_locales/entry_versions/paths
209
- — one node, one row per locale, each locale with its own slug, status
210
- and `.localized()` fields, shared fields on the node, and a per-locale
211
- version history for every collection (spec 2026-09-14; the 2026-09-06
212
- opt-in is gone): `create({ locale })`, `update(id, locale, fields)`,
213
- `setStatus(id, locale, status)`, `addLocale`, `removeLocale`,
214
- `listVersions`, `getVersion` and `restore`; the draft row is rewritten
215
- in place until published (spec 2026-09-13 history); saves rewrite the entry's refs rows over every locale's
216
- live field set, `referencesTo` answers the reverse
217
- question, `getMany` is the batched read whose signature is
218
- `resolveTree`'s `EntryFetcher`, now `(collection, ids, locale, { status })`,
219
- the published read of a versioned collection being the snapshot
220
- (with `{ status: "published" }` for the
221
- published-route read — a post-publish demotion resolves as missing
222
- instead of leaking draft fields — DESIGN.md §3 "Page edges in refs"), deletes are blocked while
223
- referenced,
224
- entry slugs are unique among SIBLINGS per locale in both adapters
225
- (a code pre-check; the `paths` primary key is the invariant),
226
- and `reorder` rewrites sort 1..N through the `smoodly_reorder` SQL
227
- function (one statement, `updated_at` untouched). Same
228
- reusable-contract pattern as PageStore; `npm run test:supabase` runs
229
- both adapters against the local stack
230
-
231
- - Proven end-to-end in `examples/site` — a real Next.js app wiring the
232
- config + Supabase stores into routes: tag-cached resolved trees,
233
- draft-mode preview, server-action writes with revalidation fan-out.
234
- The example is the multilingual layout (next-intl, `en`/`fi`, the site
235
- under `app/[locale]/`, the admin outside it), and `create-smoodly-app`
236
- generates both of its templates from it — `templates/next-intl`
237
- verbatim, `templates/next` with the four single-language route files
238
- from `variants/single/` and two rewritten lines of glue
239
-
240
- - The space layer (spec 2026-09-04 §3): `space_id` on every content
241
- table, `smoodly_current_space()`, the insert trigger, the row cap, the
242
- three cloud-state tables (`members`, `space_keys`, `spaces`) and
243
- the policy set. Service role bypasses it; a write key is scoped to its
244
- space. Contract suites run in both modes; `test/isolation.supabase.test.ts`
245
- proves isolation. Generated per-collection views are `security_invoker`,
246
- so they read through the same policy set rather than their owner's
247
- privileges. Live acceptance test in `test/rls.supabase.test.ts`. Note
248
- for self-host: the anon key now reads published rows straight off the
249
- base tables (`pages` and `entries` published in any locale, a published
250
- `page_locales`/`entry_locales` row, the `page_versions`/`entry_versions`
251
- row a published locale points at — shared content included, since it
252
- is stored as entries, spec 2026-09-07), not only through the generated
253
- views.
254
-
255
- - Admin login: `supabaseAdminAuth` (from `smoodly/admin`) + `gateAdminOp` around the ops seam;
256
- `LoginView` + `useAdminSession` in the shell; `createSmoodlyAdmin({ auth })`.
257
- Env: `smoodlyEnv()` / `createSmoodlyClient()`.
258
-
259
- - The admin, real and mounted: `smoodly/admin` (the AdminOps seam —
260
- `createAdminOps`/`runAdminOp` server-side over the stores,
261
- `makeClientOps` client-side forwarding `{ path, args }` through one
262
- server action; typed `OpResult`, never throws — `serializeAdminConfig`
263
- turns the registry into the admin's nav/forms; `validateFields` +
264
- tree-ops for pure canvas mutations), `smoodly/admin/next`
265
- (`createSmoodlyAdmin` binds registry + op action into `AdminPage`/
266
- `AdminLayout` for the app's `[[...segments]]` route group;
267
- `createAdminOpHandler` is the one server action the client ops call),
268
- and `EditorBridge` (never on a live page: the renderer loads it lazily
269
- through `next/canvas-slot.tsx` in editor mode only, spec 2026-09-29
270
- pre-install fixes §1 — runs inside the draft-route iframe, reports node, zone and
271
- marked-field geometry, forwards select/hover with the field under the
272
- pointer, executes refresh/scroll, reports each committed render). Shell
273
- (registry-derived nav, list views, its own client-side router —
274
- `shell/router.ts`, `RouteLink`, a tab-close guard for pending saves; the
275
- shell mounts from the layout and the catch-all page only makes the
276
- URL exist, spec 2026-09-08),
277
- entry form (widgets by field type, validation errors surfaced inline,
278
- save/publish/unpublish/delete with the safe-delete guard's message
279
- shown verbatim), and the editor view (dark instrument around a bright
280
- canvas — the iframe is the site's own draft route, pixel-identical by
281
- construction; every gesture mutates client tree state through pure
282
- ops, a debounced `saveDraft` persists, and the bridge refreshes the
283
- iframe on the save ack — refresh-on-change preview for structure; text
284
- and richtext are edited in place in the canvas and inspector text edits
285
- land there the same tick, spec 2026-09-10) are all real, in-house. The autosave itself is a framework-free
286
- controller (`createDraftAutosave`: debounce, doubling capped retry,
287
- pre-publish `flush`) wrapped by `useDraftAutosave`; the controller is
288
- unit-tested with fake timers, the hook only for its initial snapshot. Proven end-to-end in
289
- `examples/site/app/(smoodly)/admin` against the local Supabase stack —
290
- see its README's acceptance walk.
291
-
292
- - The admin is the page TREE (spec 2026-09-05 §7): the ops seam addresses
293
- pages by id — `pages.list`/`get`/`create`/`saveDraft`/`publish`/
294
- `delete`/`rename`/`move`/`setTemplate`, plus `entries.move`.
295
- `entries.get`/`create`/`save`/`setStatus` take a locale;
296
- `entries.addLocale`/`removeLocale`.
297
- `pages.list` materializes the code-owned root nodes before an editor
298
- touches them (`admin/fixed-nodes.ts` derives fixed pages and collection
299
- mounts from the registry and finds their records by the `pages.fixed`
300
- owner key, schema v5), and every guard asks
301
- the same `fixedNodeOf`: a fixed node is never renamed, moved or
302
- deleted, and no page is created under a mount, and a `homePageSlug`
303
- guard keeps the site root from being deleted, moved or re-slugged
304
- even without a fixed registration. `pages.get` returns the
305
- record, its draft, `paths` (locale → CMS path) and `urls` (`href`
306
- applied), so the canvas and "View live" get site URLs. A tree write
307
- expires the neighbours whose cached units embed it: publish and delete
308
- the record and its parent, rename the subtree and its parent, move the
309
- subtree plus the old and the new parent; `entries.move` expires the
310
- entry and its descendants. The Pages list IS that tree — `admin/shell/pages-tree.ts`
311
- is the pure view model (indent per depth, chevron on parents, the
312
- derived path as the URL column, and per row its kind, status, sibling
313
- position and whether it may take children), rendered by
314
- `admin/shell/PagesList.tsx` with a row menu over the tree ops (New
315
- subpage, New subpath, Add page here, Rename…, Delete — reordering is
316
- the grip's: drag or its arrow keys, since 2026-09-15); a mount a fixed
317
- page claims opens that index page's editor
318
- on click like any page row (2026-09-09), a bare mount opens the
319
- collection list. The editor
320
- is keyed by id, with a locale switcher loading that locale's own tree
321
- and pointing the canvas at `urls[locale]` and, while no block is
322
- selected, page settings (`admin/editor/PageInspector.tsx`, spec
323
- 2026-09-10 page fields: **SEO & Social** — title, description, social
324
- image, hide from search engines, under the tree's `meta` — and
325
- **Settings** — the ACTIVE locale's title and slug through `pages.rename`,
326
- the template's page fields under the tree's `fields`, remove from
327
- locale). The entry form prefixes its slug field with the collection's
328
- mount path. The serialized
329
- registry carries `collections[].path`/`depth`, `pages[].slugs` and
330
- `pageDepth`, and `defineConfig` validates `homePageSlug` — a real
331
- segment, and never a collection's mount.
332
-
333
- - `createSmoodlySite` — the site layer (`site.ts`), framework-free: one
334
- place turns a (locale, path) into a loaded page or entry, so the Next
335
- renderer and the content API can never disagree about published-only
336
- reads, folders or fallback. `locate(locale, path)` is one primary-key
337
- hit on the `paths` index; `load(target, locale, path, { draft? })`
338
- fetches the record and its tree (draft or published), resolves refs,
339
- reads the locale's own rows, and returns a `SitePage` — `record`,
340
- `template`, `tree`, localized `title`, `path`, `ancestors`, `children`,
341
- `locale` and `locales` — the page's `{ slug, path }` in every supported
342
- locale, null where it is absent or, outside draft mode, unpublished
343
- (spec 2026-09-15) — or a `SiteEntry` with the locale's merged fields (a
344
- versioned collection's published snapshot on the public path) resolved,
345
- `locale`, and the same `locales` map (an entry's slug and path are null
346
- where its row claims no URL). `getEntries` items and `getEntry` carry
347
- `locale` and `locales` too.
348
- `resolve(locale, path, { draft? })`
349
- is the two in sequence — `locate` then `load` — for a caller that just
350
- wants the hit. A folder (null template), an
351
- unpublished record outside draft mode, or a missing one is `null`.
352
- On top of it the content API for menus, sitemaps and custom routes,
353
- published-only unless `draft: true` (spec 2026-09-11):
354
- `getPagesTree({ locale, draft? })` (nested
355
- `{ id, title, path, hasPage, fields, children }`), `getPage(pathOrId)`,
356
- `getEntries(collection, { locale, parent?, order?, where?, limit?, draft? })`
357
- — `where` is equality / any-of on shared fields and `limit` a SQL limit,
358
- both run by the store — `getEntry(collection, idOrPath)` (an id, a
359
- path, or a bare slug naming a root entry) and `getEntriesTree(collection)`.
360
- In the app, read through `q` (next bullet) rather than the site layer.
361
- - `createSmoodlyQueries` (`smoodly/next`, spec 2026-09-11) — the read
362
- API the scaffold exports as `q`: `getPageTree({ locale })`,
363
- `getPage(pathOrId)`, `getEntries("articles", { where, order, limit,
364
- parent })`, `getEntry("articles", idOrPath)` (an id or a path — a bare
365
- slug is refused, since its unit would sit under a tag no op fires) and
366
- `getGlobal("header")`. Typed by the registry (names are checked, fields
367
- typed), the live draft inside the editor preview, and outside it one
368
- `unstable_cache` unit per distinct call under a tag the admin ops
369
- expire: `pages:tree` (every page op that changes the listing),
370
- `entries:<collection>` (every entry write), `page:<id>`, `entry:<id>`,
371
- `global:<name>`. `filterPageTree(items, keep)` prunes a tree for a nav
372
- (a dropped parent drops its subtree).
373
- - `smoodly/next` — `createPageRenderer`, the site-route seam over that
374
- layer, bound once by the app like `createAdminOpHandler`. The two route
375
- files call `renderSmoodlyPath(segments, { locale?, searchParams? })` and
376
- `smoodlyMetadata(segments, { locale? })`: a page at any depth in any
377
- locale rendered by the shape its `template` names, with the `page` prop
378
- (`{ id, title, path, url, ancestors, children }`, every ancestor and
379
- child carrying `url` beside its locale-relative `path`, both put through
380
- the `href` seam) beside `zones`; a collection
381
- entry rendered by its `smoodly.entryPage` as `{ entry, path, locale, locales }`; a folder,
382
- an absent locale or an unregistered template a 404. The published read is
383
- cached per (locale, path) and tagged `page:<id>` / `entry:<id>` — the
384
- `locate` hit runs outside the cache, because the tag needs the id first.
385
- Draft mode reads drafts uncached, and the editor param mounts
386
- `EditorBridge`. Metadata is the tree's `meta` plus
387
- `alternates.languages`, the locales with a URL in the hit's `locales` map
388
- through the injectable `href(path, locale)`
389
- seam (identity by default, `getPathname` with next-intl) and emitted only
390
- for a multi-locale site. `renderSmoodlyPage(Paired, …)` and
391
- `smoodlyPageMetadata` remain as the escape hatch for a FIXED page
392
- rendered from the developer's own route file; each serves only its own
393
- registration's record. All four await Next's
394
- `connection()` before reading the stores, so a route with no dynamic
395
- segment is request-rendered without a `force-dynamic` export and
396
- `next build` never reaches the database
397
- (`test/next-page-renderer.test.tsx`). Page schemas may declare a fixed `slug`
398
- (owned by code, not by editors); the admin reads it to filter
399
- New Page and protect the record. `defineConfig({ homePageSlug })`
400
- (default `"home"`) names the slug the site root serves; the paths index
401
- derives every URL from it, and `pages.get(id)` hands the admin the
402
- finished `paths` (locale → CMS path) and `urls` (`href` applied), so the
403
- admin no longer derives a path of its own.
404
- - `smoodly/image` — the site's media components: `<SmoodlyImage>`,
405
- `<SmoodlyVideo>`, `imageUrl(image, { width, quality? }, loader?)`,
406
- `frameFor`/`boxAspectOf` (the crop math). Server-safe, no `"use client"`.
407
- - `smoodly/image/config` — `smoodlyImages()` for `next.config`'s `images`:
408
- the Supabase host as a remote pattern, plus `dangerouslyAllowLocalIP`
409
- when that host is loopback or private — Next 16's optimizer refuses a
410
- private upstream otherwise, and the local stack is one. Its own entry
411
- because Next loads `next.config.ts` in plain Node, where anything that
412
- reaches `next/image` fails to resolve (next@16 has no `exports` map);
413
- `smoodly/image` still re-exports the helper for code the bundler sees.
414
- - `smoodly/richtext` — the bound richtext renderer, `createRichText({
415
- elements, sizes })`: the root `RichText` with the project's elements and
416
- body images through `<SmoodlyImage>`. Its own entry for the same reason
417
- as `smoodly/image`: it reaches `next/image`.
418
-
419
- - Locked zones are usable: `fillLockedZones` (a pure tree op) materializes
420
- the one node of every empty locked zone from the component's `sample`
421
- when the editor loads a draft, and the change rides the normal debounced
422
- save. No gesture can insert into or remove from a locked zone, so this is
423
- the only way the node gets there — it also covers pages that existed
424
- before a locked zone was added to their schema.
425
-
426
- - Global content (spec 2026-09-07; `shared` → `global` in code
427
- 2026-09-15, spec 2026-09-14 §7): `smoodly.global({ name, title, section })`
428
- registers a visual item, `smoodly.global({ name, title, fields })` an
429
- object item; one registration materializes as a singleton entry in
430
- every supported locale. `site.getGlobal(item, { locale })` and the Next
431
- glue's `q.getGlobal("footer", { locale })` fetch it code-side (the
432
- renderer's `getSmoodlyGlobal(item, { locale })` still works); the
433
- editor places a visual item in a zone from the "+" picker as a linked
434
- `{ type: "global", fields: { item, ref } }` node the resolve pass
435
- rewrites into the section, and `z.locked(footer)` binds a zone to one.
436
- Edited on its own admin page under Globals (`/admin/globals/<name>`),
437
- with "used on N pages" from `refs`. Wired through the `globals` option
438
- on the entry store and the site layer; a visual item's settings, styles
439
- and css ride its row under `$settings`, `$styles` and `$css`.
440
-
441
- - Lists and editable objects (spec 2026-09-07 list field): `f.list(item)`
442
- holds any builder but another list and refuses a ref or `.localized()`
443
- anywhere inside (refs are top-level only; localization is whole-value on
444
- a list or object). `.min`/`.max` count items. The admin edits an object
445
- as an indented fieldset and a list as rows — summary, collapse, move up
446
- and down, remove, "N of max", Add disabled at max — recursively through
447
- `FieldWidget`, with the row logic as pure functions in `admin/forms/list.ts`.
448
- `validateFields` recurses with dotted paths (`points.2.heading`) and
449
- checks list length; the serializer ships a list's `item`.
450
-
451
- - Richtext, both directions: `RichText` (package root, pure React, no
452
- wrapper) turns the TipTap document into paragraphs, headings, lists,
453
- blockquotes, hard breaks and bold/italic/link marks, unknown nodes
454
- degrading to their children; a link mark reaches the page only with a
455
- safe scheme (http(s), mailto, tel, site-relative). The admin edits it
456
- with a TipTap widget under a fixed toolbar (`admin/forms/RichtextWidget.tsx`,
457
- spec 2026-09-08): the schema is always the full one, and the field's
458
- toolset — typed names, `DEFAULT_TOOLSET` when a field declares none —
459
- gates only creation (toolbar, shortcuts, input rules, paste), so content
460
- a toolset forbids survives every round trip. Links carry `href` only. An
461
- empty document is missing for a required field. The widget emits plain
462
- JSON: ProseMirror's node attrs have a null prototype, which a server
463
- action cannot serialize. Block nodes (spec 2026-09-08 block nodes): an
464
- `image` node (media library, caption, alt override) and one generic
465
- `element` node for every registered Element, always in the schema,
466
- inserted through the toolbar's "+" or a `/` menu, edited as cards (the
467
- element card renders its fields through `FieldWidget`, nested richtext
468
- included). `RichText` takes `elements` and an `image` render prop;
469
- `smoodly/richtext` exports `createRichText` bound over `<SmoodlyImage>`.
470
- The media and refs walks descend into documents against the element
471
- schemas (`elements` beside `sections` in the store, resolve and site
472
- options).
473
- - The token guard and presence (spec 2026-09-26 concurrency): every
474
- draft write carries `{ versionId, savedAt }` from the locale row's
475
- `draftSavedAt` and is refused as `conflict` + `stale` when the draft
476
- moved (the write itself is conditional in Supabase); the admin freezes
477
- under a notice naming who saved and when and reloads through "Load
478
- their version"; one private Realtime channel per space shows who edits
479
- what (a lock in the lists, a line under the top bar) and announces
480
- saves so a clean view refreshes and a dirty one freezes early. Schema
481
- version 2 adds the draft-pointer foreign keys and the channel policies.
482
- Only the editor's own edits freeze a view (2026-09-27): two editors
483
- opening a fresh page at once both fill its locked hero, and the fill
484
- that lands second used to freeze its view under "Your unsaved changes
485
- here will be discarded" with nothing changed; now that view loads the
486
- other's quietly, on the refusal or the `saved` broadcast. This was the
487
- local-only timeout of "the guard alone" (CI's slower sign-in let the
488
- first fill land first). Tests: `concurrency.spec.ts` ("two editors
489
- opening a new page at once", with the channel cut and on; the fill
490
- save is held so the race is deterministic).
491
- - ActionMenu near the screen's edge (2026-09-27): a row menu close to
492
- the bottom opened below the viewport, where a fixed element cannot be
493
- scrolled to, and the scroll event from bringing a row into view
494
- arrived a frame after the click and closed the menu it had opened.
495
- It now opens upward by the Combobox's `opensUp`, and closes only on a
496
- scroll that moved its button. This was the Members test's flake (about
497
- 1 in 8 runs; the list was long because every concurrency run left
498
- its second member behind — `concurrency.spec.ts` removes it in
499
- `afterAll` since 2026-09-28, and `members.spec.ts` its invited Auth
500
- user, which Remove member leaves in place). Tests: `admin-action-menu`, `members.spec.ts` (a
501
- late scroll event, a real move, a row at the bottom of the screen).
502
- - The security pass over the database boundary (spec 2026-09-26 security
503
- pass): the presence channel admits a signed-in member of the topic's
504
- space (`smoodly_presence_member()`, the socket carries the session
505
- token through the client's `accessToken` callback, re-sent on refresh);
506
- every function pins `search_path`; the three mutation RPCs are revoked
507
- from `anon`/`public`. Schema version 3. The threat table, one test per
508
- cell: content, `refs`/`members`, `spaces`/`smoodly_meta` and storage
509
- columns — `test/isolation.supabase.test.ts` ("space isolation", "read
510
- keys", "cloud state rows") and `test/rls.supabase.test.ts`; presence
511
- and RPC columns — `isolation.supabase.test.ts` ("signed-in users and
512
- the public keys"); admin ops — `test/admin-auth.test.ts`,
513
- `test/admin-auth.supabase.test.ts`, `test/admin-ops.test.ts` ("members
514
- ops").
515
- - Redirects (spec 2026-09-26 redirects): a `paths` row with `redirect`
516
- set is an old address of its target (schema version 4). A published
517
- rename or move keeps the old addresses as redirects unless the editor
518
- unticks "Redirect the old address" on the live-URL confirm; the live
519
- URL wins an address; nothing chains; `renderSmoodlyPath` answers a
520
- redirect row with `permanentRedirect` through `href`. Settings ›
521
- Redirects (every member) lists, adds by hand (validated old address,
522
- target type-ahead) and removes. Tests: `test/path-index-contract.ts`
523
- (the rule table, both adapters), the store contracts, `admin-ops`
524
- ("redirects on rename and move", "redirects ops"),
525
- `next-page-renderer` ("redirects"), `examples/site/e2e/redirects.spec.ts`.
526
- - Editor safety (spec 2026-09-27 editor safety): schema drift — stored
527
- content the code no longer describes — is found by one pure walk
528
- (`admin/drift.ts`) over the serialized registry. Broken findings
529
- (an unknown section, element, page type or collection; a value that
530
- doesn't fit its field; a zone rule broken) refuse publish for pages,
531
- entries and global items; left-over ones (a removed field or zone, an
532
- element outside its toolset, a localization change) never do. The
533
- validator's one type check is `fits` (text and number checked for the
534
- first time). Settings › Content health (every member) reports every
535
- document, draft and live, grouped by the change; the editors mark the
536
- open document (notice, Outline marks, a canvas placeholder, the
537
- unknown-section inspector with Remove section, misfits as field
538
- errors, a "No longer in the schema" group with Copy and Clear, Clear
539
- zone). Turning `.localized()` on no longer deletes the other locales'
540
- value (update, discard and restore keep a localized key's shared
541
- value); the last `window.alert`s are `notify()`. No bulk writes
542
- (OQ 35). Tests: `admin-drift`, `admin-drift-copy`, `admin-health`,
543
- `admin-health-list`, `admin-health-page`, `admin-drift-markers`,
544
- `admin-unknown-node`, the store contracts (`scanTrees`,
545
- `scanEntries`, the pinning tests), `entry-store.supabase` (the
546
- localized fix across two schemas), `examples/site/e2e/health.spec.ts`.
547
- - Shadowed-page detector (spec 2026-09-27 shadowed-page detector): a
548
- canvas whose bridge never speaks within 4 s of the frame's load is
549
- diagnosed — the editor fetches the canvas URL once and
550
- `admin/editor/canvas-diagnosis.ts` names another route, a route file
551
- that drops `searchParams`, a crash, a 404, a redirect, a refusal, a
552
- framing header or a script error, as an editor sentence and a "For
553
- your developer" line (`editor/CanvasWarning.tsx`, in place of
554
- "Selection unavailable"). The renderer writes
555
- `<meta name="smoodly-draft">` in draft mode only. No reserved-path
556
- list (OQ 23 closed). Tests: `admin-canvas-diagnosis`,
557
- `admin-canvas-warning`, `next-page-renderer` (the marker),
558
- `admin-bridge`, `examples/site/e2e/editor.spec.ts`.
559
- - cacheComponents unsupported (spec 2026-09-27 cache components): under
560
- Next's Cache Components the catch-all is served from a fallback shell
561
- that commits 200, so 404s and 308s are lost; the renderer warns once
562
- per renderer when `process.env.__NEXT_CACHE_COMPONENTS` is on, and the
563
- Next.js guide says why. OQ 19 closed. Tests: `next-page-renderer`
564
- ("cacheComponents").
565
- - Section guard (spec 2026-09-27 section guard): `Zone` calls a
566
- plain-function section view inside try/catch (an async one through
567
- `SectionGuard`, in place), so a throw in a section's own code leaves it
568
- out and the page renders — nothing live, a placeholder in the canvas
569
- and under `next dev`; the adapter's `rethrow` (Next: `unstable_rethrow`)
570
- lets control flow through. In editor mode the Next adapter also wraps
571
- each section in `<Suspense>` + the client `CanvasBoundary`, the bridge
572
- reports crashed sections, the page editor lists them, and Publish asks
573
- first. A healthy page's HTML is unchanged. Tests: `section-crash`,
574
- `render` ("the section guard"), `next-canvas-boundary`,
575
- `next-page-renderer`, `admin-crash-copy`, `admin-canvas-diagnosis`,
576
- `examples/site/e2e/sections.spec.ts`.
577
- - No admin on the live site (2026-09-27): `supabaseAdminAuth` moved from
578
- `smoodly/admin/next` to `smoodly/admin` (its `AuthConfig` type too).
579
- `smoodly/server.ts`, which every site route imports, took it from the
580
- `admin/next` barrel beside `createSmoodlyAdmin`, so the admin shell was
581
- a client module of every site route. Confirmed by removing the import
582
- and rebuilding; the starter's home page, production build, went from
583
- 1,616,602 to 628,849 bytes of JavaScript (8 chunks either way, the
584
- 1,050,601-byte chunk holding `AdminApp` gone). The rest of the page's
585
- JavaScript is the site's own: of a 62,848-byte chunk, next-intl is
586
- ~34 KB, `next/link` and `next/image` most of the rest, and the
587
- editor-only modules ~3.4 KB (`EditorBridge` ~2.5 KB, the canvas net
588
- ~0.9 KB) — too little to lazy-load. Tests: `site-entries` (every entry
589
- but `smoodly/admin/next` reaches no client module except those two),
590
- `examples/site/e2e/site-bundle.spec.ts` (CI only: production chunks).
591
-
592
- - Export and import (spec 2026-09-28 export/import): `npx smoodly export
593
- [--out <dir>]` writes the key's space — the nine content tables with
594
- history, the member list, the ready assets' files — into a folder
595
- (`manifest.json`, `rows/<table>.json` without `space_id`, `media/`
596
- without the space prefix), written as `.partial` and renamed last; it
597
- refuses a publishable key (the `smoodly_meta` read), a database behind
598
- the package, and a snapshot whose foreign keys do not close ("content
599
- changed during export"). `npx smoodly import <dir>` writes it into a
600
- space that is empty or holds only this export's rows, schema versions
601
- equal: media first, rows in reference order with on-conflict-do-nothing,
602
- so a stopped run finishes by running it again. Tests: `space-transfer`,
603
- `cli-transfer`, `space-transfer.supabase`,
604
- `examples/site/e2e/transfer.spec.ts`.
605
-
606
- - Nested addresses (spec 2026-09-29 nested paths, schema v5): a
607
- collection `path` or fixed `slug` may have several parts
608
- (`company/news`), each checked as a segment, a locale the map omits
609
- filled from the default. `src/addresses.ts` turns the registry into
610
- code addresses by owner key (`collection:<name>`, `page:<name>`),
611
- `config.addresses`; `pages.fixed` names a code-owned record's owner,
612
- the record stays a root with the last part as its slug, and its path
613
- comes from the config. Anchored paths (spec 2026-09-29 anchored
614
- paths): each `paths` row names its anchor (`pages.fixed`'s owner key,
615
- `''` for the editors' tree) and stores only the editors' part; the
616
- path index (`src/anchors.ts`, both adapters, `config.anchors`) joins
617
- the address from the config, so a code change needs no write and the
618
- live site does one lookup per request. `ensureFixedNodes` finds
619
- records by owner and creates them over an editor's page, never
620
- adopting it: code wins the address. The ops refuse a page write onto
621
- or below a code address naming the owner; the Pages list flags an
622
- editor's page there and a record no longer in code (delete only).
623
- Tests: `addresses`, `anchors`, the path index contract,
624
- `admin-fixed-nodes`, `admin-ops-addresses`, `admin-pages-tree`,
625
- `site`, the page and entry store contracts,
626
- `examples/site/e2e/entries.spec.ts`.
627
-
628
- - Pre-install fixes (spec 2026-09-29 pre-install fixes, schema v6): one
629
- permissive policy per table and action (the write key reads through
630
- `smoodly_read`; `smoodly_write` splits into insert, update and delete
631
- where a public read exists, the media pair too), the missing
632
- foreign-key and published-version indexes, `smoodly_space_row_cap`
633
- revoked from anon. A live page runs no Smoodly client code: the canvas
634
- bridge and the section net load lazily from one stub under 1 KB
635
- (`next/canvas-slot.tsx`), and `smoodly/bridge` is no longer an export.
636
- Draft mode shows a preview pill (`next/preview-pill.tsx`: an inline
637
- Shadow DOM script, bottom centre, movable left/centre/right, hidden
638
- until reload, Exit preview through `previewRoute`, which every starter
639
- mounts at `app/api/preview/route.ts`; `previewPill()` for routes the
640
- renderer does not draw). The page editor, the entry form and the
641
- Globals form save a pending edit on unmount (`close()` on the autosave
642
- controller, reopened by the hook's effect for StrictMode; it waits for a
643
- save in flight and sends the rest with that save's token) and ask only
644
- before a tab close (`useUnloadGuard`); `useLeaveGuard`'s in-app "Discard"
645
- confirm has no caller now. Draft mode's pill is absent from History's
646
- version iframe (`smoodly-version`), whose Exit would end draft mode under
647
- the editor.
648
- The cached unit is keyed by (locale, path, kind, id). A new list item's
649
- required select or radio stores its first option. Every starter sets
650
- `metadataBase` from `SITE_URL`, which the installer writes. Tests:
651
- `migration-policies`, `sql`, `canvas-slot`, `site-entries`,
652
- `next-preview-route`, `next-preview-pill`, `next-page-renderer`,
653
- `admin-autosave`, `admin-list-helpers`, `env` (installer),
654
- `e2e/publish.spec.ts`, `e2e/editor.spec.ts`, `e2e/languages.spec.ts`,
655
- `e2e/site-bundle.spec.ts` (CI-only).
656
-
657
- Not yet: canvas drag-and-drop (list fields, the outline, manual
658
- collections and the pages tree drag since 2026-09-09 — spec
659
- `docs/superpowers/specs/2026-09-09-drag-and-drop-design.md`), undo/redo, sample/placeholder content
660
- marking. Per-locale section visibility is not coming: each locale has its
661
- own tree, so a locale that does not want a section removes it (DESIGN.md
662
- §3, 2026-09-14).
663
-
664
- ## Releasing
665
-
666
- Both packages move together. Bump before build (the CLI's templates are
667
- regenerated from `examples/site` in the build and pin `smoodly@<version>`),
668
- the user runs the two publishes (npm 2FA is a browser passkey), tag only
669
- after both are on the registry. From the repo root:
670
-
671
- npm version 0.0.12 -w smoodly -w create-smoodly-app --no-git-tag-version
672
- npm run build
673
- npm publish -w smoodly --dry-run && npm publish -w create-smoodly-app --dry-run
674
- npm publish -w smoodly --access public # user; first, the scaffold pins it
675
- npm publish -w create-smoodly-app --access public # user
676
- npm view smoodly@0.0.12 version # 404s for a minute or two after a good publish; poll
677
- npm view create-smoodly-app@0.0.12 version
678
- git commit -am "release: 0.0.12 — <changes since 0.0.11>" && git tag v0.0.12 && git push --tags origin main
679
-
680
- `prepublishOnly` rebuilds each package. The Claude Code skill
681
- `.claude/skills/releasing-smoodly` carries the same order with its checks.
682
-
683
- ## Follow-ups
684
-
685
- The code-level debt register, triaged 2026-09-29 into four buckets:
686
- **Now** (before the first client install), **Next** (hardening soon
687
- after), **Later** (by area) and **Cloud** (only once Smoodly Cloud
688
- exists). Each item ends with where it was logged. A fixed item is
689
- deleted — git history and the specs keep the record — and a new one
690
- goes straight into its bucket. Design-level questions live in
691
- `docs/DESIGN.md`'s Open questions, not here.
692
-
693
- ### Now
694
-
695
- - SEO for entry pages: entries have no `meta`; a `titleField`-based
696
- title and a description field are the next step. *(2026-09-10, page fields and SEO)*
697
- - `where` filters a versioned collection's LIVE row, not its published
698
- snapshot: an entry whose published version had `kind: "x"` and whose
699
- draft changed it to `"y"` drops out of `where: { kind: "x" }` before
700
- the change is published. The published gate is per locale row, the
701
- filter is on the node's shared fields. Fix by filtering the snapshot
702
- (a join on the version row) or by documenting that a versioned
703
- collection's shared fields are live for filtering. *(2026-09-11, queries)*
704
- - `getEntries`/`getEntriesTree` return refs as ids (cheap lists); `getEntry`
705
- by path resolves them, `getEntry` by id or slug does not — document or
706
- unify when a site needs resolved lists. Worse than it reads: the field
707
- types promise resolved objects everywhere (`f.ref` builds
708
- `Resolved<T>`), and `guides/collections/queries.mdx` says `getEntry`
709
- "by id or by its URL path" resolves references, so a developer's code
710
- typechecks and fails at runtime. Decide the rule and make the types,
711
- the runtime and the guide agree. *(2026-09-05; raised to Now 2026-09-29)*
712
- - The read API returns the site layer's shapes unprojected: `getEntries`
713
- gives `{ entry: EntryRecord, path }` (the locales map, sort, parentId,
714
- collection and timestamps ride along under `entry`), `getPage` gives
715
- the renderer's `SitePage` (`record`, `tree`). Project in `queries.ts`,
716
- at the public boundary, to `{ id, path, fields, updatedAt }` per entry
717
- and a page without renderer internals; the tree item is already lean.
718
- Do it before the Astro glue (OQ 29) wraps the same reads and before
719
- a second site depends on the shape — it is a breaking change to `q`. *(2026-09-11, queries)*
720
-
721
- ### Next
722
-
723
- #### Data integrity
724
-
725
- - Older than this plan: the Supabase `addLocale` rollback on
726
- `alreadyInLocale` (`supabase-store.ts`, the insertLocale catch)
727
- deletes the racing WINNER's locale row and versions. Two admins
728
- adding one locale at once converge on the next list; fix by rolling
729
- back only what this call inserted. *(2026-09-29, nested collection paths)*
730
- - A ready asset whose `poster_id` names a pending asset would fail the
731
- export's consistency check on every run (pending assets are not
732
- exported). Unverified whether the upload flow can leave that state;
733
- if it can, export the poster or null the pointer with a warning. *(2026-09-28, export/import)*
734
- - Publish, discard and restore compare the token, then move the pointer under a
735
- pointer filter: a save that rewrites the same draft row in place between the
736
- two is published unseen (one round trip wide). A SQL function would close it. *(2026-09-26, concurrency)*
737
- - Publish integrity for an entry's own refs: an entry can publish while
738
- pointing at an unpublished entry; pages are gated, entries are not. *(2026-09-14, collections draft/publish)*
739
- - Unpublishing a page does not cascade: a published child keeps serving
740
- under an unpublished parent's path. Decide whether it should. *(2026-09-13, publish flow)*
741
- - `entries.move` expires the entry and its descendants but does not fan
742
- out to the pages referencing them, nor to the old and the new parent
743
- entries the way `pages.move` does — asymmetric with `entries.save` and
744
- `entries.setStatus`, which both fan out. *(2026-09-06)*
745
-
746
- #### Multi-statement writes (no transaction on the Supabase adapters)
747
-
748
- - The Supabase entry adapter's `removeLocale` deletes the row and its
749
- versions before the paths rewrite with no rollback; its residue
750
- comment describes the opposite case (a surviving path row for a
751
- removed locale, not a present node without its path row). *(2026-09-06)*
752
- - The Supabase entry adapter's rollbacks are best-effort and can mask the
753
- original throw: `create`'s catch runs `paths.remove` before the node
754
- delete (a failing remove strands the node and replaces the real error),
755
- `update` and `move` restore by writing, and those writes can throw in
756
- place of the rewrite's rejection. `recordVersion` is two statements
757
- (insert, then point at it), so a failure between them leaves an
758
- unreferenced `entry_versions` row — invisible to every policy and
759
- harmless, but it accumulates. *(2026-09-06)*
760
- - `move` is best-effort across two statements (reorder, then path rewrite):
761
- a failed rewrite restores each destination sibling's prior `sort` row by
762
- row, so a failure in the rollback itself still leaves the order changed. *(2026-09-05)*
763
- - Rollback gaps that remain: a `smoodly_reorder`/`smoodly_reorder_pages`
764
- failure AFTER the re-parent update has no rollback at all; the entry
765
- `create` rollback discards its delete result (an orphan row survives
766
- silently); and a throw inside any rollback replaces — masks — the original
767
- error. *(2026-09-05)*
768
- - `setTemplate`/`saveDraft` insert the version row before the pointer update:
769
- an infra failure between the two orphans a version. *(2026-09-05)*
770
-
771
- #### Addresses and code-owned records
772
-
773
- - `homePageSlug` is compared with a collection's whole default path, so
774
- `"home/news"` passes boot with the home page as its middle part: the
775
- home record serves `/`, so `/home` is no page while `/home/news` is.
776
- Refuse an address whose first part is the home slug if a site trips on
777
- it. *(2026-09-29, nested collection paths)*
778
- - An owner key that changes in code — a fixed page that becomes a
779
- collection's index page (`page:x` → `collection:y`), a collection
780
- renamed — leaves the old record "No longer in code" with its
781
- sections and history, and a new empty record takes the address.
782
- Carry the record over (rewrite `fixed`) when a site asks. *(2026-09-29, nested collection paths)*
783
- - An index page registration renamed (`a` → `b`) leaves the record on
784
- template `a`: `ensureFixedNodes` only handles a folder gaining an
785
- index page, and `setTemplate` refuses a record that has one. *(2026-09-29, nested collection paths)*
786
-
787
- #### Security
788
-
789
- - The bridge posts with `"*"` on both sides. Safe today: the admin
790
- accepts a message only when `e.source` is its own iframe's window, and
791
- the canvas acts on two kinds, refresh and scroll. The target-origin
792
- pass belongs to the content-surface sweep (spec §Out of scope). *(2026-09-26, security pass)*
793
- - The invite's `redirectTo` is a client-supplied string bounded by the
794
- auth project's redirect allow-list; a same-origin check in the op is
795
- one line when wanted. *(2026-09-26, security pass)*
796
- - The content-surface sweep: `f.link` values reach section components
797
- unfiltered, uploads allow SVG and PDF on a public bucket (SVG served
798
- with `?download=`), the custom CSS refusal list, richtext hrefs. *(2026-09-26, security pass)*
799
- - `RichText` drops the anchor of a link mark whose href is not http(s),
800
- mailto, tel or site-relative (`/`, `#`, `?`, `.`). The href is normalised
801
- the way URL parsers do (tab, LF and CR removed) before the scheme test;
802
- `javascript:`, `data:`, protocol-relative `//host` and the backslash form
803
- `/\host` are rejected. The admin's link field does not validate on input yet. *(2026-09-07, list field)*
804
-
805
- #### The live site
806
-
807
- - A section's crash on a live page after data changed outside the page
808
- editor (an entry or a global item edited in its form): the guard
809
- catches a throw in the section's own view, but one inside a component
810
- it renders, in a richtext element's view or in a `'use client'`
811
- section still fails the page, and no canvas previews those forms.
812
- Catching it live needs `<Suspense>` (spec 2026-09-27 section guard,
813
- measured). Revisit if a real site hits it. *(2026-09-27, shadowed-page detector)*
814
- - Publishing a global the site layout reads (the footer) serves the old
815
- layout on the first public request made right after the publish returns;
816
- every request after it, and a first request made ~3 s later, is fresh.
817
- Pages do not show it (an unpublish answers 404 at once). Seen on
818
- `next dev`; `e2e/globals.spec.ts` polls the home page for it. Find out
819
- whether `updateTag` over a layout's `getGlobal` read expires late, and
820
- whether `next start` behaves the same. *(2026-09-26, browser suite)*
821
- - A robots `Disallow` for the admin path from `next/meta`. *(2026-09-17, admin path)*
822
- - Scripts and the seed write through the stores and expire nothing; a
823
- `revalidate` hook for out-of-band writers. *(2026-09-11, queries)*
824
- - Delivery caching (checked 2026-09-08): Supabase Storage's basic CDN
825
- fronts every public-bucket object on a hosted project with no code on
826
- our side, and the Smart CDN (Pro plan, automatic) only adds
827
- invalidation on overwrite, which never happens — objects are
828
- immutable, no upsert on either path, Replace picks a new id. So both
829
- upload paths now set a year-long `cache-control`
830
- (`MEDIA_CACHE_SECONDS`): the `cacheControl` option on the server-side
831
- upload, the header on the browser's signed PUT (without it a signed
832
- upload lands as `no-cache`; Storage's default is one hour). The live
833
- suite reads the header back from the local stack. Not yet verified
834
- against a hosted project's CDN edge; check `cf-cache-status` and
835
- `cache-control` on a real upload there once. Remaining: in v1 the
836
- site's `<SmoodlyImage>` goes through `next/image`, so the visitor hits
837
- the app server's image cache and only its origin fetch touches the
838
- CDN; video, files and SVGs hit the CDN directly. A Supabase Image
839
- Transformations loader (`/storage/v1/render/image/public/...`, Pro
840
- only, must stay optional) would move resizing to the CDN — the transform
841
- loader under Cloud. *(2026-09-08, media library)*
842
- - `examples/site/smoodly/server.ts` should carry `import "server-only"` now that it also exports `publicAuth` — a client-side import would fail loudly at build instead of at runtime. *(2026-09-04)*
843
- - Empty locked zones on the site side: `renderPage` renders nothing for a locked zone with no node. A page that predates the zone shows no prefooter on the published site until an editor opens it (the editor fills and saves). Options: render the component from `sample` when the zone is empty, or fill on `createPage`/schema load server-side. Fine for now — seeded and admin-created pages both arrive filled. *(2026-09-03)*
844
-
845
- #### The editors
846
-
847
- - A visual global item's settings misfits (`settings.x`) don't reach
848
- their widgets in the Globals form: `GlobalFields` keys errors by the
849
- bare field key, the same gap the validator's refusal keys had before.
850
- The notice and the refusal list still name them. *(2026-09-27, editor safety)*
851
- - A `refList` on a global item's `settings` still loads no options in
852
- the Globals form or the page editor: both collect targets from the
853
- item's `fields` only. *(2026-09-17, reference picker and tags)*
854
- - A validation failure on a shared save retries with backoff like a
855
- transport failure; the field error shows on the widget meanwhile. A
856
- distinct "fix the field" state would stop the retries. *(2026-09-13, shared inline editing)*
857
- - Escape inside any inspector control bubbles to the editor's window
858
- handler and clears the block selection — the link popover stops it, a
859
- textarea or the TipTap content does not. A `keydown` guard on
860
- `.sm-inspector` would fix it for every control. *(2026-09-08, richtext widget)*
861
-
862
- #### Admin
863
-
864
- - Left open by the pre-install fixes' final review (2026-09-29): the pill
865
- has `href="#"` on Exit and no keyboard way to move it; it appears after
866
- a soft navigation from a non-Smoodly route only once the page reloads
867
- (React never runs a script it creates on the client); a remounted view's
868
- `pages.get` can read the draft before the outgoing view's `close()` save
869
- commits (the next edit then meets `StaleBanner`); an in-flight save that
870
- fails after `close()` is not retried; a required `radio` with no value
871
- shows no pill pressed while the list item now stores the first option,
872
- and `nodeFromSample` seeds a required `select` as `""`; `useLeaveGuard`
873
- has no caller left; `examples/site/.env.local.example` lacks `SITE_URL`.
874
- *(2026-09-29, pre-install fixes)*
875
- - `admin/ui/theme.tsx` pulls Public Sans from Google Fonts with an `@import`.
876
- Fine today; a self-hosted font (or `next/font` in the glue layer) removes the
877
- third-party request and the flash before it loads. *(2026-09-05)*
878
-
879
- #### Performance
880
-
881
- - `pages.get` makes four sequential store round trips for a non-root page
882
- (`getPage`, `getDraftTree`, `pathsOf`, and the parent read behind
883
- `parentLocales`; three for a root, which has no parent to read), and the
884
- editor calls it on load and after every rename — one store call
885
- returning them all would cut the editor's latency. *(2026-09-06)*
886
-
887
- #### Code health
888
-
889
- - `classify` in `ops-impl.ts` is ~20 order-sensitive substring checks over
890
- store messages — `"already exists in locale"` must precede
891
- `"already exists"`, or an addLocale conflict reads as a slug conflict. A
892
- typed code on `pageErrors` (thrown and matched, not re-parsed) would
893
- remove the ordering hazard before plan 2 adds the entry messages. *(2026-09-06)*
8
+ ## Install
894
9
 
895
- #### Tests and CI
896
-
897
- - The blank-intl starter is typechecked, not walked: the first tester-agent
898
- mission (each tester site on its own local Supabase stack, two at a time),
899
- after the 0.0.35 release. *(2026-09-15, locale alternates)*
900
- - Drag and drop has no browser test (spec §4): the outline, the pages
901
- tree and list rows reorder by real pointer drags; the first plan that
902
- touches `useSortable` adds them. *(2026-09-26, browser suite)*
903
- - The suite runs Chromium only; the admin's WebKit and Firefox
904
- behaviour is unverified. *(2026-09-26, browser suite)*
905
- - The seed's early exit probes `/` alone, and `createPage` writes the path
906
- row before the tree is published, so a crash between the home record and
907
- the last page leaves a database every later run reports as "already
908
- seeded"; recovery is `supabase db reset`. A probe on the last thing the
909
- seed writes, or a per-step check, would make it resumable. *(2026-09-07, starter)*
910
- - The package root (`src/index.ts`) must stay free of Node builtins:
911
- every scaffolded section does `import { f, smoodly } from "smoodly"`,
912
- and a `"use client"` section's browser build would fail on one.
913
- `sharedEntryId` (`src/shared-id.ts`) moved off `node:crypto` onto Web
914
- Crypto for this reason (fix pass, 2026-09-07). Nothing tests the
915
- invariant itself — a future addition that reaches for `node:fs`,
916
- `node:crypto`, etc. from a module reachable through the root would
917
- regress it silently. *(2026-09-07, shared content)*
918
- - The single-language branch — no locale selector in the Pages list, no
919
- switcher, no add/remove — has no automated coverage; only three sites
920
- branch on the locale count (`PagesList.tsx`, `EditorView.tsx` and
921
- `page-renderer.tsx`'s alternates), so a regression there shows up only
922
- in a scaffolded single-language app. *(2026-09-06)*
923
- - The no-database build is the real proof that routes never prerender against the stores; the unit test only stubs `next/server`. Script it (`SUPABASE_URL=http://127.0.0.1:9 npx next build` in `examples/site`, expect `ƒ /`) and add it to CI, which today runs only the package's tests and typecheck — so a regression is caught when Next changes `connection()` semantics. — Partly resolved 2026-09-26: the `browser` job builds the example site and drives it, but with a database; the no-database build is still unscripted. *(2026-09-03)*
924
-
925
- ### Later
926
-
927
- #### Page editor and inline editing
928
-
929
- - The page editor's publish banner lists fields as plain text; the forms'
930
- lines focus the widget. Selecting the node from a `node.field` path is
931
- the missing piece. *(2026-09-14, collections draft/publish)*
932
- - Richtext instant write from the inspector: the pure `RichText` render
933
- swapped into the container while the widget is typed in. *(2026-09-10, inline editing)*
934
- - Item-level chrome in the canvas ("Key points · 3 of 4" on hover, add,
935
- remove, reorder in place, later drag within a list): the item marks are
936
- the hook. *(2026-09-10, inline editing)*
937
- - Placeholder and validation marks on the page (the sample-sourced
938
- placeholder treatment, "required, empty" outlines) wait for the tree's
939
- placeholder marking. *(2026-09-10, inline editing)*
940
- - A coverage hint for developers: the admin knows a section's text fields
941
- and could list the ones without a mark. *(2026-09-10, inline editing)*
942
- - AI verbs ("rewrite this heading") need a field under the cursor, which
943
- a mark is. *(2026-09-10, inline editing)*
944
- - Direct-child spacing rules on a richtext container (Tailwind `space-y-*`,
945
- `.prose > p`) do not reach the canvas editor's blocks during a session;
946
- flex and grid gaps are copied (onto the ProseMirror root since the
947
- walk, 69aecc6). Documented, not fixed. *(2026-09-10, inline editing)*
948
- - The floating toolbar flips below the caret only near the top of the
949
- DOCUMENT (where the page box clips it); it scrolls with the content, so
950
- a caret at the top of the scrolled canvas has its toolbar out of view
951
- until the editor scrolls. A flip keyed to the scroller's viewport would
952
- fix it. *(2026-09-10, inline editing)*
953
- - No starter section gives the canvas a richtext with blocks: the Image
954
- and text body is marks-only, and the article body (the `article`
955
- toolset) is edited in the entry form. The walk borrowed the article
956
- toolset for the block steps; a starter section with a long-form body
957
- would let the canvas show them. *(2026-09-10, inline editing)*
958
- - The caret placed right after an existing `/` reopens the slash menu
959
- (TipTap's suggestion re-triggers on the character before the caret).
960
- Harmless; a trigger keyed to typing only would be stricter. *(2026-09-10, inline editing)*
961
-
962
- #### Richtext and elements
963
-
964
- - Image sizing and float in a body (full width, wide, small, left/right):
965
- a later additive `styles` on the image node; the site's CSS answers it. *(2026-09-08, block nodes)*
966
- - Inline elements: `inline: true` on the registration; cursor, marks and
967
- selection around an inline atom are a separate node-view effort. *(2026-09-08, block nodes)*
968
- - The column context (`contexts: ["column"]`) waits for Phase 3 rows;
969
- accepted and unused today. *(2026-09-08, block nodes)*
970
- - Element copy between fields: a pasted element the target toolset
971
- forbids is dropped silently; a notice would be kinder. *(2026-09-08, block nodes)*
972
- - `hasContent` treats an unresolved image node as content, so a body
973
- whose only image was deleted from the library still passes "required". *(2026-09-08, block nodes)*
974
- - The "+" menu and the slash menu share `RichtextInsertMenu` but keep
975
- separate active-row state and key handling; one keyboard model would
976
- be smaller. *(2026-09-08, block nodes)*
977
- - A page and entry picker in the link popover: a link inside a richtext
978
- document is a reference the refs index, the resolver and the localizer
979
- cannot see (they address refs by top-level key). Its own spec. *(2026-09-08, richtext widget)*
980
- - Every richtext descriptor now carries its toolset, so the serialized
981
- registry grew by a few bytes per field; if the AI-facing schema wants
982
- the vocabulary once instead of per field, dedupe there. *(2026-09-08, richtext widget)*
983
-
984
- #### Forms, fields and pickers
985
-
986
- - A `Create…` button in the reference picker: create the target entry
987
- without leaving the form. Needs its own answer for modal vs navigation
988
- and for the parent form's pending autosave. *(2026-09-17, reference picker and tags)*
989
- - Thumbnails in picker rows: collections have no preview-image
990
- convention (`titleField` only). *(2026-09-17, reference picker and tags)*
991
- - Tags keep insertion order; no drag reorder. *(2026-09-17, reference picker and tags)*
992
- - Tag suggestions exist on collection entry forms only, and only for
993
- top-level `f.tags()` fields: a tags field inside an object, on a
994
- section, a global or a page is a plain chip input. *(2026-09-17, reference picker and tags)*
995
- - The picker's "open" link goes to `/admin/<collection>/<id>` without
996
- the edited locale; the form opens in the URL's or the default locale. *(2026-09-17, reference picker and tags)*
997
- - The Combobox list is portaled into the admin wrapper and fixed to the
998
- viewport (2026-09-27), so a modal body or scrolling form no longer
999
- clips it; it flips upwards when the viewport has no room under the
1000
- input (`listPlacement`) and follows the input on scroll. It does not
1001
- yet shrink when neither side has room for it. A single select (a
1002
- single `f.ref`, the redirect target) shows its pick inside the input;
1003
- a single ref's status, open link and remove sit in the input too. *(2026-09-17, reference picker and tags)*
1004
- - A create dialog (title and slug) before "+ New entry", if empty Untitled
1005
- drafts turn out to litter lists. *(2026-09-14, collections draft/publish)*
1006
- - `f.date()` and `f.datetime()` share one in-house calendar
1007
- (`admin/forms/DatePicker.tsx` over the pure `date-picker.ts`); the
1008
- browsers' own pickers were rejected (they differ and take no tokens).
1009
- Weeks start on Monday and month names come from the browser's language
1010
- — `weekStart` and a month-name locale as config keys are follow-ups. *(2026-09-25, date pickers)*
1011
- - Not built: a time-only field, a date range, `.min` / `.max` on dates. *(2026-09-25, date pickers)*
1012
- - Refs inside lists and objects are refused at build time (`f.list`,
1013
- `f.object`). A list of objects each holding a ref (a featured entry with
1014
- its own caption) needs the resolver, the refs index and the admin's
1015
- ref-option loading to address nested paths; add when a site asks. *(2026-09-07, list field)*
1016
- - `emptyValue` for an `image`/`video`/`file` item is `undefined`, so a new
1017
- media row starts empty; a required image item is then a validation
1018
- error until filled, which is the intended nudge but reads as an error
1019
- on a row the editor just added. *(2026-09-07, list field)*
1020
- - A list item's subtree still uses the row index as its React key, so a list
1021
- of objects each holding a list hands the inner rows another item's collapse
1022
- state when an outer row moves; fix with a stable per-item key when nested
1023
- lists get real use. *(2026-09-07, list field)*
1024
-
1025
- #### Custom sections and section settings
1026
-
1027
- - Inline editing of a column on the canvas is OFF (2026-09-15, after the
1028
- first day's use): a click on a column reveals its editor in the
1029
- inspector (`onFieldClick` in `EditorView.tsx` skips the session for the
1030
- `custom` type). The marks, paths and session code are in place and
1031
- tested; turn it on once a walk on a real device passes. *(2026-09-15, custom section)*
1032
- - A canvas drag on column edges (today the bar in the inspector). *(2026-09-15, custom section)*
1033
- - A background for a custom section from a config palette. *(2026-09-15, custom section)*
1034
- - Elements as direct column children (today through richtext's menus). *(2026-09-15, custom section)*
1035
- - A per-zone cap on columns (`custom: { columns: 2 }` or similar). *(2026-09-15, custom section)*
1036
- - Presets exist for 2, 3 and 4 columns; 5 and 6 have the bar only. *(2026-09-15, custom section)*
1037
- - Rows reorder with the ↑/↓ buttons only; no grip, no keyboard drag. *(2026-09-15, custom section)*
1038
- - An empty column has no box on the live page (an empty paragraph
1039
- renders 0px tall), so it cannot be clicked into from the canvas; the
1040
- inspector's `Column N` editor is the way in. A `min-height` in editor
1041
- mode would give it a target. *(2026-09-15, custom section)*
1042
- - An empty column publishes (its richtext descriptor is `optional`);
1043
- whether publish should refuse a row of only empty columns is open. *(2026-09-15, custom section)*
1044
- - Growing a row copies the LAST span before renormalizing, so `[5, 7]` →
1045
- `[3, 5, 4]`, not thirds; a preset is one click away. Equal thirds on
1046
- grow would be the other reasonable rule. *(2026-09-15, custom section)*
1047
- - A class-mapping API for projects that want the wrapper to emit
1048
- classes instead of inline values (DESIGN.md OQ 13). *(2026-09-15, section settings)*
1049
- - `f.global()` — a ref field on a section that renders a global item. *(2026-09-15, section settings)*
1050
- - An AI helper filling the CSS box from a prompt (the box stores CSS,
1051
- never a prompt, so the helper only fills it). *(2026-09-15, section settings)*
1052
- - `and` / `or` conditions; today one `f.when()` per field. *(2026-09-15, section settings)*
1053
- - A condition inside a list item can read the item's siblings and the
1054
- top-level namespaces, not another item; per-item scoped `settings.`
1055
- references inside lists are not a thing yet. *(2026-09-15, section settings)*
1056
- - An element's settings cannot be hidden by the enclosing section's
1057
- settings: an element card's scope is the element's own fields and
1058
- settings. *(2026-09-15, section settings)*
1059
- - A hidden field's refs still count as usage in the refs index (its value
1060
- is kept, so the edge is real; whether usage should hide with it is open). *(2026-09-15, section settings)*
1061
-
1062
- #### Globals
1063
-
1064
- - Layout items in the outline: a "From the layout" group the bridge could
1065
- populate from the `shared:` ids it reports; canvas-only today. *(2026-09-13, shared inline editing)*
1066
- - The shared card's usage line lists page ids; titles need a pages
1067
- lookup the editor does not hold (the usage rows carry only ids). *(2026-09-13, shared inline editing)*
1068
- - A "save and publish" action for sites that want no draft stage on a
1069
- shared item (every item is versioned since 2026-09-13; the flag is
1070
- gone). *(2026-09-13, shared inline editing)*
1071
- - The picker offers a shared item only in zones whose allow list includes
1072
- its section (`allowedShared` in `admin/tree-ops.ts`), so a shared item's
1073
- section is always also offered as an ordinary section. A "placeable
1074
- only" mode (a shared item whose section no zone lists) would let the
1075
- starter keep the quote shared-only. *(2026-09-07, starter)*
1076
- - `f.shared(() => item)` — a ref field on a section that renders a shared
1077
- item inside the section's own markup (spec 2026-09-07 decision 3). *(2026-09-07, shared content)*
1078
- - Instance mode: a shared *type* with many editor-created items; today
1079
- the answer is a collection plus a section with `f.ref` (decision 1). *(2026-09-07, shared content)*
1080
- - Zone-shaped shared items (`smoodly.shared({ zone })`) (decision 2). *(2026-09-07, shared content)*
1081
- - Standalone live preview on a visual item's admin page — would need a
1082
- preview route in the glue. Less pressing since 2026-09-13: every shared
1083
- render is edited in the page canvas, and the Globals page is the form. *(2026-09-07, shared content)*
1084
- - Built-in meta on shared items and on placements (anchor per placement
1085
- is the likely shape). *(2026-09-07, shared content)*
1086
- - A placement of an object item or an unregistered item gates the page's
1087
- publish (the refs edge is emitted without a registry lookup) yet never
1088
- renders; only a hand-edited tree can produce one. *(2026-09-07, shared content)*
1089
-
1090
- #### Drag and drop
1091
-
1092
- - Cross-zone drag in the outline: each zone is its own sortable list;
1093
- moving a block between zones is still insert-and-remove. *(2026-09-09)*
1094
- - Nested manual collections show no grip (`canReorder` requires
1095
- `depth === 1`) until the entry tree UI exists — a flat index is not a
1096
- sibling index there. *(2026-09-09)*
1097
- - Canvas drag: the overlay should reuse `ui/sortable.ts` across the
1098
- iframe boundary; `useSortable` measures container children, which the
1099
- overlay's ghost rows can be. *(2026-09-09)*
1100
- - A dragged subtree stays collapsed after the drop (`onDragStart`
1101
- collapses it through `toggle` and nothing re-expands it). *(2026-09-09)*
1102
-
1103
- #### Admin UI
1104
-
1105
- - The Globals page has no tab row: Content's groups, then a `Settings`
1106
- label and the Settings groups, stacked. A tab row there would match the
1107
- canvas card. *(2026-09-15, section settings)*
1108
- - The warm look is the comparison block now (`WARM_*` + `WARM_EXTRA` in
1109
- `src/admin/ui/theme.tsx`, `localStorage.smoodly-look = "warm"`); the
1110
- technical block is deleted (tag `look-technical` keeps it). Remove the
1111
- warm block once the neutral look is judged, the same way. *(2026-09-25, neutral restyle + confirm dialog)*
1112
- - Keep the previous view painted until the next one has data: today a
1113
- navigation switches instantly and the new view shows its own loading
1114
- state; a transition that holds the old view, or prefetches the next
1115
- view's ops call on hover, is the next step. *(2026-09-08, client routing)*
1116
- - `LocaleSwitcher` in pill form has no "+ add" affordance: an absent
1117
- locale reads subtle and switching to it lands on the form's or the
1118
- editor's "doesn't exist yet · Add" pane, which adds. The dropdown form
1119
- (four locales and up) still adds straight from its "Add locale" group,
1120
- so the two forms differ by one click; a "+" inside the pill would close
1121
- that gap. *(2026-09-09, admin tweaks)*
1122
- - The image field's canvas height (300px) lives twice: `CANVAS_H` in
1123
- `MediaWidget.tsx` sizes the frame, `.sm-media__canvas` /
1124
- `.sm-media__thumb` cap it in the stylesheet. One token would do. *(2026-09-09, admin tweaks)*
1125
- - `.sm-form>*{max-width:680px}` caps the banner too; if a wide
1126
- field type ever appears (a table), give it an opt-out class. *(2026-09-09, admin tweaks)*
1127
- - An element card decides "open" from its fields alone (blank = open);
1128
- an element whose fields are all optional and empty by design stays
1129
- open on every load. The richtext image card is never collapsible. *(2026-09-09, admin tweaks)*
1130
- - The "+" menu anchors to the toolbar's right end (`right:0` in
1131
- `.sm-richtext__head`), which is under the "+" only while the toolbar
1132
- fits on one line; in the 320px inspector the toolbar wraps and the
1133
- menu sits below the wrapped row's end. *(2026-09-09, admin tweaks)*
1134
- - The entry form's column is narrower than the inspector, so the default
1135
- toolbar wraps to two rows there; the inspector shows it on one. *(2026-09-08, richtext widget)*
1136
- - A list row's collapsed summary shows the item's first string subfield —
1137
- the header nav rows read `/`, `/posts` — where the label would identify
1138
- the row; `itemSummary` could prefer a `label`/`title`/`heading` key
1139
- (walk, 2026-09-07). *(2026-09-07, starter)*
1140
- - Page settings prints `paths[locale]` under each slug field — the
1141
- locale-relative CMS path, not `urls[locale]`, the site URL the canvas
1142
- and "View live" actually open. On a translated site the Finnish hint
1143
- reads `/yritys/tietoa-meista` while the page lives at
1144
- `/fi/yritys/tietoa-meista`. Both maps are already in `EditorView`;
1145
- which one belongs under the field is a UI decision, not a missing
1146
- value. *(2026-09-06)*
1147
- - The row menu in `PagesList.tsx` does not close on Escape — only a click
1148
- on the backdrop closes it. *(2026-09-06)*
1149
- - `PageSettings` re-seeds its inputs from `record` on every rename (and
1150
- every publish), so keystrokes typed while a rename is in flight can be
1151
- dropped. The blur- and Enter-driven commits themselves are unaffected. *(2026-09-06)*
1152
- - A childless folder row is inert on click (a mount opens its collection,
1153
- a page opens the editor, a folder with children expands); "Add page
1154
- here" lives in the row menu only. *(2026-09-06)*
1155
- - The tree rows nest interactive buttons — the chevron and the `···`
1156
- menu — inside a `role="button"` row. It works, because both stop the
1157
- click and the keydown, but it is an accessibility smell a real treegrid
1158
- would not have. *(2026-09-06)*
1159
- - The Pages list offers "Add <locale>" on a dimmed row whose parent lacks
1160
- that locale, and learns the refusal only after the round trip.
1161
- `pagesTreeRows` already carries every node's locales, so the parent's
1162
- presence could disable the item with its reason up front, exactly as
1163
- the editor's switcher does with `parentLocales`. `EntriesList` has the
1164
- same gap (and `entryRows` would have to carry the locales again — the
1165
- dead field was deleted rather than left unused); it is unreachable
1166
- today, since nothing in the admin creates a child entry. *(2026-09-06)*
1167
- - Design system pass (DESIGN.md §2, "The admin's visual system"): the shell,
1168
- lists, entry form, login and editor were restyled onto `admin/ui/theme.tsx`.
1169
- Deferred deliberately, because each is a feature rather than a restyle: the
1170
- list search field and status filter, the locale select in the shell's top bar
1171
- (the editor has one; the lists always read the default locale), the article
1172
- sidebar's taxonomy/SEO/publish-date sections, and the rich-text toolbar. The
1173
- pages list's tree shape (chevrons, depth indent) and its row `···` menu
1174
- shipped 2026-09-06, without the drag handle. The tokens for all of them are
1175
- already in place. *(2026-09-05)*
1176
- - `lucide-react` is now a runtime dependency, for the toggle's two icons. The
1177
- rest of the UI still uses the design system's unicode glyphs (↑ ↓ ⧉ × ··· ▾
1178
- ← ⋮⋮); swapping them for Lucide is the next step whenever it is wanted. *(2026-09-05)*
1179
-
1180
- #### Addresses and the Pages tree
1181
-
1182
- - The rename/move confirm's code-address line names the addresses in
1183
- the selected locale only, though a move re-paths every locale; the
1184
- Pages list's conflict notice is one ellipsized line (the whole text
1185
- on hover), and an editor's flagged page cannot be moved from the
1186
- notice itself. *(2026-09-29, nested collection paths)*
1187
- - An index page removed from code leaves the collection's record with
1188
- its template (spec amendment 3): the record keeps rendering as that
1189
- page type's stale name until an editor or a later pass clears it. *(2026-09-29, nested collection paths)*
1190
-
1191
- #### Collections
1192
-
1193
- - Nested entries have no admin UI beyond `entries.move`: nothing creates
1194
- a child entry or shows the entry tree, and the entry form's slug prefix
1195
- is the collection's mount base only, not the parent chain. *(2026-09-06)*
1196
- - A published entry under a draft parent is dropped from `getEntriesTree`
1197
- (the parent is not in the list to hang it from) but returned flat by
1198
- `getEntries`. Untested either way. *(2026-09-05)*
1199
-
1200
- #### Queries (`q`)
1201
-
1202
- - The read client over the read key (DESIGN.md OQ 31) can reuse `publicContent()`. *(2026-09-26, concurrency)*
1203
- - `where` on localized fields (a join on the locale row), ranges and
1204
- negation; any-of over an array-valued field (any-of compares the text
1205
- form of the field, so it covers selects, refs and numbers; on a
1206
- checkboxes, refList or list field `site.getEntries` refuses it rather
1207
- than match nothing — both adapters agree on the text form, so a
1208
- one-element array never matches its element). *(2026-09-11, queries)*
1209
- - `getEntriesTree` has no `q` counterpart yet; add one when a site
1210
- needs a nested collection nav. *(2026-09-11, queries)*
1211
- - `getShared(["header", "footer", "contact"], { locale })` returning a
1212
- typed tuple, as sugar over the `Promise.all` the layout writes today.
1213
- Keep one cache unit per item under its own tag — a single unit tagged
1214
- with all three would expire the header whenever the footer is edited. *(2026-09-11, queries)*
1215
- - An explicit JSON `null` VALUE in a declared `order.by` field sorts
1216
- FIRST in Supabase (a jsonb null is the lowest jsonb value, not SQL
1217
- NULL, so `nullsFirst: false` does not reach it) and LAST in memory. A
1218
- MISSING key is SQL NULL and sorts last in both, and the admin only ever
1219
- produces that — a cleared number field emits `undefined`, which the
1220
- JSON body drops — so this needs a programmatic or external writer.
1221
- Mixed types in one field diverge for the same reason: Postgres orders
1222
- jsonb by type first (null < string < number), memory by `String(...)`. *(2026-09-05)*
1223
-
1224
- #### SEO and page fields
1225
-
1226
- - A `styles` block on pages, when a case needs presentation separate
1227
- from content. *(2026-09-10, page fields and SEO)*
1228
- - Refs in page fields, once the refs index walks them. *(2026-09-10, page fields and SEO)*
1229
- - A canonical URL field and a search-result preview snippet in the
1230
- SEO & Social tab. *(2026-09-10, page fields and SEO)*
1231
- - Configurable SEO set (`meta: { seo: { twitter: true } }`) if the four
1232
- values prove too few. *(2026-09-10, page fields and SEO)*
1233
- - Link fields are raw: an image in a page field reaches a nav link as
1234
- `{ asset, alt }`, not a URL. Resolve on demand if a nav ever wants one. *(2026-09-10, page fields and SEO)*
1235
- - Page-field labels derive from the key (`showInNavigation` → "Show In
1236
- Navigation"), as every field's do; a `.label()` builder option would
1237
- read better for long keys. *(2026-09-10, page fields and SEO)*
1238
-
1239
- #### Site rendering and starters
1240
-
1241
- - A separate canvas route would take the last Smoodly bytes off live
1242
- pages (the lazy stub that loads the bridge and the canvas boundary in
1243
- the editor frame), at the cost of the frame no longer loading the
1244
- page's real address: the site's layout would have to be reached from
1245
- a sibling route, and a developer's own route file or the escape hatch
1246
- would preview differently from live. Only if a site needs zero.
1247
- *(2026-09-29, pre-install fixes)*
1248
- - A layout-only language switch, if a real site needs one: a
1249
- `q().getAlternates(path)` over the `paths` index plus a proxy header
1250
- carrying the request path. Not built until asked for — the starters
1251
- render the switch from the page (`components/PageFrame.tsx`,
1252
- `components/LocaleNav.tsx`). *(2026-09-15, locale alternates)*
1253
- - A paired component (`smoodly.section`) accepts only its schema's props, so
1254
- a layout cannot hand the footer the contact item or the header the locale
1255
- links through the paired `Footer`/`Header`; the starter's layouts render
1256
- `FooterView`/`HeaderView` directly with the extra prop. A supported way
1257
- to pass layout-only props through a paired component (or a `children`
1258
- slot) would let the layouts use the registered component. *(2026-09-07, starter)*
1259
- - A per-locale collection path or fixed slug must name the default locale;
1260
- the installer rewrites the starter's two lines to name exactly the
1261
- chosen locales (`articlesSegments` in `scaffold.ts`), since a path
1262
- claiming a locale the site lacks fails the index-page rule at config
1263
- load. A "fall back to the first declared segment" rule in
1264
- `defineConfig` would make the patch unnecessary. *(2026-09-07, starter)*
1265
- - Registry names are one namespace across sections, elements, collections
1266
- and page shapes (`assertUniqueNames`); the starter names its People
1267
- section `peopleSection` and its Articles page `articlesIndex` to stay
1268
- clear of the collections. Namespacing by kind would let a section and a
1269
- collection share a name. *(2026-09-07, starter)*
1270
- - With `fi` as the default locale the seed writes the English content into
1271
- `fi`. Before this fix the index page was seeded at `posts`
1272
- while the collection's `fi` path is `artikkelit`, so `ensureFixedNodes`
1273
- materialized a second, empty Articles page at `artikkelit` and the
1274
- links pointed at `/posts`; the seed now derives the segment from the
1275
- collection's `path` per locale. Left: the starter's copy in a `fi`
1276
- default is still English. *(2026-09-07, starter)*
1277
- - Cache tags are still `page:<id>`: publishing one locale expires every
1278
- locale's cached unit of that page (spec 2026-09-06 §4). A
1279
- `page:<id>:<locale>` tag would halve the revalidations on a bilingual
1280
- site. *(2026-09-06)*
1281
- - `smoodlyMetadata` does not apply the registration check `renderSmoodlyPath`
1282
- applies: a record whose `template` has no registration is a 404 body with
1283
- its meta emitted beside it. *(2026-09-05)*
1284
- - The entry-page view receives the whole `EntryRecord`, every locale's
1285
- row in `locales` included (fields, slug, status and version pointers); a
1286
- client entry page would ship all of it to the browser. *(2026-09-05)*
1287
-
1288
- #### Media
1289
-
1290
- - Video transcoding and adaptive streaming: a Mux or Cloudflare Stream
1291
- loader behind the `media.loader` seam, if a site ever needs more than
1292
- an MP4 over Storage's CDN. *(2026-09-08, media library)*
1293
- - Sweeping abandoned `pending` asset rows (an upload that began and
1294
- never called `finishUpload`); a periodic op or a cleanup on `list`. *(2026-09-08, media library)*
1295
- - A private bucket with signed reads, for sites that must not expose
1296
- draft-only media by URL before publish. *(2026-09-08, media library)*
1297
- - Pre-generated image variants at upload time, for hosts without sharp. *(2026-09-08, media library)*
1298
- - Image dimensions server-side cover JPEG and PNG (`imageDimensions`); a
1299
- WebP or AVIF seeded through `AssetStore.create` lands without a size
1300
- and resolves to nothing until the row is edited. Browser uploads
1301
- measure every type. *(2026-09-08, media library)*
1302
-
1303
- #### History and publishing
1304
-
1305
- - Client-side undo in the editor (a stack of tree snapshots); the store
1306
- is no longer an undo stack by design. *(2026-09-13, history)*
1307
- - The author per version row and in the lists; named versions. *(2026-09-13, history)*
1308
- - History on the canvas card's menu and in the list row menus. *(2026-09-13, history)*
1309
- - A diff between two versions. *(2026-09-13, history)*
1310
- - The lists' row menus (Pages, Entries) do not offer Unpublish; the
1311
- document's own control does. *(2026-09-13, publish flow)*
1312
-
1313
- #### Collaboration
1314
-
1315
- - A hard lock with takeover, if a real team asks: presence has the facts. *(2026-09-26, concurrency)*
1316
- - Presence on the members and media screens; today only pages, entries and
1317
- global items track. *(2026-09-26, concurrency)*
1318
- - Postgres Changes for live list refresh; the lists still load on navigation. *(2026-09-26, concurrency)*
1319
- - Field-level merging of two editors' changes; the guard refuses whole documents. *(2026-09-26, concurrency)*
1320
- - A dropped socket clears presence on Realtime's timeout (tens of seconds); the
1321
- lock outlives a closed tab by that much. *(2026-09-26, concurrency)*
1322
-
1323
- #### Members
1324
-
1325
- - Members management shipped 2026-09-25 (spec
1326
- `docs/superpowers/specs/2026-09-25-members-management-design.md`); out
1327
- of its scope: a pending-invite status and "resend invite" on a row
1328
- (needs the Auth user's `last_sign_in_at`, which the cloud projection
1329
- does not carry); removing the Auth account together with the member
1330
- row; invites from the cloud's `/admin` (they are smoodly.io's); a
1331
- project whose Auth is OAuth-only (the invite mail asks for a password). *(2026-09-25, settings + members)*
1332
- - The members list is not paged (tens of rows, not thousands). *(2026-09-25, settings + members)*
1333
-
1334
- #### Redirects
1335
-
1336
- - Destinations outside Smoodly, extension and query-string addresses,
1337
- code-owned renames (a collection `path`, a fixed slug): the guide's
1338
- `next.config` recipe; a `redirects` table is OQ 34. *(2026-09-26, redirects)*
1339
- - The content API's `getPage("/old")` returns null for a redirect row
1340
- (spec §7); a `follow` option is a one-line addition if a site asks. *(2026-09-26, redirects)*
1341
- - A redirect row has no audit columns (who, when); add them with a
1342
- need. The Redirects page is not paged. *(2026-09-26, redirects)*
1343
-
1344
- #### Export and import
1345
-
1346
- - `import --replace`: delete the space's content and media first, after
1347
- typing the space to confirm — a backup restored over a live project.
1348
- Mention it in the not-empty refusal when it lands. *(2026-09-28, export/import)*
1349
- - A readable export for leaving Smoodly: one document per page or entry,
1350
- fields resolved, no internal IDs. *(2026-09-28, export/import)*
1351
- - A "Download backup" button in the admin: the same export behind an op,
1352
- zipped for an editor. *(2026-09-28, export/import)*
1353
- - Import cannot expire the app's cache tags; it prints a restart note. A
1354
- revalidate call through the app (an op the CLI could reach) would make
1355
- the note unnecessary. *(2026-09-28, export/import)*
1356
-
1357
- #### Content health and drift
1358
-
1359
- - Content health lists an entry slug outside the grammar, but its link
1360
- opens an entry form that marks nothing on the slug: drift leaves the
1361
- slug out on purpose (a marker would flash while it is typed), so only
1362
- the publish refusal marks it. Mark it in the form once the box has lost
1363
- focus, if editors miss it. *(2026-09-29, pre-install fixes)*
1364
- - Content health does not check page slugs: pages refuse a bad slug at
1365
- create and rename, so only an import of older data or a hand edit could
1366
- hold one. *(2026-09-29, pre-install fixes)*
1367
- - Refs inside unknown nodes are not indexed: without a schema nothing
1368
- says which values are refs, so safe-delete cannot see them. Publish
1369
- refuses such nodes and a live one renders nothing. *(2026-09-27, editor safety)*
1370
- - Leftover shared values after `.localized()` is turned on stay on the
1371
- entry as every locale's fallback; removing them for good waits on
1372
- the fix tooling (OQ 35). `localization-on` is reported only where a
1373
- locale has no value of its own, so a fully translated entry no
1374
- longer lists it. *(2026-09-27, editor safety)*
1375
- - A CLI drift report was left out (the admin already has the config and
1376
- the database; a CLI needs the service key and a TS config loader). *(2026-09-27, editor safety)*
1377
- - Turning `.localized()` off for a field with per-locale values leaves
1378
- those values in `entry_locales.fields` until the next save of each
1379
- locale (a save writes only the current split) — the drift/codemod
1380
- pipeline (Phase 2) is where "keep en, discard fi" belongs. *(2026-09-06)*
1381
-
1382
- #### Schema and migrations
1383
-
1384
- - The views of a removed collection stay (spec 2026-09-26 §3); a
1385
- `drop view` is the developer's. *(2026-09-26, schema migrations)*
1386
- - `smoodly migrate` never pushes; a `--push` flag if the two-step
1387
- proves annoying. *(2026-09-26, schema migrations)*
1388
-
1389
- #### Data lifecycle
1390
-
1391
- - A locale dropped from `locales.supported` leaves its `page_locales`,
1392
- `page_versions` and `paths` rows in place but unreachable — nothing
1393
- lists or serves them, and nothing cleans them up. It is the mirror of
1394
- the materializer's top-up, and wants the same deliberate answer (an
1395
- admin-visible orphan list, or a prune op). *(2026-09-06)*
1396
- - `addLocale` does not bump the entry's `updatedAt` while `removeLocale`
1397
- does. Both adapters agree, so the contract is honest, but "adding a
1398
- language is not an edit and removing one is" is arbitrary — decide it
1399
- deliberately before someone sorts a list by Updated. *(2026-09-06)*
1400
- - No `rebuildPaths()`: the index is documented as derived and rebuildable, but
1401
- nothing rebuilds it. *(2026-09-05)*
1402
-
1403
- #### Config and registration
1404
-
1405
- - `LOCALE_CODE_RE` accepts any 2–4 letter subtag as script or region
1406
- (`en-ZZZZ` passes), and a duplicate entry in `supported` passes
1407
- silently — boot validation catches typos in shape, not in fact. *(2026-09-06)*
1408
- - `entryPathRows` relies on the stores validating locale keys on write
1409
- (no guard of its own); `list`/`getMany` accept an unsupported locale
1410
- silently and read as "no content". *(2026-09-06)*
1411
- - `sections` is passed twice — to `createSmoodlySite` (ref resolution) and to
1412
- `createPageRenderer` (the component map) — and `elements` cannot be passed
1413
- at all; the two lists can drift silently. *(2026-09-05)*
1414
- - `SmoodlyConfig.registry.pages` (`Registered` in `src/config.ts`) has no
1415
- call signature, so every app's glue casts it `as PageRegistration[]`. *(2026-09-05)*
1416
- - Two `entryPage` registrations for one collection are silently accepted.
1417
- `PageStore.rename` still accepts a locale outside `supported`; the admin
1418
- op rejects it first, so only a direct store caller reaches it. *(2026-09-05)*
1419
-
1420
- #### Scale and performance
10
+ npx create-smoodly-app my-site
1421
11
 
1422
- - `listLive` / `listRedirects` on Supabase read at most PostgREST's
1423
- `max_rows` (1000) per locale, as before, now ordered by (anchor, path)
1424
- and sorted by URL in JS; page them if a locale's redirect list grows
1425
- past it. *(2026-09-29, nested collection paths)*
1426
- - Scan paging: `health.scan` makes one bulk read per table (versions by
1427
- id in chunks of 100), and PostgREST's max-rows would cap a very large
1428
- space. Page it, and add a rail badge, when a real site's size asks. *(2026-09-27, editor safety)*
1429
- - Server search for ref candidates: `useRefOptions` loads the whole
1430
- target collection once per locale. When a collection outgrows that,
1431
- the hook changes (a search op, plus "titles for these ids" for the
1432
- picked rows); `RefPicker` takes options as a prop and does not. *(2026-09-17, reference picker and tags)*
1433
- - `entries.distinct` flattens in JS over `entries.list`; an RPC over
1434
- `jsonb_array_elements` when a collection outgrows it. *(2026-09-17, reference picker and tags)*
1435
- - `InspectorFields` filters hidden entries per render; a section with
1436
- many conditions re-evaluates every keystroke. Fine at the sizes seen. *(2026-09-15, section settings)*
1437
- - Ops are built per call (`createAdminOps` inside the handler) so the
1438
- session rides in as `actor`; if that ever measures, memoize the
1439
- actor-free parts. *(2026-09-13, history)*
1440
- - A GIN index on `entries.fields` when a customer's collection is large
1441
- enough to need it; additive, no migration. *(2026-09-11, queries)*
1442
- - `getEntry` by id goes through `site.getEntry`, which lists the whole
1443
- collection to find one row; a primary-key read first would be cheaper
1444
- on the uncached path (draft mode, first miss). *(2026-09-11, queries)*
1445
- - Every revalidating op (publish, delete, a save of published content)
1446
- answers with a fresh RSC render of the admin route — the layout's
1447
- styles included, ~30 KB — because `updateTag` runs inside the server
1448
- action and Next re-renders the tree it was posted to. Harmless now
1449
- that the shell lives in the layout (the empty page subtree is what
1450
- remounts), but it is the price of server actions as the transport. *(2026-09-08, client routing)*
1451
- - `getSmoodlyShared` reads the store per request in draft mode and once
1452
- per (item, locale) otherwise; a layout calling it for several items
1453
- makes one round trip each — batch if it shows. *(2026-09-07, shared content)*
1454
- - `ops.shared.get` runs `ensureSharedItems` and then lists the item
1455
- again; one round trip could go. *(2026-09-07, shared content)*
1456
- - `ensureSharedItems` runs on every `ops.shared.list()` — which is every
1457
- editor mount, not only the Shared content page — costing one
1458
- `entries.list` per registration per open. *(2026-09-07, shared content)*
1459
- - `fanOut` resolves every shared registration's row id (one
1460
- `entries.list` each) on every entry write, so it can expire
1461
- `shared:<name>` when something the item references changes; a row-id
1462
- cache would remove the reads but has to survive materialization. *(2026-09-07, shared content)*
1463
- - `ensureFixedNodes` runs on every `pages.list` and every ROOT
1464
- `pages.create` — one `listPages()` each, and a second one when it
1465
- tried to create something. It also treats a root record sitting at a
1466
- fixed slug as that node even when its `template` is a foreign one: the
1467
- node is adopted, never recreated, and the ops then guard it as
1468
- code-owned. *(2026-09-06)*
1469
- - `fixedNodeSpecs(config)` rebuilds the whole spec list on every
1470
- `fixedNodeOf` call, and the ops call `fixedNodeOf` per guarded write. A
1471
- `WeakMap` memo keyed by the config object is the whole fix. *(2026-09-06)*
1472
- - `SupabasePageStore.updateLocale` re-reads the record (`must(id)`) after
1473
- every update, so `setTemplate` is N+1 in the page's locales: one update
1474
- and one full read each. Only the last read is used. The Supabase entry
1475
- adapter is the same shape: `create` is insert → insert → read →
1476
- version → read → paths → refs, and `removeLocale` re-fetches the entry
1477
- three times. *(2026-09-06)*
1478
- - `entries.list` filters `{ locale, status }` in memory after fetching
1479
- every row (PostgREST cannot filter the parent by an embedded row
1480
- without `!inner`, which would drop the other rows); fine at collection
1481
- sizes today. *(2026-09-06)*
1482
- - `assertPublishable` (`store.ts`) awaits one `entries.get` per
1483
- referenced entry, sequentially, on every publish — a `refList` of a
1484
- dozen articles is a dozen serial reads, now per locale. `getMany(ids,
1485
- locale)` takes exactly that shape and would make it one call. *(2026-09-06)*
1486
- - `loadPage` calls `listPages()` for ancestors and children on every cache
1487
- miss; fine for hundreds of nodes, a `children(id)`/`chain(id)` store query
1488
- is the fix when a site outgrows it. *(2026-09-05)*
1489
- - `loadEntry` probes each mounted collection in turn: the `paths` row
1490
- carries the target id but not its collection. *(2026-09-05)*
12
+ This creates a Next.js site with the admin mounted, the database schema
13
+ in place and a first editor who can sign in.
1491
14
 
1492
- #### Code health
15
+ ## Environment
1493
16
 
1494
- - `SharedForm.tsx` is a near-verbatim fork of `EntryForm.tsx`
1495
- (`applyResult`, `InfoRow`, the ref-options effect; the locale helpers
1496
- are shared since 2026-09-08) and `SharedList.tsx` is the third copy of
1497
- the remembered-locale block (`EntriesList`, `PagesList`); extract a
1498
- `useFormLocale` hook when the next form arrives. *(2026-09-07, shared content)*
1499
- - `CollectionSchema.kind` was widened to carry `"shared"`, so a
1500
- `SharedSchema` typechecks where `registry.collections` is expected;
1501
- `defineConfig` should throw on a `kind === "shared"` entry listed there. *(2026-09-07, shared content)*
1502
- - Because `fanOut` lists every shared registration, an entry store built
1503
- without `options.shared` now fails on every ordinary entry write with
1504
- "no collection named", not only on `ops.shared.*`; both scaffolds pass
1505
- the same `shared` array to the store and the config, so this bites only
1506
- a hand-wired app. *(2026-09-07, shared content)*
1507
- - `subtreeIds` and `entrySubtreeIds` in `ops-impl.ts` are the same O(n²)
1508
- walk over a full list, written twice. One generic descendant walk when
1509
- the list sizes make it matter. *(2026-09-06)*
1510
- - `ops-impl.ts` is ~436 lines with a ~165-line `pages` group. The guard
1511
- helpers (`nameOf`, `isHomeNode`, `supportedLocale`, `mountGuard`,
1512
- `owned`) are the extraction seam — a `pages-ops.ts` taking them as
1513
- collaborators. The `entries` group now duplicates two of them outright:
1514
- the `supportedLocale` guard and the `parentLocales` computation exist
1515
- once per group. *(2026-09-06)*
1516
- - `EntryForm.tsx` grew the locale lifecycle beside the fields; the
1517
- `LocaleSwitcher` is shared with the editor now, the add/remove flows
1518
- are not (`doAddLocale`/`doRemoveLocale` exist twice). *(2026-09-06)*
1519
- - `removeLocale`'s blocker list (`localeInUse`) is unordered in the
1520
- Supabase adapter — the children query has no `.order()` — so a
1521
- multi-blocker message can name the titles in a different order than the
1522
- memory adapter's. Message text only; the contract case has one blocker. *(2026-09-06)*
1523
- - `entry-store.ts` is ~624 lines. The pure helpers (`localizedKeys`,
1524
- `splitFields`, `entryFieldsIn`, `entryRefEdges`, `entryTitleIn`) are the
1525
- extraction seam from the memory adapter, the same shape as the
1526
- `EditorView.tsx` and `ops-impl.ts` entries in this list. *(2026-09-06)*
1527
- - The memory stores default to SEPARATE private path indexes while the
1528
- Supabase stores share one `paths` table: pages and entries share a URL space
1529
- only when the wiring passes one `paths` option to both (convention, not
1530
- structure). *(2026-09-05)*
1531
- - `SupabasePathIndex` falls back to `pathTakenError("?", "?")` when
1532
- Postgres reports a unique violation without `details` — the message then
1533
- names no path. *(2026-09-05)*
1534
- - `chainOf` has no cycle guard: a corrupted `parent_id` loop would spin
1535
- forever. The stores prevent cycles on `move`, so it is unreachable today. *(2026-09-05)*
1536
- - The `scroll` message in `admin/editor/protocol.ts` is no longer sent: with the
1537
- canvas column as the scroller, `EditorView` scrolls it directly instead of
1538
- asking the bridge to `scrollIntoView` across the frame. `EditorBridge` still
1539
- handles the message, so old and new admins interoperate; drop the message on
1540
- the next protocol change. *(2026-09-05)*
1541
- - `exports` has no `"./package.json"` entry, so tooling that reads a dependency's `package.json` through the exports map cannot. One line to add when something needs it. *(2026-09-04)*
1542
- - `src/ref-index.ts` contains two raw NUL bytes used as key separators, which makes git show the file as binary in diffs. Replacing them with `\0` escapes would make it diffable again. *(2026-09-04)*
1543
- - `serialize.ts` structural cast duplicates `PageSchema`; tighten `Registered.schema` so the cast goes. *(2026-09-03)*
1544
- - `EditorView` split (autosave extracted 2026-09-03; the rest 2026-09-08, before the TipTap widget): `usePageLocale` (switch/add/remove, over `locale-url.ts`), `useCanvasBridge` (geometry, select/hover, `postToCanvas`, the geometry timeout), `CanvasOverlay` over `overlay-geometry.ts` (`plusButtonsFor`, pure and tested), `InsertPicker`, `Outline`, `NoticePane`. `EditorView.tsx` is ~660 lines of load, gestures, publish and layout. Remaining seam: the inspector's field form (`FieldWidget` rows plus the tabs) stays put until inline editing lands (DESIGN.md §3 puts TipTap in the canvas, not the sidebar). The ref-option loading became `forms/useRefOptions.ts` (2026-09-17). (logged 2026-09-06, updated 2026-09-08) *(2026-09-03)*
17
+ A self-hosted app needs three variables:
1545
18
 
1546
- #### Tests
19
+ | Variable | What it is |
20
+ | --- | --- |
21
+ | `SMOODLY_URL` | Your Supabase project's URL |
22
+ | `SMOODLY_SECRET_KEY` | The project's secret key. Server-only. |
23
+ | `SMOODLY_PUBLISHABLE_KEY` | The project's publishable key |
1547
24
 
1548
- - The media test uploads a starter photo under a suffixed name rather
1549
- than a fixture file, so `e2e/fixtures/` from the spec does not exist. *(2026-09-26, browser suite)*
1550
- - ListView rows that are not clickable (Members) carry no role; the
1551
- members test finds its row by `.sm-table__body > div`. A table role
1552
- set (`table`/`row`/`cell`) on ListView would give every list a proper
1553
- locator. *(2026-09-26, browser suite)*
1554
- - The picker's click cannot be unit-tested (no DOM in the suite); the
1555
- walk covers it. A jsdom environment for the admin tests is a future
1556
- tooling item. *(2026-09-15, custom section)*
1557
- - The list widget has no test for an object item holding a nested list
1558
- subfield. *(2026-09-07, list field)*
1559
- - The row menu's item set (`menuItems`) and the row-click routing live in
1560
- `PagesList.tsx`, untested; extract them into `pages-tree.ts` before
1561
- plan 4 adds entry rows to the same menu. *(2026-09-06)*
1562
- - `publish`'s "has no draft to publish" branch is unreachable with the
1563
- memory store — `createPage` gives every templated page a first version
1564
- — and is untested. It is defence for the Supabase adapter. *(2026-09-06)*
1565
- - Classifications the ops tests do not assert: a move that breaks the
1566
- home page's no-children rule or exceeds the tree depth (create asserts
1567
- both), and `entries.move`'s cross-collection and sibling-slug guards.
1568
- `MemoryEntryStore.move` has no children guard at all — the subtree
1569
- rides along — so `has child` is reachable from delete only. *(2026-09-06)*
1570
- - No test pins that a published child's breadcrumb carries an UNPUBLISHED
1571
- ancestor's title with `hasPage: false`; `site.test.tsx` covers the
1572
- folder ancestor only, and the two paths share one `hasPage` predicate. *(2026-09-06)*
1573
- - `MemoryPageStore.publish` throws the "is a folder" message when a
1574
- templated row has no draft version. Unreachable through the ops (a
1575
- templated page always gets a first version), but the message would be
1576
- wrong if it ever were. *(2026-09-06)*
1577
- - `admin-entries-list.test.ts` has no case for a row with differing
1578
- pointers (the `draft edits` status), nor one asserting that an absent
1579
- row's `updatedAt` falls back to the node's. Two assertions. *(2026-09-06)*
1580
- - The live suites run on vitest's DEFAULT 5s per-test timeout against a real
1581
- database, while a single contract test makes dozens of round trips. On a
1582
- loaded or degraded local stack `npm run test:supabase` then fails with bare
1583
- timeouts on arbitrary tests (every file passes on its own, and the whole
1584
- run passes with `--testTimeout=30000`). Either raise the timeout in
1585
- `scripts/test-supabase.sh` or accept the flake in CI. *(2026-09-05)*
1586
- - Entry `move` coverage is thinner than pages' — no omitted-index, clamp or
1587
- cross-collection tests. *(2026-09-05)*
25
+ ## Upgrading
1588
26
 
1589
- ### Cloud
27
+ A new version can need a newer database schema. After updating the
28
+ package, `npx smoodly migrate` writes the migration files; the
29
+ Upgrading guide has the rest.
1590
30
 
1591
- - A copy inside one database with fresh IDs — the cloud's "duplicate
1592
- environment", staging → production; needs the reference walk (parent
1593
- links, version pointers, refs, paths, asset ids in trees, fields and
1594
- richtext) the eject avoids by keeping IDs. *(2026-09-28, export/import)*
1595
- - Every op call with a junk token costs one `auth.getUser` against the
1596
- auth project; rate limiting is the session-model spec's (OQ 20). *(2026-09-26, security pass)*
1597
- - The social image URL goes through the default `next` loader at 1200px;
1598
- the cloud's transform loader (OQ 28) should serve a real 1200×630. *(2026-09-10, page fields and SEO)*
1599
- - A cross-origin admin needs the bridge-side editing variant (spec §3). *(2026-09-10, inline editing)*
1600
- - Transform loaders beyond the Next default: Supabase Image
1601
- Transformations, imgix, Cloudflare Images (DESIGN.md OQ 28). *(2026-09-08, media library)*
1602
- - `<SmoodlyImage>` sizes the image by the crop factor, so `sizes` picks a
1603
- candidate for the box, not for the framed image; a CDN loader with
1604
- `handlesCrop` removes the overfetch. *(2026-09-08, media library)*
1605
- - Light/dark toggle (nav foot): the choice is stored in `localStorage`
1606
- (`smoodly-theme`) and written as `data-theme` on the admin wrapper, never on
1607
- the host `<html>`. It is per browser, not per editor account — a server-side
1608
- preference would need a place to live (`members`, or a cloud user profile). *(2026-09-05)*
1609
- - Once the policy-based published read exists, decide whether it becomes the canonical headless read path and the generated per-collection views turn optional (cloud has no views). *(2026-09-04)*
1610
- - A malformed `space_id`/`key_id` claim raises `22P02` inside the policy: fails closed but surfaces as a 500. Only reachable from a validly-signed key, so it is a cloud key-minting guard, not a request-path one. *(2026-09-04)*
1611
- - **Verified and kept 2026-09-26 (security pass §3)** — Authorization trusts the JWT claims alone; `smoodly_space_key_revoked()` checks only `revoked_at`. When cloud key-minting exists, make it a full key check (the claims must match the `space_keys` row). *(2026-09-04)*
1612
- - **Verified and kept 2026-09-26 (security pass §3)** — `memberOf` and `SupabaseMemberStore` read `members` (and `spaces`) with no space filter: under a cloud write key RLS scopes it, but a service-role client bypasses RLS and would admit an editor of any space. Harmless in self-host (one space); never use a service-role client against the shared content project. *(2026-09-04)*
31
+ ## Docs and source
1613
32
 
1614
- ## Notes for maintainers
33
+ Guides: https://github.com/laniakea-studio/smoodly-cms/tree/main/guides
34
+ Source: https://github.com/laniakea-studio/smoodly-cms
1615
35
 
1616
- - The live suites wipe `members` and the content tables; a pane walk after
1617
- them needs `npm run reseed` (or `scripts/demo-editor.ts`) first. *(2026-09-26, concurrency)*
1618
- - Drafting version N+1: `npx tsx scripts/emit-migration.ts` prints the
1619
- whole schema plus the upsert; keep only the delta, name the file with
1620
- the current UTC stamp and `_smoodly_v<N+1>.sql`, bump `SCHEMA_VERSION`,
1621
- run `npm run db:migrate` at the root so the repo copy follows, and
1622
- `npm run check:migrations`. Additive only; a contraction waits for the
1623
- compatibility window and carries `-- smoodly:contraction`. *(2026-09-26, schema migrations)*
36
+ MIT licensed.