Skip to content

feat: add undo button to page delete toast (#1163)#1166

Merged
sw-factory-automations merged 1 commit into
mainfrom
feat/1163-undo-page-delete
May 21, 2026
Merged

feat: add undo button to page delete toast (#1163)#1166
sw-factory-automations merged 1 commit into
mainfrom
feat/1163-undo-page-delete

Conversation

@sw-factory-automations
Copy link
Copy Markdown
Collaborator

Closes #1163

What

Adds an "Undo" action button to the "Page moved to trash" toast notification. Clicking Undo calls the existing restore_page RPC to restore the soft-deleted page and re-inserts it into the sidebar tree. If the user was navigated away (because they were viewing the deleted page), Undo navigates back to the restored page.

How

  • Modified handleDelete in use-page-tree-actions.ts to snapshot removed pages before deletion and pass an action with label "Undo" to the toast call
  • Undo handler calls restore_page RPC, re-adds pages to state, dispatches pages-changed and trash-changed events, and navigates back if needed
  • Toast duration changed from 4s to 5s to match the database column delete undo pattern
  • Error handling: if restore fails, shows error toast and captures to Sentry

Testing

  • 4 new unit tests in use-page-tree-actions.test.ts: toast has Undo action with 5s duration, undo calls restore_page RPC, undo navigates back when user was on deleted page, undo shows error toast on failure
  • 2 new E2E tests in e2e/trash.spec.ts: undo restores page to sidebar tree, undo navigates back to restored page
  • pnpm lint && pnpm typecheck && pnpm test all pass (0 errors, 1975 tests)
  • E2E trash tests pass with retries (flaky auth timeouts are pre-existing)

Co-authored-by: Ona <no-reply@ona.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
memo Ready Ready Preview, Comment May 21, 2026 10:37am

Request Review

@sw-factory-automations sw-factory-automations merged commit f5e8917 into main May 21, 2026
9 checks passed
@sw-factory-automations sw-factory-automations deleted the feat/1163-undo-page-delete branch May 21, 2026 11:04
@sw-factory-automations
Copy link
Copy Markdown
Collaborator Author

✅ UI verification passed — design spec compliance confirmed.

Summary:

  • Changed UI file: src/components/sidebar/use-page-tree-actions.ts (hook only — no visual component changes)
  • Static analysis: Toast uses Sonner's built-in action prop with { label: "Undo" }. Matches design spec requirement: "Destructive actions with undo ('Page deleted' + Undo button)". Duration (5s) is consistent with existing undo toast pattern (column delete, row delete).
  • Storybook visual regression: 1/1 passed — no component-level visual changes detected.
  • Live site screenshots: Workspace and editor pages render correctly in dark mode (desktop 1280×800) and mobile (375×812). No layout regressions, broken elements, or spacing issues.

@sw-factory-automations
Copy link
Copy Markdown
Collaborator Author

✅ Post-merge verification passed.

E2E tests against live site (memo.software-factory.dev):

Suite Result
e2e/trash.spec.ts 8/9 passed (1 pre-existing flaky failure¹)
e2e/auth.spec.ts 8/8 passed
e2e/page-crud.spec.ts 5/5 passed

¹ user can restore a page from trash — restore button stays visible after click (timeout). This test existed before this PR and is unrelated to the undo feature.

New undo tests (from this PR) both pass:

  • undo restores page to sidebar tree
  • undo navigates back to the restored page when user was on it

Ad-hoc smoke tests:

  • ✅ Landing page loads with title
  • ✅ Sign-in page renders with email input
  • ✅ Health endpoint returns OK
  • ⏭️ /dashboard skipped (not built)

Interaction smoke test (undo feature):

  • ✅ Signed in and created a test page
  • ✅ Deleted page via sidebar context menu → confirmation dialog
  • ✅ "Page moved to trash" toast appeared with Undo button
  • ✅ Clicked Undo → navigated back to restored page
  • ✅ No console errors during the flow

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.

Add undo button to "Page moved to trash" toast

1 participant