Skip to content

Restore trashed notes to where their folder moved - #258

Merged
BunsDev merged 5 commits into
mainfrom
notes-trash-rebase
Oct 16, 2026
Merged

BunsDev merged 5 commits into
mainfrom
notes-trash-rebase

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Part of #241 (finding 3: trashed notes keep stale original paths after moves).

What was wrong

Renaming or moving a workspace, project or folder rewrote the index paths of live notes only. A note trashed earlier (its trash.original), or deleted outside Modex (its original), still pointed at the old place. Restoring it made the old folder again. The reviewer's probe: trash a note in Personal/Notes, rename the project, restore. The note came back in a new Personal/Notes, a project with no marker, outside the linked Modex project. A note in a folder did the same: it came back in a copy of the folder at its old path.

What changed

notes-store.ts has a new rebaseOriginals(index, from, to). It rewrites the trashed and deleted originals under a moved folder. It is called from:

  • place(), for renames and tree moves of workspaces, projects and folders;
  • rebase(), for folder moves, including a folder note moved to a new parent page through save();
  • settle(), after a folder with a folder note is renamed. That rename goes through the settlement journal and calls neither place() nor rebase().

Trashed children of a live folder note were already placed by their parent page. They are unchanged.

Regression tests

  • notes-tree.test.ts: notes trashed before a {project rename, workspace rename, project move, folder rename, folder move} are restored where it went, without making the old place again. Each case trashes one note in the project and one in a folder, makes the change, and restores both. It then checks that both notes are in the new place, now and after a reopen, that no workspace, project or folder appears, and that the old folder path is not made again.
  • notes-store.test.ts: a file deleted outside Modex before its project is renamed is restored in the renamed project.
  • notes-store.test.ts: a note trashed from a plain folder inside a folder note is restored after the folder note's {move, rename}. This covers the rebase() path through save() and the settle() path.

All 8 failed on unmodified main, each restoring to the old path (for example Personal/Notes/Loose.md instead of Personal/Journal/Loose.md). With the fix they pass.

Verification

  • New tests on unmodified main: 8 of 8 failed. With the fix, every notes test file (notes-tree, notes-store, notes-projects, notes-files, notes-migration) passed: 80/80.
  • pnpm build && pnpm test from the worktree root, on top of 5efafc4 (Make Analytics look like the rest of Modex and fit the window #248): build passed. Unit tests: 1,445 total, 1,428 passed, 0 failed, 16 skipped, 1 timed out. The timeout was the unrelated demo waits for a slow turn to reach approval before auto-answering, which has a 5 s limit. The Mac's load average was in the hundreds, with other agents building. Rerun alone, demo.test.js passed 3/3.
  • An earlier full run, on f17608d, timed out a different unrelated test instead: runner-durable-admission's "a script completed before Store failure…", which has a 10 s limit. Rerun alone, that file passed: 16 passed, 1 skipped, 0 failed.
  • The .mjs tests that pnpm test runs last were skipped because of the timeout, so they were run on their own: 21/21 passed.

Coven-Harness: Claude Code / claude-opus-5-5

Before: renaming or moving a workspace, project or folder rewrote the
index paths of live notes only. A note trashed earlier, or deleted
outside Modex, kept its old original path, so restoring it made the old
folder again (for example Personal/Notes as a project with no marker,
outside the linked Modex project).

Now the trashed and deleted originals under the moved folder are
rewritten too: in place() for renames and tree moves, in rebase() for
folder moves, and after a folder is renamed through its folder note.

Coven-Harness: Claude Code / claude-opus-5-5
@vercel

vercel Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
modex Ready Ready Preview Oct 16, 2026 7:30am UTC

Request Review

@github-code-quality

github-code-quality Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

main 00e1e9d notes-trash-rebase 5347833 +/-
61% 61% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 16, 2026 07:57 UTC

@BunsDev
BunsDev merged commit bdc4bdf into main Oct 16, 2026
13 checks passed
@BunsDev
BunsDev deleted the notes-trash-rebase branch October 16, 2026 07:57

This branch was successfully deployed

1 active deployment
Preview — 53478337 Deployed Oct 16, 2026 by vercel[bot]
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