Skip to content

mac: fix residual discard-recovery edge cases (#811) - #879

Merged
jay3332 merged 1 commit into
mainfrom
mac/fix-811-discard-recovery
Sep 18, 2026
Merged

jay3332 merged 1 commit into
mainfrom
mac/fix-811-discard-recovery

Conversation

@jay3332

@jay3332 jay3332 commented Sep 18, 2026

Copy link
Copy Markdown
Member

Summary

Closes #811 — the four residual notes from #810's review.

  1. Stale partial snapshot → rolled back. keepDiscarded reads each member's prior snapshot before writing; on a later member's failure rollBackSnapshots restores the prior snapshot or removes the new one (reverse order). preserveDiscardedText now returns .kept/.clean/.failed(why) so the failure text is captured before rollback writes reset lastError. The note says which snapshots were withdrawn.
  2. Disabled restore hint → reworded. Member snapshots are only offered on 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.
  3. No-folder file → no false promise. With documentURL == nil the hint says "(this session only: it has no file, so no snapshot is kept)" and never names the snapshot command.
  4. Tests (in 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 without rules-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 — OK
  • FLASHTEX_NO_ACTIVATE=1 swift test --filter 'AutosaveTests|DirtySnapshotsTests|DocumentFilesTests|EditorMenuTests|CommandTableTests' — all pass (AutosaveTests 40/40)
  • Note: DesignSnapshots.ShellSnapshotTests/CompletionSnapshotTests (pixel comparisons) fail 15 on this host — verified identical on base 8017e3db, 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

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
@jay3332
jay3332 merged commit 93e2536 into main Sep 18, 2026
21 checks passed
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.

mac: residual discard-recovery edge cases after #810 (stale partial snapshots, disabled restore hint, no-folder files)

1 participant