Repository navigation
A joining iPhone or iPad no longer makes a second Personal space - #1106
Conversation
…ing the account Root cause: SyncBridge.receive took the account on the first catch-up page that carried any space. The server sends a catch-up oldest change first, 500 records a page, so another space (ECI) can come pages before the account's first space. The rebuild then found no first space to merge the starting Personal into, imported it, and flushLocal pushed it as a new space. An iPhone that joined this way gave the account a second Personal, which every device, the iPad's sidebar foot included, shows. Taking the account from a batch now needs the line live; the catch-up's end already takes it in changed(.live), as a rejoin does.
…irst and deletes it Root cause: before the join waited for the whole catch-up, an iPhone could take the account on a catch-up page that had Work but not yet the first space. Its used starting Personal then had no first space to merge into, so flushLocal sent it up under a fresh id (browser-ids.json maps local.personal to it). The existing prune never removes it: it holds pages, and its maker is a living device. Only the device that made the copy repairs it, on each live line, beside pruneEmptyPersonals: its own mapping names the copy, the first space is in, the copy is still Personal with the house, has no sign-ins or folders, and holds no other device's tab of today. Its tabs go into the first space with the existing merge (pins pinned, kept kept), the moves are written, and the copy is deleted only once the journal holds nothing of it but blanks. One device only, because a tab's removal wins and two devices moving and deleting at once could lose a tab. The merge also no longer doubles a pin the first space already has at that address.
Three places decided whether a space is still the starting Personal: the join's merge (name only), the empty-Personal prune and the broken-join repair (name and house, trimmed). They now share isStartingPersonal(name:icon:), so the merge, too, treats a starting space given another icon as the person's own, as the repair already did. The merge's pin dedupe built its set from every pin of the first space, a pin with no address as "". Blank pins never reach the compare (isBlank drops them first), so no pin was lost, but the set now holds only real addresses and a test pins that two address-less pins are no duplicates.
SyncBridge.swift is over 3,000 lines, and the broken-join repair is a self-contained rule with its own tests. joinDuplicate, repairJoinDuplicate and isStartingPersonal move as they are into SyncBridge+JoinRepair.swift; the bridge's app, mirror and ids become readable (private(set)) and its log internal so the extension can reach them. No behavior change; SyncBridgeTests pass as before.
A first catch-up cut after a page (Work in, the first space not yet) left a journal with spaces. The next launch took the account from it before the line was up, and the starting Personal went up as a second Personal. The in-session path already waited for live; the launch path read "the journal holds spaces" as "caught up". The phone's own association file (browser-ids.json) now keeps a mark set when the line first reaches live, and a launch takes the account from the journal only with it. Fixture worlds and seeds keep today's rule: they have no saved association. Migration: a file saved before the mark existed is read as caught up. It is written only after the iPhone took the account, so an install that joined on an older build keeps taking it offline at launch.
[Medium impact] The changes affect iPhone joins and shared space records across devices. Fix the saved-pin deletion before merging; preserving split views also needs attention. FindingsSummaryThis PR waits for a full sync catch-up before adopting an account and repairs duplicate Personal spaces on the device that created them.
Two repair cases need attention: distinct saved pins can be deleted, and Mac split views are lost. The iOS tests were not run here.
|
| let pinned = Set(first.pins.filter { !isBlank($0) }.compactMap { $0.url.map(address) }) | ||
| for tab in start.keptTabs where !isBlank(tab) && !have.contains(tab.id) { out.kept.append(.tab(tab)) } | ||
| for tab in start.pins where !tab.isPrivate && !isBlank(tab) && !have.contains(tab.id) { out.pins.append(tab) } | ||
| for tab in start.pins where !tab.isPrivate && !isBlank(tab) && !have.contains(tab.id) && !pinned.contains(tab.url.map(address) ?? "") { |
There was a problem hiding this comment.
Distinct saved pins get deleted. The new filter compares each pin's current
url, not its saved home. On a Mac, pins with different saved addresses can both navigate to the same page, such as a sign-in page. If one is in each Personal space, repair drops the copy's pin and flushLocal() deletes its record everywhere, including its distinct saved address. Compare saved addresses from the sync records, falling back to the current address only when no home exists.
| flushLocal() | ||
| let row = engine.row(copy) | ||
| guard row.folders.isEmpty, (row.all + row.elsewhere).allSatisfy({ Self.blankURL($0.url) }) else { | ||
| log.notice("sync: the second Personal still holds tabs; its delete waits") | ||
| return true | ||
| } | ||
| log.notice("sync: moved the second Personal a broken join made into the first space") | ||
| deleteSpace(local) |
There was a problem hiding this comment.
Repair loses Mac split views. A duplicate Personal can contain two shared pins or kept tabs paired on a Mac and still pass these checks.
flushLocal() moves the tabs, but PhoneSync.move leaves their SyncPair records under the copy. deleteSpace then removes those records, so the Mac loses the saved split view. Move pairs whose tabs survive into the first space too, or skip such copies before moving their tabs.
What changes
When an iPhone or iPad joins sync, it no longer makes a second Personal space. A device that already made one moves its tabs back into the first Personal and deletes the copy, by itself.
Part 1 of 4 replacing #1049. It stands alone on
main.Why it happened
A joining device took the account after the first page of the catch-up, before the Mac's spaces had arrived. With no Personal in sight it made its own, so the account ended up with two Personal spaces, and the sidebar foot showed the same icon twice.
SyncBridgenow takes the account only when the line is.live, meaning the whole catch-up is in.browser-ids.json. Files from before this change read as caught up, so devices already in sync are not affected.SyncBridge+JoinRepair.swift):00000000-…0001) and drops pins that are already there by URL.docs/sync.mddescribes the rule.Ruled out:
Proof
SyncBridgeTests, new tests that fail onmainand pass here:Checked on
Checklist
SyncBridgeTestsandHistoryTests: iPad 99/99, iPhone 75/75.main:testTheJoinSheetComesBackUntilThisIPhoneIsInandtestTheRecoveryKeyLetsTheIPhoneInfail when run afterBrowserKeysTests.testAPushInTheBackCatchesUpAndClosesTheLineis flaky onmaintoo../design-check --base origin/mainandscripts/swift-parse-check --base origin/mainare clean.