feat(pages): add page deletion with safe subpage reparenting - #49
Open
Pioneer113 wants to merge 4 commits into
Open
Pioneer113 wants to merge 4 commits into
Pioneer113 wants to merge 4 commits into
Conversation
…cover cleanup in tests
…document deletion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User workflow
Users can create pages, save AI drafts, organize subpages, and move pages within Spaces, but there was previously no way to delete unwanted or temporary pages.
This PR adds page deletion to the document workspace. When a user deletes a page, any nested subpages are reparented to the deleted page's parent (or moved to the root level if the deleted page was at the top level), so no child documents are lost.
Changes
src/server/pages.ts):Pages.delete(spaceId, id)runs in oneBEGIN IMMEDIATEtransaction. It reparents children (bumping theirrevisionso clients resync the new parent), removes the page'spage_threadsbinding, deletes the page, and validates the Space. It returnsfalsefor a missing page. NewPages.exists(spaceId, id)helper.src/server/page-routes.ts):DELETE /spaces/:spaceId/pages/:idreturns{ ok: true }or 404 for a missing page or Space. The review receipt endpoint (GET /conversations/:id/reviewed-page/:toolCallId) now returns{ deleted: true, pageId, spaceId }when the reviewed page was deleted, instead of a 404.SpaceWorkspaceremoves it, re-parents its children locally and keeps a tombstone so a stale poll cannot bring it back (mergePageSnapshototherwise never removes pages). It also drops the pending autosave and the dirty flag before navigating home, so the "Leave your unsaved page draft?" prompt does not appear for a page that no longer exists.PageReviewCardshows "Saved, then deleted" for such a review and lets the conversation continue (the agent is told not to link the page).docs/SETUP.mdlists page deletion.Design decisions
page_reviewsrows are kept on delete.createRevieweduses them for idempotent retries ("retries recover the same saved page"). Deleting them would let a retried approval silently recreate a deleted page. A retry after deletion now fails with 404 instead.page_threadsbinding is removed. The page's conversation thread stays in the configured Intelligence project; no Intelligence deletion call is made.Known limitations
PageService.conversation()call racing with a delete could leave an orphanedpage_threadsrow (no foreign keys in the schema). The window is small and the row is unreachable because lookups join againstpages.outcome.approved) still show an "Open page" link; it leads to a missing page if that page was deleted later. This predates this PR's receipt handling.Verification
npm test— 170/170 passed (also under Node 24.21).npm run typecheck,npm run lint,npm run check-format— passed.npm run build— succeeded.tests/pages.test.ts); DELETE route and deleted-review receipt (tests/page-routes.test.ts); deleted-review recognition (tests/page-review.test.tsx). The new regression tests fail on the code before the fix.Manual UI check (dev server, local)