Skip to content
TypeScript

feat(web): reveal timestamps on tool rows and turn folds (#8641)

Alex Southwellb900fc94ebe6
diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsx
index 0987b852e71..3bf5f482948 100644
--- a/apps/web/src/components/chat/MessagesTimeline.test.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx
@@ -9,7 +9,7 @@ import {
import { act, createRef, useLayoutEffect, type ReactNode, type Ref } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { create, type ReactTestRenderer } from "react-test-renderer";
-import { beforeAll, describe, expect, it, vi } from "vite-plus/test";
+import { beforeAll, beforeEach, describe, expect, it, vi } from "vite-plus/test";
import type { LegendListRef, MaintainScrollAtEndOptions } from "@legendapp/list/react";
import { shouldUseRestingComposerLayout } from "../composerFooterLayout";
import { useComposerFocusState } from "./useComposerFocusState";
@@ -146,7 +146,9 @@ function matchMedia() {
let MessagesTimeline: typeof import("./MessagesTimeline").MessagesTimeline;
let resolvePreviewAnnotationImage: typeof import("./MessagesTimeline").resolvePreviewAnnotationImage;
-beforeAll(async () => {
+const ElementStub = class ElementStub {};
+
+function stubDomGlobals() {
const classList = {
add: () => {},
remove: () => {},
@@ -154,6 +156,7 @@ beforeAll(async () => {
contains: () => false,
};
+ vi.stubGlobal("Element", ElementStub);
vi.stubGlobal("localStorage", {
getItem: () => null,
setItem: () => {},
@@ -161,6 +164,7 @@ beforeAll(async () => {
clear: () => {},
});
vi.stubGlobal("window", {
+ Element: ElementStub,
matchMedia,
addEventListener: () => {},
removeEventListener: () => {},
@@ -177,10 +181,17 @@ beforeAll(async () => {
offsetHeight: 0,
},
});
+}
+beforeAll(async () => {
+ stubDomGlobals();
({ MessagesTimeline, resolvePreviewAnnotationImage } = await import("./MessagesTimeline"));
}, 30_000);
+// The scroll-settling test clears every global stub; mounted timeline rows
+// still touch `window` through the tooltip's focus handling.
+beforeEach(stubDomGlobals);
+
const ACTIVE_THREAD_ENVIRONMENT_ID = EnvironmentId.make("environment-local");
const MESSAGE_CREATED_AT = "2026-03-17T19:12:28.000Z";
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index 09aa61bd518..976f261981e 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -2063,12 +2063,49 @@ function RevertUserMessageButton({
);
}
+/**
+ * Hover-revealed wall-clock time with a full-date tooltip — the same metadata
+ * presentation as message rows, for work entries and turn folds. The parent
+ * carries `group/timeline-row`; hover or focus on an existing control reveals
+ * the time without adding a tab stop. Hidden timestamps stay outside the row
+ * layout. Visibility changes immediately so leaving flow cannot overlap text
+ * during a fade-out. Render it as the row's rightmost flex child so the
+ * revealed time lands at the right edge, clear of disclosure controls.
+ */
+function TimelineRowTimestamp({
+ createdAt,
+ timestampFormat,
+ className,
+}: {
+ createdAt: string;
+ timestampFormat: TimestampFormat;
+ className?: string;
+}) {
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span
+ className={cn(
+ "pointer-events-none absolute me-1 shrink-0 whitespace-nowrap rounded-md text-muted-foreground text-xs tabular-nums opacity-0 group-hover/timeline-row:pointer-events-auto group-hover/timeline-row:static group-hover/timeline-row:opacity-100 group-focus-within/timeline-row:pointer-events-auto group-focus-within/timeline-row:static group-focus-within/timeline-row:opacity-100",
+ className,
+ )}
+ />
+ }
+ >
+ {formatDayAwareTimestamp(createdAt, timestampFormat)}
+ </TooltipTrigger>
+ <TooltipPopup>{formatChatTimestampTooltip(createdAt, timestampFormat)}</TooltipPopup>
+ </Tooltip>
+ );
+}
+
function TurnFoldTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "turn-fold" }> }) {
const ctx = use(TimelineRowCtx);
const Icon = row.expanded ? ChevronDownIcon : ChevronRightIcon;
return (
- <div className="border-b border-border/60 pb-2 pt-1">
+ <div className="group/timeline-row relative flex items-center gap-1 border-b border-border/60 pb-2 pe-0.5 pt-1">
<button
type="button"
aria-expanded={row.expanded}
@@ -2079,6 +2116,11 @@ function TurnFoldTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "turn-
<span>{row.label}</span>
<Icon className="size-3.5" />
</button>
+ <TimelineRowTimestamp
+ createdAt={row.createdAt}
+ timestampFormat={ctx.timestampFormat}
+ className="ms-auto"
+ />
</div>
);
}
@@ -2770,7 +2812,7 @@ function WorkGroupToggleTimelineRow({
return (
<button
type="button"
- className="group/tool-group flex min-h-6 w-full cursor-pointer items-center gap-1.5 rounded-md px-0.5 py-0.5 text-left text-sm leading-relaxed transition-colors duration-150 hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70"
+ className="group/tool-group group/timeline-row relative flex min-h-6 w-full cursor-pointer items-center gap-1.5 rounded-md px-0.5 py-0.5 text-left text-sm leading-relaxed transition-colors duration-150 hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70"
aria-label={row.hasFailure ? `${row.summary}, tool call failed` : undefined}
aria-expanded={row.expanded}
onClick={() => ctx.onToggleWorkGroup(row.groupId, row.id)}
@@ -2786,6 +2828,7 @@ function WorkGroupToggleTimelineRow({
/>
</span>
<span className="min-w-0 flex-1 truncate text-secondary-label">{row.summary}</span>
+ <TimelineRowTimestamp createdAt={row.createdAt} timestampFormat={ctx.timestampFormat} />
</button>
);
}
@@ -4234,7 +4277,7 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {
onToggleEntry?: ((collapsed: boolean) => void) | undefined;
}) {
const { workEntry, workspaceRoot, isExpandedToolGroupEntry, displayLabel } = props;
- const { threadRef, onImageExpand } = use(TimelineRowCtx);
+ const { threadRef, onImageExpand, timestampFormat } = use(TimelineRowCtx);
const groupView = use(WorkGroupViewCtx);
const [expanded, setExpanded] = useState(
() => groupView?.state.expandedEntries.has(workEntry.id) ?? false,
@@ -4336,7 +4379,7 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {
return (
<div
className={cn(
- "flex flex-col rounded-md px-0.5 transition-colors",
+ "group/timeline-row relative flex flex-col rounded-md px-0.5 transition-colors",
isExpandedToolGroupEntry ? "py-0" : "py-0.5",
expanded && "mb-1",
canExpand &&
@@ -4406,6 +4449,7 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: {
)}
/>
</span>
+ <TimelineRowTimestamp createdAt={workEntry.createdAt} timestampFormat={timestampFormat} />
</div>
</div>
{expanded && viewedImage && threadRef ? (