Repository navigation
Keep Modex responsive while importing files into notes - #261
Merged
Merged
Conversation
Before, Import files copied each file with copyFileSync on the main process: up to 50 files of 100 MB each. A real copy from another disk, a network share or an iCloud placeholder froze the whole window until it finished. Now the import awaits fs.promises.copyFile (same EXCL and FICLONE flags, same limits, errors still reported per file), and the IPC handler awaits it. Because other notes actions can now run while a copy is in flight, each file is copied into a hidden staging file in .modex/ and then hard-linked into the folder under a name chosen at that moment. A read never sees half a file, two imports of the same name into one folder both land (Report.md, Report 2.md), a link still never replaces anything, and a folder renamed or moved mid-import is followed by id. The staging file is always removed. A new test holds the copy open and checks that the import yields, that the folder shows nothing until the copy is done, and that a concurrent same-name import, a mid-copy rename and a failed copy all behave. It failed on main at its first assertion. Coven-Harness: Claude Code / claude-opus-5-5
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
# Conflicts: # docs/status.md
# Conflicts: # docs/status.md
This was referenced Oct 18, 2026
BunsDev
added a commit
that referenced
this pull request
Oct 19, 2026
… and the routines spec (#310) v0.2.0 was published on 2026-10-18 (23:14Z) from the signed tag on 01b1b8a. This follows Val's status layout (#290): - Shipped gains a v0.2.0 row linking its release and its review. - The 13 "On main, unreleased" items move unchanged to a new "Status summary" at the end of the v0.2.0 review, along with the old In flight entry. Each one was introduced by a commit in the tag (#248, #253, #254, #257 to #261, #263, #264, #266, #267, #269). The CF slices and #283's Markdown parser came after the tag, so they stay. - In flight keeps a short follow-ups entry for the gates no receipt records yet: the independent download checks, the banner upgrade on the release Mac, and the Companion 0.2.0 (7) TestFlight upload. - The routines spec and the README now say Phase 1, and most of Phase 0, ship from v0.2.0. Unchanged: the website's static fallback (apps/site/release.json) and the release evidence, which stay with the release owner. Claimed on #290. Coven-Harness: Claude Code / claude-opus-5-5
This branch was successfully deployed
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.
Part of #241 (finding 4: "Import copies on the main thread").
What was wrong
NotesStore.importFilescopied each file withfs.copyFileSyncon the Electron main process: up to 50 files of up to 100 MB each. A copy that is not an instant APFS clone (another disk, a network share, an iCloud placeholder that has to download) froze the whole window until every file had copied.What changed
importFilesis nowasync. It awaitsfs.promises.lstatandfs.promises.copyFilewith the sameCOPYFILE_EXCL | COPYFILE_FICLONEflags. The 50-file and 100 MB limits are unchanged, and errors are still collected and reported per file.notes:importIPC handler inapps/desktop/src/main/index.tsawaits it. The renderer (SpaceView→bridge.invoke("notes:import")) already awaited the IPC result, so it needs no change.writeFileDurablyandmoveNoClobber):.modex/, then hard-linked into the folder. A tree or page read never sees half a file. Without this, a half-copied.mdfile would be recorded as a page with a truncated first version.Report.mdinto the same folder at the same time both land, asReport.mdandReport 2.md. The link still never replaces anything..modex/is skipped by the folder watcher, so a large copy does not make Space re-read the folder.docs/status.md: one bullet under On main, unreleased.The legacy
space.jsonbackupcopyFileSyncat startup is a different path and is unchanged.One thing to know: if Modex crashes in the middle of a copy, a hidden
import-*.tmpfile can stay in.modex/. This is the same as any interruptedwriteFileDurablywrite, and it never appears in the notes.Regression test
apps/desktop/test/notes-tree.test.ts: "importing waits for each copy without blocking, and a file still copying never shows in the folder". The test replacesfs.promises.copyFilewith a version that copies the bytes and then waits until the test releases it. This is deterministic: there are no large files and no timing. The test checks that:.tmpfile is left anywhere under the notes folder.On unmodified
main, the test failed at its first assertion:'imported' !== 'copying'("the import waits for its copy instead of blocking until it is done"). The existing import test now awaits the call and usesassert.rejectsfor the target and 50-file checks. Its assertions are otherwise unchanged and it passes.What I ran
All of these ran in this worktree on the branch rebased onto
mainat 5efafc4 (#248), with the Mac heavily loaded:pnpm build: passed.pnpm test: passed. Worktree scripts 107/107, core 16/16, desktop 1,422 passed and 16 skipped of 1,438 with 0 failures, desktop packaging and update scripts 21/21, site 10/10, store-desktop 16/16. No unrelated flakes. A run before the rebase also passed: desktop 1,421 passed and 16 skipped of 1,437.node --test dist/test/notes-tree.test.js: 28/28 passed.pnpm exec playwright test e2e/notes-files.spec.ts(Import files… from the Notes menu, including a second import of the same file): 1 passed.Coven-Harness: Claude Code / claude-opus-5-5