Repository navigation
mac: fix residual discard-recovery edge cases (#811) - #879
Merged
Merged
Conversation
Follow-ups from #810's review: 1. Stale partial snapshot: keepDiscarded now records, per dirty member, the snapshot the file had before its write. When a later member's write fails the attempt is aborted (as before) and rollBackSnapshots puts each earlier file back to its previous snapshot, or removes the one just written. Nothing was discarded, so nothing stays on disk to be offered as "discarded" after the user later edits and saves it. preserveDiscardedText returns kept/clean/failed(why) so the failure text is captured before the rollback's writes reset the store's lastError. 2. Disabled restore hint: File > Restore Unsaved Snapshot… is enabled only once the member is open again under its project (member snapshots are offered on openDocument), so the discard hint and the reload summary now say "once main.tex and chapter.tex are open again" rather than pointing at a disabled item. The menu's enablement is unchanged: widening it would need cross-project restore in restoreDirtySnapshot, which is neither trivial nor safe. 3. No project folder: a buffer with no file (documentURL nil) has no root, so no snapshot can be written; it goes to the session slot only. The hint now says "this session only: it has no file, so no snapshot is kept" and never names the snapshot command. Members without a root (not reachable today) get "discarded without a snapshot" rather than a promise. 4. Tests (AutosaveTests, next to the #806 block): fixture rejection via the layout-capability check (a rule item with rules-v1 not accepted) records no discard; two dirty members where the second write fails roll back the first (restored to an earlier session's snapshot, or removed) and a later edit-and-save is not shadowed; a no-file buffer discard promises no snapshot; the reopen wording is asserted. Implementation-Agent: Claude Code (mac-claude-a) Commit-Executor: git via Claude Code Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
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.
Summary
Closes #811 — the four residual notes from #810's review.
keepDiscardedreads each member's prior snapshot before writing; on a later member's failurerollBackSnapshotsrestores the prior snapshot or removes the new one (reverse order).preserveDiscardedTextnow returns.kept/.clean/.failed(why)so the failure text is captured before rollback writes resetlastError. The note says which snapshots were withdrawn.openDocument, so widening the menu item would need cross-project restore logic. Hint now: "chapter.tex via File > Restore Unsaved Snapshot… once main.tex and chapter.tex are open again". No menu title changed.documentURL == nilthe hint says "(this session only: it has no file, so no snapshot is kept)" and never names the snapshot command.AutosaveTests.swift, next to the mac: unsaved-member discard follow-ups after #804 (snapshot write unchecked, wrong recovery hint, Reload widens discard) #806 block with the fixtures): capability-check fixture rejection (rule item withoutrules-v1); two-member partial failure with rollback to the prior snapshot and to none; no-file discard; reopen wording. One existing substring assertion updated.Test plan
cd apps/mac && swift build— OKFLASHTEX_NO_ACTIVATE=1 swift test --filter 'AutosaveTests|DirtySnapshotsTests|DocumentFilesTests|EditorMenuTests|CommandTableTests'— all pass (AutosaveTests 40/40)DesignSnapshots.ShellSnapshotTests/CompletionSnapshotTests(pixel comparisons) fail 15 on this host — verified identical on base8017e3db, pre-existing reference mismatch, unrelated.Implementation-Agent: Claude Code (mac-claude-a, Fable subagent)
Commit-Executor: git via Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn