fix(sync): pulled rows keep local-only fields and newer offline edits #157

Merged
maximus merged 2 commits from issue-149-pull-keeps-local into master 2026-10-25 01:22:09 +00:00

2 commits

Author SHA1 Message Date
le king fu
aaa8cc2a27 fix(sync): never keep a local tag version on pull
The server has no updatedAt on tags and sends updated_at = created_at, so a
local tag rename always looked newer than the server row: after a sign-out /
sign-in, a stale phone rename overwrote a later web rename. Tags now always
take the server version on pull (an offline tag rename is lost, as before),
locked by a smoke source check. Lists and tasks keep the keepLocal rule.

Refs #149

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:15:28 -04:00
le king fu
0b8bf144df fix(sync): pulled rows keep local-only fields and newer offline edits
Move the construction of pulled rows into a pure, import-free module
(src/services/syncRules.ts) executed by node --test:

- pulled{List,Task,Tag}Values always build the full row; an existing row
  keeps its local createdAt, and a task keeps its calendarEventId (the
  server has no such column, so the pull used to null it);
- keepLocal: in a whole-account pull (since === SYNC_EPOCH), a local row
  strictly newer than the server copy is left untouched and re-queued in
  the outbox, so edits made while signed out survive the reconnection;
- server deletions still always apply; task-tag links are unchanged.

fullSync and initialReset use SYNC_EPOCH. REVIEW.md lists syncRules.ts
in the Haut table (Sync zone) with the new rules, and the smoke test
keeps the module import-free.

Refs #149

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 14:21:45 -04:00