fix(sync): insert the new inbox before merging, and redirect tasks sent to an archived inbox #154

Merged
maximus merged 2 commits from issue-145-inbox-merge-order into master 2026-10-25 01:21:54 +00:00

2 commits

Author SHA1 Message Date
le king fu
7b4331176d test(sync): pin the account filter of the archived-inbox redirection
A task sent to the caller's archived inbox must land in the caller's
active inbox, never in a more recent inbox of another account.

Refs #145

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 14:01:26 -04:00
le king fu
1bad78205d fix(sync): insert the new inbox before merging, and redirect tasks sent to an archived inbox
A list create with isInbox: true moved the tasks of the active inbox into
the new id before inserting it. sl_tasks.list_id -> sl_lists.id is not
deferrable, so the operation was skipped as soon as the old inbox held a
task, typically on the first sync of a second device.

The transaction now inserts the new inbox first, then merges every other
active inbox of the account into it. An insert that creates nothing (an id
already in the caller's account, such as an inbox pushed back by
initialMerge) merges nothing. Only one new inbox is created per POST; the
next one is skipped with "Only one new inbox per request". Task create and
update send a task aimed at an archived inbox to the active one.

REVIEW.md (Sync) states the exact rule.

Refs #145

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 13:58:22 -04:00