Skip to content

Support for Undo#406

Draft
johankool wants to merge 19 commits intopointfreeco:mainfrom
johankool:feature/undo
Draft

Support for Undo#406
johankool wants to merge 19 commits intopointfreeco:mainfrom
johankool:feature/undo

Conversation

@johankool
Copy link
Contributor

An AI assisted implementation for adding undo support to SQLiteData. I have not yet tried out all features in full, and I think some parts could/should be rewritten better: using StructuredQueries more instead of SQL directly for example. I think the overall API seems quite nice but probably needs some more refinement. Marking this as draft until I am more confident in the code once I've integrated it in my actual app.

johankool and others added 19 commits February 21, 2026 20:48
Use #sql macro-based execution/fetch paths in undo setup, replay, and trigger helpers for safer SQL handling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Echo-backs from handleSentRecordZoneChanges now suppress undo recording
entirely via a new SyncChangeKind TaskLocal (.sent vs .fetched), threaded
through UserDatabase.write to UndoManager.writeSyncChanges. This prevents
redundant undo groups from CloudKit echo-backs.

Add SyncRedoPolicy (.clear/.preserve) to control whether the redo stack
is cleared when remote sync changes arrive, and hasSyncChangesSince(_:)
so delegates can detect intervening sync changes before confirming redo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Own-zone fetched changes (echo-backs or same-user-other-device writes) no
longer create sync undo groups. Only shared-zone changes from other users
are recorded on the undo stack, preventing local actions from appearing as
"Sync iCloud changes" entries.

- Add isSharedZoneChange property to UndoGroup to track zone ownership
- Add _isSharedZoneChange TaskLocal set at fetchedRecordZoneChanges based
  on CKCurrentUserDefaultName
- Thread isSharedZoneChange through UserDatabase → writeSyncChanges →
  recordSyncChanges → UndoGroup
- Suppress undo recording in writeSyncChanges when !isSharedZoneChange
  for .enabled sync undo policy
- Skip Foundation bridge registration for sync groups with .preserve
  redo policy to prevent Foundation from clearing its redo stack
- Update delegates (Reminders + Lithos) to only confirm undo for
  isSharedZoneChange groups
- Add tests for zone-aware recording suppression and delegation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant