Skip to content

[Bug]: Home calendar widget builds its day range from UTC midnight while the header uses local midnight #1920

Description

@h4yfans

Found while reviewing #1916 (fixes #1911). Confirmed, deliberately left out of that PR to keep it scoped.

What is wrong

Two places build "today" for the Home board and they disagree.

  • todayCalendarRange in apps/desktop/src/renderer/src/lib/home/calendar-widget-events.ts:85 takes the local date components and pins them to T00:00:00.000Z.
  • todayRangeIso in apps/desktop/src/renderer/src/components/home/home-header.tsx:20 uses setHours(0, 0, 0, 0), which is local.

In UTC-7, an event at 22:00 local is 05:00Z the next day. That falls inside the header's range and outside the widget's. The header counts an event the widget never shows, on the same board, in the same viewport.

A comment in that area claims the two share a query key. They do not.

Why it is not part of #1911

#1911 is about the widget never hearing that an event was created. This is about the widget asking for the wrong window once it does hear. Different bug, different fix, and folding it in would have made that PR's regression tests ambiguous.

Acceptance criteria

  • The widget and the header agree on the day boundary for every timezone offset, including negative offsets and half-hour offsets.
  • A test pins the disagreement case directly: a local-evening event in a westerly timezone appears in both the widget and the header count.
  • The E2E seeds for apps/desktop/tests/e2e/home-calendar-widget-refresh.e2e.ts are updated together with the fix; they currently build their seed day from local components to match todayCalendarRange's local-then-pin behaviour, and that coupling has to move with it.
  • The stale comment claiming a shared query key is corrected or deleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomplexity-lowLow complexity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions