Event times as clock times, and one timeline row for consecutive calls of the same prompt

This commit is contained in:
aiongg committed 2026-11-04 17:39:35 +00:00
1 parent 3203dfb8b8
commit b86a4af495
28 files changed
+218 -97

No files matched your search

+7 -4
View File
@@ -119,14 +119,17 @@ const jobs: Source = {
/** SQL that leaves out runs that also touched a hidden repo (one `?` per name). */
export const hiddenSql = (hidden: string[]): string => (hidden.length ? ` AND NOT EXISTS (SELECT 1 FROM agent_run_items x WHERE x.run_id = r.id AND x.repo IN (${hidden.map(() => "?").join(",")}))` : "");
export const RUN_COLUMNS = `r.id, r.step, r.model, r.provider, r.state, r.started_at, r.ended_at, r.input_tokens, r.output_tokens, r.cost_usd, r.summary, r.job_id,
/** Prompts whose calls are named by what they do, not by the step that makes them. */
const PROMPT_TITLES: Record<string, string> = { "lint.reference.jev": "Reference lint", "lint.reference.haiku": "Reference lint" };
export const RUN_COLUMNS = `r.id, r.step, r.prompt_id, r.model, r.provider, r.state, r.started_at, r.ended_at, r.input_tokens, r.output_tokens, r.cost_usd, r.summary, r.job_id,
COALESCE(a.label, r.account_id) AS label, (SELECT COUNT(*) FROM agent_run_tools t WHERE t.run_id = r.id) AS tools`;
export const runEvent = (r: { id: number; step: string; model: string; provider: string; state: string; started_at: string; ended_at: string | null; input_tokens: number | null; output_tokens: number | null;
export const runEvent = (r: { id: number; step: string; prompt_id: string; model: string; provider: string; state: string; started_at: string; ended_at: string | null; input_tokens: number | null; output_tokens: number | null;
cost_usd: number | null; summary: string | null; label: string | null; tools: number; job_id: number | null }): Ev => ({
id: `run:${r.id}`, kind: "model-call", at: r.started_at, head: null, actor: model(r.model, "model"),
summary: `${stepTitle(r.step)}: ${r.state === "running" ? "running" : r.state === "failed" ? "failed" : clip(r.summary, 100) || "done"}`,
summary: `${PROMPT_TITLES[r.prompt_id] ?? stepTitle(r.step)}: ${r.state === "running" ? "running" : r.state === "failed" ? "failed" : clip(r.summary, 100) || "done"}`,
ref: { runId: r.id, ...(r.job_id !== null ? { jobId: r.job_id } : {}) },
call: { model: r.model, provider: r.provider, account: r.label, state: r.state, inputTokens: r.input_tokens, outputTokens: r.output_tokens, costUsd: r.cost_usd, toolCalls: r.tools, endedAt: r.ended_at },
call: { promptId: r.prompt_id, step: stepTitle(r.step), model: r.model, provider: r.provider, account: r.label, state: r.state, inputTokens: r.input_tokens, outputTokens: r.output_tokens, costUsd: r.cost_usd, toolCalls: r.tools, endedAt: r.ended_at },
});
const modelCalls: Source = {
+22 -4
View File
@@ -8,6 +8,21 @@ export const at = (minAgo: number) => new Date(NOW - minAgo * 60_000).toISOStrin
const H1 = "3f2a9c1d0e8b7a6f5e4d3c2b1a0f9e8d7c6b5a49";
const H2 = "9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c";
/** The reference lint of one review: one call per text of the review (ten for Jev, one for Haiku), all in job 55. */
const LINT: TraceEvent[] = [
...Array.from({ length: 11 }, (_, i): TraceEvent => {
const haiku = i === 7;
return {
id: `run:${950 + i}`, kind: "model-call", at: at(12.9 - i * 0.07), head: H2, actor: { type: "model", name: haiku ? "haiku" : "jev" },
summary: `Reference lint: ${haiku ? "clean" : i % 4 === 3 ? "refers to documentation" : "clean"}`, ref: { runId: 950 + i, jobId: 55 },
call: {
promptId: haiku ? "lint.reference.haiku" : "lint.reference.jev", step: "Review pull requests", model: haiku ? "haiku" : "jev", provider: haiku ? "claude" : "jev",
account: haiku ? "Team account A" : "Jev", state: "done", inputTokens: haiku ? 1_100 : 900, outputTokens: haiku ? 40 : 12, costUsd: haiku ? 0.003 : 0, toolCalls: 0, endedAt: at(12.9 - i * 0.07 - 0.02),
},
};
}),
];
export const EVENTS: TraceEvent[] = ([
{ id: "plan:41", kind: "plan", at: at(4), head: H2, actor: { type: "step", name: "Planner" }, summary: "Plan reviewing → verifying, waiting for CI at 9b8c7d6", ref: { head: H2 } },
{ id: "check:12", kind: "check", at: at(9), head: H2, actor: { type: "step", name: "Fix-up" }, summary: "Clippy on app-core: no findings", ref: { checkId: 12, runId: 902, head: H2 } },
@@ -15,7 +30,7 @@ export const EVENTS: TraceEvent[] = ([
{ id: "audit:77", kind: "write", at: at(12), head: H2, actor: { type: "step", name: "AutoCraft" }, summary: "Posted review", ref: { auditRowid: 77, head: H2 } },
{
id: "run:903", kind: "model-call", at: at(14), head: H2, actor: { type: "model", name: "opus" }, summary: "Review pull requests: take-fix with two fixes", ref: { runId: 903, jobId: 55 },
call: { model: "opus", provider: "claude", account: "Team account B", state: "done", inputTokens: 48_200, outputTokens: 2_900, costUsd: 0.91, toolCalls: 7, endedAt: at(13) },
call: { promptId: "review.opus", step: "Review pull requests", model: "opus", provider: "claude", account: "Team account B", state: "done", inputTokens: 48_200, outputTokens: 2_900, costUsd: 0.91, toolCalls: 7, endedAt: at(13) },
},
{ id: "review:opus:5", kind: "review", at: at(13), head: H2, actor: { type: "model", name: "opus" }, summary: "Opus review: take with two fixes, not sure", ref: { reviewId: "opus:5", head: H2 } },
{ id: "gh:push", kind: "github", at: at(30), head: H2, actor: { type: "person", name: "contributor" }, summary: "Pushed 9b8c7d6", ref: { head: H2 } },
@@ -23,10 +38,13 @@ export const EVENTS: TraceEvent[] = ([
{ id: "decision:d9:asked", kind: "decision", at: at(95), head: H1, actor: { type: "step", name: "Ask decisions" }, summary: "Asked: Merge this fix?", ref: { decisionId: "designcraft#1484:merge" } },
{
id: "run:901", kind: "model-call", at: at(120), head: H1, actor: { type: "model", name: "opus" }, summary: "Review pull requests: hold", ref: { runId: 901, jobId: 52 },
call: { model: "opus", provider: "claude", account: "Team account C", state: "done", inputTokens: 51_000, outputTokens: 3_300, costUsd: 0.97, toolCalls: 11, endedAt: at(118) },
call: { promptId: "review.opus", step: "Review pull requests", model: "opus", provider: "claude", account: "Team account C", state: "done", inputTokens: 51_000, outputTokens: 3_300, costUsd: 0.97, toolCalls: 11, endedAt: at(118) },
},
{ id: "plan:38", kind: "plan", at: at(125), head: H1, actor: { type: "step", name: "Planner" }, summary: "Plan started as reviewing", ref: { head: H1 } },
{ id: "gh:opened", kind: "github", at: at(130), head: H1, actor: { type: "person", name: "contributor" }, summary: "Opened pull request on GitHub by contributor", ref: {} },
{ id: "gh:opened", kind: "github", at: at(400 * 1440), head: H1, actor: { type: "person", name: "contributor" }, summary: "Opened pull request on GitHub by contributor", ref: {} },
{ id: "gh:push0", kind: "github", at: at(6 * 1440 + 30), head: H1, actor: { type: "person", name: "contributor" }, summary: "Pushed 3f2a9c1", ref: { head: H1 } },
{ id: "comment:c1", kind: "github", at: at(1000), head: H1, actor: { type: "person", name: "maintainer" }, summary: "Posted a comment, 96 characters", ref: { commentId: "c1" } },
...LINT,
] as TraceEvent[]).sort((a, b) => (a.at < b.at ? 1 : a.at > b.at ? -1 : a.id < b.id ? 1 : -1));
const OFF_EVENTS: TraceEvent[] = [
@@ -65,7 +83,7 @@ export function traceRunDetail(id: number): AgentRunDetail | null {
const c = e.call;
const text = (n: number) => Array.from({ length: n }, (_, i) => `Line ${i + 1} of the model text for ${e.summary}.`).join("\n");
return {
id, jobId: e.ref.jobId ?? null, step: "opus-review", stage: 5, promptId: "opus-review", promptVersion: "a1b2c3d", provider: "claude", model: c.model, accountId: "b", accountLabel: c.account,
id, jobId: e.ref.jobId ?? null, step: "opus-review", stage: 5, promptId: c.promptId ?? "review.opus", promptVersion: "a1b2c3d", provider: "claude", model: c.model, accountId: "b", accountLabel: c.account,
items: [], itemCount: 1, state: "done", startedAt: e.at, endedAt: c.endedAt, inputTokens: c.inputTokens, outputTokens: c.outputTokens, cacheReadTokens: null, cacheWriteTokens: null, costUsd: c.costUsd, summary: null,
prompt: text(40), output: text(18), error: null, tools: TOOLS,
};
+2
View File
@@ -1793,6 +1793,8 @@ export type TraceEvent = {
ref: TraceRef;
/** Model calls only. */
call?: {
/** The prompt the call ran; calls of one step and prompt family are grouped on the item page. */
promptId?: string; /** The step's display name. */ step?: string;
model: string; provider: string; account: string | null; state: string;
inputTokens: number | null; outputTokens: number | null; costUsd: number | null; toolCalls: number; endedAt: string | null;
};
+20
View File
@@ -13,6 +13,26 @@ export function ago(isoTime: string, short = true): string {
return `${v} ${word}${v === 1 ? "" : "s"} ago`;
}
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
/**
* An event time for reading: "now", "12m ago", then the local clock time ("14:32") for the rest of today,
* "yesterday 14:32", "Nov 3 14:32" earlier this year and "Nov 3 2025" before that. Times in the future read as "now".
*/
export function eventTime(isoTime: string): string {
const t = Date.parse(isoTime);
const s = Math.max(0, (now() - t) / 1000);
if (s < 60) return "now";
if (s < 3600) return `${Math.floor(s / 60)}m ago`;
const d = new Date(t), n = new Date(now());
const midnight = (x: Date) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
const days = Math.round((midnight(n) - midnight(d)) / 86400_000);
if (days <= 0) return clock(t);
if (days === 1) return `yesterday ${clock(t)}`;
const md = `${MONTHS[d.getMonth()]} ${d.getDate()}`;
return d.getFullYear() === n.getFullYear() ? `${md} ${clock(t)}` : `${md} ${d.getFullYear()}`;
}
export const num = (n: number) => n.toLocaleString("en");
export const pct = (a: number, b: number) => (b ? `${Math.round((a / b) * 100)}%` : "–");
+41
View File
@@ -64,3 +64,44 @@ export const NEXT_LABEL: Record<string, string> = {
merge: "Merge",
};
export const nextLabel = (kind: string) => NEXT_LABEL[kind] ?? kind.replace(/[-_]/g, " ").replace(/^./, (c) => c.toUpperCase());
export type TraceRow = { event: TraceEvent; calls?: undefined } | { event: TraceEvent; calls: TraceEvent[] };
/** Calls of one prompt close in time: no job id on both sides means "within five minutes". */
const GROUP_GAP_MS = 5 * 60_000;
const family = (promptId: string) => (promptId.startsWith("lint.reference.") ? "lint.reference" : promptId);
const sameRun = (a: TraceEvent, b: TraceEvent) => {
if (!a.call?.promptId || !b.call?.promptId || a.call.step !== b.call.step || family(a.call.promptId) !== family(b.call.promptId)) return false;
if (a.ref.jobId !== undefined || b.ref.jobId !== undefined) return a.ref.jobId === b.ref.jobId;
return Math.abs(Date.parse(a.at) - Date.parse(b.at)) <= GROUP_GAP_MS;
};
/** Consecutive model calls of the same step and prompt (the reference lint runs once per review text) become one row; its `event` is the newest call and `calls` all of them, newest first. */
export function groupCalls(events: TraceEvent[]): TraceRow[] {
const out: TraceRow[] = [];
for (const e of events) {
const last = out[out.length - 1];
const prev = last && (last.calls ? last.calls[last.calls.length - 1]! : last.event);
if (last && prev && e.kind === "model-call" && prev.kind === "model-call" && sameRun(prev, e)) {
if (last.calls) last.calls.push(e);
else out[out.length - 1] = { event: last.event, calls: [last.event, e] };
} else out.push({ event: e });
}
return out;
}
const modelName = (m: string) => m.charAt(0).toUpperCase() + m.slice(1);
/** "Reference lint: 10 Jev calls, 1 Haiku call, $0.04". */
export function callGroupSummary(calls: TraceEvent[]): string {
const counts = new Map<string, number>();
let cost = 0;
for (const c of calls) {
const m = modelName(c.call?.model ?? "model");
counts.set(m, (counts.get(m) ?? 0) + 1);
cost += c.call?.costUsd ?? 0;
}
const title = calls[0]!.summary.split(": ")[0]!;
const parts = [...counts].sort((a, b) => b[1] - a[1]).map(([m, n]) => `${n} ${m} call${n === 1 ? "" : "s"}`);
return `${title}: ${parts.join(", ")}${cost > 0 ? `, $${cost.toFixed(cost < 0.1 ? 3 : 2)}` : ""}`;
}
+3 -3
View File
@@ -5,7 +5,7 @@ import { KeyIcon, PencilSimpleIcon } from "@phosphor-icons/react";
import { Dialog } from "radix-ui";
import { useApi, useQuery } from "../../api/client";
import type { ClaudeAccount } from "../../api/types";
import { ago } from "../../lib/format";
import { eventTime } from "../../lib/format";
import { useUser } from "../../shell/UserContext";
import { Badge } from "../../ui/atoms/Badge";
import { Button } from "../../ui/atoms/Button";
@@ -120,9 +120,9 @@ function Row({ a, operator, onChanged }: { a: ClaudeAccount; operator: boolean;
<dt className="text-ink/55">Login expires</dt>
<dd className={cn(exp !== null && exp < Date.now() + 7 * 86_400_000 && "text-warn")}>{when(a.auth.expiresAt)}</dd>
<dt className="text-ink/55">Status read</dt>
<dd>{a.auth.checkedAt ? ago(a.auth.checkedAt, false) : "never"}</dd>
<dd>{a.auth.checkedAt ? eventTime(a.auth.checkedAt) : "never"}</dd>
<dt className="text-ink/55">Usage read</dt>
<dd>{a.usage.readAt ? ago(a.usage.readAt, false) : "never"}</dd>
<dd>{a.usage.readAt ? eventTime(a.usage.readAt) : "never"}</dd>
</dl>
{operator && (
<div className="mt-3 flex flex-wrap items-center gap-2 border-t border-line pt-3">
+4 -3
View File
@@ -7,7 +7,8 @@ import { Badge } from "../../ui/atoms/Badge";
import { Button } from "../../ui/atoms/Button";
import { cn } from "../../ui/cn";
import { Count } from "../../ui/atoms/Heading";
import { ago, day, when } from "../../lib/format";
import { day, when } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { useIsPhone } from "../../shell/useMedia";
import { Block } from "../../ui/molecules/Block";
import { ConfirmButton } from "../../ui/molecules/ConfirmButton";
@@ -215,7 +216,7 @@ function Sessions({ sessions }: { sessions: SessionInfo[] }) {
{s.current && <Badge tone="accent">this session</Badge>}
</div>
<div className="mt-0.5 text-xs text-ink/55">
{browser(s.userAgent)} · seen {ago(s.lastSeen, false)}
{browser(s.userAgent)} · seen <TimeAgo iso={s.lastSeen} />
</div>
</div>
{revoke(s)}
@@ -251,7 +252,7 @@ function Sessions({ sessions }: { sessions: SessionInfo[] }) {
</td>
<td className="num whitespace-nowrap px-3 text-ink/65">{when(s.createdAt)}</td>
<td className="px-3 text-ink/65" title={when(s.lastSeen)}>
{ago(s.lastSeen, false)}
<TimeAgo iso={s.lastSeen} />
</td>
<td className="num whitespace-nowrap px-3 text-ink/65">{when(s.expiresAt)}</td>
<td className="px-3 text-right">{revoke(s)}</td>
+2 -2
View File
@@ -2,7 +2,7 @@ import { useApi } from "../../api/client";
import type { TrackedRepo } from "../../api/types";
import { Badge } from "../../ui/atoms/Badge";
import { Button } from "../../ui/atoms/Button";
import { ago, num } from "../../lib/format";
import { num, eventTime } from "../../lib/format";
import { useUser } from "../../shell/UserContext";
import { ConfirmButton } from "../../ui/molecules/ConfirmButton";
import { Switch } from "../../ui/atoms/Switch";
@@ -134,7 +134,7 @@ export function PipelineSwitch({ r, write }: { r: TrackedRepo; write: Write }) {
}
export const synced = (r: TrackedRepo) =>
r.syncedAt ? `${ago(r.syncedAt, false)}` : "never";
r.syncedAt ? `${eventTime(r.syncedAt)}` : "never";
export const maybe = (n: number | null) => (n === null ? "–" : num(n));
/** The checks whose failure does not stop a merge: a list for everyone, with remove and add for operators. */
+4 -3
View File
@@ -7,7 +7,8 @@ import { CaretDownIcon, CaretRightIcon, XIcon } from "@phosphor-icons/react";
import { usePagedQuery, useQuery } from "../../api/client";
import type { AgentRun, AgentRunDetail, AgentRunFilter, AgentRunPage, AgentRunState } from "../../api/types";
import type { ViewProps } from "../../registry/types";
import { ago, nowMs, num, span } from "../../lib/format";
import { nowMs, num, span } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { useNow } from "../../lib/useNow";
import { Badge, type Tone } from "../../ui/atoms/Badge";
import { Button } from "../../ui/atoms/Button";
@@ -141,7 +142,7 @@ function RecentRuns({ selected }: { selected?: number }) {
<tr key={r.id} className={cn("relative border-t border-line hover:bg-ink/[0.03]", selected === r.id && "bg-accent/10")}>
<td className="relative z-10 whitespace-nowrap px-3 py-1.5 text-ink/70" title={r.startedAt}>
<span className={cn("mr-1.5 inline-block size-2 rounded-full md:hidden", r.state === "failed" ? "bg-bad" : r.state === "running" ? "bg-accent" : "bg-ok")} role="img" aria-label={STATE_LABEL[r.state]} />
{ago(r.startedAt, true)}<span className="max-md:hidden"> ago</span>
<TimeAgo iso={r.startedAt} /><span className="max-md:hidden"> ago</span>
</td>
<td className="whitespace-nowrap px-3 code text-xs">
<Link to={`/agents/${r.id}${location.search}`} className="after:absolute after:inset-0">
@@ -219,7 +220,7 @@ function DetailBody({ id }: { id: number }) {
</dd>
<dt className="text-ink/55">Started</dt>
<dd className="num">
{ago(r.startedAt, false)} · {r.endedAt ? `took ${elapsed(r)}` : `running for ${elapsed(r)}`}
<TimeAgo iso={r.startedAt} /> · {r.endedAt ? `took ${elapsed(r)}` : `running for ${elapsed(r)}`}
</dd>
<dt className="text-ink/55">Tokens</dt>
<dd className="num">
+1 -1
View File
@@ -77,7 +77,7 @@ function Ci({ b }: { b: BatchDetail }) {
if (b.prNumber === null) return null;
const ci = b.ci;
return (
<Block className="mt-3" title="Integration CI" aside={ci ? <>read <TimeAgo iso={ci.fetchedAt} short={false} /></> : undefined}>
<Block className="mt-3" title="Integration CI" aside={ci ? <>read <TimeAgo iso={ci.fetchedAt} /></> : undefined}>
{!ci ? (
<p className="text-sm text-ink/55">No CI read yet.</p>
) : (
+5 -4
View File
@@ -5,7 +5,8 @@ import type { ConversationCard, ConversationTurn, RepoName } from "../../api/typ
import { Avatar } from "../../ui/atoms/Avatar";
import { Button } from "../../ui/atoms/Button";
import { Markdown } from "../../ui/molecules/Markdown";
import { ago } from "../../lib/format";
import { } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { useNow } from "../../lib/useNow";
const message = (e: unknown) => (e instanceof Error ? e.message : String(e));
@@ -84,7 +85,7 @@ function Turn({ t, operator }: { t: ConversationTurn; operator: boolean }) {
<li className="flex items-start gap-2 text-xs text-ink/50">
<span className="mt-1.5 size-1.5 shrink-0 rounded-full bg-ink/30" />
<span className="min-w-0 flex-1">{t.body}</span>
<span className="shrink-0">{ago(t.at)}</span>
<span className="shrink-0"><TimeAgo iso={t.at} /></span>
</li>
);
}
@@ -93,7 +94,7 @@ function Turn({ t, operator }: { t: ConversationTurn; operator: boolean }) {
<div className="flex items-center gap-2">
<Avatar login={t.login} size={20} />
<span className="text-sm font-semibold">{t.kind === "opus" ? "Opus" : t.login}</span>
<span className="ml-auto text-xs text-ink/45">{ago(t.at)}</span>
<span className="ml-auto text-xs text-ink/45"><TimeAgo iso={t.at} /></span>
</div>
<div className="mt-1 pl-7 text-sm leading-5 text-ink/80">
{t.kind === "opus" ? <Markdown source={t.body} /> : <p className="whitespace-pre-wrap">{t.body}</p>}
@@ -181,7 +182,7 @@ function ActionCard({ a, operator }: { a: ConversationCard; operator: boolean })
) : (
a.done.label
)}{" "}
· {ago(a.done.at, false)}
· <TimeAgo iso={a.done.at} />
{a.by ? ` · ${a.by}` : ""}
</p>
)}
+5 -4
View File
@@ -14,7 +14,8 @@ import { ConfirmButton, useWrite } from "../admin/parts";
import { Count } from "../../ui/atoms/Heading";
import { Markdown, Collapsible } from "../../ui/molecules/Markdown";
import { cn } from "../../ui/cn";
import { ago } from "../../lib/format";
import { } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { ClaimPill, ClassifierLines, Disclosure, Facts, KindTag, RelatedList } from "./parts";
import { Refs } from "./Refs";
import { FeedbackBox } from "./FeedbackBox";
@@ -172,7 +173,7 @@ export function DecisionBody({
)}
<PriorityBadge p={d.priority} />
{!isBatch && <QueueBadge slot={d.queue} />}
<span>asked {ago(d.askedAt)} ago</span>
<span>asked <TimeAgo iso={d.askedAt} /></span>
<ClaimPill claim={d.claim} />
{!isBatch && (
<span className="ml-auto flex flex-wrap items-center gap-1.5">
@@ -200,7 +201,7 @@ export function DecisionBody({
<SparkleIcon className="text-[12px] text-accent-ink" />
<span className="font-semibold text-ink/75">AI summary</span>
<span>
· {d.summaryBy} · {ago(d.summaryAt)} ago
· {d.summaryBy} · <TimeAgo iso={d.summaryAt} />
</span>
</div>
<p className="text-sm leading-[21px] text-ink/90">
@@ -384,7 +385,7 @@ export function AnsweredState({ d, canUndo }: { d: Decision; canUndo: boolean })
<span className="text-sm font-medium">{label}</span>
<span className="text-xs text-ink/55">
by {d.answeredBy}
{d.adoptedOpinion ? `, using ${d.adoptedOpinion.login}'s answer` : ""} · {ago(d.answeredAt!)} ago{backlog ? "" : ` · ${d.appliedAt ? "applied" : "not applied yet"}`}
{d.adoptedOpinion ? `, using ${d.adoptedOpinion.login}'s answer` : ""} · <TimeAgo iso={d.answeredAt!} />{backlog ? "" : ` · ${d.appliedAt ? "applied" : "not applied yet"}`}
</span>
{d.answerNote && <span className="w-full text-sm text-ink/70">“{d.answerNote}”</span>}
{backlog && canUndo && (
+4 -3
View File
@@ -8,7 +8,8 @@ import { useHotkeys, useShortcutHelp } from "../../shell/keyboard";
import { Count } from "../../ui/atoms/Heading";
import { Button } from "../../ui/atoms/Button";
import { cn } from "../../ui/cn";
import { ago, ageDays } from "../../lib/format";
import { ago, ageDays, when } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { ItemRef } from "../../ui/molecules/ItemRef";
import { ClaimPill, KIND_ICON } from "./parts";
import { canActOn } from "./DecisionDetail";
@@ -135,8 +136,8 @@ function Row({ d, canUndo, active, checked, mine, onOpen, activeRef }: { d: Deci
<div ref={activeRef} role="option" tabIndex={0} aria-selected={active} onClick={onOpen} onKeyDown={(e) => { if (e.target === e.currentTarget && (e.key === "Enter" || e.key === " ")) { e.preventDefault(); onOpen(); } }} className="min-w-0 flex-1 cursor-pointer rounded-none py-2 pr-3 text-left">
<div className="flex items-baseline gap-2">
<span className={cn("min-w-0 flex-1 break-words text-sm", active ? "font-medium text-ink" : "text-ink/90")}>{d.title}</span>
<span className={cn("num shrink-0 text-xs", old ? "text-warn" : "text-ink/45")} title={`asked ${ago(d.askedAt, false)}`}>
{ago(d.askedAt)}
<span className={cn("num shrink-0 text-xs", old ? "text-warn" : "text-ink/45")} title={`asked ${when(d.askedAt)}`}>
<TimeAgo iso={d.askedAt} />
</span>
</div>
<div className="mt-0.5 flex items-start gap-1.5 text-xs text-ink/50">
+3 -2
View File
@@ -5,7 +5,8 @@ import type { ViewProps } from "../../registry/types";
import { Avatar } from "../../ui/atoms/Avatar";
import { cn } from "../../ui/cn";
import { Count } from "../../ui/atoms/Heading";
import { ago } from "../../lib/format";
import { } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { localActions, useDecisionList, usePinned, useSelection } from "./state";
import { scrollToWorkflow } from "./Workflow";
import { canAct, canComment } from "../../registry/permissions";
@@ -99,7 +100,7 @@ export function FeedbackList({ d, me, onUse, onRetract, compact }: { d: Decision
{e.write ? "write" : "no write"}
</span>
)}
<span className="text-xs text-ink/45">{ago(e.at)}</span>
<span className="text-xs text-ink/45"><TimeAgo iso={e.at} /></span>
</span>
</div>
{e.text && <p className="mt-1 whitespace-pre-wrap break-words pl-7 text-sm leading-5 text-ink/80">{e.text}</p>}
+4 -3
View File
@@ -15,7 +15,8 @@ import { Avatar } from "../../ui/atoms/Avatar";
import { Kbd } from "../../ui/atoms/Kbd";
import { Count } from "../../ui/atoms/Heading";
import { cn } from "../../ui/cn";
import { ago } from "../../lib/format";
import { eventTime } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { Refs } from "./Refs";
import { KIND_LABEL } from "./state";
import { useNow } from "../../lib/useNow";
@@ -44,11 +45,11 @@ export function ClaimPill({ claim, compact }: { claim: Decision["claim"]; compac
useNow();
if (!claim) return null;
return (
<span className="inline-flex items-center gap-1.5 text-xs text-warn" title={`${claim.login} opened this ${ago(claim.since, false)}`}>
<span className="inline-flex items-center gap-1.5 text-xs text-warn" title={`${claim.login} opened this ${eventTime(claim.since)}`}>
<Avatar login={claim.login} size={16} />
{!compact && (
<span>
{claim.login} is viewing · {ago(claim.since)}
{claim.login} is viewing · <TimeAgo iso={claim.since} />
</span>
)}
</span>
+6 -6
View File
@@ -7,7 +7,8 @@ import { CheckIcon, CopyIcon, DownloadSimpleIcon, PencilSimpleIcon, PlusIcon, XI
import { useApi, usePagedQuery, useQuery } from "../../api/client";
import type { BuildEnv, BuildSummary, BuildTask, BuildTaskDetail, Capabilities, EnvKind, Requires, TaskBatch, TaskFilter, TaskState } from "../../api/types";
import type { ViewProps } from "../../registry/types";
import { ago, nowMs, num, span } from "../../lib/format";
import { nowMs, num, span, eventTime } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { useUser } from "../../shell/UserContext";
import { Badge, type Tone } from "../../ui/atoms/Badge";
import { Button } from "../../ui/atoms/Button";
@@ -155,7 +156,7 @@ function EnvCard({ e, operator }: { e: BuildEnv; operator: boolean }) {
<dt className="text-ink/55">Worker</dt>
<dd className="num">{e.version ? `version ${e.version}` : "never connected"}</dd>
<dt className="text-ink/55">Last seen</dt>
<dd className="num">{e.lastSeenAt ? `${ago(e.lastSeenAt, false)}` : "never"}</dd>
<dd className="num">{e.lastSeenAt ? `${eventTime(e.lastSeenAt)}` : "never"}</dd>
{e.pausedReason && (
<>
<dt className="text-ink/55">Paused</dt>
@@ -373,8 +374,7 @@ function Tasks({ selected }: { selected?: number }) {
<tr key={r.id} className={cn("relative border-t border-line hover:bg-ink/[0.03]", selected === r.id && "bg-accent/10")}>
<td className="whitespace-nowrap px-3 py-1.5 text-ink/70">
<Link to={`/envs/${r.id}${location.search}`} title={r.queuedAt} className="after:absolute after:inset-0">
{ago(r.queuedAt, true)}
<span className="max-md:hidden"> ago</span>
<TimeAgo iso={r.queuedAt} />
</Link>
</td>
<td className="px-3 py-1.5">
@@ -454,7 +454,7 @@ function DetailBody({ id }: { id: number }) {
<dt className="text-ink/55">Environment</dt>
<dd>{t.envLabel ?? "not claimed yet"}</dd>
<dt className="text-ink/55">Queued</dt>
<dd className="num">{ago(t.queuedAt, false)}</dd>
<dd className="num"><TimeAgo iso={t.queuedAt} /></dd>
<dt className="text-ink/55">Run time</dt>
<dd className="num">{duration(t)}</dd>
<dt className="text-ink/55">Warm build</dt>
@@ -474,7 +474,7 @@ function DetailBody({ id }: { id: number }) {
{t.heartbeatAt && active && (
<>
<dt className="text-ink/55">Heartbeat</dt>
<dd className="num">{ago(t.heartbeatAt, false)}</dd>
<dd className="num"><TimeAgo iso={t.heartbeatAt} /></dd>
</>
)}
</dl>
+4 -3
View File
@@ -9,7 +9,8 @@ import { Slot } from "../../registry/Slot";
import { useUser } from "../../shell/UserContext";
import { Badge } from "../../ui/atoms/Badge";
import { cn } from "../../ui/cn";
import { ago, num } from "../../lib/format";
import { num } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { JobBadge } from "../pipeline/views";
import { StageLimitRow } from "../pipeline/controls";
import { PromptCard } from "../prompts/views";
@@ -59,7 +60,7 @@ function StepBlock({ name, title }: { name: string; title: string }) {
{j.summary ?? j.error ?? j.progress ?? "–"}
</span>
<span className="text-xs text-ink/50">
{ago(j.endedAt ?? j.startedAt ?? j.requestedAt)} ago · by {j.requestedBy}
<TimeAgo iso={j.endedAt ?? j.startedAt ?? j.requestedAt} /> · by {j.requestedBy}
{j.usage?.costUsd ? ` · $${j.usage.costUsd.toFixed(2)}` : j.usage?.calls ? ` · ${num(j.usage.input + j.usage.output)} tokens` : ""}
</span>
</span>
@@ -166,7 +167,7 @@ export function FlowPanel({ flow, node: n, onClose, onSelect }: { flow: Flow; no
{n.facts.map((f) => (
<div key={f.label} className="contents">
<dt className="text-ink/55">{f.label}</dt>
<dd className="min-w-0 break-words">{/^\d{4}-\d\d-\d\dT/.test(f.value) ? `${ago(f.value)} ago` : f.value}</dd>
<dd className="min-w-0 break-words">{/^\d{4}-\d\d-\d\dT/.test(f.value) ? <><TimeAgo iso={f.value} /></> : f.value}</dd>
</div>
))}
</dl>
+4 -3
View File
@@ -8,7 +8,8 @@ import type { Flow } from "../../api/types";
import type { ViewProps } from "../../registry/types";
import { useMedia } from "../../shell/useMedia";
import { RepoSelect } from "../../ui/molecules/RepoSelect";
import { ago, num } from "../../lib/format";
import { num } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { ErrorLine, useUrlState } from "../admin/parts";
import { PipelineSwitch } from "../pipeline/controls";
import { Chart } from "./Chart";
@@ -87,8 +88,8 @@ export function FlowView(_: ViewProps) {
<h1 className="text-xl font-semibold">Pipeline flow</h1>
{flow && (
<p className="mt-0.5 text-sm text-ink/55">
{num(open)} open items{repo ? ` in ${repo}` : ""} · last sync {flow.lastSync ? `${ago(flow.lastSync)} ago` : "never"}
{flow.countedAt && ` · counted ${ago(flow.countedAt)} ago`}
{num(open)} open items{repo ? ` in ${repo}` : ""} · last sync {flow.lastSync ? <><TimeAgo iso={flow.lastSync} /></> : "never"}
{flow.countedAt && <> · counted <TimeAgo iso={flow.countedAt} /></>}
{flow.uncounted > 0 && ` · ${num(flow.uncounted)} repos not counted yet`}
</p>
)}
+8 -7
View File
@@ -10,7 +10,8 @@ import { Markdown } from "../../ui/molecules/Markdown";
import { useUser } from "../../shell/UserContext";
import { ConfirmButton, ErrorLine, useWrite } from "../admin/parts";
import { decisionPath } from "../../lib/links";
import { ago, span } from "../../lib/format";
import { span } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { useNow } from "../../lib/useNow";
function Box({ title, aside, children }: { title: string; aside?: ReactNode; children: ReactNode }) {
@@ -45,7 +46,7 @@ function Verify({ v }: { v: ItemVerification }) {
<span className="font-medium">{KIND[v.kind]}</span>
<span className="code text-xs text-ink/50" title={v.headSha}>{v.headSha.slice(0, 7)}</span>
{!v.current && <Badge tone="warn">Older head</Badge>}
<span className="ml-auto text-xs text-ink/50">{v.finishedAt ? `finished ${ago(v.finishedAt)} ago` : `planned ${ago(v.createdAt)} ago`}</span>
<span className="ml-auto text-xs text-ink/50">{v.finishedAt ? <>finished <TimeAgo iso={v.finishedAt} /></> : <>planned <TimeAgo iso={v.createdAt} /></>}</span>
</div>
<p className="mt-2 text-ink/80">{v.reason}</p>
{p && (
@@ -188,7 +189,7 @@ function Postmerge({ p, repo }: { p: ItemPostmerge; repo: string }) {
{p.error ? <Badge tone="warn">No review</Badge> : p.findings.length === 0 ? <Badge tone="ok">No findings</Badge> : null}
{p.error && <span className="text-ink/75">{p.error}</span>}
<span className="code text-xs text-ink/50" title={p.mergeSha}>{p.mergeSha.slice(0, 7)}</span>
<span className="ml-auto text-xs text-ink/50">{ago(p.at)} ago</span>
<span className="ml-auto text-xs text-ink/50"><TimeAgo iso={p.at} /></span>
</div>
{p.earlier.length > 0 && (
<div className="mb-2 flex flex-wrap items-center gap-2 text-xs text-ink/70">
@@ -218,7 +219,7 @@ function Premerge({ rows }: { rows: ItemPremerge[] }) {
{r.error ? <Badge tone="warn">No review</Badge> : r.findings.length === 0 ? <Badge tone="ok">No findings</Badge> : null}
{r.error && <span className="min-w-0 break-words text-ink/75">{r.error} ({r.tries} {r.tries === 1 ? "try" : "tries"})</span>}
{r.model && <span className="text-xs text-ink/50">{r.model}</span>}
<span className="ml-auto text-xs text-ink/50">{ago(r.at)} ago</span>
<span className="ml-auto text-xs text-ink/50"><TimeAgo iso={r.at} /></span>
</div>
{r.findings.length > 0 && (
<ul className="divide-y divide-line rounded-md border border-line">
@@ -259,7 +260,7 @@ function PatchChecks({ rows }: { rows: ItemPatchCheck[] }) {
<Badge tone={c.verdict === "approve" ? "ok" : "bad"}>{c.verdict === "approve" ? "Approved" : "Rejected"}</Badge>
<span className="text-xs text-ink/55">Opus check · round {c.round}</span>
<span className="code text-xs text-ink/55" title={c.subject}>{c.subject.slice(0, 7)}</span>
<span className="ml-auto text-xs text-ink/50">{ago(c.createdAt)} ago</span>
<span className="ml-auto text-xs text-ink/50"><TimeAgo iso={c.createdAt} /></span>
</div>
{c.reasons && <p className="mt-1 text-ink/75">{c.reasons}</p>}
{c.problems.length > 0 && (
@@ -297,7 +298,7 @@ function Fixups({ rows }: { rows: ItemFixup[] }) {
{f.fromHead.slice(0, 7)}
{f.toHead && ` → ${f.toHead.slice(0, 7)}`}
</span>
<span className="ml-auto text-xs text-ink/50">{ago(f.createdAt)} ago</span>
<span className="ml-auto text-xs text-ink/50"><TimeAgo iso={f.createdAt} /></span>
</div>
{f.reason && <p className="mt-1 text-ink/75">{f.reason}</p>}
{f.files.length > 0 && <p className="code mt-1 break-all text-xs leading-5 text-ink/65">{f.files.join(", ")}</p>}
@@ -330,7 +331,7 @@ function Actions({ rows, repo, number }: { rows: ItemAction[]; repo: string; num
<Link to={decisionPath({ id: a.decisionId, repo, number: a.decisionKind ? number : null, kind: a.decisionKind ?? undefined })} className="code text-xs text-ink/50 hover:underline">
{a.decisionId}
</Link>
<span className="ml-auto text-xs text-ink/50">{ago(a.createdAt)} ago</span>
<span className="ml-auto text-xs text-ink/50"><TimeAgo iso={a.createdAt} /></span>
</div>
{a.reason && <p className="mt-1 text-ink/75">{a.reason}</p>}
</li>
+36 -16
View File
@@ -8,7 +8,7 @@ import { TimelineEvent } from "../../ui/molecules/TimelineEvent";
import { TraceFilters } from "../../ui/molecules/TraceFilters";
import { HeadGroup } from "../../ui/organisms/HeadGroup";
import { TraceHeader } from "../../ui/organisms/TraceHeader";
import { groupByHead, pushedBy, TRACE_KIND } from "../../lib/trace";
import { callGroupSummary, groupByHead, groupCalls, pushedBy, TRACE_KIND } from "../../lib/trace";
import { TraceEventBody } from "./TraceEventBody";
const PAGE = 50;
@@ -93,21 +93,41 @@ export function TracePanel({ repo, number, it }: { repo: string; number: number;
{groups.length === 0 && <p className="px-3 py-3 text-sm text-ink/55">No events match.</p>}
{groups.map((g) => (
<HeadGroup key={`${g.head}:${g.events[0]!.id}`} head={g.head} pushedBy={g.head ? pushedBy(events, g.head) : null}>
{g.events.map((e) => (
<TimelineEvent
key={e.id}
id={e.id}
Icon={TRACE_KIND[e.kind].Icon}
at={e.at}
actor={e.actor.name}
actorTone={e.actor.type === "person" ? "person" : "ours"}
summary={e.summary}
open={open.has(e.id)}
onToggle={() => toggle(e.id)}
>
<TraceEventBody event={e} item={it} />
</TimelineEvent>
))}
{groupCalls(g.events).map((r) => {
const row = (e: TraceEvent) => (
<TimelineEvent
key={e.id}
id={e.id}
Icon={TRACE_KIND[e.kind].Icon}
at={e.at}
actor={e.actor.name}
actorTone={e.actor.type === "person" ? "person" : "ours"}
summary={e.summary}
open={open.has(e.id)}
onToggle={() => toggle(e.id)}
>
<TraceEventBody event={e} item={it} />
</TimelineEvent>
);
if (!r.calls) return row(r.event);
const gid = `group:${r.event.id}`;
return (
<TimelineEvent
key={gid}
id={gid}
Icon={TRACE_KIND[r.event.kind].Icon}
at={r.event.at}
actor={r.event.call?.step ?? r.event.actor.name}
actorTone="ours"
summary={callGroupSummary(r.calls)}
open={r.calls.some((c) => c.id === hashEvent()) !== open.has(gid)}
onToggle={() => toggle(gid)}
flush
>
<ul className="overflow-hidden rounded-md border border-line bg-panel">{r.calls.map(row)}</ul>
</TimelineEvent>
);
})}
</HeadGroup>
))}
</div>
+7 -6
View File
@@ -27,7 +27,8 @@ import { Badge, type Tone } from "../../ui/atoms/Badge";
import { PriorityBadge } from "../../ui/atoms/PriorityBadge";
import { Count } from "../../ui/atoms/Heading";
import { cn } from "../../ui/cn";
import { ago, num } from "../../lib/format";
import { num } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { KindTag, tallyOf } from "../decisions/parts";
import { RecommendationLine } from "../../ui/molecules/RecommendationLine";
import { Markdown, Collapsible } from "../../ui/molecules/Markdown";
@@ -144,7 +145,7 @@ function Header({ it }: { it: Item }) {
<span className="inline-flex items-center gap-1.5">
<Avatar login={it.author} size={18} />
<span>
<span className="font-medium text-ink">{it.author}</span> opened {ago(it.createdAt)} ago in <span className="code text-ink/80">{it.repo}</span>
<span className="font-medium text-ink">{it.author}</span> opened <TimeAgo iso={it.createdAt} /> in <span className="code text-ink/80">{it.repo}</span>
</span>
</span>
<span className="ml-auto flex flex-wrap items-center gap-1.5">
@@ -241,7 +242,7 @@ function Properties({ it }: { it: Item }) {
))}
</Prop>
<Prop label="Updated">
<span className="text-ink/80">{ago(it.updatedAt, false)}</span>
<span className="text-ink/80"><TimeAgo iso={it.updatedAt} /></span>
</Prop>
</dl>
);
@@ -300,7 +301,7 @@ function Verdicts({ cls }: { cls: Classification[] }) {
<span className="font-semibold">{c.classifier}</span>
<span className={cn(c.typeLabel !== typeMaj && off)}>{c.typeLabel}</span>
<span className={cn(WANT[c.want], c.want !== wantMaj && off)}>want {c.want}</span>
<span className="ml-auto text-xs text-ink/45">{ago(c.at)}</span>
<span className="ml-auto text-xs text-ink/45"><TimeAgo iso={c.at} /></span>
</div>
{c.reference && <div className="mt-0.5 text-xs text-ink/55">Reference: {c.reference}</div>}
<div className="mt-1 text-sm text-ink/70">
@@ -324,7 +325,7 @@ function Verdicts({ cls }: { cls: Classification[] }) {
<th className="w-[96px] px-3 py-2" />
{cls.map((c) => (
<th key={c.classifier} className="px-3 py-2 font-semibold">
{c.classifier} <span className="ml-1 text-xs font-normal text-ink/45">{ago(c.at)} ago</span>
{c.classifier} <span className="ml-1 text-xs font-normal text-ink/45"><TimeAgo iso={c.at} /></span>
</th>
))}
</tr>
@@ -401,7 +402,7 @@ export function ItemSide(props: ViewProps) {
<Link key={d.id} to={decisionPath(d, { siblings: ds })} className="block rounded-md border border-line p-2.5 transition-colors duration-fast hover:border-line-strong hover:bg-ink/[0.03]">
<div className="flex items-center gap-2">
<KindTag kind={d.kind} />
<span className="ml-auto text-xs text-ink/50">{d.answer ? `answered ${ago(d.answeredAt!)} ago` : `waiting ${ago(d.askedAt)}`}</span>
<span className="ml-auto text-xs text-ink/50">{d.answer ? <>answered <TimeAgo iso={d.answeredAt!} /></> : <>waiting <TimeAgo iso={d.askedAt} /></>}</span>
</div>
<p className="mt-1.5 text-sm font-medium leading-5">{d.question}</p>
{d.answer ? (
+4 -3
View File
@@ -10,7 +10,8 @@ import type { ViewProps } from "../../registry/types";
import { Badge, type Tone } from "../../ui/atoms/Badge";
import { ItemRef } from "../../ui/molecules/ItemRef";
import { cn } from "../../ui/cn";
import { ago, day, num, when } from "../../lib/format";
import { day, num, when } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { useIsPhone } from "../../shell/useMedia";
import { Block, ErrorLine, Page, Pager, selectCls, TextInput, useUrlState } from "../admin/parts";
import { useNow } from "../../lib/useNow";
@@ -331,7 +332,7 @@ function Table({ rows, byUs }: { rows: ItemListRow[]; byUs: boolean }) {
</td>
<td className="truncate px-3 py-2 text-ink/70">{it.author}</td>
<td className="num relative z-10 whitespace-nowrap px-3 py-2 text-ink/55" title={`created ${day(it.createdAt)}, updated ${when(it.updatedAt)}`}>
{(byUs ? it.mergedAt : it.updatedAt) ? `${ago((byUs ? it.mergedAt : it.updatedAt)!)} ago` : "–"}
{(byUs ? it.mergedAt : it.updatedAt) ? <><TimeAgo iso={(byUs ? it.mergedAt : it.updatedAt)!} /></> : "–"}
</td>
<td className="px-3 py-2">
<SettledBadge s={it.settled} />
@@ -361,7 +362,7 @@ function Cards({ rows, byUs }: { rows: ItemListRow[]; byUs: boolean }) {
<ItemRef repo={it.repo} number={it.number} kind={it.kind} state={it.state} title={it.title} stretch />
<div className="mt-1 flex items-center gap-2 pl-6 text-xs text-ink/55">
<span className="truncate">{it.author}</span>
<span className="num ml-auto shrink-0">{(byUs ? it.mergedAt : it.updatedAt) ? `${byUs ? "merged " : ""}${ago((byUs ? it.mergedAt : it.updatedAt)!)} ago` : ""}</span>
<span className="num ml-auto shrink-0">{(byUs ? it.mergedAt : it.updatedAt) ? <>{byUs ? "merged " : ""}<TimeAgo iso={(byUs ? it.mergedAt : it.updatedAt)!} /></> : ""}</span>
</div>
{it.snippet && it.snippet.field !== "title" && (
<div className="mt-1 line-clamp-2 pl-6">
+3 -2
View File
@@ -5,7 +5,8 @@ import { useEffect, useRef, useState } from "react";
import { PauseIcon, PlayIcon } from "@phosphor-icons/react";
import { useApi, useQuery } from "../../api/client";
import type { PipelineState, StageLimit } from "../../api/types";
import { ago, dayResetLocal, num, when } from "../../lib/format";
import { dayResetLocal, num, when } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { useUser } from "../../shell/UserContext";
import { Badge } from "../../ui/atoms/Badge";
import { Button } from "../../ui/atoms/Button";
@@ -73,7 +74,7 @@ export function PipelineSwitch({ className }: { className?: string }) {
{s.changedAt && (
<span title={s.changedAt}>
{" "}
Switched {s.enabled ? "on" : "off"} by {s.changedBy ?? "unknown"} {ago(s.changedAt, false)} ({when(s.changedAt)}).
Switched {s.enabled ? "on" : "off"} by {s.changedBy ?? "unknown"} <TimeAgo iso={s.changedAt} /> ({when(s.changedAt)}).
</span>
)}
</div>
+5 -4
View File
@@ -11,7 +11,8 @@ import { can } from "../../registry/permissions";
import { Badge, type Tone } from "../../ui/atoms/Badge";
import { Button } from "../../ui/atoms/Button";
import { cn } from "../../ui/cn";
import { ago, num } from "../../lib/format";
import { num, eventTime } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { Block, ConfirmButton, ErrorLine, Page, useWrite, when } from "../admin/parts";
import { PilotPanel, PipelineSwitch, StageLimits } from "./controls";
import { useNow } from "../../lib/useNow";
@@ -49,7 +50,7 @@ const paramText = (p: JobParams) =>
function SyncRuns({ runs, last }: { runs: SyncRun[]; last: string | null }) {
useNow();
return (
<Block flush title="Sync" aside={last ? `last finished ${ago(last, false)}; runs on its own timer` : "runs on its own timer"}>
<Block flush title="Sync" aside={last ? `last finished ${eventTime(last)}; runs on its own timer` : "runs on its own timer"}>
{runs.length === 0 ? (
<p className="p-4 text-sm text-ink/50">No sync runs recorded yet.</p>
) : (
@@ -147,7 +148,7 @@ function Jobs({ selected }: { selected?: number }) {
<JobBadge j={j} />
</td>
<td className="whitespace-nowrap px-3 text-ink/65" title={j.requestedAt}>
{j.requestedBy} · {ago(j.requestedAt)}
{j.requestedBy} · <TimeAgo iso={j.requestedAt} />
</td>
<td className="num whitespace-nowrap px-3 text-right">{took(j.startedAt, j.endedAt)}</td>
<td className="max-w-[340px] truncate px-3 text-ink/70" title={j.error ?? j.summary ?? j.progress ?? ""}>
@@ -178,7 +179,7 @@ function RunnerLine({ o }: { o: PipelineOverview }) {
return (
<span className="inline-flex items-center gap-1.5">
<span className={cn("size-2 rounded-full", o.runner.alive ? "bg-ok" : "bg-bad")} aria-hidden />
{o.runner.alive ? "Runner running" : o.runner.lastSeen ? `Runner not running since ${ago(o.runner.lastSeen, false)}: jobs wait until it starts` : "Runner not started: jobs wait until it starts"}
{o.runner.alive ? "Runner running" : o.runner.lastSeen ? `Runner not running since ${eventTime(o.runner.lastSeen)}: jobs wait until it starts` : "Runner not started: jobs wait until it starts"}
{" · "}
{o.counts.running} running, {o.counts.queued} queued
</span>
+4 -3
View File
@@ -7,7 +7,8 @@ import type { BatchState, QueueBatch, QueueMergeRow, QueueRow, QueueState, Tier
import { Badge, type Tone } from "../../ui/atoms/Badge";
import { ItemRef } from "../../ui/molecules/ItemRef";
import { cn } from "../../ui/cn";
import { ago, when } from "../../lib/format";
import { when } from "../../lib/format";
import { TimeAgo } from "../../ui/atoms/TimeAgo";
import { useNow } from "../../lib/useNow";
import { batchPath, decisionPath } from "../../lib/links";
import { FastMark } from "./fastTrack";
@@ -76,7 +77,7 @@ export function BatchFacts({ b }: { b: QueueBatch }) {
{b.baseSha.slice(0, 7)}
</a>
<span className="num text-2xs text-ink/50" title={`created ${when(b.createdAt)}, updated ${when(b.updatedAt)}`}>
{ago(b.updatedAt)} ago
<TimeAgo iso={b.updatedAt} />
</span>
</>
);
@@ -167,7 +168,7 @@ function ReviewText({ r }: { r: QueueRow }) {
<Why row={r} />
<DecisionLink row={r} />
<span className="num text-ink/40" title={`reviewed ${when(r.reviewedAt)} at ${r.head.slice(0, 7)}`}>
reviewed {ago(r.reviewedAt)} ago
reviewed <TimeAgo iso={r.reviewedAt} />
</span>
</div>
</div>
+4 -4
View File
@@ -1,12 +1,12 @@
import { ago, when } from "../../lib/format";
import { eventTime, when } from "../../lib/format";
import { useNow } from "../../lib/useNow";
/** "3m" or "3 minutes ago"; re-renders as time passes. The tooltip shows the time in the viewer's time zone. */
export function TimeAgo({ iso, short = true, className }: { iso: string; short?: boolean; className?: string }) {
/** An event time ("now", "12m ago", "14:32", "yesterday 14:32", "Nov 3 14:32"); re-renders as time passes. The tooltip shows the full time in the viewer's time zone. */
export function TimeAgo({ iso, className }: { iso: string; className?: string }) {
useNow();
return (
<time dateTime={iso} title={when(iso)} className={className}>
{short ? ago(iso) : ago(iso, false)}
{eventTime(iso)}
</time>
);
}
+4 -2
View File
@@ -7,7 +7,7 @@ import { TimeAgo } from "../atoms/TimeAgo";
* One row of an event timeline: kind icon, summary, actor and time. The row is a disclosure button;
* `children` are the expanded body and are only rendered while open.
*/
export function TimelineEvent({ id, lead, Icon, at, actor, actorTone, summary, open, onToggle, children }: {
export function TimelineEvent({ id, lead, Icon, at, actor, actorTone, summary, open, onToggle, flush, children }: {
id: string;
/** A line above the row that is not part of the disclosure button (a link to the item, say). */
lead?: ReactNode;
@@ -19,6 +19,8 @@ export function TimelineEvent({ id, lead, Icon, at, actor, actorTone, summary, o
summary: string;
open: boolean;
onToggle: () => void;
/** The body holds rows of its own and needs no inset on the left. */
flush?: boolean;
children?: ReactNode;
}) {
const Caret = open ? CaretDownIcon : CaretRightIcon;
@@ -42,7 +44,7 @@ export function TimelineEvent({ id, lead, Icon, at, actor, actorTone, summary, o
</span>
<Caret className="mt-1 shrink-0 text-ink/40" />
</button>
{open && <div className="border-t border-line bg-ink/[0.02] px-3 py-3 pl-[42px] max-md:pl-3">{children}</div>}
{open && <div className={cn("border-t border-line bg-ink/[0.02] px-3 py-3 pl-[42px] max-md:pl-3", flush && "pl-3")}>{children}</div>}
</li>
);
}
+2 -2
View File
@@ -25,7 +25,7 @@ export function TraceHeader({ header, decisionHref }: { header: ItemTraceHeader;
<p className="mt-0.5 flex flex-wrap items-center gap-x-2 text-xs text-ink/55">
{now.state && <Badge>{now.state}</Badge>}
{now.head && <span className="code">{shortSha(now.head)}</span>}
{now.plannedAt && <TimeAgo iso={now.plannedAt} short={false} className="num" />}
{now.plannedAt && <TimeAgo iso={now.plannedAt} className="num" />}
</p>
)}
{now.reasons.length > 0 && <p className="mt-0.5 text-xs text-ink/60">{now.reasons.join("; ")}</p>}
@@ -55,7 +55,7 @@ export function TraceHeader({ header, decisionHref }: { header: ItemTraceHeader;
))}
{who.holds.map((h) => (
<p key={h.at} className="mt-0.5 text-ink/70">
On hold by {h.by} <TimeAgo iso={h.at} short={false} className="num text-xs text-ink/50" />
On hold by {h.by} <TimeAgo iso={h.at} className="num text-xs text-ink/50" />
</p>
))}
</Cell>