Skip to content

fix(app): key the synced-conversation pointer by the local day (#10980) - #10994

Merged
kodjima33 merged 1 commit into
mainfrom
watchdog/issue-10980-sync-pointer-day-key
Aug 1, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
watchdog/issue-10980-sync-pointer-day-key

Conversation

@kodjima33

Copy link
Copy Markdown
Collaborator

Bug

On the Processed Conversations page (synced_conversations_page.dart), tapping a synced row could open the detail page against the wrong conversation — the one previously cached — instead of the row that was tapped.

Root cause

ConversationSyncUtils._createPointer built each pointer's key from createdAt's raw year/month/day:

final date = DateTime(conversation.createdAt.year, conversation.createdAt.month, conversation.createdAt.day);

Server timestamps parse as UTC, so those are UTC fields. The conversation list groups by conversationLocalDayKey(startedAt ?? createdAt) — the viewer's local day. The pointer's key is handed straight to ConversationDetailProvider.updateConversation on tap, which looks the day-group up by that key:

final list = conversationProvider?.groupedConversations[date];
if (list != null) { ... }   // silently no-ops on a miss

The two keys disagree in two independent ways:

  1. UTC vs local — for any viewer off UTC whose local calendar day differs from the UTC one (evening ahead of UTC, post-UTC-midnight behind it).
  2. createdAt vs startedAt ?? createdAt — a conversation whose start and creation land on different days misses at every offset, UTC included.

On a miss the selection no-ops, so selectedDate/_cachedConversationId keep pointing at the previously opened conversation and conversationOrNull resolves to it. ConversationDetailPage's post-frame callback re-resolves the day correctly, so the wrong conversation is what the page renders until that callback runs.

Fix

Call the one authority, conversationLocalDayKey(startedAt ?? createdAt) — the same function the grouper uses — and expose the pointer builder (@visibleForTesting) so the guard file can drive it.

This is the fourth instance of FC-day-bucket-key-recomputed and the last call site in the conversation-grouping family that still re-derived the key; #10981, #10987 and #10988 fixed the others. No new guard surface is added because the class already has one — app/test/providers/conversation_day_key_call_sites_test.dart — and this call site joins it.

What I tested

  • Added the case to the class's existing guard file, which sweeps all 24 hours so a single pinned hour cannot stay green at the runner's UTC offset.
  • flutter test test/providers/conversation_day_key_call_sites_test.dart — passes in TZ=UTC, Asia/Kolkata, Europe/Berlin, America/Los_Angeles, Pacific/Kiritimati, Pacific/Midway.
  • With the lib/ change reverted, that same file fails +3 -1 in every one of those zones (including UTC, via the startedAt/createdAt divergence).
  • Full app suite flutter test: 996 passed, 0 failed.

Not exercised on a device: reproducing the original symptom needs a real device sync producing synced-conversation pointers. Verification here is the unit-level guard through the production call site.

Failure-Class: FC-day-bucket-key-recomputed

Refs #10980

🤖 automated by hourly watchdog — tested and merged

`ConversationSyncUtils._createPointer` built the pointer's `key` from
`createdAt`'s raw year/month/day. Server timestamps parse as UTC, so those are
UTC fields, while the conversation list groups by `conversationLocalDayKey`
over `startedAt ?? createdAt` — the local day. The pointer's key is handed
straight to `ConversationDetailProvider.updateConversation` when a row on the
Processed Conversations page is tapped, so whenever the two disagree (any
viewer off UTC near local midnight, or a conversation whose `startedAt` and
`createdAt` land on different days) the lookup found no group, the selection
silently no-opped, and the detail page rendered against whatever conversation
was still cached until the page's post-frame callback re-resolved the day.

Fourth instance of FC-day-bucket-key-recomputed, and the last call site in the
conversation-grouping family that still re-derived the key: it now calls the
one authority, like #10981, #10987 and #10988.

Tested: added the case to the class's existing guard file
`app/test/providers/conversation_day_key_call_sites_test.dart`, which sweeps
all 24 hours. `flutter test test/providers/conversation_day_key_call_sites_test.dart`
passes in TZ=UTC, Asia/Kolkata, Europe/Berlin, America/Los_Angeles,
Pacific/Kiritimati and Pacific/Midway, and fails (+3 -1) in every one of those
zones with the lib change reverted. Full `flutter test` suite: 996 passed, 0
failed.

Failure-Class: FC-day-bucket-key-recomputed
@kodjima33
kodjima33 merged commit 940fa68 into main Aug 1, 2026
26 checks passed
@kodjima33
kodjima33 deleted the watchdog/issue-10980-sync-pointer-day-key branch August 1, 2026 23:21
@undivisible undivisible added the AI label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants