Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

feat(books): outline editor, browser test and docs (7/7) - #274

Open
nehalkumarsingh wants to merge 15 commits into
nehal/book-mode-6-readerfrom
nehal/book-mode-7-editor
Open

nehalkumarsingh wants to merge 15 commits into
nehal/book-mode-6-readerfrom
nehal/book-mode-7-editor

Conversation

@nehalkumarsingh

Copy link
Copy Markdown
Contributor

Stack: 7/7. Based on #273 (reader UI), then #272, #271, #270, #269 and #268. Review this PR after #273.

What and why

This PR finishes Book mode v1.

  • Outline editor (/app/b/:bookId/outline, folder editors only):

    • drag-and-drop with the installed @dnd-kit/core, plus keyboard Move up/down;
    • parts, planned chapters, a "Not in outline" pool, and front and back matter;
    • chapter numbers computed live;
    • save with a base version and an optional note. Validation problems show next to the row they point at, and a conflict gets a clear reload message.
  • Folder page: "Make this a book" for folder editors when Book mode is enabled, and "Read as book" once a book exists.

  • Browser test (frontend/e2e/book-mode.spec.ts), which runs in CI:

    • make a book, read chapter 1, then → to chapter 2;
    • publish a new version of chapter 1, see it on book home and in the chip, and clear it from a changed section;
    • resume on a second browser (at chapter 1, the last one visited);
    • text size and paper theme inside the frame;
    • restore after a reload.

    The e2e stack sets SLASHDOCS_BOOKS_ENABLED=true.

  • Configuration and docs:

    • SLASHDOCS_BOOKS_ENABLED in .env.example, Helm (features.books, default false) and docs/self-hosting.md;
    • agent guidelines ask authors to keep heading ids stable, and skills/slashdocs/SKILL.md gains a Books section;
    • TODOS.md adds two follow-ups: signed-out readers of public books, and one batched access query for manifests;
    • the proposal is updated to match what was built.

How it was tested

  • npm test passes all 208 tests, npm run lint shows 0 errors, npm run format:check is clean and npm run build passes.
  • go test ./api/... ./internal/... ./cli/... -count=1 passes with 0 skipped DB tests.
  • The browser spec passes npm run e2e:typecheck and playwright --list. It runs in CI with make e2e-browser; the author's machine has no Docker.
  • helm template sets SLASHDOCS_BOOKS_ENABLED from features.books.

Checklist

  • Tests pass locally (browser suite runs in CI)
  • Tests added
  • Docs updated (.env.example, Helm, docs/self-hosting.md, guidelines, skill, proposal, TODOS.md)
  • No breaking change (off by default)

🤖 Generated with Claude Code

nehalkumarsingh and others added 15 commits November 5, 2026 17:03
Folder editors get "Make this a book" on the folder page (or "Read as
book" once one exists), which opens an outline editor. The editor edits a
local draft: drag or Move up/down for chapters and parts, Move to part,
planned chapters, front and back matter, and a Not in outline list.
Chapter numbers follow the draft live. Save sends the base version and an
optional note; 422 problems show at their rows and 409 offers a reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#273 hid the button until the outline route existed. This PR adds the
route, so editors get the button again; readers still do not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The outline error screen shows only when there is no outline, so a
failed refetch after a save keeps the editor and its draft. It offers
Try again, retries outages like the other book reads, and neither the
outline nor the manifest query raises the global error toast: the page
explains its own errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The folder's book lookup answers 404 for every ordinary folder, and the
global query handler toasted it. The lookup now keeps its errors to
itself, and only a 404 offers Make this a book: after any other error
the folder may already have one, so the action shows nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The manifest's toc has chapters only, so every front and back matter row
read "Untitled document", and removing one put that name in the pool.
Titles now come from readingOrder, which has every document slot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rows were keyed by index, so after "Move Alpha down" the focused button
belonged to Beta and a second press undid the move. Rows now have stable
keys: the document id, or a client-only key for parts and planned
chapters that is dropped before the outline is compared or sent. After a
move, focus goes to the moved row's Move button in the same direction,
or the other one at an edge, across parts too.

Also: an empty subtitle no longer marks the draft changed, removePart
reuses poolEntry, the draft is cloned with structuredClone, the row
label reuses the row name, and the global-error spies in the tests are
typed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server prunes deleted and moved-out documents before it returns the
outline, so the draft matched it and Save stayed disabled while the
notice said saving would drop them. Save is now enabled while documents
were removed, and the notice says "Save to drop them". An empty
subtitle no longer counts as a change (test for the previous commit's
normaliser).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The banner came from the history state, which survives a save and a
refresh, so it kept showing the creation-time counts. The page now reads
the state once and clears it, and shows the banner only on the first
outline version. Reload refetches through the book's query key alone,
which covers the outline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops the canEditFolder alias; the R1 note moves to the call site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The main test is marked slow: it makes several page loads with nested
frames, a second browser context and throttled saves, which can pass
the default 30 s on a slow runner.

A viewport report that arrives before the reader has restored its place
is dropped, and nothing reports again until the next scroll, so a
one-shot wait for the position save could hang. The test now watches
for the save and scrolls again whenever it does not come.

A new test opens a chapter that fits on screen and checks that it is not
marked read when it opens (#272's reached-end rule).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guidelines told agents to pass --base-version <n>. The flag takes
the outline's version_id (bov_...), and an agent that passed the
outline number got a conflict on every push, then a "pull again" loop.
The guidelines and the skill now say to push the pulled file, whose
version_id is the base, and to pass --base-version only with a bare
outline, as the version_id. Both say the book commands work only when
Book mode is enabled on the server.

The heading-id guideline test checks only the review page; the join
over every page was redundant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… details

- Book search results come back in relevance order, not by chapter
  number.
- "Reached the end" follows the shipped rule: a scroll to the end in
  this visit, or 15 seconds on screen for a chapter that fits.
- Outline versions are listed through the API; the editor shows the
  current version number.
- With Book mode off the MCP server does not offer the book tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…titles

- The outline query refetches on every mount (no staleTime: Infinity) and
  the page shows its skeleton until this visit's fetch, so a returning
  editor never builds a draft on a cached version and then hits a
  conflict on Save. Focus and reconnect refetches stay off.
- The page also waits for the manifest, so placed rows never flash (or,
  when removed, stay) "Untitled document"; a manifest error still falls
  through to generic names.
- The "fits" browser test waits for a position save for the chapter before
  its 3 s no-reached_end window, so it cannot pass on a hook that dropped
  every report.
- self-hosting.md: the flag also disables /v1/folders/{id}/book.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nehalkumarsingh
nehalkumarsingh force-pushed the nehal/book-mode-6-reader branch from 1d5f068 to 7a20082 Compare November 5, 2026 12:13
@nehalkumarsingh
nehalkumarsingh force-pushed the nehal/book-mode-7-editor branch from f4fdea0 to 6dd1fe0 Compare November 5, 2026 12:13
@nehalkumarsingh

Copy link
Copy Markdown
Contributor Author

End-to-end test evidence (stack tip 6dd1fe0)

Ran a real slashdocs-server built from the branch tip (frontend build embedded, SLASHDOCS_BOOKS_ENABLED=true, Postgres 17 with every migration) and drove it with headless Chromium as three signed-in users. Blobs used the in-memory store and sessions were signed cookies, so there was no S3 and no Dex; the compose jobs in CI cover both.

Check Result
Walkthrough: 12 flows, each asserted through the API and the screen 12/12 pass
frontend/e2e on the same server 26/28. book-mode.spec.ts passes 4/4. The 2 failures need Dex: the public-view sign-in and the @mention picker. The stack changes none of that code.
Frontend unit tests 289/289
Go suite (Postgres-backed, 0 skipped) pass
golangci-lint v2.14.0 0 issues
Flag off every book route 404, no book buttons, chapters still open as documents

What this PR's code did in the run:

  • "Make this a book" on a folder opens the outline editor, seeded in title order.
  • Save stays disabled until an edit, and an edit to the subtitle and note saves (200).
  • With the flag off, the folder shows neither "Make this a book" nor "Read as book".
  • A note: a title whose number doesn't match its position (5 · Being on call as chapter 4) keeps its prefix. That is per the spec, but it could use a sentence in the authoring docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant