Repository navigation
fix(app): group conversations by local calendar day, not raw UTC (#10198) - #10398
Merged
kodjima33 merged 1 commit intoJul 23, 2026
Conversation
…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]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Conversations from today were missing from the conversations list but appeared under the date filter (#10198).
Root cause
started_at/created_atarrive from the API as UTC (ISO-8601Z) andServerConversation.fromGeneratedkeeps them UTC. The conversations list bucketed into day-groups by the timestamps' raw UTC calendar day (_buildGroupedByDateand the sibling groupers inconversation_provider.dart), while the date filter built its range from the localselectedDate(_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/flutterin 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