Repository navigation
Conversation
`ConversationDetailProvider.conversationOrNull` validated the resolved conversation by comparing the raw year/month/day of its effective date (`startedAt ?? createdAt`) against `selectedDate`. Server timestamps parse as UTC, so those are UTC fields, while `selectedDate` is the *local* day key `conversationLocalDayKey` produced when grouping. Wherever a conversation's local calendar day differs from its UTC one — started late in the UTC day ahead of UTC, or at the start of it behind — the check failed for a conversation sitting in the selected day-group, so the getter returned null: a blank detail page on build paths, `StateError` from the non-null getter on gesture paths. Both sides now go through `conversationLocalDayKey`, the same function the grouping uses, so the getter can only accept or reject the key the grouper produced. The regression test derived its instant from a pinned 23:30 UTC, which only diverges ahead of UTC — it was green on every host behind it, including CI at UTC, where local and UTC days can never diverge at all. It now derives the instant from the host's offset at that date so the divergence is constructed on either side of UTC. Verified: `flutter test test/providers/conversation_detail_provider_selection_test.dart` fails on the parent commit and passes on this one under TZ=Europe/Berlin, Asia/Tokyo, Asia/Kathmandu, Pacific/Kiritimati, America/New_York, America/Los_Angeles and Pacific/Midway; full suite `bash app/test.sh` is 987 passed / 0 failed (was 957/1 on main). fixes #10976
The two sibling-identity tests in this file pinned their fixtures to UTC instants two hours apart, which straddle local midnight at far-enough offsets and split into two day groups — `groupedConversations.keys.single` then threw `Bad state: Too many elements` under TZ=Pacific/Kiritimati (+14) and Pacific/Midway (-11). Neither test is about UTC/local divergence; both need one group. Anchoring them in local time gives that in every timezone. Verified: the file passes under TZ=UTC, Europe/Berlin, Asia/Tokyo, Asia/Kathmandu, Australia/Sydney, Pacific/Kiritimati, Pacific/Midway, America/New_York and America/Los_Angeles.
There was a problem hiding this comment.
2 issues found across 2 files
Confidence score: 3/5
- In
app/lib/pages/conversation_detail/conversation_detail_provider.dart, fallback/external-entry flows can misinterpret a raw UTC calendar date as a local day, soselectedDatemay not match the intended conversation on non-UTC devices and resolve to null for users — normalize these paths to the same timezone/day semantics before lookup (e.g., convert to local-day or keep everything UTC consistently). - In
app/test/providers/conversation_detail_provider_selection_test.dart, the regression test can pass on UTC hosts without actually validating the local-vs-UTC day split, which leaves this bug class underprotected in CI depending on runner timezone — make the test timezone-explicit/deterministic so it fails when day-boundary handling regresses.
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:94">
P2: Conversation details opened through the fallback or external-entry paths can still resolve to null on non-UTC devices: those paths pass a raw UTC calendar date, while this line interprets `selectedDate` as a local-day key. Normalizing those remaining date arguments with `conversationLocalDayKey` (or passing the grouper's key through every entry path) would keep the validation consistent.</violation>
</file>
<file name="app/test/providers/conversation_detail_provider_selection_test.dart">
<violation number="1" location="app/test/providers/conversation_detail_provider_selection_test.dart:132">
P3: The new regression test only exercises the local-vs-UTC day divergence on non-UTC hosts: on a UTC host _instantSplittingUtcAndLocalDay() returns 23:59 UTC where the local and UTC calendar days coincide, so the getter's day-key comparison takes the trivial equality path and the test asserts plain resolution. Because CI runs at UTC, this test won't catch a future reintroduction of the raw-UTC comparison bug that caused #10976. Consider pinning the process timezone (e.g., set TZ=/var/run/... to a non-UTC zone in the test, or inject a clock/timezone) so the regression path is exercised deterministically in CI.</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)) { |
There was a problem hiding this comment.
P2: Conversation details opened through the fallback or external-entry paths can still resolve to null on non-UTC devices: those paths pass a raw UTC calendar date, while this line interprets selectedDate as a local-day key. Normalizing those remaining date arguments with conversationLocalDayKey (or passing the grouper's key through every entry path) would keep the validation consistent.
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 94:
<comment>Conversation details opened through the fallback or external-entry paths can still resolve to null on non-UTC devices: those paths pass a raw UTC calendar date, while this line interprets `selectedDate` as a local-day key. Normalizing those remaining date arguments with `conversationLocalDayKey` (or passing the grouper's key through every entry path) would keep the validation consistent.</comment>
<file context>
@@ -84,15 +84,14 @@ 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>
| /// a DST boundary between the two cannot flip which side it falls on. | ||
| DateTime _instantSplittingUtcAndLocalDay() { | ||
| final offset = DateTime.utc(2026, 7, 18, 12).toLocal().timeZoneOffset; | ||
| return offset.isNegative ? DateTime.utc(2026, 7, 18, 0, 0) : DateTime.utc(2026, 7, 18, 23, 59); |
There was a problem hiding this comment.
P3: The new regression test only exercises the local-vs-UTC day divergence on non-UTC hosts: on a UTC host _instantSplittingUtcAndLocalDay() returns 23:59 UTC where the local and UTC calendar days coincide, so the getter's day-key comparison takes the trivial equality path and the test asserts plain resolution. Because CI runs at UTC, this test won't catch a future reintroduction of the raw-UTC comparison bug that caused #10976. Consider pinning the process timezone (e.g., set TZ=/var/run/... to a non-UTC zone in the test, or inject a clock/timezone) so the regression path is exercised deterministically in CI.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/test/providers/conversation_detail_provider_selection_test.dart, line 132:
<comment>The new regression test only exercises the local-vs-UTC day divergence on non-UTC hosts: on a UTC host _instantSplittingUtcAndLocalDay() returns 23:59 UTC where the local and UTC calendar days coincide, so the getter's day-key comparison takes the trivial equality path and the test asserts plain resolution. Because CI runs at UTC, this test won't catch a future reintroduction of the raw-UTC comparison bug that caused #10976. Consider pinning the process timezone (e.g., set TZ=/var/run/... to a non-UTC zone in the test, or inject a clock/timezone) so the regression path is exercised deterministically in CI.</comment>
<file context>
@@ -112,6 +122,19 @@ void main() {
+/// a DST boundary between the two cannot flip which side it falls on.
+DateTime _instantSplittingUtcAndLocalDay() {
+ final offset = DateTime.utc(2026, 7, 18, 12).toLocal().timeZoneOffset;
+ return offset.isNegative ? DateTime.utc(2026, 7, 18, 0, 0) : DateTime.utc(2026, 7, 18, 23, 59);
+}
+
</file context>
|
Superseded — the same fix landed in #10981 ( 🤖 hourly watchdog |
|
Hey @kodjima33 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
What
ConversationDetailProvider.conversationOrNullvalidated the conversation it resolved by comparing the rawyear/month/dayof its effective date (startedAt ?? createdAt) againstselectedDate. Server timestamps parse as UTC, so those are UTC fields — whileselectedDateis the local day key thatconversationLocalDayKeyproduced when grouping.Both sides now go through
conversationLocalDayKey, so the getter can only accept or reject the very key the grouper produced.Why
Wherever a conversation's local calendar day differs from its UTC one — started late in the UTC day ahead of UTC, or at the start of it behind — the check failed for a conversation that is sitting in the selected day-group, and the getter returned null:
conversationOrNull) render a blank detail page;conversation) throwStateError: No valid conversation found.That is every user whose device is not at UTC, for any conversation near their local midnight.
Reported in #10976 as a red test on
main. It is not fixture rot: the fixture was pinned at23:30UTC, which only diverges ahead of UTC, so the guard was green on every host behind UTC — including CI, which runsubuntu-latestat UTC, where local and UTC calendar days can never diverge at all. That is why the defect shipped and why the test looked fine here until someone ran it from a positive offset.Second commit
The two sibling-identity tests in the same file pinned fixtures to UTC instants two hours apart. Those straddle local midnight at far-enough offsets and split into two day groups, so
groupedConversations.keys.singlethrewBad state: Too many elementsunderTZ=Pacific/Kiritimati(+14) andPacific/Midway(-11). Neither test is about UTC/local divergence — both just need one group — so they are anchored in local time.What I tested
flutter test test/providers/conversation_detail_provider_selection_test.dart, run per timezone, on the parent commit and on this branch:Pacific/MidwayAmerica/Los_AngelesAmerica/New_YorkUTCEurope/BerlinAsia/KathmanduAsia/TokyoAustralia/SydneyPacific/Kiritimati¹ Stated plainly: at UTC the two calendar days cannot diverge, so the case under test cannot be constructed and the guard asserts only plain resolution there. CI runs at UTC, so CI will not catch a regression of this bug — the guard is real on every developer machine outside UTC, and inert on the runner. Pinning
TZfor the app test lane would fix that, but it changes the CI workflow and is out of scope here.Also run:
bash app/test.sh→ 987 passed, 0 failed (issue reports 957 passed / 1 failed onmain).dart format --line-length 120→ 0 changed.make preflight→ passing.Not exercised in a running app build: this is a pure provider-lookup path with no UI change, covered by the unit test above driving the real
groupConversationsByDate→updateConversation→conversationOrNullsequence.Notes
app/scripts/analyze_ratchet.shis red on my machine, onmainas well as here, from onedeprecated_member_use_from_same_packageongetDeviceImagePathByModel(lib/pages/conversations/wal_item_detail/wal_item_detail_page.dart:634). That is a local-toolchain artifact, not a repo state: the same run reportsexperimental_member_use0-found against a baseline of 13, and this box is on Flutter 3.38.5 while CI takes currentstable. CI's own ratchet is green onmain. Nothing here touches either file.conversationLocalDayKey(chat/widgets/ai_message.dart,onboarding/conversation_created_widget.dart,memories/widgets/memory_item.dart,conversation_detail/page.dartfallback). Same defect class, but in widget code I cannot unit-verify, so per the repo's "only make an opportunistic fix you can verify" rule they are filed as Four conversation day-key call sites derive the key from raw UTC fields instead of conversationLocalDayKey #10980 rather than changed blind.Failure-Class: none
fixes #10976
Auto-generated from issue feedback by the mini issues-improver — tested and merged.