The best way to control Claude Code, Codex and more from any computer or phone
fix(web): time-based labels update under the React Compiler (#21026)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 17, 2026 at 15:56 UTC
e712d9781535ac10cea4ead2d2ccc33b7bb04f2b
19 files changed
+144
-75
apps/web/src/components/LegacySidebar.tsx
+4
-4
@@ -131,7 +131,7 @@ import { threadEnvironment, useEnvironmentThread } from "../state/threads";
131
import { useEnvironment, useEnvironments, usePrimaryEnvironmentId } from "../state/environments";
132
import { buildThreadRouteParams, resolveActiveThreadRouteRef } from "../threadRoutes";
133
import { stackedThreadToast, toastManager } from "./ui/toast";
134
-import { formatRelativeTimeLabel } from "../timestampFormat";
134
+import { RelativeTime } from "./RelativeTime";
135
import { Kbd } from "./ui/kbd";
136
import {
137
getArm64IntelBuildWarningDescription,
@@ -874,9 +874,9 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
874
isHighlighted ? "text-foreground" : "text-secondary-label"
875
}`}
876
>
877
- {formatRelativeTimeLabel(
878
- thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt,
879
- )}
877
+ <RelativeTime
878
+ timestamp={thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt}
879
+ />
880
</span>
881
)}
882
</span>
apps/web/src/components/RelativeTime.tsx
new
+9
@@ -0,0 +1,9 @@
1
+import { useRelativeTimeState } from "../hooks/useRelativeTimeState";
2
+
3
+// A "5m ago" label that keeps counting. Formatting the label inline in render
4
+// does not: the React Compiler caches it on the timestamp alone.
5
+export function RelativeTime(props: { timestamp: string }) {
6
+ const relative = useRelativeTimeState(props.timestamp);
7
+ if (relative.status !== "relative") return null;
8
+ return relative.suffix ? `${relative.value} ${relative.suffix}` : relative.value;
9
+}
apps/web/src/components/Sidebar.tsx
+29
-3
@@ -33,6 +33,8 @@ import { CSS } from "@dnd-kit/utilities";
33
import {
34
canSnooze,
35
effectiveSnoozed,
36
+ hasQueuedTurnStart,
37
+ QUEUED_TURN_START_GRACE_MS,
38
threadWokeAt,
39
} from "@t3tools/client-runtime/state/thread-settled";
40
import { createInboxReturnTracker } from "@t3tools/client-runtime/state/thread-inbox";
@@ -1853,10 +1855,34 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1855
onSnooze(threadRef, preset);
1856
};
1857
const [snoozeMenuOpenRaw, setSnoozeMenuOpen] = useState(false);
1858
+ // The React Compiler caches render results on their inputs, so a clock read
1859
+ // here would stay frozen until `thread` changes and a queued-turn gate would
1860
+ // never reopen. The gate's clock is state, reset with the thread.
1861
+ const [snoozeGateClock, setSnoozeGateClock] = useState(() => ({
1862
+ thread,
1863
+ now: new Date().toISOString(),
1864
+ }));
1865
+ if (snoozeGateClock.thread !== thread) {
1866
+ setSnoozeGateClock({ thread, now: new Date().toISOString() });
1867
+ }
1868
+ const snoozeGateNow = snoozeGateClock.now;
1869
+ const snoozeGateExpiryMs = hasQueuedTurnStart(thread, { now: snoozeGateNow })
1870
+ ? Date.parse(thread.latestUserMessageAt ?? "") + QUEUED_TURN_START_GRACE_MS
1871
+ : Number.NaN;
1872
+ useEffect(() => {
1873
+ // A gate still closed past its expiry is held by runtime status, not time,
1874
+ // so no clock tick can open it.
1875
+ if (!Number.isFinite(snoozeGateExpiryMs) || snoozeGateExpiryMs <= Date.parse(snoozeGateNow)) {
1876
+ return;
1877
+ }
1878
+ const id = window.setTimeout(
1879
+ () => setSnoozeGateClock({ thread, now: new Date().toISOString() }),
1880
+ Math.min(Math.max(0, snoozeGateExpiryMs - Date.now()) + 50, 2_147_483_647),
1881
+ );
1882
+ return () => window.clearTimeout(id);
1883
+ }, [snoozeGateExpiryMs, snoozeGateNow, thread]);
1884
const showSnoozeButton =
1857
- canOperateThread &&
1858
- props.snoozeSupported &&
1859
- canSnooze(thread, { now: new Date().toISOString() });
1885
+ canOperateThread && props.snoozeSupported && canSnooze(thread, { now: snoozeGateNow });
1886
// Closing here, not just masking, keeps the menu from reopening when the button returns.
1887
if (snoozeMenuOpenRaw && !showSnoozeButton) setSnoozeMenuOpen(false);
1888
const snoozeMenuOpen = snoozeMenuOpenRaw && showSnoozeButton;
apps/web/src/components/chat/ComposerStashMenu.tsx
+2
-2
@@ -2,7 +2,7 @@ import { BookmarkIcon, FileIcon, FileTextIcon } from "lucide-react";
2
import { memo, useEffect, useRef, useState } from "react";
3
import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
4
5
-import { formatRelativeTimeLabel } from "../../timestampFormat";
5
+import { RelativeTime } from "../RelativeTime";
6
import { cn } from "~/lib/utils";
7
import { type PromptStashEntry } from "../../promptStashStore";
8
import { ComposerBanner } from "./ComposerBanner";
@@ -205,7 +205,7 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
205
dateTime={entry.createdAt}
206
className="shrink-0 text-muted-foreground tabular-nums max-sm:hidden"
207
>
208
- {formatRelativeTimeLabel(entry.createdAt)}
208
+ <RelativeTime timestamp={entry.createdAt} />
209
</time>
210
<ComposerBanner.Dismiss
211
className="z-10"
apps/web/src/components/chat/ThreadAutomationsPanel.tsx
+11
-6
@@ -16,7 +16,7 @@ import {
16
17
import { ThreadDetailsSection } from "./ThreadDetailsSection";
18
import { cn } from "../../lib/utils";
19
-import { relativeLabel, scheduleLabel } from "../settings/ScheduledTasksSettings";
19
+import { ScheduledRelativeLabel, scheduleLabel } from "../settings/ScheduledTasksSettings";
20
import { useEnvironmentQuery } from "../../state/query";
21
import { serverEnvironment } from "../../state/server";
22
import { useAtomCommand } from "../../state/use-atom-command";
@@ -168,11 +168,16 @@ export function ThreadAutomationsPanel(props: {
168
</span>
169
<p className="truncate text-2xs text-muted-foreground">
170
{scheduleLabel(task.schedule)}
171
- {task.enabled && task.nextRunAt !== null
172
- ? ` · next ${relativeLabel(task.nextRunAt)}`
173
- : task.enabled
174
- ? ""
175
- : " · paused"}
171
+ {task.enabled && task.nextRunAt !== null ? (
172
+ <>
173
+ {" · next "}
174
+ <ScheduledRelativeLabel value={task.nextRunAt} />
175
+ </>
176
+ ) : task.enabled ? (
177
+ ""
178
+ ) : (
179
+ " · paused"
180
+ )}
181
</p>
182
</div>
183
<Tooltip>
apps/web/src/components/preview/PreviewRecentUrlCard.tsx
+4
-6
@@ -2,8 +2,7 @@ import type { ScopedThreadRef } from "@t3tools/contracts";
2
import { X } from "lucide-react";
3
4
import { isValidHistoryTimestamp, type BrowserHistoryEntry } from "~/browserHistoryStore";
5
-import { useNowMinute } from "~/hooks/useNowMinute";
6
-import { formatRelativeTimeLabel } from "~/timestampFormat";
5
+import { RelativeTime } from "~/components/RelativeTime";
6
7
import { PreviewFaviconIcon } from "./PreviewFaviconIcon";
8
@@ -18,10 +17,9 @@ export function PreviewRecentUrlCard({ threadRef, entry, onOpen, onRemove }: Pro
17
const parsed = new URL(entry.url);
18
const path = parsed.pathname === "/" ? "" : parsed.pathname;
19
const label = `${parsed.host}${path}${parsed.search}${parsed.hash}`;
21
- const visitedAt = isValidHistoryTimestamp(entry.lastVisitedAt)
22
- ? formatRelativeTimeLabel(new Date(entry.lastVisitedAt).toISOString())
23
- : "";
24
- useNowMinute();
20
+ const visitedAt = isValidHistoryTimestamp(entry.lastVisitedAt) ? (
21
+ <RelativeTime timestamp={new Date(entry.lastVisitedAt).toISOString()} />
22
+ ) : null;
23
return (
24
<div className="group relative flex w-full items-center">
25
<button
apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+9
-3
@@ -96,7 +96,7 @@ import { PullRequestStackMenu } from "./PullRequestStackMenu";
96
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
97
import { PullRequestThreadLinks } from "./PullRequestThreadLinks";
98
import { vcsEnvironment } from "~/state/vcs";
99
-import { formatRelativeTimeLabel } from "~/timestampFormat";
99
+import { RelativeTime } from "~/components/RelativeTime";
100
import { useUiStateStore } from "~/uiStateStore";
101
102
import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";
@@ -2340,7 +2340,9 @@ export function PullRequestDetailPanel({
2340
variant="avatar"
2341
className="shrink-0"
2342
/>
2343
- <span className="shrink-0">{formatRelativeTimeLabel(detail.updatedAt)}</span>
2343
+ <span className="shrink-0">
2344
+ <RelativeTime timestamp={detail.updatedAt} />
2345
+ </span>
2346
</span>
2347
<span aria-hidden className="h-3 w-px shrink-0 bg-border/70" />
2348
<span className="flex min-w-0 flex-1 items-center gap-1.5 font-mono text-2xs text-muted-foreground/65">
@@ -2511,7 +2513,11 @@ export function PullRequestDetailPanel({
2513
author={
2514
<PullRequestActorLabel actor={detail.author} profileUrl={authorProfileUrl} />
2515
}
2514
- updated={<span>updated {formatRelativeTimeLabel(detail.updatedAt)}</span>}
2516
+ updated={
2517
+ <span>
2518
+ updated <RelativeTime timestamp={detail.updatedAt} />
2519
+ </span>
2520
+ }
2521
checkout={
2522
checkoutCommand ? (
2523
<PullRequestCopyableCode
apps/web/src/components/pullRequest/PullRequestGhosts.tsx
+4
-2
@@ -13,7 +13,7 @@ import type { ReactNode } from "react";
13
14
import { readLocalApi } from "~/localApi";
15
import { cn } from "~/lib/utils";
16
-import { formatRelativeTimeLabel } from "~/timestampFormat";
16
+import { RelativeTime } from "~/components/RelativeTime";
17
18
import { Button, InlineButton } from "../ui/button";
19
import { MiddleTruncate } from "../ui/middle-truncate";
@@ -203,7 +203,9 @@ export function PullRequestDetailGhost({
203
}
204
updated={
205
seed ? (
206
- <span>updated {formatRelativeTimeLabel(seed.updatedAt)}</span>
206
+ <span>
207
+ updated <RelativeTime timestamp={seed.updatedAt} />
208
+ </span>
209
) : (
210
<GhostBar className="h-3 w-16" />
211
)
apps/web/src/components/pullRequest/PullRequestLinkPreview.tsx
+2
-2
@@ -11,7 +11,7 @@ import {
11
type ReactNode,
12
} from "react";
13
14
-import { formatRelativeTimeLabel } from "~/timestampFormat";
14
+import { RelativeTime } from "~/components/RelativeTime";
15
import { pullRequestEnvironment } from "~/state/pullRequests";
16
import { useAtomQueryRunner } from "~/state/use-atom-query-runner";
17
import { useEnvironmentQuery } from "~/state/query";
@@ -139,7 +139,7 @@ export function PullRequestLinkPreview({
139
<span className="min-w-0 truncate">{authorLabel}</span>
140
<span aria-hidden>·</span>
141
<span className="shrink-0">
142
- opened {formatRelativeTimeLabel(detail.createdAt)}
142
+ opened <RelativeTime timestamp={detail.createdAt} />
143
</span>
144
</div>
145
</div>
apps/web/src/components/pullRequest/PullRequestListRow.tsx
+2
-2
@@ -6,7 +6,7 @@ import type {
6
import type { ReactNode } from "react";
7
8
import { cn } from "~/lib/utils";
9
-import { formatRelativeTimeLabel } from "~/timestampFormat";
9
+import { RelativeTime } from "~/components/RelativeTime";
10
11
import { MiddleTruncate } from "../ui/middle-truncate";
12
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
@@ -96,7 +96,7 @@ export function PullRequestRowLines({
96
{meta}
97
{updatedAt ? (
98
<span className="ml-auto shrink-0 whitespace-nowrap tabular-nums">
99
- {formatRelativeTimeLabel(updatedAt)}
99
+ <RelativeTime timestamp={updatedAt} />
100
</span>
101
) : null}
102
</span>
apps/web/src/components/pullRequest/PullRequestReviewAnnotation.tsx
+4
-2
@@ -12,7 +12,7 @@ import { Circle, CircleCheck } from "lucide";
12
import { useRef, useState } from "react";
13
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
14
15
-import { formatRelativeTimeLabel } from "~/timestampFormat";
15
+import { RelativeTime } from "~/components/RelativeTime";
16
import { cn } from "~/lib/utils";
17
18
import { Button } from "../ui/button";
@@ -266,7 +266,9 @@ export function ReviewThreadCard({
266
<article key={comment.id} className="group min-w-0">
267
<div className="flex flex-wrap items-center gap-2 text-xs text-muted-foreground">
268
<PullRequestActorLabel actor={comment.author} />
269
- <span>{formatRelativeTimeLabel(comment.createdAt)}</span>
269
+ <span>
270
+ <RelativeTime timestamp={comment.createdAt} />
271
+ </span>
272
<PullRequestReactionBar
273
className="ml-auto justify-end"
274
reactions={comment.reactions ?? []}
apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx
+4
-2
@@ -24,7 +24,7 @@ import { pullRequestEnvironment } from "~/state/pullRequests";
24
import { useLocalStorage } from "~/hooks/useLocalStorage";
25
import { cn } from "~/lib/utils";
26
import { useOpenLink } from "~/browser/useOpenLink";
27
-import { formatRelativeTimeLabel } from "~/timestampFormat";
27
+import { RelativeTime } from "~/components/RelativeTime";
28
29
import { Button } from "../ui/button";
30
import { PullRequestEditButton } from "./PullRequestEditButton";
@@ -104,7 +104,9 @@ function CommentIdentity({
104
)
105
}
106
>
107
- <time dateTime={comment.createdAt}>{formatRelativeTimeLabel(comment.createdAt)}</time>
107
+ <time dateTime={comment.createdAt}>
108
+ <RelativeTime timestamp={comment.createdAt} />
109
+ </time>
110
</TooltipTrigger>
111
<TooltipPopup>
112
{new Date(comment.createdAt).toLocaleString()}
apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx
+12
-6
@@ -19,7 +19,7 @@ import { useState, type ReactNode } from "react";
19
import { cn } from "~/lib/utils";
20
import { readLocalApi } from "~/localApi";
21
import { pullRequestEnvironment } from "~/state/pullRequests";
22
-import { formatRelativeTimeLabel } from "~/timestampFormat";
22
+import { RelativeTime } from "~/components/RelativeTime";
23
24
import { Button } from "../ui/button";
25
import { PullRequestEditButton } from "./PullRequestEditButton";
@@ -220,7 +220,9 @@ function ConversationCard({
220
{event.reviewState ? <ReviewStateBadge state={event.reviewState} /> : null}
221
</div>
222
<PullRequestMetaLine className="mt-1 flex-wrap text-2xs text-muted-foreground">
223
- <span>{formatRelativeTimeLabel(event.at)}</span>
223
+ <span>
224
+ <RelativeTime timestamp={event.at} />
225
+ </span>
226
{event.path ? (
227
<span className="inline-flex min-w-0 items-center gap-1">
228
<FileCode2Icon aria-hidden className="size-3 shrink-0" />
@@ -327,7 +329,7 @@ function ConversationGroup({
329
</span>
330
<span className="block truncate text-3xs text-muted-foreground">
331
{actors.length.toLocaleString()} {actors.length === 1 ? "author" : "authors"} ·{" "}
330
- {formatRelativeTimeLabel(first.at)}
332
+ <RelativeTime timestamp={first.at} />
333
</span>
334
</span>
335
<ChevronDownIcon
@@ -388,7 +390,9 @@ function CommitEvent({
390
</div>
391
<div className="mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-3xs text-muted-foreground">
392
<code className="font-mono">{event.id.slice(0, 7)}</code>
391
- <span>{formatRelativeTimeLabel(event.at)}</span>
393
+ <span>
394
+ <RelativeTime timestamp={event.at} />
395
+ </span>
396
</div>
397
</div>
398
{event.additions !== null && event.deletions !== null ? (
@@ -429,7 +433,7 @@ function LifecycleEvent({ event }: { event: PullRequestTimelineEvent }) {
433
<span className="font-semibold text-foreground">{presentation.label}</span>
434
</div>
435
<div className="mt-0.5 text-2xs text-muted-foreground">
432
- {formatRelativeTimeLabel(event.at)}
436
+ <RelativeTime timestamp={event.at} />
437
</div>
438
</div>
439
</div>
@@ -483,7 +487,9 @@ function ReviewVerdictEvent({
487
</div>
488
<div className="mt-0.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
489
<PullRequestMetaLine className="flex-wrap text-2xs text-muted-foreground">
486
- <span>{formatRelativeTimeLabel(event.at)}</span>
490
+ <span>
491
+ <RelativeTime timestamp={event.at} />
492
+ </span>
493
{event.path ? (
494
<span className="inline-flex min-w-0 items-center gap-1">
495
<FileCode2Icon aria-hidden className="size-3 shrink-0" />
apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
+8
-4
@@ -30,7 +30,7 @@ import { useProjects, useServerConfigs, useThreadShell } from "~/state/entities"
30
import { PullRequestsUnavailableState } from "./PullRequestsUnavailableState";
31
import { threadEnvironment } from "~/state/threads";
32
import { useAtomCommand } from "~/state/use-atom-command";
33
-import { formatRelativeTimeLabel } from "~/timestampFormat";
33
+import { RelativeTime } from "~/components/RelativeTime";
34
import { Button } from "../ui/button";
35
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
36
import { MiddleTruncate } from "../ui/middle-truncate";
@@ -181,7 +181,7 @@ function LinkRowImpl({
181
#{link.number}
182
</TooltipTrigger>
183
<TooltipPopup>
184
- {SOURCE_LABELS[link.source]} · {formatRelativeTimeLabel(link.linkedAt)}
184
+ {SOURCE_LABELS[link.source]} · <RelativeTime timestamp={link.linkedAt} />
185
</TooltipPopup>
186
</Tooltip>
187
}
@@ -376,7 +376,6 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
376
(link) => link.snapshot === null || link.snapshot.state === "open",
377
).length;
378
const lastSynced = latestSyncedAt(links);
379
- const syncedLabel = lastSynced ? ` · synced ${formatRelativeTimeLabel(lastSynced)}` : "";
379
const linkCount = links.length;
380
const modifiers = useShortcutModifierState(true);
381
const speedMode =
@@ -462,7 +461,12 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
461
<footer className="flex items-center justify-between border-t border-border/60 px-2 py-1.5 text-2xs text-muted-foreground">
462
<span>
463
{openCount} open · {linkCount} linked
465
- {syncedLabel}
464
+ {lastSynced ? (
465
+ <>
466
+ {" · synced "}
467
+ <RelativeTime timestamp={lastSynced} />
468
+ </>
469
+ ) : null}
470
</span>
471
<Button size="xs" variant="ghost" onClick={openLinkDialog}>
472
<PlusIcon className="size-3.5" />
apps/web/src/components/settings/DiagnosticsSettings.tsx
+8
-12
@@ -23,7 +23,6 @@ import * as Option from "effect/Option";
23
import { cn } from "../../lib/utils";
24
import { ensureLocalApi } from "../../localApi";
25
import { useOpenInPreferredEditor } from "../../editorPreferences";
26
-import { formatRelativeTimeLabel } from "../../timestampFormat";
26
import { useRelativeTimeState } from "../../hooks/useRelativeTimeState";
27
import { useEnvironmentQuery } from "../../state/query";
28
import { serverEnvironment } from "../../state/server";
@@ -64,13 +63,10 @@ function formatBytes(value: number): string {
63
return `${next.toFixed(next >= 10 ? 1 : 2)} ${units[unitIndex]}`;
64
}
65
67
-function formatRelative(value: DateTime.Utc | null): string {
68
- if (!value) return "No trace records";
69
- return formatRelativeTimeLabel(DateTime.formatIso(value));
70
-}
71
-
72
-function formatRelativeNoWrap(value: DateTime.Utc | null): string {
73
- return formatRelative(value).replaceAll(" ", "\u00a0");
66
+function RelativeTimeNoWrap(props: { value: DateTime.Utc }) {
67
+ const relative = useRelativeTimeState(DateTime.formatIso(props.value));
68
+ if (relative.status !== "relative") return null;
69
+ return relative.suffix ? `${relative.value}\u00a0${relative.suffix}` : relative.value;
70
}
71
72
function shortenTraceId(traceId: string): string {
@@ -1182,7 +1178,7 @@ export function DiagnosticsSettingsPanel() {
1178
{formatDuration(failure.durationMs)}
1179
</td>
1180
<td className="whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums text-muted-foreground last:sm:pr-5">
1185
- {formatRelativeNoWrap(failure.endedAt)}
1181
+ <RelativeTimeNoWrap value={failure.endedAt} />
1182
</td>
1183
</tr>
1184
))}
@@ -1210,7 +1206,7 @@ export function DiagnosticsSettingsPanel() {
1206
<ExpandableText text={failure.cause} />
1207
</td>
1208
<td className="w-px whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums text-muted-foreground last:sm:pr-5">
1213
- {formatRelativeNoWrap(failure.lastSeenAt)}
1209
+ <RelativeTimeNoWrap value={failure.lastSeenAt} />
1210
</td>
1211
</tr>
1212
))}
@@ -1238,7 +1234,7 @@ export function DiagnosticsSettingsPanel() {
1234
{formatDuration(span.durationMs)}
1235
</td>
1236
<td className="w-px whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums text-muted-foreground">
1241
- {formatRelativeNoWrap(span.endedAt)}
1237
+ <RelativeTimeNoWrap value={span.endedAt} />
1238
</td>
1239
<td className="min-w-0 whitespace-nowrap px-4 py-3 align-top text-muted-foreground last:sm:pr-5">
1240
<TraceIdCell traceId={span.traceId} />
@@ -1284,7 +1280,7 @@ export function DiagnosticsSettingsPanel() {
1280
className="hover:bg-muted/15"
1281
>
1282
<td className="whitespace-nowrap px-4 py-3 align-top font-mono tabular-nums text-muted-foreground sm:pl-5">
1287
- {formatRelativeNoWrap(event.seenAt)}
1283
+ <RelativeTimeNoWrap value={event.seenAt} />
1284
</td>
1285
<td className="px-4 py-3 align-top">
1286
<span className="inline-flex rounded bg-muted px-1.5 py-0.5 font-mono text-2xs font-medium uppercase text-foreground/80">
apps/web/src/components/settings/ScheduledTasksSettings.tsx
+24
-15
@@ -51,6 +51,7 @@ import { requestConfirmDialog } from "../../confirmDialog";
51
import { webhookAddress } from "@t3tools/client-runtime/webhook-address";
52
import { Link } from "@tanstack/react-router";
53
import { useCopyToClipboard } from "../../hooks/useCopyToClipboard";
54
+import { useNowMinute } from "../../hooks/useNowMinute";
55
import {
56
useEnvironment,
57
useEnvironmentHttpBaseUrl,
@@ -108,7 +109,6 @@ import {
109
SettingsRow,
110
SettingsSection,
111
SETTINGS_PICKER_TRIGGER_CLASSNAME,
111
- useRelativeTimeTick,
112
} from "./settingsLayout";
113
114
const WEEKDAY_ORDER = [1, 2, 3, 4, 5, 6, 0] as const;
@@ -202,11 +202,11 @@ export function scheduleLabel(schedule: ScheduledTaskSchedule): string {
202
* instant — render "in 5m" style labels for upcoming runs instead of a
203
* misleading "just now".
204
*/
205
-export function relativeLabel(value: string | null): string {
205
+function relativeLabel(value: string | null, nowMs: number): string {
206
if (!value) return "Not scheduled";
207
- const diffMs = new Date(value).getTime() - Date.now();
207
+ const diffMs = new Date(value).getTime() - nowMs;
208
if (diffMs <= 0) {
209
- const relative = formatRelativeTime(value);
209
+ const relative = formatRelativeTime(value, nowMs);
210
if (!relative) return "Not scheduled";
211
return relative.suffix ? `${relative.value} ${relative.suffix}` : relative.value;
212
}
@@ -218,6 +218,13 @@ export function relativeLabel(value: string | null): string {
218
return `in ${Math.round(hours / 24)}d`;
219
}
220
221
+// The clock is the label's own minute tick: the React Compiler caches a
222
+// `Date.now()` read in render on the timestamp alone.
223
+export function ScheduledRelativeLabel(props: { value: string | null }) {
224
+ const nowMinute = useNowMinute();
225
+ return relativeLabel(props.value, Date.parse(`${nowMinute}:00.000Z`));
226
+}
227
+
228
const DELIVERY_OUTCOME_LABELS: Record<ScheduledTaskWebhookDeliveryOutcome, string> = {
229
accepted: "Ran",
230
dispatch_failed: "Run failed",
@@ -372,7 +379,6 @@ function ScheduledTaskEnvironmentList({
379
onEdit(environmentId, linkedTask);
380
}
381
}, [environmentId, linkedTask, onEdit]);
375
- useRelativeTimeTick(60_000);
382
383
const loaded = states.filter((state) => state.connected && state.error === null && state.tasks);
384
const populated = loaded.filter((state) => state.tasks && state.tasks.length > 0);
@@ -504,7 +510,6 @@ function ScheduledTaskEnvironmentSection({
510
onEdit(environment.environmentId, linkedTask);
511
}
512
}, [environment.environmentId, linkedTask, onEdit]);
507
- useRelativeTimeTick(60_000);
513
return (
514
<SettingsSection
515
title={environment.label}
@@ -607,13 +612,17 @@ function ScheduledTaskRow({
612
<div className="flex flex-wrap items-center gap-2">
613
<span>
614
{scheduleLabel(task.schedule)} ·{" "}
610
- {!task.enabled
611
- ? "Paused"
612
- : isWebhook
613
- ? "Listening"
614
- : task.nextRunAt
615
- ? `Next run ${relativeLabel(task.nextRunAt)}`
616
- : "Not scheduled"}
615
+ {!task.enabled ? (
616
+ "Paused"
617
+ ) : isWebhook ? (
618
+ "Listening"
619
+ ) : task.nextRunAt ? (
620
+ <>
621
+ Next run <ScheduledRelativeLabel value={task.nextRunAt} />
622
+ </>
623
+ ) : (
624
+ "Not scheduled"
625
+ )}
626
</span>
627
{task.lastRunStatus !== "never" ? (
628
<Badge variant={statusVariant(task.lastRunStatus)}>{task.lastRunStatus}</Badge>
@@ -730,7 +739,7 @@ function WebhookDeliveriesDialog({
739
{DELIVERY_OUTCOME_LABELS[selected.outcome]}
740
</Badge>
741
<span>
733
- {selected.method} · {relativeLabel(selected.receivedAt)}
742
+ {selected.method} · <ScheduledRelativeLabel value={selected.receivedAt} />
743
</span>
744
{selected.signatureVerified ? (
745
<span className="text-muted-foreground">Signature verified</span>
@@ -777,7 +786,7 @@ function WebhookDeliveriesDialog({
786
</Badge>
787
<span>{delivery.method}</span>
788
<span className="text-muted-foreground">
780
- {relativeLabel(delivery.receivedAt)}
789
+ <ScheduledRelativeLabel value={delivery.receivedAt} />
790
</span>
791
{delivery.missingFields.length > 0 ? (
792
<span className="text-muted-foreground">
apps/web/src/components/settings/SettingsPanels.tsx
+3
-3
@@ -105,7 +105,7 @@ import { isMacPlatform } from "../../lib/utils";
105
import { useEnvironmentProviders } from "../../state/environments";
106
import { EMPTY_SERVER_PROVIDERS } from "../../state/server";
107
import { useArchivedThreadSnapshots } from "../../lib/archivedThreadsState";
108
-import { formatRelativeTimeLabel } from "../../timestampFormat";
108
+import { RelativeTime } from "../RelativeTime";
109
import { Button } from "../ui/button";
110
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible";
111
import {
@@ -3510,9 +3510,9 @@ export function ArchivedThreadsPanel() {
3510
description={
3511
<span className={hasMultipleEnvironments ? "block truncate" : undefined}>
3512
{hasMultipleEnvironments ? `${thread.environmentLabel} · ` : null}
3513
- Archived {formatRelativeTimeLabel(thread.archivedAt ?? thread.createdAt)}
3513
+ Archived <RelativeTime timestamp={thread.archivedAt ?? thread.createdAt} />
3514
{" \u00b7 Created "}
3515
- {formatRelativeTimeLabel(thread.createdAt)}
3515
+ <RelativeTime timestamp={thread.createdAt} />
3516
</span>
3517
}
3518
control={
apps/web/src/timestampFormat.test.ts
+2
@@ -287,6 +287,8 @@ describe("relative time boundaries", () => {
287
expect(msUntilRelativeTimeChange("2026-04-05T00:00:00.000Z", nowMs)).toBe(12 * 3_600_000);
288
// A future timestamp reads "just now" until a minute after it.
289
expect(msUntilRelativeTimeChange("2026-04-07T12:00:10.000Z", nowMs)).toBe(70_000);
290
+ // A far-future timestamp stays within setTimeout's range.
291
+ expect(msUntilRelativeTimeChange("2026-06-01T00:00:00.000Z", nowMs)).toBe(86_400_000);
292
});
293
294
it("keeps the elapsed snapshot stable while the label is unchanged", () => {
apps/web/src/timestampFormat.ts
+3
-1
@@ -235,7 +235,9 @@ export function msUntilRelativeTimeChange(
235
const elapsedMs = Math.max(0, nowMs - date.getTime());
236
const unitMs = relativeTimeUnitMs(elapsedMs);
237
const nextChangeMs = date.getTime() + (Math.floor(elapsedMs / unitMs) + 1) * unitMs;
238
- return nextChangeMs - nowMs;
238
+ // setTimeout fires at once past 2^31-1 ms, which would loop on a far-future
239
+ // timestamp. Waking early is harmless: the caller re-reads and re-schedules.
240
+ return Math.min(nextChangeMs - nowMs, DAY_MS);
241
}
242
243
export function formatRelativeElapsed(elapsedMs: number): RelativeTimeParts {