Skip to content

fix(app): group conversations by local calendar day, not raw UTC (#10198) - #10398

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
aryanorastar:fix/10198-conversation-local-day-grouping
Jul 23, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
aryanorastar:fix/10198-conversation-local-day-grouping

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

What

Conversations from today were missing from the conversations list but appeared under the date filter (#10198).

Root cause

started_at/created_at arrive from the API as UTC (ISO-8601 Z) and ServerConversation.fromGenerated keeps them UTC. The conversations list bucketed into day-groups by the timestamps' raw UTC calendar day (_buildGroupedByDate and the sibling groupers in conversation_provider.dart), while the date filter built its range from the local selectedDate (_getDateFilterRange).

So for any viewer east of UTC, an early-morning-local conversation is still the previous day in UTC → filed under "Yesterday", absent from "Today" — while the local-day filter still returns it. The report's 06:48-local screenshot fits a positive-UTC-offset device exactly.

Fix

Bucket by the local calendar day via a single shared conversationLocalDayKey(ts) => ts.toLocal() day-key, applied at every grouping site (main list, search, memory groupers, index lookup). Sorts stay on raw timestamps (ordering is timezone-independent). The already-local group-key normalizers (getConversationIndexById, getAdjacentConversation) are unchanged.

Tests

app/test/providers/conversation_local_day_key_test.dart — locks the helper's local-day-truncation contract and same-day/next-day bucketing.

Verification — please read

I don't have dart/flutter in my environment, so I could not compile or run the analyzer/tests locally — this PR relies on the Dart Analyze & Tests CI check to verify compile + tests. The change is mechanical (a shared .toLocal() day-key swapped in at each bucketing site).

And an honest limit on the test's reach: DateTime.toLocal() uses the ambient timezone, which is UTC in CI, so the unit test can't reproduce the UTC-vs-local divergence there — it locks the contract and catches a raw-UTC revert on a non-UTC host. The end-to-end proof is on-device in a UTC+ timezone.

Product invariants affected

none

Failure-Class: none

Review in cubic

…edHardware#10198)

started_at/created_at arrive as UTC (ISO-8601 Z) and are kept UTC, but the
conversations list bucketed into day-groups by their raw UTC year/month/day
while the date filter used the local selectedDate. For any UTC+ viewer an
early-morning-local conversation was filed under the previous (UTC) day, so it
vanished from the "Today" group even though the local-day filter still found it.

Bucket by the local calendar day via a shared conversationLocalDayKey helper at
every grouping site; sorts (tz-independent ordering) stay on the raw timestamps.

Fixes BasedHardware#10198.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bug fix (#10198): group conversations by local calendar day; scoped, test added, CI green — 5/5

@kodjima33
kodjima33 merged commit 49c98b6 into BasedHardware:main Jul 23, 2026
26 checks passed
kodjima33 added a commit that referenced this pull request Aug 1, 2026
…) (#10981)

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

`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

* test(app): anchor day-group sibling fixtures to local time

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants