Show every time in the system's time zone and follow its changes (#1001) #1005

Closed
charles wants to merge 0 commits from fix-1001-local-time into textchat
Owner

Closes #1001

Cause (confirmed)

messages::State::utc_offset (crates/fluxer-ui/src/screens/main/messages.rs) started at UtcOffset::UTC and nothing assigned it at run time (the only assignment copied it into the thread panel). The system offset read at startup (fluxer_platform::settings::local_utc_offset_minutes → LocalSettings::utc_offset_minutes) reached only the search (app.chat.search.utc_offset) and three core selectors (mutes, custom status ends, profile local time). The profile bio, forum guidelines and forum composer preview passed UtcOffset::UTC outright, and "Member since" and ban dates were formatted in UTC (short_date(ts.as_offset_date_time())). The existing test row_times_follow_the_utc_offset set the view's field by hand, which is why it never caught this.

The new UI test failed on origin/textchat with left: "23:30" right: "01:30" (a store loaded with a +02:00 system offset still showed UTC).

Fix

  • One source of truth: App::utc_offset() (a field on the store) plus App::local(ts). The startup load sets it from LocalSettings::utc_offset_minutes; the new CoreEvent::SystemUtcOffset { minutes } updates it, along with the search's copy and settings.utc_offset_minutes. It works before the load too. fluxer-core still does no I/O.
  • Refresh while running: dailyuse_rt::utc_offset_loop, run on the existing 15 s idle tick (idle_every), calls local_utc_offset_minutes() and sends the event only when the value changes. chrono::Local caches the zone and checks the system's at most once a second (on Unix it stats /etc/localtime and reads TZ), so each read is cheap. Tests can fake the source with Runtime::with_utc_offset.
  • messages::State::utc_offset is removed. Every view reads app.utc_offset(), and selectors::timeline / message_list default to it instead of UTC.

Places checked

Now in the system zone (via app.utc_offset() / app.local()):

  • message times, their full-date tooltips, compact-mode times and edited marks (message_row, RowCtx)
  • day separators and the "N new messages since …" bar (message_list_with_offset, new_messages)
  • <t:…> timestamps in messages and embed footers (RenderCtx, embed::display)
  • replies, search results, pins and inbox cards (card_ctx)
  • the thread panel (it shared the main view's copied field; now it reads the store) and the core thread preview (timeline)
  • forum post cards and the post list (clock tuple)
  • forum guidelines, the forum composer preview and the profile bio (were hard-coded UTC)
  • profile "Member since", both dates (selectors::profile)
  • ban details: banned on and expires (admin::bans)
  • the members page: date tooltips and the custom date range form
  • "Muted until", custom status "clear after", and the profile's "local time / ahead of you" (already read settings; now app.utc_offset())
  • search date parsing (kept in sync)

No absolute date or time to localise:

  • invites (relative countdown and created time)
  • the thread browser (relative)
  • the members page relative columns
  • attachment expiry (compared in Unix time)
  • the slowmode and barrier countdowns
  • the DM list and desktop notifications (they show no time)
  • the update banner (shows no date; published_at is only validated)

Stays UTC on purpose:

  • message_row::estimate_height's embed display: a height estimate with no App in reach, and the footer takes the same lines in any zone (commented).
  • Search query literals with an explicit Z.
  • The Timestamp wire format, and log and crash-file names.
  • Unit tests that pass UtcOffset::UTC explicitly.

Tests

  • fluxer-ui/tests/message_list.rs::row_times_follow_the_system_time_zone replaces the test that poked the view's field. The store is loaded with a +120 min system offset and rendered through messages::model with a default State, so it gets the offset the way the running app does. Then SystemUtcOffset { -300 } moves the same message to 18:30 on the previous day.
  • fluxer-core/tests/chat_persist.rs::the_system_offset_is_the_stores_and_follows_the_runtime covers UTC before the load, the load, a runtime change (search included), surviving a logout, an invalid offset becoming UTC, and an out-of-range instant staying in UTC.
  • admin_bans_invites.rs checks a ban at 09:30Z reads "Nov 13, 2026" at −10:00. profiles.rs checks a "Member since" join at 18:04Z reads "Oct 3, 2026" at +06:00.
  • apps/fluxer/tests/dailyuse_runtime.rs::system_utc_offset_followed_while_running runs the real runtime against the devserver with a faked offset source (60, then −300) and waits for the snapshot to follow.
  • Every test pins its offset explicitly; none depends on the machine's zone. Screenshot goldens are unchanged: the screenshot apps load no settings, so they stay UTC.

Gate

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: ==> xtask ci: all steps passed (livekit-interop skipped, as usual).

Windows

On Windows chrono::Local uses GetTimeZoneInformationForYear with the current system zone on every call; nothing is cached in-process, so a zone or DST change is picked up on the next tick. I could not run this on Windows. The Windows CI runner will build and test it, but nobody has checked by hand that a zone change made in Windows Settings is noticed while the app runs.

Follow-up

#1003: the profile bio, forum guidelines and forum composer preview also pass now_unix: 0, so <t:…:R> there counts from 1970. Separate bug, not fixed here.

🤖 Generated with Claude Code

Closes #1001 ## Cause (confirmed) `messages::State::utc_offset` (`crates/fluxer-ui/src/screens/main/messages.rs`) started at `UtcOffset::UTC` and nothing assigned it at run time (the only assignment copied it into the thread panel). The system offset read at startup (`fluxer_platform::settings::local_utc_offset_minutes` → `LocalSettings::utc_offset_minutes`) reached only the search (`app.chat.search.utc_offset`) and three core selectors (mutes, custom status ends, profile local time). The profile bio, forum guidelines and forum composer preview passed `UtcOffset::UTC` outright, and "Member since" and ban dates were formatted in UTC (`short_date(ts.as_offset_date_time())`). The existing test `row_times_follow_the_utc_offset` set the view's field by hand, which is why it never caught this. The new UI test failed on `origin/textchat` with `left: "23:30" right: "01:30"` (a store loaded with a +02:00 system offset still showed UTC). ## Fix - **One source of truth:** `App::utc_offset()` (a field on the store) plus `App::local(ts)`. The startup load sets it from `LocalSettings::utc_offset_minutes`; the new `CoreEvent::SystemUtcOffset { minutes }` updates it, along with the search's copy and `settings.utc_offset_minutes`. It works before the load too. fluxer-core still does no I/O. - **Refresh while running:** `dailyuse_rt::utc_offset_loop`, run on the existing 15 s idle tick (`idle_every`), calls `local_utc_offset_minutes()` and sends the event only when the value changes. `chrono::Local` caches the zone and checks the system's at most once a second (on Unix it stats `/etc/localtime` and reads `TZ`), so each read is cheap. Tests can fake the source with `Runtime::with_utc_offset`. - `messages::State::utc_offset` is removed. Every view reads `app.utc_offset()`, and `selectors::timeline` / `message_list` default to it instead of UTC. ## Places checked Now in the system zone (via `app.utc_offset()` / `app.local()`): - message times, their full-date tooltips, compact-mode times and edited marks (`message_row`, `RowCtx`) - day separators and the "N new messages since …" bar (`message_list_with_offset`, `new_messages`) - `<t:…>` timestamps in messages and embed footers (`RenderCtx`, `embed::display`) - replies, search results, pins and inbox cards (`card_ctx`) - the thread panel (it shared the main view's copied field; now it reads the store) and the core thread preview (`timeline`) - forum post cards and the post list (`clock` tuple) - forum guidelines, the forum composer preview and the profile bio (were hard-coded UTC) - profile "Member since", both dates (`selectors::profile`) - ban details: banned on and expires (`admin::bans`) - the members page: date tooltips and the custom date range form - "Muted until", custom status "clear after", and the profile's "local time / ahead of you" (already read settings; now `app.utc_offset()`) - search date parsing (kept in sync) No absolute date or time to localise: - invites (relative countdown and created time) - the thread browser (relative) - the members page relative columns - attachment expiry (compared in Unix time) - the slowmode and barrier countdowns - the DM list and desktop notifications (they show no time) - the update banner (shows no date; `published_at` is only validated) Stays UTC on purpose: - `message_row::estimate_height`'s embed display: a height estimate with no `App` in reach, and the footer takes the same lines in any zone (commented). - Search query literals with an explicit `Z`. - The `Timestamp` wire format, and log and crash-file names. - Unit tests that pass `UtcOffset::UTC` explicitly. ## Tests - `fluxer-ui/tests/message_list.rs::row_times_follow_the_system_time_zone` replaces the test that poked the view's field. The store is loaded with a +120 min system offset and rendered through `messages::model` with a default `State`, so it gets the offset the way the running app does. Then `SystemUtcOffset { -300 }` moves the same message to 18:30 on the previous day. - `fluxer-core/tests/chat_persist.rs::the_system_offset_is_the_stores_and_follows_the_runtime` covers UTC before the load, the load, a runtime change (search included), surviving a logout, an invalid offset becoming UTC, and an out-of-range instant staying in UTC. - `admin_bans_invites.rs` checks a ban at 09:30Z reads "Nov 13, 2026" at −10:00. `profiles.rs` checks a "Member since" join at 18:04Z reads "Oct 3, 2026" at +06:00. - `apps/fluxer/tests/dailyuse_runtime.rs::system_utc_offset_followed_while_running` runs the real runtime against the devserver with a faked offset source (60, then −300) and waits for the snapshot to follow. - Every test pins its offset explicitly; none depends on the machine's zone. Screenshot goldens are unchanged: the screenshot apps load no settings, so they stay UTC. ## Gate `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: `==> xtask ci: all steps passed` (livekit-interop skipped, as usual). ## Windows On Windows `chrono::Local` uses `GetTimeZoneInformationForYear` with the current system zone on every call; nothing is cached in-process, so a zone or DST change is picked up on the next tick. I could not run this on Windows. The Windows CI runner will build and test it, but nobody has checked by hand that a zone change made in Windows Settings is noticed while the app runs. ## Follow-up #1003: the profile bio, forum guidelines and forum composer preview also pass `now_unix: 0`, so `<t:…:R>` there counts from 1970. Separate bug, not fixed here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The message view kept its own `utc_offset`, which started at UTC and was never
set at run time; only the search read the offset the startup load got from the
system. Profile bios, the forum guidelines and the forum composer preview passed
UTC outright, and "Member since" and ban dates were formatted in UTC.

The store now holds the one offset (`App::utc_offset()`, `App::local()`): set by
the startup load and by the new `CoreEvent::SystemUtcOffset`, which the runtime
sends from its 15 s tick when `chrono::Local` reports a new offset (daylight
saving time, a changed system zone). Every view reads it; the field in
`messages::State` is gone.

Refs #1001

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #1001

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Merged by hand into textchat (8f270714) with the other open PRs; the combined tree passed the full gate locally, LiveKit interop included.

Merged by hand into textchat (8f270714) with the other open PRs; the combined tree passed the full gate locally, LiveKit interop included.
charles closed this pull request 2026-11-20 07:25:20 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.