Skip to content

Four conversation day-key call sites derive the key from raw UTC fields instead of conversationLocalDayKey #10980

Closed

Description

@kodjima33

Split out of #10976 / #10979, which fixed the same defect in ConversationDetailProvider.conversationOrNull.

The contract

Conversations are bucketed by conversationLocalDayKey(startedAt ?? createdAt) — the local calendar day (app/lib/providers/conversation_provider.dart:33, used by _buildGroupedByDate). Any code that looks a conversation up by day, or hands a day to ConversationDetailProvider.updateConversation, must derive its key the same way.

Sites that don't

Each reads .year/.month/.day straight off the timestamp. Server timestamps parse as UTC, so those are UTC fields — a different day from the group key for every user not at UTC whose conversation sits near their local midnight. Two also use createdAt alone where the grouping uses startedAt ?? createdAt.

  • app/lib/pages/chat/widgets/ai_message.dart:810 — DateTime(data.$2.createdAt.year, …); the miss makes idx == -1, so tapping a conversation link in chat silently does nothing.
  • app/lib/pages/onboarding/conversation_created_widget.dart:18 — same expression; the onboarding hand-off selects a day that has no group.
  • app/lib/pages/memories/widgets/memory_item.dart:199-200 (_getConversationDate, used by both _ensureConversationInGroup and the updateConversation call at :233) — inserts the conversation under one key and can select another.
  • app/lib/pages/conversation_detail/page.dart:210-211 — the fallback when getConversationDateAndIndex returns null sets selectedDate from raw components, so the detail page opens on a day key nothing is grouped under.

getConversationDateAndIndex (conversation_provider.dart:247) already routes through the helper and is the shape the rest should match.

Why it is filed rather than fixed

These are widget paths with no seam I could drive from a unit test, and #10979 only lands changes it can actually verify. Fixing them wants either a widget test per call site or pulling the lookup behind a testable provider method.

Found while fixing #10976 (conversationOrNull compared raw UTC fields against the local day key); these are the remaining instances of the same derivation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions