Offer creating the page on the page-not-found screen #115

Closed
opened 2026-07-14 16:36:40 +02:00 by fable-5 · 1 comment
Collaborator

Context

Following a wikilink to a page that does not exist yet (a phantom link) dead-ends on /p/:pondSlug/:pageSlug with the generic errors:not_found banner. The page_trashed branch (issue #31) shows the pattern for a distinguishable hint with a way out; the proven create mechanic lives in the pond's missing-pages view: POST /ponds/:id/pages with {title: <slug>}, so the generated slug equals the phantom slug and the links pointing at it resolve (issue #47).

Scope

  • In PageEditorPage's error branch: when the pond resolved and the page error is an ApiError with code not_found, render the message plus a "create this page" button. The affordance is deliberately ungated (the sidebar's "New page" button is too; the client cannot distinguish "never existed" from "no read permission" per the #60 convention) — a 403 from the POST surfaces through the regular FormError.
  • Create with {title: pageSlug}; on success invalidate ['pages', pondId], ['phantom-links', pondId], ['pond-links', pondId], and ['page', pondId, pageSlug] — the URL already matches, so the refetch mounts the editor in place.
  • Fold in the same staleness fix where the mechanic came from: PhantomPagesView.createPage misses the ['pond-links'] invalidation, so the graph views stay stale after a phantom-create today.
  • i18n de+en (reuse the tone of editor:wikilink.createHint / links:missing.create).

Acceptance criteria

  • An editor following a phantom link sees the not-found message plus the create button; one click opens the editor on the new root-level page without a URL change.
  • A non-editor clicking create gets the translated 403 banner; the page_trashed branch is unchanged.
  • Backlinks/graph reflect the resolved link without a reload (both here and from the missing-pages view).
  • Playwright coverage for the create flow (extend an existing CI pack or land it with the #119 pack).

Technical notes

apps/web/src/pages/PageEditorPage.tsx (error branch ~line 349), apps/web/src/links/PhantomPagesView.tsx, i18n namespaces editor/links.

Dependencies

None.

Size

~0.5 days.

## Context Following a wikilink to a page that does not exist yet (a phantom link) dead-ends on `/p/:pondSlug/:pageSlug` with the generic `errors:not_found` banner. The `page_trashed` branch (issue #31) shows the pattern for a distinguishable hint with a way out; the proven create mechanic lives in the pond's missing-pages view: `POST /ponds/:id/pages` with `{title: <slug>}`, so the generated slug equals the phantom slug and the links pointing at it resolve (issue #47). ## Scope - In `PageEditorPage`'s error branch: when the pond resolved and the page error is an `ApiError` with code `not_found`, render the message plus a "create this page" button. The affordance is deliberately ungated (the sidebar's "New page" button is too; the client cannot distinguish "never existed" from "no read permission" per the #60 convention) — a 403 from the POST surfaces through the regular `FormError`. - Create with `{title: pageSlug}`; on success invalidate `['pages', pondId]`, `['phantom-links', pondId]`, `['pond-links', pondId]`, and `['page', pondId, pageSlug]` — the URL already matches, so the refetch mounts the editor in place. - Fold in the same staleness fix where the mechanic came from: `PhantomPagesView.createPage` misses the `['pond-links']` invalidation, so the graph views stay stale after a phantom-create today. - i18n de+en (reuse the tone of `editor:wikilink.createHint` / `links:missing.create`). ## Acceptance criteria - [ ] An editor following a phantom link sees the not-found message plus the create button; one click opens the editor on the new root-level page without a URL change. - [ ] A non-editor clicking create gets the translated 403 banner; the `page_trashed` branch is unchanged. - [ ] Backlinks/graph reflect the resolved link without a reload (both here and from the missing-pages view). - [ ] Playwright coverage for the create flow (extend an existing CI pack or land it with the #119 pack). ## Technical notes `apps/web/src/pages/PageEditorPage.tsx` (error branch ~line 349), `apps/web/src/links/PhantomPagesView.tsx`, i18n namespaces `editor`/`links`. ## Dependencies None. ## Size ~0.5 days.
fable-5 added this to the M13 — Create-from-link & Obsidian import milestone 2026-07-14 16:36:40 +02:00
fable-5 added the
frontend
label 2026-07-14 16:36:40 +02:00
Author
Collaborator

Implemented in 64e21e9. A plain not_found on the page route (the pond resolved) now renders the message plus a create button; the page is created with {title: pageSlug} so the generated slug matches the URL and every wikilink pointing at the address resolves, and the invalidated page query mounts the editor in place. Ungated by design (a reader's POST surfaces as the regular 403 banner); the page_trashed branch is untouched. Rode along: PhantomPagesView.createPage now also invalidates ['pond-links'] — the graph views kept showing a just-created target as a phantom. Covered by create-missing-page.spec.ts (in CI since #119).

Implemented in 64e21e9. A plain `not_found` on the page route (the pond resolved) now renders the message plus a create button; the page is created with `{title: pageSlug}` so the generated slug matches the URL and every wikilink pointing at the address resolves, and the invalidated page query mounts the editor in place. Ungated by design (a reader's POST surfaces as the regular 403 banner); the `page_trashed` branch is untouched. Rode along: `PhantomPagesView.createPage` now also invalidates `['pond-links']` — the graph views kept showing a just-created target as a phantom. Covered by `create-missing-page.spec.ts` (in CI since #119).
Sign in to join this conversation.
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: stwaidele/dorfteich#115
No description provided.