Skip to content

refactor: keep undo history per page instead of per tab - #9

Merged
ljm12914 merged 1 commit into
mainfrom
refactor/history-by-page
Nov 18, 2026
Merged

ljm12914 merged 1 commit into
mainfrom
refactor/history-by-page

Conversation

@ljm12914

Copy link
Copy Markdown
Member

Continues the bottom-up refactor after #8 (service layer, settings and IPC).

Undo history per page

  • One workspace-wide record net: a history tree per page plus one workspace tree for view tabs (calendar, lists, library).
  • A commit enters its source history and every page it changed, including pages that hold a synced copy of a changed block. The owner lookup is shared with page notifications and runs once per commit.
  • Undo and redo replay a whole record; every other history holding it gets a new replay record.
  • A safety net removes stale nodes and reattaches their children; emptying trash removes only records that touched the purged pages or blocks.
  • Closing a tab keeps its page history; closing the workspace clears all history.

API and settings

  • History calls take a history source instead of a tab id; adds the history:changed event and removes history:close-tab.
  • Page and paper writes pass the history source next to the tab id.
  • New history.limit setting (default unlimited); lowering it trims at once.

Verification

  • pnpm typecheck: 0 errors. Lint: 0 errors, 47 existing warnings.
  • DB baseline check passes; DB tools 5/5, services and IPC 221/221, feed 40/40.
  • pnpm perf: every absolute threshold passes. With 10,000 records over 100 pages, single-block commit and undo on a 10,000-block page stay near 10 ms P95; trimming to 100 records takes about 7 ms.
  • Script-driven Electron dev run: one page in two tab groups, edit in one and undo in the other, history kept after closing and reopening the tabs, undo from the calendar.
  • Not done: real-input smoke test, full build.

🤖 Generated with Claude Code

One workspace-wide record net with a history tree per page and one
workspace tree for view tabs. A commit enters its source history and
every changed page, reusing the owner expansion done for notifications.
Undo and redo replay whole records into the other holders; a safety net
prunes stale nodes; emptying trash prunes only records that touched the
purged objects. Closing a tab keeps history; closing the workspace
clears it. Adds the history.limit setting (default unlimited) and the
history:changed event, and removes history:close-tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ljm12914
ljm12914 merged commit be9b37f into main Nov 18, 2026
1 check passed
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