Repository navigation
fix(renderer): timestamps follow a system time-zone change - #2466
Conversation
Four module-level Intl.DateTimeFormat instances were built without a timeZone, so they froze the zone the app loaded in: an inline <time> chip in assistant prose, the lane-share "Ends …" label and the issue due-date label kept the old zone until a restart, and the due-date label could show the wrong calendar day. Pin them to UTC and format a wall-clock-shifted Date, so the output is local time that follows the current zone with no rebuild timer. The chat transcript cache already rebuilds every minute and is unchanged. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit details
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. |
There was a problem hiding this comment.
Devin Review found 1 potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| export function wallClockAsUtc(date: Date): Date { | ||
| return new Date(date.getTime() - date.getTimezoneOffset() * 60_000); | ||
| } |
There was a problem hiding this comment.
🟡 Incorrect historical timestamps in chat
For historical instants with sub-minute zone offsets, wallClockAsUtc drops the offset seconds. Chat timestamps near a minute boundary then display the wrong minute even when the system zone never changes.
Learn more
timeEntity accepts valid zoned ISO timestamps from assistant prose without a lower date bound. ThreadEntityNode displays those instants with formatThreadEntityTimestamp. The previous formatter applied the zone's historical offset directly. The new helper uses getTimezoneOffset(), which returns whole minutes and drops offset seconds before the UTC formatter chooses what minute to print.
Example: With the system zone set to Europe/Paris, an assistant reply containing 1900-01-01T12:00:45Z previously displayed Jan 1, 12:10 PM in en-US. Paris used UTC+00:09:21 at that instant. The new helper shifts by nine minutes, so the same reply displays Jan 1, 12:09 PM.
Recommended fix: Copy the local calendar and clock fields into a UTC date instead of shifting by getTimezoneOffset(). Use setUTCFullYear to avoid JavaScript's special handling of years 0–99 in Date.UTC.
| export function wallClockAsUtc(date: Date): Date { | |
| return new Date(date.getTime() - date.getTimezoneOffset() * 60_000); | |
| } | |
| export function wallClockAsUtc(date: Date): Date { | |
| const wallClock = new Date(0); | |
| wallClock.setUTCFullYear(date.getFullYear(), date.getMonth(), date.getDate()); | |
| wallClock.setUTCHours(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()); | |
| return wallClock; | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
| export function wallClockAsUtc(date: Date): Date { | ||
| return new Date(date.getTime() - date.getTimezoneOffset() * 60_000); |
There was a problem hiding this comment.
Time-zone changes lack coverage
The new time-zone behavior has no regression test. The existing suites do not call wallClockAsUtc, formatThreadEntityTimestamp, or formatLaneShareEnd, so passing them does not check this fix. CI could miss stale labels or an incorrect offset shift.
Add a test that loads the formatters in one fixed zone, switches to another, and checks the next output. Also cover dates on both sides of a daylight-saving change.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/shared/formatting.ts
Line: 78-79
Comment:
**Time-zone changes lack coverage**
The new time-zone behavior has no regression test. The existing suites do not call `wallClockAsUtc`, `formatThreadEntityTimestamp`, or `formatLaneShareEnd`, so passing them does not check this fix. CI could miss stale labels or an incorrect offset shift.
Add a test that loads the formatters in one fixed zone, switches to another, and checks the next output. Also cover dates on both sides of a daylight-saving change.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Review follow-up: `Date.getTimezoneOffset()` truncates to whole minutes, so the offset arithmetic lost historical sub-minute (local-mean-time) offsets and could shift a old timestamp or due date by up to 59 seconds. Copy the local calendar and clock fields into a UTC date instead; it still follows a live zone change because the local getters read the current zone. Co-Authored-By: Claude Code <noreply@anthropic.com>
Why
Four module-level
Intl.DateTimeFormatinstances were built without atimeZone, so they froze the zone the app loaded in. After a system time-zone change, an inline<time>chip in assistant prose, the lane-share "Ends …" label and the issue due-date label kept the old zone until a restart; the due-date label could show the wrong calendar day.Same defect class as pingdotgg/t3code#32371, verified against ADE's formatters. The main chat timestamp cache already rebuilds every minute and was left alone.
What changed
Those four formatters are pinned to UTC and format a wall-clock-shifted
Date, so the output is still local time but follows the current zone with no rebuild timer. The same-day check, field sets, locale and output for an unchanged zone are identical.Evidence
threadEntitiesandlaneShareModelsuites pass (38 tests).npm --prefix apps/desktop run typecheckpasses.Date.getTimezoneOffset(), read at format time.Not checked
No new test: the affected formatters had no display tests, and a
process.env.TZtest would be machine-dependent. Not exercised with a live OS zone change. Full CI matrix not run locally.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with the earlier non-blocking test-coverage concern still open.Fix with agent prompt
Summary
Updates cached date formatters so labels use the current local time zone when formatted.
Reviews (2) · Last reviewed commit: "fix(renderer): build the wall-clock date..." · Reviewed by Greptile