fix(sync): no merge across accounts, sync off until the first-sync choice #185

Closed
maximus wants to merge 5 commits from issue-165-account-switch into issue-178-sync-scheduler

5 commits

Author SHA1 Message Date
le king fu
532b628887 test(sync): pin the write-back of remapped outbox entries
Refs #165

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 21:12:51 -05:00
le king fu
0317d15266 fix(sync): queue the user's writes made during the first sync
Decision of Max at /pr-brief 185 (2026-11-03): a change made during the few
seconds of « Fusionner » (or « Charger ce compte ») must reach the server.
initialMerge and initialReset run while sync is still off, so writeOutboxEntry
dropped such a write. The outbox now also queues while a first sync runs, and
the merge points the pending entries that name the fixed local Inbox at the
server Inbox (remapInboxEntry), otherwise the server refuses them.

Refs #165

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 21:12:24 -05:00
le king fu
a5d0772345 Merge branch 'issue-178-sync-scheduler' into issue-165-account-switch 2026-11-03 20:41:37 -05:00
le king fu
7c4292a8bc docs(review): account rule of #165 and the sync's own outbox writes
Refs #165

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:10:55 -05:00
le king fu
38bcf8b893 fix(sync): no merge across accounts, sync off until the first-sync choice
Refs #165

A device holding another account's data (dataOwnerId, persisted, kept at
sign-out) only offers « Charger ce compte » (initialReset) or « Annuler »
(sign-out, data untouched), at sign-in and on « Synchroniser ». The rule
lives in syncRules.ts (firstSyncChoice).

Sync stays off until initialMerge or initialReset has succeeded, and the
scheduler refuses every sync while the local data belong to another account
(canSync): the outbox of the old account is never pushed under the new one.
The sync's own outbox writes (kept rows, the Inbox of initialReset) no
longer depend on syncEnabled, and the token getter follows the session, so
that the first sync runs with sync still off.

Sign-out pushes the outbox first (10 s at most, in the first-sync state of
the scheduler, one request reserved outside its budget) and warns with the
number of changes still unsent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:06:10 -05:00