Repository navigation
fix(studio): safe markdown-folder persistence that follows outside edits - #108
Merged
Merged
Conversation
… edits Data-loss fixes: - An element whose description was never opened lost it on the second save after a rename or move: its lazily-loaded body path went stale. Body paths now follow each write (serializeToMdFolderWithPaths). - Pruning deleted any top-level .json and anything under nodes/. Only the manifest, the known sidecars and node files with id/type frontmatter are pruned now (staleMdFolderFiles); "Save as folder…" asks before writing into a folder that holds other files but no model. - Overlapping saves could prune each other's files. Disk saves run one at a time per document and collapse into the newest payload; localStorage saves stay synchronous for the page-hide flush. - A slow load finishing after a document switch loaded into the new document, which autosave then overwrote. Loads are sequenced; an edit still in the debounce window is saved to the document being left. Outside edits: - MdFolderSession (@radical/common) keeps a baseline of the model files: it writes only changed files, refuses to write over files changed on disk since the last read, and polls for such changes. Electron keeps one per folder in the main process (1 s polling, like the --file watcher; native events are unreliable on external volumes); the web build keeps one per directory handle (2 s). - Autosave watches the active md document and reloads it on an outside edit, keeping the open view and selection. The disk wins. - Only model files are read (no walking node_modules); folder writes are confined to the model folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Save as folder, reload, renames that move unopened elements' files, edits made outside Studio, and files Studio must leave alone. The directory picker returns an OPFS directory the test can also edit. Runs in a persistent profile: Chromium crashes when an off-the-record page reads a stored directory handle back from IndexedDB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Makes models stored as a folder of Markdown files safe to use alongside other editors and git. Before this, Studio could silently lose descriptions, delete files it didn't write, and overwrite edits made outside it.
Data-loss fixes
.json(e.g.package.json) and anything undernodes/(e.g. a hand-writtenREADME.md). Now only the manifest, the known sidecars and node files withid/typefrontmatter are ever pruned. "Save as folder…" asks before writing into a folder that has other files but no model.Outside edits
MdFolderSession(packages/common/src/formats/mdFolderSync.ts, platform-free) remembers each model file's content and stamp (mtime + size) as last read or written:poll()reports such changes.--filewatcher, because native fs events are unreliable on external volumes. NewwatchFolder/onFolderChangedhost capabilities.node_modules. Folder writes can't leave the model folder.Tests
mdFolderSafety.test.tsfail on the old code; the other 2 exercise logic in@radical/commonthat wasn't reverted.apps/e2e/tests/studio/folders.spec.ts), 6 scenarios. The directory picker returns an OPFS directory that the test also edits directly, standing in for another editor. Turning off the rename fix or the watcher fails exactly the matching scenario.npm test,npm run typecheckand the full e2e suite pass locally (e2e: 51 passed; the 4known-issuestests aretest.failas before). The Electron build bundles the new main-process code. Not tried by hand in the desktop app.Still open
Listed in
docs/IMPROVEMENTS.mdunder "Markdown-folder persistence (review 2026-09-30)", among them:🤖 Generated with Claude Code