Conversation
…save, and move diff work off the main thread
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This branch was successfully deployed
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
Defects left over from #2505 and the PRs that followed it, in one PR.
com.apple.TextEncoding; non-UTF-8 files did not open from Finder or File > Open File…PersistedTabRoundTripTestsEdits reverted by a sync's own echo
Root cause. The push cleared every pushed record's dirty flag, including a record the user edited again during the round trip. The pull that follows returned this Mac's own pushed copy and applied it over the newer edit, and the next sync found the record clean.
Fix.
SyncChangeTrackerkeeps a monotonic, in-memory edit generation per record. The push snapshots them before it reads any record and clears only the records not edited since.SyncEchoGuardthat withholds a record only when it was saved in this cycle and edited since. Withheld records are not cached. Connections are exempt, because their dirty branch already does a three-way merge.SyncPushInterruption), so the guard and the clearing use the real outcome.@MainActor, so the process-wide suppression during a pull cannot drop a mark made elsewhere.MainActorSerialQueue, so a local edit cannot land between a remote apply's check and its write.readAllFavorites) instead of an empty list.SyncTransportis a seam overCloudKitSyncEngine, so the push, clear and pull sequence runs in tests. The coordinator's push collection, deletion handling and settings code moved to extension files for the SwiftLint limits.Known limits.
Saved-query store stuck after a failed open
SQLFavoriteStorageset its prepared flag before opening. It now keeps a handle only after a successful open and retries on the next access.SQL file encodings
FileTextLoaderrecords how a file was read: the encoding, the byte order mark, and thecom.apple.TextEncodingattribute when that attribute alone identified it.FileTextWriterchecks that the text fits the encoding. It writes a hidden staging file in the target's folder, with the mark and the bytes in the original byte order, sets the attribute, copies the permissions, then renames it into place. A failure leaves the original untouched, and errors are reported as the matching write failure (no permission, out of space, read-only volume). Symbolic links are written through.Cmd+S, save on close, batch close), and the tab stays open. Save As writes UTF-8, which is how a file is converted. An ASCII-tagged file saves as UTF-8.FileTextLoader. An unreadable file now says so instead of failing silently.Measured on APFS and FAT32: UTF-8, UTF-8 BOM, UTF-16 LE/BE BOM, UTF-32 LE/BE BOM, attribute-only Shift_JIS, windows-1251, macintosh and UTF-16, the Latin-1 fallback, and an empty file all round-trip byte for byte, attribute and file mode included. A read-only tagged file still saves.
Known limit. Keep My Changes in the conflict sheet writes the tab's recorded encoding, even if another app has since converted the file.
Main-thread work
QueryPlanComparisonModel.makeContentis@concurrent. UnderSWIFT_APPROACHABLE_CONCURRENCY, a plainnonisolated asyncfunction runs on its caller's actor.StructureDefinitionDiffViewcomputes its diff once per input in.task(id:), followingFileConflictDiffSheet.Tests
All affected suites pass locally on current
main, plus theTableProSyncTestspackage suites. New suites:SyncCoordinatorEchoTests,SyncDirtyMarkingTests,SQLFavoriteStorageOpenTests,MainActorSerialQueueTests,PushOutcomeTests.SourceFileEncodingSaveTests,FileTextWriterTests,SQLFileOpeningTests,LinkedSQLFavoriteEncodingTests.StructureDefinitionDiffPresentationTests.No UI automation:
The unit tests drive the same entry points instead.
Deliberately not fixed here
Three changes were written, reviewed and removed, because review kept finding new defects in them:
markDirtyto cancel a pending tombstone for the same id.QuickSwitcherViewModelTests, because results arrived after the tests' flush point.