Repository navigation
mac: replacing the project saves or snapshots every dirty document, not just the active one (#786, #789) - #804
Conversation
…ot just the active one (#786, #789) Open, New Project, fixture load, Reload from disk and Restore Discarded Buffer now go through one project-wide unsaved-edits resolution in DocumentFiles.swift. Save writes the entry and every dirty member and aborts the replacement on any failure or conflict. Discard snapshots each dirty member under its own path. Prompts list every dirty file. ProjectDocuments.saveConflict becomes a per-member map (saveConflicts), so two conflicted members no longer evict each other and autosave stops retrying them. Six new AutosaveTests cover these cases; all six fail against the old code. Implementation-Agent: Claude Opus 5 (daniel-parent subagent) Commit-Executor: daniel-parent (Claude Opus 5) Co-authored-by: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
|
Commander (daniel-parent): independent Opus review of PR #804 review — head 5b96697 (verified)"mac: replacing the project saves or snapshots every dirty document, not just the active one (#786, #789)" Reviewer: opus (independent, read-only). Scope: Material findingsNone. I found no path where this PR loses unsaved text or writes it to the wrong file, and no regression from main.
On a partial save-all failure with The discard snapshots are keyed correctly: the entry goes under
Non-blocking notes (recommended follow-ups)
Tests run
VERDICT: APPROVE |
…lash-tex#806) Follow-ups to flash-tex#804, which made replacing a project save or snapshot every dirty document. - Snapshot write failure: keepDiscarded now writes each dirty member's snapshot first and checks the result (preserveDiscardedText). If the store cannot keep a member's text, nothing is replaced (open, direct reload, fixture load all return .saveFailed), recoverableBuffer is untouched, and captureNote names the file and the store error; the text stays in the editor. - Recovery hints: Save/Discard prompts (Open, New Project, fixture load) and the open/reload notes now name the command per file: Edit > Restore Discarded Buffer for the entry, File > Restore Unsaved Snapshot… for members (discardRecoveryRoutes). - Reload: ReloadReview carries entryDirty and discardedMembers (bufferDirty is now derived). A direct reload's summary, shown by the conflict panel's Reload and by Reload from Disk, names the dirty members it also discards. - Fixture load records the discard only after the fixture decodes and validates (loadFixtures' beforeReplacing hook); a rejected fixture no longer overwrites the recoverable buffer or member snapshots. - Tests: privateSnapshots now points the model's store directly (the env override came after the store was created). New tests cover the private store, entry saved then member save failing, discard via fixture and via reload after an entry conflict, a rejected fixture, the open hint, a member conflict carried across a rename, and a failed snapshot write. Implementation-Agent: Claude Opus 5 (daniel-parent subagent) Commit-Executor: daniel-parent (Claude Opus 5) Co-authored-by: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
Fixes #786. Fixes #789.
Problem
When the project was replaced (Open, New Project, fixture load, Reload from disk), the app checked only the active document for unsaved edits. Edits in inactive member files were silently discarded. Separately,
ProjectDocuments.saveConflictheld one conflict at a time, so two conflicted members evicted each other and autosave kept retrying both.Change
DocumentFiles.swiftcovers the entry file plus every dirty member..blockedByUnsavedEdits.recoverableBuffer.openTexPanel/openTex), New Project, fixture load (the newloadFixturesReplacingProject), and the direct Reload from disk. The preview-controller reload still checks only the active document, because it changes only the entry text. Restore Discarded Buffer refuses while anything is dirty.saveConflictbecomes a per-member mapsaveConflicts: [String: DocumentConflict]with asaveConflict(for:)lookup. It is cleared on open and close, carried over on rename, and autosave skips conflicted members.Tests
AutosaveTestscover: open refused, discard snapshots the member, reload refused, fixture Save writes the member, fixture aborted on a member conflict, and two member conflicts both retained with neither retried.AutosaveTests|ProjectDocumentsTests|DocumentFilesTests|DirtySnapshotsTests|ShellModelTests|WorkspaceShellTests: 84 tests, 0 failures, 10 skipped. The skipped tests need helper binaries that aren't built locally.Independent review pending before merge.
🤖 Generated with Claude Code