Skip to content

fix(app): resolve the conversation detail page by local day key (#10976) - #10981

Merged
kodjima33 merged 2 commits into
mainfrom
watchdog/issue-10976-conversation-detail-local-day
Aug 1, 2026
Merged

kodjima33 merged 2 commits into
mainfrom
watchdog/issue-10976-conversation-detail-local-day

Conversation

@kodjima33

@kodjima33 kodjima33 commented Aug 1, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #10976.

Bug

Opening a conversation whose local calendar day differs from its UTC day blanks the detail page. ConversationDetailProvider.conversationOrNull returns null for a conversation that is present in the day group the user just tapped, and the non-null conversation accessor throws StateError on the gesture paths (delete / rename / visibility).

It bites an evening conversation for any UTC+ viewer and a post-UTC-midnight one for any UTC- viewer — i.e. a slice of every day for most of the world.

Root cause

The list groups by conversationLocalDayKey(startedAt ?? createdAt) — the local calendar day (that function exists because bucketing by raw UTC filed early-morning-local conversations under the previous day, #10198 / #10398).

conversationOrNull then validated the resolved conversation by comparing the effective date's raw UTC year/month/day against selectedDate, which is one of those local-day group keys. Two different derivations of the same bucket, so they disagree exactly when local day != UTC day.

Same contract #10398 fixed for grouping, broken again in the consumer.

Fix

Compare through conversationLocalDayKey on both sides. One expression, no behavior change where the two already agreed.

Why CI stayed green

The existing regression test pinned one absolute timestamp (2026-07-18 23:30Z). That only trips the bug at some UTC offsets — red on a UTC+5:30 machine (how #10976 was found), green in UTC CI. The test now sweeps all 24 hours of a day, which exposes it at every non-zero offset. At UTC exactly the bug is unobservable and the old code correct, so no fixture can catch it there.

Second commit: the two-conversation fixtures in the same file pinned 09:00/11:00 UTC and asserted one day group — at UTC+14 / UTC-11 those land on different local days and keys.single threw before any assertion. Pre-existing red on main, unrelated to the getter, found while sweeping. Anchored to a fixed local day instead.

Tested

  • app/test.sh — 987 passed, in local America/New_York (UTC-4) and in TZ=UTC.
  • flutter test test/providers/conversation_detail_provider_selection_test.dart green in UTC, Asia/Kolkata, America/New_York, Europe/Berlin, Pacific/Auckland, Pacific/Kiritimati, Pacific/Midway, Australia/Adelaide.
  • The test fails without the fix: reverting only the lib/ hunk turns it red in America/New_York, Asia/Kolkata, Europe/Berlin, Pacific/Auckland (and green in UTC, as expected).
  • make preflight green.

Not exercised in a running app build — the assertion drives the production getter through the same seam the detail page uses.

Product invariants affected

none

Failure class (fixes)

Failure-Class: new

Registers FC-day-bucket-key-recomputed: a derived day-bucket key has one authority, and a consumer that re-derives it from raw UTC calendar fields reads a present record as absent for every viewer whose local day differs. Second instance of the cause behind #10398, so it gets a registry entry with a guard artifact (the sweeping contract test) rather than another one-off declaration.

🤖 automated by hourly watchdog — tested and merged

Review in cubic

`ConversationDetailProvider.conversationOrNull` validated the selected
conversation by comparing its raw UTC year/month/day against `selectedDate`.
`selectedDate` is a group key produced by `conversationLocalDayKey`, i.e. the
*local* calendar day — so the two disagree for every timestamp whose local day
differs from its UTC day: an evening conversation for a UTC+ viewer, a
post-UTC-midnight one for a UTC- viewer. The getter then reported a miss for a
conversation that is present in the selected group, blanking the detail page
the user just tapped (and throwing `StateError` from the non-null accessor on
the gesture paths).

This is the same contract #10398 fixed for grouping, broken again in the
consumer: compare through `conversationLocalDayKey` on both sides.

The existing regression test pinned one absolute timestamp, so it only tripped
at some UTC offsets — red on a UTC+5:30 machine, green in UTC CI, which is how
this reached main. It now sweeps all 24 hours, which exposes the bug at every
non-zero offset (it is unobservable, and the code correct, at UTC exactly).

Tested: `app/test.sh` (987 tests) green in local (UTC-4) and in TZ=UTC; the
single file green in UTC, Asia/Kolkata, America/New_York, Europe/Berlin,
Pacific/Auckland, Pacific/Kiritimati, Pacific/Midway, Australia/Adelaide; and
with the lib change reverted the new test fails in every non-UTC zone tried.

Failure-Class: new
The two-conversation fixtures pinned 09:00 and 11:00 UTC and then asserted a
single day group. At extreme offsets (UTC+14, UTC-11) those two instants land
on different local days, so `keys.single` threw `Bad state: Too many elements`
before any assertion ran — a pre-existing failure on main, unrelated to the
getter fix, found while sweeping timezones for it.

Anchor them to a fixed *local* day instead, so they share a group at any offset
while still being UTC instants like real server data.

Tested: this file green in UTC, Asia/Kolkata, America/New_York, Europe/Berlin,
Pacific/Auckland, Pacific/Kiritimati, Pacific/Midway, Australia/Adelaide (it
failed in the last two before this commit).

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Confidence score: 3/5

  • In app/lib/pages/conversation_detail/conversation_detail_provider.dart, the fallback assignment in ConversationDetailPage appears to use non-normalized conversation dates, so detail pages for conversations missing from the current grouped list can reject valid cached data around UTC midnight, causing users to lose access to that thread until refresh/reload—align the fallback with the same date normalization used by convers... to remove the boundary-time mismatch.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/lib/pages/conversation_detail/conversation_detail_provider.dart">

<violation number="1" location="app/lib/pages/conversation_detail/conversation_detail_provider.dart:95">
P1: Detail pages opened for a conversation absent from the current grouped list can now reject their cached conversation again near UTC midnight. Normalize the fallback assignment in `ConversationDetailPage` with `conversationLocalDayKey(effectiveDate)` so this validator receives the same group key.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

if (effectiveDate.year == selectedDate.year &&
effectiveDate.month == selectedDate.month &&
effectiveDate.day == selectedDate.day) {
if (conversationLocalDayKey(effectiveDate) == conversationLocalDayKey(selectedDate)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Detail pages opened for a conversation absent from the current grouped list can now reject their cached conversation again near UTC midnight. Normalize the fallback assignment in ConversationDetailPage with conversationLocalDayKey(effectiveDate) so this validator receives the same group key.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/pages/conversation_detail/conversation_detail_provider.dart, line 95:

<comment>Detail pages opened for a conversation absent from the current grouped list can now reject their cached conversation again near UTC midnight. Normalize the fallback assignment in `ConversationDetailPage` with `conversationLocalDayKey(effectiveDate)` so this validator receives the same group key.</comment>

<file context>
@@ -84,15 +84,15 @@ class ConversationDetailProvider extends ChangeNotifier with MessageNotifierMixi
-      if (effectiveDate.year == selectedDate.year &&
-          effectiveDate.month == selectedDate.month &&
-          effectiveDate.day == selectedDate.day) {
+      if (conversationLocalDayKey(effectiveDate) == conversationLocalDayKey(selectedDate)) {
         return _cachedConversation = result;
       }
</file context>

@kodjima33
kodjima33 merged commit e6db4d5 into main Aug 1, 2026
31 checks passed
@kodjima33
kodjima33 deleted the watchdog/issue-10976-conversation-detail-local-day branch August 1, 2026 16:05
kodjima33 added a commit that referenced this pull request Aug 1, 2026
… (#10994)

`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
@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.

conversation_detail_provider_selection_test fails on main — the different-days guard is red

2 participants