Centralize date/time formatting utilities (#11831)

This commit is contained in:
max
2026-02-08 04:53:31 -08:00
committed by GitHub
parent 74fbbda283
commit a1123dd9be
77 changed files with 1508 additions and 1075 deletions

View File

@@ -14,8 +14,8 @@ import {
normalizeUsageDisplay,
resolveResponseUsageMode,
} from "../auto-reply/thinking.js";
import { formatRelativeTimestamp } from "../infra/format-time/format-relative.ts";
import { normalizeAgentId } from "../routing/session-key.js";
import { formatRelativeTime } from "../utils/time-format.js";
import { helpText, parseCommand } from "./commands.js";
import {
createFilterableSelectList,
@@ -158,7 +158,9 @@ export function createCommandHandlers(context: CommandHandlerContext) {
// Avoid redundant "title (key)" when title matches key
const label = title && title !== formattedKey ? `${title} (${formattedKey})` : formattedKey;
// Build description: time + message preview
const timePart = session.updatedAt ? formatRelativeTime(session.updatedAt) : "";
const timePart = session.updatedAt
? formatRelativeTimestamp(session.updatedAt, { dateFallback: true, fallback: "" })
: "";
const preview = session.lastMessagePreview?.replace(/\s+/g, " ").trim();
const description =
timePart && preview ? `${timePart} · ${preview}` : (preview ?? timePart);

View File

@@ -1,5 +1,5 @@
import type { GatewayStatusSummary } from "./tui-types.js";
import { formatAge } from "../infra/channel-summary.js";
import { formatTimeAgo } from "../infra/format-time/format-relative.ts";
import { formatTokenCount } from "../utils/usage-format.js";
import { formatContextUsageLine } from "./tui-formatters.js";
@@ -14,7 +14,7 @@ export function formatStatusSummary(summary: GatewayStatusSummary) {
const linked = summary.linkChannel.linked === true;
const authAge =
linked && typeof summary.linkChannel.authAgeMs === "number"
? ` (last refreshed ${formatAge(summary.linkChannel.authAgeMs)})`
? ` (last refreshed ${formatTimeAgo(summary.linkChannel.authAgeMs)})`
: "";
lines.push(`${linkLabel}: ${linked ? "linked" : "not linked"}${authAge}`);
}
@@ -63,7 +63,7 @@ export function formatStatusSummary(summary: GatewayStatusSummary) {
if (recent.length > 0) {
lines.push("Recent sessions:");
for (const entry of recent) {
const ageLabel = typeof entry.age === "number" ? formatAge(entry.age) : "no activity";
const ageLabel = typeof entry.age === "number" ? formatTimeAgo(entry.age) : "no activity";
const model = entry.model ?? "unknown";
const usage = formatContextUsageLine({
total: entry.totalTokens ?? null,