Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor(frontend): name the clock's blind spot, and stop relying on a name

zchpeterda3df40c1e7a
diff --git a/docs/design/timestamp-display.md b/docs/design/timestamp-display.md
index ce9a9a4d51..82a06ce8ef 100644
--- a/docs/design/timestamp-display.md
+++ b/docs/design/timestamp-display.md
@@ -292,7 +292,11 @@ no seconds per D5. Relative age may accompany it in the tooltip.
least as late as the one it was computed on, so a clock stepped backward wakes every
subscribed display at the next check. The evidence of a step is the highest clock reading the
clock has seen, not the last one taken: arming happens on any commit, so a display mounting
- between the step and the next check would otherwise erase it. A reading that has settled for
+ between the step and the next check would otherwise erase it. The detector's blind spot is a
+ step smaller than the time since the clock last armed, which is safe because it self-tunes:
+ a display that changes by the second arms often, shrinking exactly the window it needs, and a
+ step too small for that window is also too small to change a reading that counts in minutes
+ or days. A reading that has settled for
good holds no subscription, so a clock stepped back past its last change leaves it as it was
until something else renders it — the price of settled displays costing nothing. The clock
wakes only the subscribers that are due, re-checks a woken display that names the same instant
diff --git a/frontend/biome.json b/frontend/biome.json
index e87f2e41be..ea8b30d89a 100644
--- a/frontend/biome.json
+++ b/frontend/biome.json
@@ -310,7 +310,8 @@
"!src/**/*.test.ts",
"!src/**/*.test.tsx",
"!src/utils/datetime.ts",
- "!src/utils/accessGrant.ts"
+ "!src/utils/accessGrant.ts",
+ "!src/hooks/useTimeReading.ts"
],
"plugins": ["./biome-plugins/time-reading-through-hook.grit"]
},
diff --git a/frontend/src/components/HumanizeTs.tsx b/frontend/src/components/HumanizeTs.tsx
index 1798b9599b..af9866822d 100644
--- a/frontend/src/components/HumanizeTs.tsx
+++ b/frontend/src/components/HumanizeTs.tsx
@@ -40,7 +40,7 @@ interface HumanizeTsProps {
// Tooltip bodies mount only while open, so as components they cost nothing
// for the rows nobody hovers, and a time-varying one can keep counting.
-function FullDateTime({ tsMs }: { tsMs: number }) {
+export function FullDateTime({ tsMs }: { tsMs: number }) {
return <>{formatAbsoluteDateTime(tsMs)}</>;
}
@@ -86,15 +86,13 @@ export function HumanizeTs({
}: HumanizeTsProps) {
// Subscribe to locale changes so the rendered strings update on a language switch.
useTranslation();
- const tsMs = ts * 1000;
- const { label: labelReading, Hidden } = MODES[mode];
// An unvalidated string reaching `new Date(...)` gives NaN, which `Intl`
// throws on; a row loses its timestamp rather than the page its subtree.
- const label = useTimeReading(
- labelReading,
- Number.isFinite(tsMs) ? tsMs : undefined
- );
- if (label === undefined) {
+ const instantMs = ts * 1000;
+ const tsMs = Number.isFinite(instantMs) ? instantMs : undefined;
+ const { label: labelReading, Hidden } = MODES[mode];
+ const label = useTimeReading(labelReading, tsMs);
+ if (tsMs === undefined) {
return null;
}
if (!tooltip) {
diff --git a/frontend/src/components/task-run-log/SectionContent.tsx b/frontend/src/components/task-run-log/SectionContent.tsx
index 94a7e15a2a..db0e36be95 100644
--- a/frontend/src/components/task-run-log/SectionContent.tsx
+++ b/frontend/src/components/task-run-log/SectionContent.tsx
@@ -1,17 +1,11 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
+import { FullDateTime } from "@/components/HumanizeTs";
import { Button } from "@/components/ui/button";
import { Tooltip } from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";
-import { formatAbsoluteDateTime } from "@/utils";
import type { Section } from "./types";
-// Mounts only while the tooltip is open, so the rows nobody hovers cost
-// nothing.
-function FullDateTime({ tsMs }: { tsMs: number }) {
- return <>{formatAbsoluteDateTime(tsMs)}</>;
-}
-
const ITEM_HEIGHT = 20;
const MAX_VISIBLE_ITEMS = 10;
const MAX_RENDERED_ITEMS = 50;
diff --git a/frontend/src/hooks/useTimeReading.ts b/frontend/src/hooks/useTimeReading.ts
index 2420681069..1c51b2766a 100644
--- a/frontend/src/hooks/useTimeReading.ts
+++ b/frontend/src/hooks/useTimeReading.ts
@@ -73,6 +73,7 @@ function tick(): void {
clockHighWaterMs = nowMs;
}
let nextMs = Number.POSITIVE_INFINITY;
+ let wokeAnyone = false;
for (const subscriber of subscribers) {
const isDue = subscriber.changesAtMs <= nowMs;
if (isDue) {
@@ -82,10 +83,13 @@ function tick(): void {
// declared: that is absolute, so it survives and still gets its own wake.
if (isDue || clockSteppedBack) {
subscriber.wake();
- lastWakeMs = nowMs;
+ wokeAnyone = true;
}
nextMs = Math.min(nextMs, subscriber.changesAtMs);
}
+ if (wokeAnyone) {
+ lastWakeMs = nowMs;
+ }
arm(nextMs);
}