Commit a0ef2ee
Fix sync replaying stale history on fresh tab
A fresh tab starts with lastEventId = 0, so the first poll to
/api/sync/events asked for "all changes id > 0 AND source != me".
Each tab generates its own crypto.randomUUID() sourceId, so changes
from prior sessions of the same browser are foreign and were returned
— up to 50 rows of history from the last 24 hours.
The client applies each event's `data` (a full row snapshot) over the
current store, so rapid clicks could "snap back" a few seconds later
as old per-item snapshots overwrote the just-clicked state, and
unrelated items would flip on as their old packed snapshots replayed.
On first poll (no Last-Event-ID header) return only the current max
changeLog id as a checkpoint with no events. The initial GET
/trip-items already reflects all prior changes, so we just need a
starting point for forward sync — there's nothing to replay.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 4b3ac7c commit a0ef2ee
1 file changed
Lines changed: 27 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
8 | 16 | | |
9 | 17 | | |
10 | 18 | | |
11 | 19 | | |
12 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
13 | 25 | | |
14 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
15 | 38 | | |
16 | 39 | | |
17 | 40 | | |
| |||
55 | 78 | | |
56 | 79 | | |
57 | 80 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 81 | + | |
64 | 82 | | |
0 commit comments