Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(chat): timestamp agent replies with the wall-clock time (#11191)

b0o0wen5543c906914c
diff --git a/apps/mobile/components/chat/chat-message-list.tsx b/apps/mobile/components/chat/chat-message-list.tsx
index d94738c8a8..5d03484b76 100644
--- a/apps/mobile/components/chat/chat-message-list.tsx
+++ b/apps/mobile/components/chat/chat-message-list.tsx
@@ -29,7 +29,7 @@ import { Markdown } from "@/lib/markdown";
import { ImageSequenceProvider } from "@/lib/markdown/image-sequence";
import { failureReasonKey } from "@/lib/failure-reason-label";
import type { QueuedChatMessage } from "@/lib/chat-queued-messages";
-import { formatElapsedMs } from "@/lib/format-elapsed";
+import { formatElapsedMs, formatMessageTime } from "@/lib/format-elapsed";
import { cn } from "@/lib/utils";
import { useChatSelectStore } from "@/data/chat-select-store";
import { useChatMessageLongPress } from "./message-long-press";
@@ -45,7 +45,7 @@ import {
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible";
-import { useT } from "@/lib/i18n";
+import { useLocale, useT } from "@/lib/i18n";
interface Props {
messages: ChatMessage[];
@@ -313,6 +313,7 @@ function MessageRow({
reasonLabel={t(failureReasonKey(message.failure_reason))}
rawError={message.content}
elapsedMs={message.elapsed_ms ?? null}
+ createdAt={message.created_at}
isSelecting={isSelecting}
longPress={longPress}
/>
@@ -380,7 +381,8 @@ function MessageRow({
* - Process-steps fold (from `task-messages` cache; same cache fed by
* the live timeline above, so completed runs keep their trace).
* - Markdown content (the model's final answer).
- * - "Replied in Ns" caption when `elapsed_ms` is stamped.
+ * - "Replied in Ns · 14:32" caption: duration from `elapsed_ms` when
+ * stamped, plus the wall-clock reply time.
*
* Web's equivalent is `AssistantMessage` in packages/views/chat/components/
* chat-message-list.tsx — same shape, simplified for RN (no inner Tooltip
@@ -439,12 +441,11 @@ function AssistantRow({
attachments={message.attachments}
content={message.content}
/>
- {message.elapsed_ms != null ? (
- <ElapsedCaption
- variant={isNoResponse ? "finished" : "replied"}
- elapsedMs={message.elapsed_ms}
- />
- ) : null}
+ <ReplyTimingCaption
+ variant={isNoResponse ? "finished" : "replied"}
+ elapsedMs={message.elapsed_ms ?? null}
+ createdAt={message.created_at}
+ />
</View>
);
const messageBody = isSelecting ? body : (
@@ -532,24 +533,40 @@ function QuickActions({
}
// Persistent caption rendered under the assistant bubble / failure bubble
-// once the server has written `elapsed_ms`. Server computes once at task
-// completion, so this caption is identical across reloads and clients.
-function ElapsedCaption({
+// once the turn settles: duration from the server-stamped `elapsed_ms` plus
+// the wall-clock reply time, e.g. "Replied in 38s · 14:32". The server
+// computes elapsed once at task completion, so the caption is identical
+// across reloads and clients; legacy rows without `elapsed_ms` still show
+// the time. Mirrors web's MessageFooter caption in packages/views/chat/
+// components/chat-message-list.tsx.
+function ReplyTimingCaption({
variant,
elapsedMs,
+ createdAt,
}: {
variant: "replied" | "failed" | "finished";
- elapsedMs: number;
+ elapsedMs: number | null;
+ createdAt: string;
}) {
const { t } = useT("chat");
- const label =
- variant === "replied"
- ? t("elapsed.replied", { time: formatElapsedMs(elapsedMs) })
- : variant === "finished"
- ? t("elapsed.finished", { time: formatElapsedMs(elapsedMs) })
- : t("elapsed.failed", { time: formatElapsedMs(elapsedMs) });
+ const locale = useLocale();
+ const timeLabel = formatMessageTime(createdAt, locale);
+ const parts: string[] = [];
+ if (elapsedMs != null) {
+ parts.push(
+ variant === "replied"
+ ? t("elapsed.replied", { time: formatElapsedMs(elapsedMs) })
+ : variant === "finished"
+ ? t("elapsed.finished", { time: formatElapsedMs(elapsedMs) })
+ : t("elapsed.failed", { time: formatElapsedMs(elapsedMs) }),
+ );
+ }
+ if (timeLabel) parts.push(timeLabel);
+ if (parts.length === 0) return null;
return (
- <Text className="text-xs text-muted-foreground/80 mt-1">{label}</Text>
+ <Text className="text-xs text-muted-foreground/80 mt-1">
+ {parts.join(" · ")}
+ </Text>
);
}
@@ -557,12 +574,14 @@ function FailureBubble({
reasonLabel,
rawError,
elapsedMs,
+ createdAt,
isSelecting,
longPress,
}: {
reasonLabel: string;
rawError: string;
elapsedMs: number | null;
+ createdAt: string;
isSelecting: boolean;
longPress: ReturnType<typeof useChatMessageLongPress>;
}) {
@@ -619,9 +638,11 @@ function FailureBubble({
</Collapsible>
) : null}
</View>
- {elapsedMs != null ? (
- <ElapsedCaption variant="failed" elapsedMs={elapsedMs} />
- ) : null}
+ <ReplyTimingCaption
+ variant="failed"
+ elapsedMs={elapsedMs}
+ createdAt={createdAt}
+ />
</View>
);
if (isSelecting) return body;
diff --git a/apps/mobile/lib/format-elapsed.test.ts b/apps/mobile/lib/format-elapsed.test.ts
new file mode 100644
index 0000000000..ccb6710b20
--- /dev/null
+++ b/apps/mobile/lib/format-elapsed.test.ts
@@ -0,0 +1,33 @@
+// @vitest-environment node
+import { describe, expect, it } from "vitest";
+import { formatMessageTime } from "./format-elapsed";
+
+// Dates are built from local components and `now` is injected, so the
+// expectations hold in any host timezone.
+const local = (y: number, month: number, day: number, h: number, m: number) =>
+ new Date(y, month, day, h, m).toISOString();
+
+describe("formatMessageTime", () => {
+ it("shows clock time for a message from today", () => {
+ expect(
+ formatMessageTime(local(2026, 10, 22, 14, 32), "en-GB", new Date(2026, 10, 22, 20, 0)),
+ ).toBe("14:32");
+ });
+
+ it("shows date + clock time for an earlier day in the same year", () => {
+ expect(
+ formatMessageTime(local(2026, 10, 21, 14, 32), "en-GB", new Date(2026, 10, 22, 20, 0)),
+ ).toBe("21/11, 14:32");
+ });
+
+ it("adds the year for a message from an earlier year", () => {
+ expect(
+ formatMessageTime(local(2025, 11, 31, 23, 59), "en-GB", new Date(2026, 10, 22, 20, 0)),
+ ).toBe("31/12/2025, 23:59");
+ });
+
+ it("returns an empty label for a missing or unparseable timestamp", () => {
+ expect(formatMessageTime("", "en-GB")).toBe("");
+ expect(formatMessageTime("not-a-date", "en-GB")).toBe("");
+ });
+});
diff --git a/apps/mobile/lib/format-elapsed.ts b/apps/mobile/lib/format-elapsed.ts
index 40c3616c12..5e3f14d930 100644
--- a/apps/mobile/lib/format-elapsed.ts
+++ b/apps/mobile/lib/format-elapsed.ts
@@ -16,3 +16,30 @@ export function formatElapsedSecs(secs: number): string {
export function formatElapsedMs(ms: number): string {
return formatElapsedSecs(Math.max(0, Math.round(ms / 1000)));
}
+
+/**
+ * Wall-clock time for the reply caption: today → clock time, an earlier day
+ * → numeric date + clock time, with the year added when it differs from
+ * `now`. Mirrors `formatMessageTime` in packages/views/chat/lib/format.ts so
+ * the caption reads identically across web / desktop / mobile. Returns ""
+ * for a missing or unparseable timestamp. `now` is injectable for
+ * deterministic tests.
+ */
+export function formatMessageTime(
+ dateStr: string,
+ locale: string,
+ now: Date = new Date(),
+): string {
+ const date = new Date(dateStr);
+ if (Number.isNaN(date.getTime())) return "";
+ if (date.toDateString() === now.toDateString()) {
+ return date.toLocaleTimeString(locale, { hour: "2-digit", minute: "2-digit" });
+ }
+ return date.toLocaleString(locale, {
+ ...(date.getFullYear() !== now.getFullYear() ? { year: "numeric" } : {}),
+ month: "numeric",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ });
+}
diff --git a/packages/views/chat/components/chat-message-list.test.tsx b/packages/views/chat/components/chat-message-list.test.tsx
index 51c115528d..4d01ff53cb 100644
--- a/packages/views/chat/components/chat-message-list.test.tsx
+++ b/packages/views/chat/components/chat-message-list.test.tsx
@@ -705,6 +705,88 @@ describe("ChatMessageList quick actions skeleton", () => {
});
});
+describe("ChatMessageList reply timing caption", () => {
+ // Built from local components so the caption is stable in any host timezone;
+ // the matcher tolerates the hour's leading zero differing between Node and
+ // browser Intl ("2:32 PM" vs "02:32 PM").
+ const now = new Date();
+ const todayAt = (h: number, m: number) =>
+ new Date(now.getFullYear(), now.getMonth(), now.getDate(), h, m).toISOString();
+
+ it("appends the wall-clock time to the elapsed caption", async () => {
+ render(
+ <I18nProvider locale="en" resources={TEST_RESOURCES}>
+ <QueryClientProvider client={new QueryClient()}>
+ <ChatMessageList
+ messages={[{
+ id: "timed-reply",
+ chat_session_id: "s1",
+ role: "assistant",
+ content: "Done.",
+ task_id: null,
+ created_at: todayAt(14, 32),
+ elapsed_ms: 38000,
+ }]}
+ pendingTask={null}
+ availability="online"
+ />
+ </QueryClientProvider>
+ </I18nProvider>,
+ );
+
+ expect(await screen.findByText(/Replied in 38s · 0?2:32 PM/)).toBeInTheDocument();
+ });
+
+ it("shows the time alone for legacy replies without elapsed_ms", async () => {
+ render(
+ <I18nProvider locale="en" resources={TEST_RESOURCES}>
+ <QueryClientProvider client={new QueryClient()}>
+ <ChatMessageList
+ messages={[{
+ id: "legacy-reply",
+ chat_session_id: "s1",
+ role: "assistant",
+ content: "Done.",
+ task_id: null,
+ created_at: todayAt(14, 32),
+ }]}
+ pendingTask={null}
+ availability="online"
+ />
+ </QueryClientProvider>
+ </I18nProvider>,
+ );
+
+ expect(await screen.findByText(/2:32 PM/)).toBeInTheDocument();
+ expect(screen.queryByText(/Replied in/)).not.toBeInTheDocument();
+ });
+
+ it("timestamps failed replies", async () => {
+ render(
+ <I18nProvider locale="en" resources={TEST_RESOURCES}>
+ <QueryClientProvider client={new QueryClient()}>
+ <ChatMessageList
+ messages={[{
+ id: "failed-reply",
+ chat_session_id: "s1",
+ role: "assistant",
+ content: "boom",
+ task_id: null,
+ created_at: todayAt(14, 32),
+ elapsed_ms: 12000,
+ failure_reason: "manual",
+ }]}
+ pendingTask={undefined}
+ availability="online"
+ />
+ </QueryClientProvider>
+ </I18nProvider>,
+ );
+
+ expect(await screen.findByText(/Failed after 12s · 0?2:32 PM/)).toBeInTheDocument();
+ });
+});
+
describe("ChatMessageList onboarding kickoff", () => {
it("hides the product-authored kickoff while rendering Mika's reply", async () => {
render(
diff --git a/packages/views/chat/components/chat-message-list.tsx b/packages/views/chat/components/chat-message-list.tsx
index 0e7288d668..da4a5d03ed 100644
--- a/packages/views/chat/components/chat-message-list.tsx
+++ b/packages/views/chat/components/chat-message-list.tsx
@@ -52,14 +52,14 @@ import { CHAT_COLUMN, CHAT_GUTTER } from "./chat-column";
import { FOLLOW_EDGE_THRESHOLD } from "../../common/task-transcript/transcript-follow";
import { LIVE_END_ROW_ATTR, useStickToBottom } from "./stick-to-bottom";
import { JumpToLiveEndButton, useJumpToLiveEnd } from "./jump-to-live-end";
-import { formatElapsedMs } from "../lib/format";
+import { formatElapsedMs, formatMessageTime } from "../lib/format";
import {
canonicalAnswerText,
extractCopyText,
splitTimeline,
} from "../lib/copy-text";
import { stripChatQuickActionsProtocol } from "../lib/quick-actions";
-import { useT } from "../../i18n";
+import { useLocale, useT } from "../../i18n";
import { isAnnotatableChatMessage, type ChatAnnotations } from "./use-chat-annotations";
import { ChatWakeupCards, ChatWakeupDivider, useWakeupsBySourceTask } from "./chat-wakeups";
@@ -694,6 +694,7 @@ function AssistantMessage({
rawError={message.content}
timeline={timeline}
elapsedMs={message.elapsed_ms}
+ createdAt={message.created_at}
/>
);
}
@@ -914,7 +915,7 @@ function QuickActions({
}
// Light inline prefix label for the follow-up pill row — the row sits below
-// the reply footer ("Replied in Xs · Copy") behind a faint top border, so
+// the reply footer ("Replied in Xs · time · Copy") behind a faint top border, so
// the pills read as a labelled next-steps strip, not part of the reply body.
// shrink-0 keeps the label whole at the row start when narrow widths wrap
// the pills.
@@ -960,8 +961,8 @@ function NoResponseNotice() {
);
}
-// Inline footer row beneath the assistant reply: "Replied in 38s · [Copy]".
-// Action icons live here (not as a hover-floating overlay) so they're
+// Inline footer row beneath the assistant reply: "Replied in 38s · 2:32 PM ·
+// [Copy]". Action icons live here (not as a hover-floating overlay) so they're
// discoverable on first read and don't shift content. Buttons stay quiet
// (muted) until hover. Copy is suppressed during streaming because the
// final text is still being appended.
@@ -976,20 +977,25 @@ function MessageFooter({
isPending: boolean;
transformContent?: (content: string) => string;
}) {
+ const locale = useLocale();
// A no_response turn has nothing to copy, and its caption uses a neutral
// "Finished in Xs" instead of "Replied in Xs" (MUL-4351).
const isNoResponse = message.message_kind === "no_response";
const copyContent = extractCopyText(message, timeline, transformContent);
const showCopy = !isPending && !isNoResponse && copyContent.trim().length > 0;
- if (message.elapsed_ms == null && !showCopy) return null;
+ const timeLabel = formatMessageTime(message.created_at, locale);
+ if (message.elapsed_ms == null && !showCopy && !timeLabel) return null;
return (
<div className="flex items-center gap-1.5">
- {message.elapsed_ms != null && (
+ {message.elapsed_ms != null ? (
<ElapsedCaption
variant={isNoResponse ? "finished" : "replied"}
elapsedMs={message.elapsed_ms}
+ timeLabel={timeLabel || undefined}
/>
- )}
+ ) : timeLabel ? (
+ <div className="text-caption text-muted-foreground">{timeLabel}</div>
+ ) : null}
{showCopy && (
<MessageCopyButton content={copyContent} />
)}
@@ -1032,18 +1038,21 @@ function MessageCopyButton({
);
}
-// Persisted "Replied in 38s" / "Failed after 12s" line under the assistant
-// bubble. Reads `elapsed_ms` straight off the chat_message — server computes
-// it once at task completion, so this caption is identical across reloads
-// and devices. Skipped silently when null (legacy messages predating
-// migration 063 + user messages).
+// Persisted "Replied in 38s · 2:32 PM" / "Failed after 12s · 2:32 PM" line
+// under the assistant bubble. Reads `elapsed_ms` straight off the chat_message
+// — server computes it once at task completion, so this caption is identical
+// across reloads and devices; `timeLabel` is the pre-formatted wall-clock time
+// derived from `created_at`. Skipped silently when null (legacy messages
+// predating migration 063 + user messages).
function ElapsedCaption({
variant,
elapsedMs,
+ timeLabel,
className,
}: {
variant: "replied" | "failed" | "finished";
elapsedMs: number;
+ timeLabel?: string;
className?: string;
}) {
const { t } = useT("chat");
@@ -1056,7 +1065,7 @@ function ElapsedCaption({
: t(($) => $.message_list.failed_after, { elapsed });
return (
<div className={cn("text-caption text-muted-foreground", className)}>
- {text}
+ {timeLabel ? `${text} · ${timeLabel}` : text}
</div>
);
}
@@ -1066,13 +1075,17 @@ function FailureBubble({
rawError,
timeline,
elapsedMs,
+ createdAt,
}: {
reason: string;
rawError: string;
timeline: ChatTimelineItem[];
elapsedMs?: number | null;
+ createdAt?: string;
}) {
const { t } = useT("chat");
+ const locale = useLocale();
+ const timeLabel = createdAt ? formatMessageTime(createdAt, locale) : "";
const [open, setOpen] = useState(false);
// Chat gets its own friendly, reassuring copy per failure reason — plain
// language + a "try again" nudge — instead of the terse developer labels
@@ -1156,9 +1169,13 @@ function FailureBubble({
</div>
</div>
{timeline.length > 0 && <TimelineView items={timeline} />}
- {elapsedMs != null && (
- <ElapsedCaption variant="failed" elapsedMs={elapsedMs} />
- )}
+ {elapsedMs != null || timeLabel ? (
+ elapsedMs != null ? (
+ <ElapsedCaption variant="failed" elapsedMs={elapsedMs} timeLabel={timeLabel || undefined} />
+ ) : (
+ <div className="text-caption text-muted-foreground">{timeLabel}</div>
+ )
+ ) : null}
</div>
);
}
diff --git a/packages/views/chat/lib/format.test.ts b/packages/views/chat/lib/format.test.ts
new file mode 100644
index 0000000000..8e3d76c511
--- /dev/null
+++ b/packages/views/chat/lib/format.test.ts
@@ -0,0 +1,33 @@
+// @vitest-environment node
+import { describe, expect, it } from "vitest";
+import { formatMessageTime } from "./format";
+
+// Dates are built from local components and `now` is injected, so the
+// expectations hold in any host timezone.
+const local = (y: number, month: number, day: number, h: number, m: number) =>
+ new Date(y, month, day, h, m).toISOString();
+
+describe("formatMessageTime", () => {
+ it("shows clock time for a message from today", () => {
+ expect(
+ formatMessageTime(local(2026, 10, 22, 14, 32), "en-GB", new Date(2026, 10, 22, 20, 0)),
+ ).toBe("14:32");
+ });
+
+ it("shows date + clock time for an earlier day in the same year", () => {
+ expect(
+ formatMessageTime(local(2026, 10, 21, 14, 32), "en-GB", new Date(2026, 10, 22, 20, 0)),
+ ).toBe("21/11, 14:32");
+ });
+
+ it("adds the year for a message from an earlier year", () => {
+ expect(
+ formatMessageTime(local(2025, 11, 31, 23, 59), "en-GB", new Date(2026, 10, 22, 20, 0)),
+ ).toBe("31/12/2025, 23:59");
+ });
+
+ it("returns an empty label for a missing or unparseable timestamp", () => {
+ expect(formatMessageTime("", "en-GB")).toBe("");
+ expect(formatMessageTime("not-a-date", "en-GB")).toBe("");
+ });
+});
diff --git a/packages/views/chat/lib/format.ts b/packages/views/chat/lib/format.ts
index d67d7506ed..9fe580bf9a 100644
--- a/packages/views/chat/lib/format.ts
+++ b/packages/views/chat/lib/format.ts
@@ -17,3 +17,30 @@ export function formatElapsedSecs(secs: number): string {
export function formatElapsedMs(ms: number): string {
return formatElapsedSecs(Math.max(0, Math.round(ms / 1000)));
}
+
+/**
+ * Wall-clock time for the reply caption: today → clock time, an earlier day
+ * → numeric date + clock time, with the year added when it differs from
+ * `now`. Every tier keeps the time of day — the caption answers "when did
+ * this reply land", which a bare date cannot. Returns "" for a missing or
+ * unparseable timestamp so captions can drop the time part silently. `now`
+ * is injectable for deterministic tests.
+ */
+export function formatMessageTime(
+ dateStr: string,
+ locale: string,
+ now: Date = new Date(),
+): string {
+ const date = new Date(dateStr);
+ if (Number.isNaN(date.getTime())) return "";
+ if (date.toDateString() === now.toDateString()) {
+ return date.toLocaleTimeString(locale, { hour: "2-digit", minute: "2-digit" });
+ }
+ return date.toLocaleString(locale, {
+ ...(date.getFullYear() !== now.getFullYear() ? { year: "numeric" } : {}),
+ month: "numeric",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ });
+}
diff --git a/packages/views/rich-content/rich-content-parity.test.tsx b/packages/views/rich-content/rich-content-parity.test.tsx
index 9a468d268b..09fedc218b 100644
--- a/packages/views/rich-content/rich-content-parity.test.tsx
+++ b/packages/views/rich-content/rich-content-parity.test.tsx
@@ -35,6 +35,7 @@ vi.mock("../i18n", async () => {
select((ns === "chat" ? chat : editor) as Record<string, unknown>),
}),
useTimeAgo: () => "just now",
+ useLocale: () => "en",
};
});