Repository navigation
fix(app): label import-history rows from the viewer's local day (#10984) - #10988
Merged
Merged
Conversation
`_buildJobCard` compared an import job's raw UTC `year/month/day` against a `today` built from local `DateTime.now()`, and rendered the raw UTC `hour`/`minute`. Both sides of a day comparison must come from the same authority: for any viewer off UTC the two disagree, so a row flips between the today / yesterday / absolute-date branches at the wrong boundary and prints the wrong clock time — an import started at 21:00 in New York rendered as "01:00" and on the following day. The formatting moves into `formatImportJobTimestamp`, which projects the timestamp with `toLocal()` before reading any component and takes the reference clock as a parameter so the behavior is testable. The yesterday key now uses calendar arithmetic (`day - 1`) instead of `today - Duration(days: 1)`, which lands at 23:00/01:00 on a DST transition day and never equals a midnight key. Fixes #10984 Failure-Class: FC-day-bucket-key-recomputed
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
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.
Bug
#10984 — every row in Settings → Import History labels the wrong day and shows the wrong clock time for any viewer whose local day differs from the UTC day.
Root cause
_buildJobCardmixed two clocks in one comparison (app/lib/pages/settings/import_history_page.dart):job.createdAtis a server timestamp (datetime.now(timezone.utc).isoformat(),backend/models/import_job.py:28) and parses UTC-flagged, sojobDateis its UTC day whiletodayis the local day. The row therefore flips between the today / yesterday / absolute-date branches at the wrong boundary, and each branch independently renders raw UTChour/minute.Second, latent defect on the same lines: the yesterday key used
today.subtract(const Duration(days: 1)), which on a DST transition day lands at 23:00 or 01:00 rather than midnight and never equals a day key.Fix
The formatting moves into a top-level
formatImportJobTimestamp(l10n, createdAt, {now}): it projects withtoLocal()before reading any component, so both sides of the comparison and the rendered time come from the viewer's local calendar; and it derives the yesterday key with calendar arithmetic (day - 1).nowis injectable so the branch behavior is testable.Not routed through
conversationLocalDayKey: that key is owned byConversationProviderand scoped to conversation grouping — importing the provider into a settings page to reuse three lines would be worse coupling than the duplication. If a shared local-day util lands, this is a caller to migrate.What I tested
New
app/test/unit/import_job_timestamp_test.dart(4 cases: today sweep over all 24 local hours, yesterday sweep over all 24 local hours, yesterday across all 366 calendar days, absolute-date branch, plus a widget case that renders the page's owncontext.l10nexpression from anImportJobResponse.fromJsondecode).TZ=UTC,America/New_York,Asia/Kolkata,Pacific/Auckland,Pacific/Kiritimati,Pacific/Midway.TZ=America/New_York: 24/24 hours wrong — e.g. local 20:30 rendered2/8/2026 at 00:30(tomorrow's date), local 00:30 renderedToday at 04:30.TZ=Asia/Kolkata: 24/24 wrong — local 00:30 renderedYesterday at 19:00.TZ=Pacific/Auckland: 24/24 wrong — local 00:30 renderedYesterday at 12:30.toLocal(), oldDuration(days: 1)key): 2/366 days wrong inAmerica/New_York(2026-03-08, 2026-11-01), 2/366 inPacific/Auckland(2026-04-05, 2026-09-27) — each degraded the yesterday row to the absolute date.app/test.sh: 995 tests passed.flutter analyzeon both changed files: no issues.dart format --line-length 120: clean.Not exercised in a running build: reaching this page needs a signed-in account with a real Limitless import job. The widget case drives the exact production expression (
formatImportJobTimestamp(context.l10n, job.createdAt!)) through a localizedBuildContextinstead.Product invariants affected
none (
scripts/pr-preflight --suggest)Failure class
A derived day-bucket key has exactly one authority; a consumer that re-derives it from raw UTC calendar fields disagrees with that authority for every off-UTC viewer. Same class as #10980 / PR #10987, which fixed the conversation-grouping instance and filed this one.
Failure-Class: FC-day-bucket-key-recomputed
🤖 automated by hourly watchdog — tested and merged