fix(web): fall back to workspace timezone for time displays - #9796
fix(web): fall back to workspace timezone for time displays#9796Liewzheng wants to merge 1 commit into
Conversation
◈ PR Lens
Architecture 4 components touched across 2 lanes. Inside the changed components — 1 viewComponent view — Web timezone resolution Internal hook and UI components resolving timezones and observing workspace state Data flow
Drill down
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Time displays in the web app ignored the workspace timezone and mixed two different timezones on a single row:
home/user-greetings.tsxanduser/user-greetings.tsx: the clock time useduser.user_timezone(DB defaultUTCfor anyone who never picked one) while the greeting word, weekday and date used the browser timezone.profile/time.tsx(ProfileSidebarTime): used only the profileuser_timezone.workspaces.timezonewas only referenced by the settings page itself.This PR adds a shared resolver in
apps/web/core/hooks/use-display-timezone.tsand applies it to all three components. Resolution order:UTCtreated as "unset" — it is the database default, so a user who never chose a timezone is indistinguishable from one who deliberately picked UTC; the organization-declared workspace timezone is the better fallback for the common case (documented in code comments).useWorkspace().currentWorkspace.timezone).undefined, which makes the Intl APIs use the browser's local timezone.All fields on the greeting row (
hourused for the morning/afternoon/evening decision,date,weekDay,timeString) now share the same resolved timezone, fixing the inconsistency where the greeting word and the clock time could belong to different timezones. The three components are wrapped inobserversince they now read from the MobX workspace store.useTimeZoneConverter(project-vs-user comparison for scheduling views) was intentionally left untouched as its semantics differ.Type of Change
Test Scenarios
Asia/Hong_Kong, profile timezone unset (DB defaultUTC): home greeting shows12:33(workspace tz) instead of04:33(UTC), and the greeting word matches the displayed time.undefined.pnpm turbo run check:types --filter=web,pnpm check:lintand oxfmt all pass.References
Closes #9795