Skip to content

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

Go

MUL-7780 feat(issues): run charts follow the pointer; a cost sparkline replaces the sidebar strip (#8912)

Jiayuan Zhang67d61a2073ba
diff --git a/packages/views/issues/components/execution-log-section.test.tsx b/packages/views/issues/components/execution-log-section.test.tsx
index 1b7e88f580..19153506ea 100644
--- a/packages/views/issues/components/execution-log-section.test.tsx
+++ b/packages/views/issues/components/execution-log-section.test.tsx
@@ -447,23 +447,32 @@ describe("execution log past runs", () => {
expect(within(row).queryByText("892K")).not.toBeInTheDocument();
});
- it("draws one strip bar per past run and sums the agent time", () => {
+ it("draws the spend sparkline over a track of every run and sums the agent time", () => {
renderSection([past(1), past(2), past(3, { status: "failed", usage: [] })]);
- const strip = screen.getByRole("button", {
- name: "Cost of each run, oldest to newest — open the run timeline",
+ const chart = screen.getByRole("button", {
+ name: "Cumulative cost over time — open the run timeline",
});
- expect(strip.children).toHaveLength(3);
+ expect(chart.querySelectorAll("[data-run]")).toHaveLength(3);
expect(screen.getByText(/30m agent time/)).toBeInTheDocument();
- fireEvent.click(strip);
+ fireEvent.click(chart);
expect(screen.getByRole("heading", { name: "Runs" })).toBeInTheDocument();
});
- it("skips the strip for a single run, where it would say nothing", () => {
+ it("draws the sparkline from the first priced run", () => {
+ // Review repro (MUL-7780): the old bar strip waited for two runs and then
+ // drew them as two 12px bars in the corner of an empty strip.
renderSection([past(1)]);
expect(
- screen.queryByRole("button", { name: /Cost of each run/ }),
+ screen.getByRole("button", { name: /Cumulative cost over time/ }),
+ ).toBeInTheDocument();
+ });
+
+ it("skips the sparkline when no run recorded usage — there is no curve to draw", () => {
+ renderSection([past(1, { usage: [] }), past(2, { usage: [] })]);
+ expect(
+ screen.queryByRole("button", { name: /Cumulative cost over time/ }),
).not.toBeInTheDocument();
});
});
diff --git a/packages/views/issues/components/execution-log-section.tsx b/packages/views/issues/components/execution-log-section.tsx
index e79373c3f3..30d91c6890 100644
--- a/packages/views/issues/components/execution-log-section.tsx
+++ b/packages/views/issues/components/execution-log-section.tsx
@@ -8,6 +8,7 @@ import { api } from "@multica/core/api";
import { issueTasksOptions } from "@multica/core/issues/queries";
import { useCustomPricingStore } from "@multica/core/runtimes/custom-pricing-store";
import type { AgentTask } from "@multica/core/types";
+import { cn } from "@multica/ui/lib/utils";
import { useLocale, useTimeAgo } from "../../i18n";
import {
Tooltip,
@@ -28,19 +29,27 @@ import {
summarizeTaskUsageAcross,
} from "../../runtimes/utils";
import { TerminateTaskConfirmDialog } from "./terminate-task-confirm-dialog";
-import { IssueRunsDialog, RunTriggerLabel } from "./issue-runs-dialog";
-import { buildRunTimeline, type TimelineRun } from "./issue-run-timeline";
+import { IssueRunsDialog, RunTriggerLabel, runBarTone } from "./issue-runs-dialog";
+import {
+ buildRunTimeline,
+ cumulativeCostAt,
+ idleSpanAround,
+ runIndexAt,
+ stepCurvePath,
+ type RunTimeline,
+ type TimelineRun,
+} from "./issue-run-timeline";
import { canRetryRun, RetryRunButton } from "./retry-run-button";
import { TaskStatusIcon } from "./task-status-icon";
import { useStatusLabel, useTriggerText } from "./task-run-labels";
import { WakeupRunLabel } from "./wakeup-source-chip";
// Right-panel section that lists every agent run for this issue. Active
-// runs sit at the top (always visible when present); below them a spend strip
-// (one bar per past run, oldest to newest, height = cost) and the latest few
-// past runs. The full history lives in the Runs dialog the header total, the
-// strip and the "Open timeline" row open — 21 rows do not belong in a 320px
-// column, and the dialog can lay them out in time.
+// runs sit at the top (always visible when present); below them a spend
+// sparkline (the issue's cumulative cost over time, above a track of its runs)
+// and the latest few past runs. The full history lives in the Runs dialog the
+// header total, the sparkline and the "Open timeline" row open — 21 rows do not
+// belong in a 320px column, and the dialog can lay them out in time.
//
// Replaces:
// - the click-to-expand timeline that used to live inside the in-body live
@@ -128,7 +137,7 @@ export function ExecutionLogSection({ issueId, identifier, issueTitle }: Executi
});
}, [tasks]);
- // Sidebar-only figures: the strip's bars and the agent-time line. Priced
+ // Sidebar-only figures: the sparkline and the agent-time line. Priced
// with the same helpers as the dialog, and re-derived on a saved custom rate
// for the same reason IssueRunsTotal subscribes.
const timeline = useMemo(
@@ -197,7 +206,7 @@ export function ExecutionLogSection({ issueId, identifier, issueTitle }: Executi
<div className="my-1.5 border-t border-border/60" />
)}
- {pastRuns.length >= 2 && <RunSpendStrip runs={pastRuns} onOpen={openRuns} />}
+ {timeline.pricedCount > 0 && <RunSpendSparkline timeline={timeline} onOpen={openRuns} />}
{timeline.agentMs > 0 && (
<p className="truncate px-1 pb-1 text-caption text-muted-foreground">
{t(($) => $.execution_log.agent_time, {
@@ -247,107 +256,200 @@ export function ExecutionLogSection({ issueId, identifier, issueTitle }: Executi
);
}
-// ─── Spend strip ───────────────────────────────────────────────────────────
-
-// The most bars the strip draws; older runs stay in the Runs dialog. Past this
-// a 260px column cannot keep a gap between bars.
-const STRIP_MAX_RUNS = 48;
-const STRIP_HEIGHT = 36;
-
-// One bar per past run, oldest to newest, height = that run's cost — the
-// issue's rhythm at a glance: how busy it has been, which runs were expensive,
-// and where one failed. The whole strip is one button into the Runs dialog;
-// each bar carries its own hover summary.
-function RunSpendStrip({ runs, onOpen }: { runs: TimelineRun[]; onOpen: () => void }) {
+// ─── Spend sparkline ───────────────────────────────────────────────────────
+
+const SPARK_HEIGHT = 34;
+// The curve tops out a little below the box, so the dot at its end has room.
+const SPARK_HEADROOM = 0.9;
+// Same idea as the Runs dialog's slop: a run a few seconds long is a 3px
+// sliver here, and the pointer only has to come near it.
+const SPARK_SLOP_PX = 6;
+
+// The Runs dialog's chart in miniature: the issue's cumulative cost as a step
+// curve over a track of its runs, on one time axis. Whatever the run count it
+// spans the column — the one-bar-per-run strip it replaced drew 12px bars from
+// the left, so an issue with three runs showed three bars in a corner of an
+// empty strip (MUL-7780) — and clicking it opens the same chart full size.
+// Hovering works like the dialog: a crosshair that follows the pointer, and a
+// tooltip naming the run under it or, between runs, the quiet stretch and what
+// the issue had spent by then.
+function RunSpendSparkline({ timeline, onOpen }: { timeline: RunTimeline; onOpen: () => void }) {
const { t } = useT("issues");
const locale = useLocale();
- const shown = runs.slice(-STRIP_MAX_RUNS);
- const maxCost = shown.reduce((m, run) => Math.max(m, run.usage?.cost ?? 0), 0);
- const dayOf = (ms: number) => new Date(ms).toDateString();
- const edgeLabel = (ms: number) =>
- dayOf(ms) === new Date().toDateString()
- ? t(($) => $.runs_timeline.day_today)
- : new Intl.DateTimeFormat(locale, { month: "short", day: "numeric" }).format(ms);
- const first = shown[0];
- const last = shown[shown.length - 1];
+ const [hover, setHover] = useState<{ t: number; width: number } | null>(null);
+ const [d0, d1] = timeline.domain;
+ const [e0, e1] = timeline.extent;
+ const xPct = (ms: number) => ((ms - d0) / (d1 - d0)) * 100;
+ const yMax = timeline.totalCost / SPARK_HEADROOM;
+ const yPct = (cost: number) => (1 - cost / yMax) * 100;
+ const { line, area } = stepCurvePath(timeline.cumulative, timeline.domain, yMax);
+ const last = timeline.cumulative[timeline.cumulative.length - 1];
+
+ const trackPointer = (event: React.PointerEvent<HTMLElement>) => {
+ const rect = event.currentTarget.getBoundingClientRect();
+ if (rect.width <= 0) return;
+ const at = d0 + ((event.clientX - rect.left) / rect.width) * (d1 - d0);
+ setHover({ t: Math.min(Math.max(at, e0), e1), width: rect.width });
+ };
+ const hoverIndex = hover
+ ? runIndexAt(timeline.runs, hover.t, (SPARK_SLOP_PX / hover.width) * (d1 - d0))
+ : -1;
+ const hovered = hoverIndex >= 0 ? timeline.runs[hoverIndex] : undefined;
+ // One dot, on whatever the pointer is about: the hovered run's step, the
+ // curve under the crosshair between runs, or at rest, where the curve ends.
+ const dot = hover
+ ? hovered
+ ? hovered.usage
+ ? { t: hovered.endMs, cost: hovered.costSoFar }
+ : null
+ : { t: hover.t, cost: cumulativeCostAt(timeline.cumulative, hover.t) }
+ : last
+ ? { t: last.t, cost: last.cost }
+ : null;
+
+ // The axis ends: clock times while the whole issue is today's, days once it
+ // spans more; "Now" while a run is still going.
+ const [startLabel, endLabel] = useMemo(() => {
+ const today = new Date().toDateString();
+ const hour = new Intl.DateTimeFormat(locale, { hour: "2-digit", minute: "2-digit", hour12: false });
+ const day = new Intl.DateTimeFormat(locale, { month: "short", day: "numeric" });
+ const allToday = new Date(e0).toDateString() === today;
+ const end =
+ timeline.activeCount > 0
+ ? t(($) => $.execution_log.sparkline_now)
+ : allToday
+ ? hour.format(e1)
+ : new Date(e1).toDateString() === today
+ ? t(($) => $.runs_timeline.day_today)
+ : day.format(e1);
+ return [allToday ? hour.format(e0) : day.format(e0), end];
+ }, [e0, e1, timeline.activeCount, locale, t]);
return (
<div className="px-1 pb-1">
- <button
- type="button"
- onClick={onOpen}
- aria-label={t(($) => $.execution_log.strip_aria)}
- className="flex w-full items-end gap-[3px] rounded-xs"
- style={{ height: STRIP_HEIGHT }}
- >
- {shown.map((run) => (
- <StripBar key={run.task.id} run={run} maxCost={maxCost} />
- ))}
- </button>
- {/* Day boundaries, on the same flex grid as the bars so each tick sits
- exactly between the last run of one day and the first of the next. */}
- <div aria-hidden className="flex h-1.5 gap-[3px] border-t border-border">
- {shown.map((run, i) => (
- <span key={run.task.id} className="relative max-w-3 flex-1">
- {i > 0 && dayOf(run.startMs) !== dayOf(shown[i - 1]!.startMs) && (
- <span className="absolute top-0 -left-[2px] h-1.5 w-px bg-faint-foreground" />
+ <Tooltip trackCursorAxis="x">
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ onClick={onOpen}
+ onPointerMove={trackPointer}
+ onPointerDown={trackPointer}
+ onPointerLeave={() => setHover(null)}
+ aria-label={t(($) => $.execution_log.strip_aria)}
+ />
+ }
+ className="relative block w-full rounded-xs text-left"
+ >
+ <span aria-hidden className="relative block" style={{ height: SPARK_HEIGHT }}>
+ <svg
+ className="absolute inset-0 size-full overflow-visible"
+ viewBox="0 0 1000 100"
+ preserveAspectRatio="none"
+ >
+ <path d={area} fill="var(--chart-1)" fillOpacity={0.1} />
+ <path
+ d={line}
+ fill="none"
+ stroke="var(--chart-1)"
+ strokeWidth={1.5}
+ strokeLinejoin="round"
+ vectorEffect="non-scaling-stroke"
+ />
+ </svg>
+ {dot && (
+ <span
+ className="absolute size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-chart-1 ring-2 ring-background"
+ style={{ left: `${xPct(dot.t)}%`, top: `${yPct(dot.cost)}%` }}
+ />
)}
</span>
- ))}
- </div>
- {first && last && (
- <div aria-hidden className="flex justify-between text-micro text-muted-foreground">
- <span>{edgeLabel(first.startMs)}</span>
- {dayOf(first.startMs) !== dayOf(last.startMs) && <span>{edgeLabel(last.startMs)}</span>}
- </div>
- )}
+ <span aria-hidden className="relative mt-1 block h-2 rounded-full bg-muted">
+ {timeline.runs.map((run) => (
+ <span
+ key={run.task.id}
+ data-run={run.task.id}
+ className={cn(
+ "absolute inset-y-0 min-w-[3px] rounded-full transition-opacity",
+ runBarTone(run, run === timeline.peak),
+ hovered && run !== hovered && "opacity-35",
+ )}
+ style={{
+ left: `${xPct(run.startMs)}%`,
+ width: `${xPct(run.endMs) - xPct(run.startMs)}%`,
+ }}
+ />
+ ))}
+ </span>
+ {hover && (
+ <span
+ aria-hidden
+ className="pointer-events-none absolute top-0 w-px bg-foreground/30"
+ style={{ left: `${xPct(hover.t)}%`, height: SPARK_HEIGHT + 12 }}
+ />
+ )}
+ <span aria-hidden className="mt-0.5 flex justify-between text-micro tabular-nums text-muted-foreground">
+ <span>{startLabel}</span>
+ <span>{endLabel}</span>
+ </span>
+ </TooltipTrigger>
+ <TooltipContent className="max-w-64 flex-col items-start gap-0">
+ {hovered ? (
+ <SparklineRunSummary run={hovered} />
+ ) : hover ? (
+ <SparklineIdleSummary timeline={timeline} at={hover.t} />
+ ) : (
+ t(($) => $.execution_log.usage_total_tooltip)
+ )}
+ </TooltipContent>
+ </Tooltip>
</div>
);
}
-function StripBar({ run, maxCost }: { run: TimelineRun; maxCost: number }) {
+function SparklineRunSummary({ run }: { run: TimelineRun }) {
const { t } = useT("issues");
const trigger = useTriggerText(run.task);
const status = useStatusLabel(run.task.status);
const cost = run.usage?.cost;
- // A run without usage is not a zero-height bar — that would read as "free".
- // It gets a dot on the baseline instead, coloured by how it ended.
- const bar =
- cost != null ? (
- <span
- className="block w-full rounded-t-xs bg-chart-2 transition-colors group-hover/strip-bar:bg-chart-1"
- style={{ height: Math.max(3, maxCost > 0 ? (cost / maxCost) * STRIP_HEIGHT : 3) }}
- />
- ) : (
- <span
- className={`mx-auto block size-1 rounded-full ${
- run.task.status === "failed" ? "bg-destructive" : "bg-faint-foreground"
- }`}
- />
- );
return (
- <Tooltip>
- <TooltipTrigger
- render={<span />}
- className="group/strip-bar flex h-full max-w-3 min-w-0 flex-1 items-end"
- >
- {bar}
- </TooltipTrigger>
- <TooltipContent className="max-w-64 flex-col items-start gap-0">
- <RunTriggerLabel task={run.task} fallback={trigger}>
- {(label) => <span className="max-w-full truncate">{label}</span>}
- </RunTriggerLabel>
- <span className="text-micro text-muted-foreground">
- {[
- cost != null ? formatUsd(cost) : t(($) => $.execution_log.strip_no_usage),
- run.durationMs != null ? formatAgentTime(run.durationMs / 1000, "0s") : null,
- run.task.status === "completed" ? null : status,
- ]
- .filter(Boolean)
- .join(" · ")}
- </span>
- </TooltipContent>
- </Tooltip>
+ <>
+ <RunTriggerLabel task={run.task} fallback={trigger}>
+ {(label) => <span className="max-w-full truncate">{label}</span>}
+ </RunTriggerLabel>
+ <span className="text-micro text-muted-foreground">
+ {[
+ // A run still going has not reported usage yet — that is not "none".
+ cost != null ? formatUsd(cost) : run.active ? null : t(($) => $.execution_log.strip_no_usage),
+ run.durationMs != null ? formatAgentTime(run.durationMs / 1000, "0s") : null,
+ run.task.status === "completed" ? null : status,
+ ]
+ .filter(Boolean)
+ .join(" · ")}
+ </span>
+ </>
+ );
+}
+
+function SparklineIdleSummary({ timeline, at }: { timeline: RunTimeline; at: number }) {
+ const { t } = useT("issues");
+ const { fromMs, toMs } = idleSpanAround(timeline.runs, at);
+ return (
+ <>
+ <span>{t(($) => $.runs_timeline.hover_no_run)}</span>
+ <span className="text-micro text-muted-foreground">
+ {[
+ fromMs != null && toMs != null
+ ? t(($) => $.runs_timeline.hover_idle, { duration: formatAgentTime((toMs - fromMs) / 1000, "0s") })
+ : null,
+ t(($) => $.runs_timeline.tooltip_total, {
+ cost: formatUsd(cumulativeCostAt(timeline.cumulative, at)),
+ }),
+ ]
+ .filter(Boolean)
+ .join(" · ")}
+ </span>
+ </>
);
}
diff --git a/packages/views/issues/components/issue-run-timeline.test.ts b/packages/views/issues/components/issue-run-timeline.test.ts
index d494a53735..5ddf748cc4 100644
--- a/packages/views/issues/components/issue-run-timeline.test.ts
+++ b/packages/views/issues/components/issue-run-timeline.test.ts
@@ -3,9 +3,12 @@ import { describe, expect, it } from "vitest";
import type { AgentTask, TaskUsage } from "@multica/core/types";
import {
buildRunTimeline,
+ cumulativeCostAt,
groupRunsByDay,
- nearestRunIndex,
+ idleSpanAround,
niceTicks,
+ runIndexAt,
+ stepCurvePath,
timeTicks,
} from "./issue-run-timeline";
@@ -83,6 +86,7 @@ describe("buildRunTimeline", () => {
expect(timeline.agentMs).toBe(30 * 60 * 1000);
// Elapsed runs from the first start to now, while a run is still going.
expect(timeline.elapsedMs).toBe(NOW - new Date("2026-09-24T10:00:00").getTime());
+ expect(timeline.extent).toEqual([new Date("2026-09-24T10:00:00").getTime(), NOW]);
});
it("ignores deferred runs, which the execution log does not list", () => {
@@ -200,7 +204,8 @@ describe("costSoFar", () => {
});
});
-describe("nearestRunIndex", () => {
+describe("runIndexAt", () => {
+ const MINUTE = 60_000;
const { runs } = buildRunTimeline(
[
makeTask({ id: "a", started_at: "2026-09-24T10:00:00", completed_at: "2026-09-24T10:30:00" }),
@@ -208,16 +213,39 @@ describe("nearestRunIndex", () => {
],
NOW,
);
- const at = (iso: string) => runs[nearestRunIndex(runs, new Date(iso).getTime())]!.task.id;
+ const at = (iso: string, slopMs = MINUTE) => {
+ const i = runIndexAt(runs, new Date(iso).getTime(), slopMs);
+ return i < 0 ? null : runs[i]!.task.id;
+ };
it("picks the run under the pointer", () => {
expect(at("2026-09-24T10:15:00")).toBe("a");
});
- it("snaps to the nearest bar, however thin, when between runs", () => {
- expect(at("2026-09-24T11:00:00")).toBe("a");
- expect(at("2026-09-24T13:00:00")).toBe("b");
- expect(at("2026-09-25T00:00:00")).toBe("b");
+ it("reaches a sliver of a run within the slop", () => {
+ // `b` lasts 20s; the pointer lands a few pixels — here 40s — off it.
+ expect(at("2026-09-24T13:59:20")).toBe("b");
+ expect(at("2026-09-24T14:01:00")).toBe("b");
+ });
+
+ it("reports no run between runs instead of snapping across the gap", () => {
+ // Review repro (MUL-7780): the crosshair used to jump to whichever run
+ // was nearest, hundreds of pixels from the pointer.
+ expect(at("2026-09-24T11:00:00")).toBeNull();
+ expect(at("2026-09-24T13:00:00")).toBeNull();
+ expect(at("2026-09-25T00:00:00")).toBeNull();
+ });
+
+ it("prefers the run the pointer is inside over one it is merely near", () => {
+ const { runs: adjacent } = buildRunTimeline(
+ [
+ makeTask({ id: "long", started_at: "2026-09-24T10:00:00", completed_at: "2026-09-24T11:00:00" }),
+ makeTask({ id: "blip", started_at: "2026-09-24T11:00:30", completed_at: "2026-09-24T11:00:40" }),
+ ],
+ NOW,
+ );
+ const i = runIndexAt(adjacent, new Date("2026-09-24T10:59:50").getTime(), MINUTE);
+ expect(adjacent[i]!.task.id).toBe("long");
});
it("reaches a run nested inside a longer one", () => {
@@ -229,7 +257,7 @@ describe("nearestRunIndex", () => {
],
NOW,
);
- const pick = (iso: string) => nested[nearestRunIndex(nested, new Date(iso).getTime())]!.task.id;
+ const pick = (iso: string) => nested[runIndexAt(nested, new Date(iso).getTime(), MINUTE)]!.task.id;
expect(pick("2026-09-24T10:30:00")).toBe("inner");
expect(pick("2026-09-24T09:30:00")).toBe("outer");
expect(pick("2026-09-24T11:30:00")).toBe("outer");
@@ -244,12 +272,78 @@ describe("nearestRunIndex", () => {
NOW,
);
const t = new Date("2026-09-24T10:10:00").getTime();
- expect(lanes[nearestRunIndex(lanes, t)]!.task.id).toBe("lambda");
- expect(lanes[nearestRunIndex(lanes, t, "agent-emacs")]!.task.id).toBe("emacs");
+ expect(lanes[runIndexAt(lanes, t, MINUTE)]!.task.id).toBe("lambda");
+ expect(lanes[runIndexAt(lanes, t, MINUTE, "agent-emacs")]!.task.id).toBe("emacs");
});
it("has nothing to point at without runs", () => {
- expect(nearestRunIndex([], 0)).toBe(-1);
+ expect(runIndexAt([], 0, MINUTE)).toBe(-1);
+ });
+});
+
+describe("cumulativeCostAt", () => {
+ const timeline = buildRunTimeline(
+ [
+ makeTask({ id: "a", started_at: "2026-09-24T10:00:00", completed_at: "2026-09-24T10:30:00", usage: usage(400_000) }),
+ makeTask({ id: "b", started_at: "2026-09-24T11:00:00", completed_at: "2026-09-24T11:30:00", usage: usage(200_000) }),
+ ],
+ NOW,
+ );
+ const at = (iso: string) => cumulativeCostAt(timeline.cumulative, new Date(iso).getTime());
+
+ it("reads the curve: flat until a run finishes, then up by its cost", () => {
+ expect(at("2026-09-24T09:00:00")).toBe(0);
+ // Mid-run nothing has been billed yet — usage lands at completion.
+ expect(at("2026-09-24T10:15:00")).toBe(0);
+ expect(at("2026-09-24T10:30:00")).toBe(10);
+ expect(at("2026-09-24T10:45:00")).toBe(10);
+ expect(at("2026-09-24T12:00:00")).toBe(15);
+ });
+});
+
+describe("idleSpanAround", () => {
+ const { runs } = buildRunTimeline(
+ [
+ makeTask({ id: "a", agent_id: "agent-lambda", started_at: "2026-09-24T10:00:00", completed_at: "2026-09-24T10:30:00" }),
+ makeTask({ id: "b", agent_id: "agent-emacs", started_at: "2026-09-24T11:00:00", completed_at: "2026-09-24T11:10:00" }),
+ makeTask({ id: "c", agent_id: "agent-lambda", started_at: "2026-09-24T12:00:00", completed_at: "2026-09-24T12:30:00" }),
+ ],
+ NOW,
+ );
+ const ms = (iso: string) => new Date(iso).getTime();
+
+ it("spans from the last run's end to the next run's start", () => {
+ expect(idleSpanAround(runs, ms("2026-09-24T10:45:00"))).toEqual({
+ fromMs: ms("2026-09-24T10:30:00"),
+ toMs: ms("2026-09-24T11:00:00"),
+ });
+ });
+
+ it("reads one lane's quiet stretch", () => {
+ expect(idleSpanAround(runs, ms("2026-09-24T10:45:00"), "agent-lambda")).toEqual({
+ fromMs: ms("2026-09-24T10:30:00"),
+ toMs: ms("2026-09-24T12:00:00"),
+ });
+ });
+
+ it("leaves an open side before the first run and after the last", () => {
+ expect(idleSpanAround(runs, ms("2026-09-24T09:00:00")).fromMs).toBeNull();
+ expect(idleSpanAround(runs, ms("2026-09-24T13:00:00")).toMs).toBeNull();
+ });
+});
+
+describe("stepCurvePath", () => {
+ it("rises at each step and holds flat to the right edge", () => {
+ const { line, area } = stepCurvePath(
+ [
+ { t: 250, cost: 5 },
+ { t: 750, cost: 10 },
+ ],
+ [0, 1000],
+ 10,
+ );
+ expect(line).toBe("M0,100 L250.00,100.00 L250.00,50.00 L750.00,50.00 L750.00,0.00 L1000,0.00");
+ expect(area).toBe(`${line} L1000,100 L0,100 Z`);
});
});
diff --git a/packages/views/issues/components/issue-run-timeline.ts b/packages/views/issues/components/issue-run-timeline.ts
index 8f44a1176f..1064161a41 100644
--- a/packages/views/issues/components/issue-run-timeline.ts
+++ b/packages/views/issues/components/issue-run-timeline.ts
@@ -68,6 +68,8 @@ export interface RunTimeline {
cancelledCount: number;
activeCount: number;
domain: [number, number];
+ /** First start to last end — the stretch of the axis that holds runs. */
+ extent: [number, number];
/** The running total after each priced run, in completion order. */
cumulative: CumulativeStep[];
/** One lane per agent, in order of first appearance. */
@@ -182,6 +184,7 @@ export function buildRunTimeline(tasks: readonly AgentTask[], nowMs: number): Ru
cancelledCount,
activeCount,
domain: paddedDomain(first?.startMs ?? nowMs, lastEnd),
+ extent: [first?.startMs ?? nowMs, lastEnd],
cumulative,
lanes: Array.from(laneMap, ([agentId, laneRuns]) => ({ agentId, runs: laneRuns })),
peak,
@@ -226,19 +229,24 @@ export function niceTicks(max: number, maxCount = 4): number[] {
}
/**
- * The run a pointer at time `t` is about: the one whose bar it is over, else
- * the one whose bar is nearest. Bars can be a few pixels wide, so the whole
- * chart snaps to runs rather than asking the pointer to land on one.
+ * The run a pointer at time `t` is on: the one whose bar spans `t`, give or
+ * take `slopMs` — the time a few pixels cover, so a bar one pixel wide is
+ * still something a pointer can land on. -1 between runs: the chart says so,
+ * rather than reaching across a gap for a run the pointer is nowhere near.
+ * Snapping to the nearest run was what made the crosshair jump — hundreds of
+ * pixels for a few pixels of pointer travel.
*
* Runs overlap — one agent's short run inside another's long one, or two
- * agents at once — so "the bar it is over" can be several. The shortest wins:
- * a bar fully inside another is otherwise unreachable, while the long one
- * still owns every moment the short one doesn't cover. `agentId` narrows the
- * choice to one lane when the pointer is over that lane.
+ * agents at once — so "the bar it is on" can be several. A bar the pointer is
+ * inside beats one it is merely near, then the shortest wins: a bar fully
+ * inside another is otherwise unreachable, while the long one still owns
+ * every moment the short one doesn't cover. `agentId` narrows the choice to
+ * one lane when the pointer is over that lane.
*/
-export function nearestRunIndex(
+export function runIndexAt(
runs: readonly TimelineRun[],
t: number,
+ slopMs: number,
agentId?: string,
): number {
let best = -1;
@@ -247,6 +255,7 @@ export function nearestRunIndex(
runs.forEach((run, i) => {
if (agentId && run.task.agent_id !== agentId) return;
const distance = t < run.startMs ? run.startMs - t : t > run.endMs ? t - run.endMs : 0;
+ if (distance > slopMs) return;
const span = run.endMs - run.startMs;
if (distance < bestDistance || (distance === bestDistance && span < bestSpan)) {
best = i;
@@ -257,6 +266,61 @@ export function nearestRunIndex(
return best;
}
+/** What the cumulative curve reads at `t`: the total once every run that had
+ * finished by then was paid for. */
+export function cumulativeCostAt(steps: readonly CumulativeStep[], t: number): number {
+ let cost = 0;
+ for (const step of steps) {
+ if (step.t > t) break;
+ cost = step.cost;
+ }
+ return cost;
+}
+
+/**
+ * The quiet stretch around `t`: when the last run before it ended and the
+ * next one after it started. Either side is null past the first or last run.
+ * `agentId` reads one lane's quiet stretch.
+ */
+export function idleSpanAround(
+ runs: readonly TimelineRun[],
+ t: number,
+ agentId?: string,
+): { fromMs: number | null; toMs: number | null } {
+ let fromMs: number | null = null;
+ let toMs: number | null = null;
+ for (const run of runs) {
+ if (agentId && run.task.agent_id !== agentId) continue;
+ if (run.endMs <= t && (fromMs == null || run.endMs > fromMs)) fromMs = run.endMs;
+ if (run.startMs >= t && (toMs == null || run.startMs < toMs)) toMs = run.startMs;
+ }
+ return { fromMs, toMs };
+}
+
+/**
+ * The cumulative cost as a step curve in a 1000×100 box, for an SVG stretched
+ * over the plot with `preserveAspectRatio="none"`. Usage is written when a run
+ * finishes, so the line rises at each run's end and holds flat between.
+ */
+export function stepCurvePath(
+ steps: readonly CumulativeStep[],
+ [d0, d1]: [number, number],
+ yMax: number,
+): { line: string; area: string } {
+ const x = (t: number) => (((t - d0) / (d1 - d0)) * 1000).toFixed(2);
+ const y = (cost: number) => ((1 - cost / yMax) * 100).toFixed(2);
+ let line = "M0,100";
+ let prevY = "100.00";
+ for (const step of steps) {
+ const sx = x(step.t);
+ const sy = y(step.cost);
+ line += ` L${sx},${prevY} L${sx},${sy}`;
+ prevY = sy;
+ }
+ line += ` L1000,${prevY}`;
+ return { line, area: `${line} L1000,100 L0,100 Z` };
+}
+
export interface TimeTick {
t: number;
/** "day" ticks sit on local midnight; "hour" ticks on a whole hour. */
diff --git a/packages/views/issues/components/issue-runs-dialog.test.tsx b/packages/views/issues/components/issue-runs-dialog.test.tsx
index 14b6fcdb2a..6007a86f72 100644
--- a/packages/views/issues/components/issue-runs-dialog.test.tsx
+++ b/packages/views/issues/components/issue-runs-dialog.test.tsx
@@ -190,29 +190,57 @@ describe("IssueRunsDialog", () => {
expect(screen.getAllByText("$7.00").length).toBeGreaterThan(0);
});
- it("answers a pointer anywhere on the chart with the nearest run", () => {
+ // The plot column sits beside the lane labels; give it a width, which jsdom
+ // does not lay out. Returns the x of a moment on the chart's padded domain.
+ function layOut(plot: HTMLElement, first: string, last: string) {
+ plot.getBoundingClientRect = () => ({ left: 0, width: 1000, top: 0, height: 200, right: 1000, bottom: 200, x: 0, y: 0, toJSON: () => ({}) });
+ const [d0, d1] = [new Date(first).getTime(), new Date(last).getTime()];
+ const pad = (d1 - d0) * 0.02;
+ return (iso: string) => ((new Date(iso).getTime() - (d0 - pad)) / (d1 - d0 + 2 * pad)) * 1000;
+ }
+ const hoverCard = (plot: HTMLElement) => plot.querySelector("[data-hover-card]") as HTMLElement | null;
+
+ it("follows the pointer: the run under it answers, a gap says so", () => {
open([
makeTask({ id: "early", trigger_summary: "Early run", started_at: "2026-09-27T09:00:00", completed_at: "2026-09-27T09:30:00", usage: [usage()] }),
makeTask({ id: "late", trigger_summary: "Late run", started_at: "2026-09-27T15:00:00", completed_at: "2026-09-27T15:10:00", usage: [usage({ output_tokens: 200_000 })] }),
]);
- // The plot column sits beside the lane labels; give it a width, which
- // jsdom does not lay out.
const plot = screen.getByRole("img").children[1] as HTMLElement;
- plot.getBoundingClientRect = () => ({ left: 0, width: 1000, top: 0, height: 200, right: 1000, bottom: 200, x: 0, y: 0, toJSON: () => ({}) });
+ const x = layOut(plot, "2026-09-27T09:00:00", "2026-09-27T15:10:00");
- // Far right, past the last bar: snaps to the last run.
- fireEvent.pointerMove(plot, { clientX: 995 });
- expect(within(plot).getByText("Late run")).toBeInTheDocument();
- expect(within(plot).getByText(/Total so far \$30\.00/)).toBeInTheDocument();
+ fireEvent.pointerMove(plot, { clientX: x("2026-09-27T15:05:00") });
+ expect(within(hoverCard(plot)!).getByText("Late run")).toBeInTheDocument();
+ expect(within(hoverCard(plot)!).getByText(/Total so far \$30\.00/)).toBeInTheDocument();
- // Far left: the first run, with the curve's reading there.
- fireEvent.pointerMove(plot, { clientX: 5 });
- expect(within(plot).getByText("Early run")).toBeInTheDocument();
- expect(within(plot).getByText(/Total so far \$25\.00/)).toBeInTheDocument();
+ // Review repro (MUL-7780): between runs the crosshair used to snap to the
+ // nearest run's end, hundreds of pixels away. Now it stays put and the
+ // card says nothing ran here, for how long, and what was spent by then.
+ fireEvent.pointerMove(plot, { clientX: x("2026-09-27T12:00:00") });
+ const idle = within(hoverCard(plot)!);
+ expect(idle.getByText("No run")).toBeInTheDocument();
+ expect(idle.getByText("09:30 → 15:00 · Idle 5h 30m")).toBeInTheDocument();
+ expect(idle.getByText("Total so far $25.00")).toBeInTheDocument();
+ expect(within(plot).getByText("12:00")).toBeInTheDocument();
+
+ fireEvent.pointerMove(plot, { clientX: x("2026-09-27T09:15:00") });
+ expect(within(hoverCard(plot)!).getByText("Early run")).toBeInTheDocument();
- // Leaving hands the plot back to the peak label.
fireEvent.pointerLeave(plot);
- expect(within(plot).queryByText(/Total so far/)).not.toBeInTheDocument();
+ expect(hoverCard(plot)).not.toBeInTheDocument();
+ });
+
+ it("keeps the hover when the pointer drifts off the plot onto the lane labels", () => {
+ open([
+ makeTask({ id: "early", trigger_summary: "Early run", started_at: "2026-09-27T09:00:00", completed_at: "2026-09-27T09:30:00", usage: [usage()] }),
+ makeTask({ id: "late", trigger_summary: "Late run", started_at: "2026-09-27T15:00:00", completed_at: "2026-09-27T15:10:00", usage: [usage()] }),
+ ]);
+ const chart = screen.getByRole("img");
+ const plot = chart.children[1] as HTMLElement;
+ layOut(plot, "2026-09-27T09:00:00", "2026-09-27T15:10:00");
+
+ // Left of the plot: clamped to where the runs begin.
+ fireEvent.pointerMove(chart.children[0] as HTMLElement, { clientX: -40 });
+ expect(within(hoverCard(plot)!).getByText("Early run")).toBeInTheDocument();
});
it("picks the run on the lane under the pointer when runs overlap", () => {
@@ -222,18 +250,14 @@ describe("IssueRunsDialog", () => {
makeTask({ id: "short", agent_id: "agent-emacs", trigger_summary: "Short run", started_at: "2026-09-27T10:00:00", completed_at: "2026-09-27T11:00:00", usage: [usage({ output_tokens: 200_000 })] }),
]);
const plot = screen.getByRole("img").children[1] as HTMLElement;
- plot.getBoundingClientRect = () => ({ left: 0, width: 1000, top: 0, height: 200, right: 1000, bottom: 200, x: 0, y: 0, toJSON: () => ({}) });
+ const x = layOut(plot, "2026-09-27T09:00:00", "2026-09-27T12:00:00");
const lane = (agentId: string) => plot.querySelector(`[data-lane="${agentId}"]`) as HTMLElement;
- // The x of 10:30 on the chart's padded domain.
- const [d0, d1] = [new Date("2026-09-27T09:00:00").getTime(), new Date("2026-09-27T12:00:00").getTime()];
- const pad = (d1 - d0) * 0.02;
- const x = ((new Date("2026-09-27T10:30:00").getTime() - (d0 - pad)) / (d1 - d0 + 2 * pad)) * 1000;
- fireEvent.pointerMove(lane("agent-lambda"), { clientX: x });
- expect(within(plot).getByText("Long run")).toBeInTheDocument();
+ fireEvent.pointerMove(lane("agent-lambda"), { clientX: x("2026-09-27T10:30:00") });
+ expect(within(hoverCard(plot)!).getByText("Long run")).toBeInTheDocument();
- fireEvent.pointerMove(lane("agent-emacs"), { clientX: x });
- expect(within(plot).getByText("Short run")).toBeInTheDocument();
+ fireEvent.pointerMove(lane("agent-emacs"), { clientX: x("2026-09-27T10:30:00") });
+ expect(within(hoverCard(plot)!).getByText("Short run")).toBeInTheDocument();
});
it("opens a run's cost split from a real button, not hover alone", () => {
diff --git a/packages/views/issues/components/issue-runs-dialog.tsx b/packages/views/issues/components/issue-runs-dialog.tsx
index 1ed8362e74..f966db44a6 100644
--- a/packages/views/issues/components/issue-runs-dialog.tsx
+++ b/packages/views/issues/components/issue-runs-dialog.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useMemo, useState } from "react";
+import { useMemo, useRef, useState } from "react";
import { ArrowRight, Ban, XCircle } from "lucide-react";
import type { AgentTask } from "@multica/core/types";
import { cn } from "@multica/ui/lib/utils";
@@ -32,9 +32,12 @@ import {
import { AttributionBadge } from "./attribution-badge";
import {
buildRunTimeline,
+ cumulativeCostAt,
groupRunsByDay,
- nearestRunIndex,
+ idleSpanAround,
niceTicks,
+ runIndexAt,
+ stepCurvePath,
timeTicks,
type RunTimeline,
type TimelineRun,
@@ -232,14 +235,33 @@ function RunStats({ timeline }: { timeline: RunTimeline }) {
// ─── Chart ─────────────────────────────────────────────────────────────────
const PLOT_HEIGHT = 112;
-
-function runBarTone(run: TimelineRun, isPeak: boolean): string {
+// How far the pointer can miss a bar and still be on it: a run a few seconds
+// long draws as a 3px sliver, which nobody lands on exactly.
+const HOVER_SLOP_PX = 8;
+// The hover card's `max-w-72` plus its gap from the crosshair. With less room
+// than this to the right of the crosshair, the card opens on its left.
+const HOVER_CARD_ROOM_PX = 298;
+// Half the widest pointer-time tag ("Sep 27, 14:44"): nearer the plot's edge
+// than this, the tag aligns to the edge instead of centring on the crosshair,
+// and tick labels this close to it step aside.
+const TIME_TAG_HALF_PX = 48;
+
+export function runBarTone(run: TimelineRun, isPeak: boolean): string {
if (run.active) return "bg-info animate-pulse";
if (run.task.status === "failed") return "bg-destructive";
if (run.task.status === "cancelled") return "bg-faint-foreground";
return isPeak ? "bg-chart-1" : "bg-chart-2";
}
+interface ChartHover {
+ /** The moment under the pointer, clamped to the stretch that holds runs. */
+ t: number;
+ /** The lane the pointer is over, if any. */
+ lane?: string;
+ /** The plot's rendered width, which turns pixels into time. */
+ width: number;
+}
+
function RunTimelineChart({ timeline }: { timeline: RunTimeline }) {
const { t } = useT("issues");
const locale = useLocale();
@@ -255,26 +277,27 @@ function RunTimelineChart({ timeline }: { timeline: RunTimeline }) {
const yPct = (cost: number) => (1 - cost / yMax) * 100;
const ticks = timeTicks(timeline.domain);
- const tickFormat = useMemo(() => {
+ const multiDay = d1 - d0 > 36 * 60 * 60 * 1000;
+ const [tickFormat, pointerFormat] = useMemo(() => {
const day = new Intl.DateTimeFormat(locale, { weekday: "short", month: "short", day: "numeric" });
const hour = new Intl.DateTimeFormat(locale, { hour: "2-digit", minute: "2-digit", hour12: false });
- return (tick: (typeof ticks)[number]) =>
- tick.kind === "day" ? day.format(tick.t) : hour.format(tick.t);
- }, [locale]);
+ const dayHour = new Intl.DateTimeFormat(locale, {
+ month: "short",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ hour12: false,
+ });
+ return [
+ (tick: (typeof ticks)[number]) => (tick.kind === "day" ? day.format(tick.t) : hour.format(tick.t)),
+ (ms: number) => (multiDay ? dayHour.format(ms) : hour.format(ms)),
+ ] as const;
+ }, [locale, multiDay]);
// Step curve in a 1000×100 box stretched over the plot; the stroke keeps its
// 2px via non-scaling-stroke however wide the dialog is.
const steps = timeline.cumulative;
- let line = `M0,100`;
- let prevY = 100;
- for (const step of steps) {
- const x = xPct(step.t) * 10;
- const y = yPct(step.cost);
- line += ` L${x.toFixed(2)},${prevY.toFixed(2)} L${x.toFixed(2)},${y.toFixed(2)}`;
- prevY = y;
- }
- line += ` L1000,${prevY.toFixed(2)}`;
- const area = `${line} L1000,100 L0,100 Z`;
+ const { line, area } = stepCurvePath(steps, timeline.domain, yMax);
const last = steps[steps.length - 1];
// Label the one run that moved the curve most. Left of its step the curve is
@@ -286,25 +309,55 @@ function RunTimelineChart({ timeline }: { timeline: RunTimeline }) {
const peakStep = peak ? steps.find((s) => s.t === peak.endMs) : undefined;
const peakX = peakStep ? xPct(peakStep.t) : 0;
- // Hover layer: anywhere over the plot column snaps to the nearest run — a
- // crosshair where it finished, the curve's reading there, and a card with the
- // run itself. Lane bars can be a few pixels wide, so asking the pointer to
- // land on one would make most of them unreachable. The list below carries the
- // same figures for keyboard and screen-reader users.
- const [hoverIndex, setHoverIndex] = useState<number | null>(null);
- const hovered = hoverIndex != null ? timeline.runs[hoverIndex] : undefined;
- const hoverX = hovered ? xPct(hovered.endMs) : 0;
+ // Hover layer. The crosshair is the pointer: it follows it across the whole
+ // chart row — lane labels and y scale included, so drifting a few pixels
+ // off the plot does not drop the hover — clamped to the stretch that holds
+ // runs. Whatever is under it answers: the run whose bar spans that moment,
+ // or between runs, the quiet stretch and what the curve reads there. It used
+ // to snap to the nearest run's end instead, which moved it hundreds of
+ // pixels for a few pixels of pointer travel (MUL-7780). The list below
+ // carries the same figures for keyboard and screen-reader users.
+ const plotRef = useRef<HTMLDivElement>(null);
+ const [hover, setHover] = useState<ChartHover | null>(null);
const trackPointer = (event: React.PointerEvent<HTMLDivElement>) => {
- const rect = event.currentTarget.getBoundingClientRect();
- if (rect.width <= 0) return;
- const t = d0 + ((event.clientX - rect.left) / rect.width) * (d1 - d0);
+ const rect = plotRef.current?.getBoundingClientRect();
+ if (!rect || rect.width <= 0) return;
+ const [e0, e1] = timeline.extent;
+ const at = d0 + ((event.clientX - rect.left) / rect.width) * (d1 - d0);
// Over a lane, only that lane's runs are candidates — the pointer is on a
// specific agent's row. Over the curve, any agent's run can answer.
- const lane = (event.target as Element).closest?.("[data-lane]");
- const index = nearestRunIndex(timeline.runs, t, lane?.getAttribute("data-lane") ?? undefined);
- setHoverIndex(index >= 0 ? index : null);
+ const lane = (event.target as Element).closest?.("[data-lane]")?.getAttribute("data-lane");
+ setHover({ t: Math.min(Math.max(at, e0), e1), lane: lane ?? undefined, width: rect.width });
};
+ const hoverIndex = hover
+ ? runIndexAt(timeline.runs, hover.t, (HOVER_SLOP_PX / hover.width) * (d1 - d0), hover.lane)
+ : -1;
+ const hovered = hoverIndex >= 0 ? timeline.runs[hoverIndex] : undefined;
+ const hoverX = hover ? xPct(hover.t) : 0;
+ const hoverPx = hover ? (hoverX / 100) * hover.width : 0;
+ // The point the card is about: the hovered run's step on the curve, or
+ // between runs, the curve's reading under the crosshair. A run that has not
+ // reported usage has no step to point at.
+ const dot =
+ !hover || plotHeight === 0
+ ? null
+ : hovered
+ ? hovered.usage
+ ? { x: xPct(hovered.endMs), cost: hovered.costSoFar }
+ : null
+ : { x: hoverX, cost: cumulativeCostAt(steps, hover.t) };
+ // The card sits in whichever half of the plot its dot is not in, so it never
+ // covers the point it describes.
+ const cardTop = dot && yPct(dot.cost) < 50 ? Math.round(plotHeight * 0.4) : 0;
+ const cardOnLeft = hover ? hoverPx + HOVER_CARD_ROOM_PX > hover.width : false;
+ const tagTransform = !hover
+ ? undefined
+ : hoverPx < TIME_TAG_HALF_PX
+ ? "none"
+ : hoverPx > hover.width - TIME_TAG_HALF_PX
+ ? "translateX(-100%)"
+ : "translateX(-50%)";
return (
<div
@@ -314,13 +367,16 @@ function RunTimelineChart({ timeline }: { timeline: RunTimeline }) {
cost: formatUsd(timeline.totalCost),
})}
className="mt-5 flex gap-3 border-b px-6 pb-3"
+ onPointerMove={trackPointer}
+ onPointerDown={trackPointer}
+ onPointerLeave={() => setHover(null)}
>
{/* Lane labels, aligned with the lanes in the plot column. */}
<div className="w-24 shrink-0" aria-hidden>
<div style={{ height: plotHeight }} />
- <div className={cn("space-y-1.5", plotHeight > 0 && "mt-3")}>
+ <div className={cn(plotHeight > 0 && "mt-[9px]")}>
{timeline.lanes.map((lane) => (
- <div key={lane.agentId} className="flex h-3.5 min-w-0 items-center gap-1.5">
+ <div key={lane.agentId} className="flex h-5 min-w-0 items-center gap-1.5">
<ActorAvatar actorType="agent" actorId={lane.agentId} size="xs" />
<span className="truncate text-micro text-muted-foreground">
{getActorName("agent", lane.agentId)}
@@ -330,12 +386,7 @@ function RunTimelineChart({ timeline }: { timeline: RunTimeline }) {
</div>
</div>
- <div
- className="relative min-w-0 flex-1"
- onPointerMove={trackPointer}
- onPointerDown={trackPointer}
- onPointerLeave={() => setHoverIndex(null)}
- >
+ <div ref={plotRef} className="relative min-w-0 flex-1">
{/* Time gridlines run through the curve and the lanes alike. */}
{ticks.map((tick) => (
<span
@@ -377,15 +428,18 @@ function RunTimelineChart({ timeline }: { timeline: RunTimeline }) {
style={{ left: `${xPct(last.t)}%`, top: `${yPct(last.cost)}%` }}
/>
)}
- {hovered && plotHeight > 0 && (
+ {dot && (
<span
className="pointer-events-none absolute z-10 size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-chart-1 ring-2 ring-popover"
- style={{ left: `${hoverX}%`, top: `${yPct(hovered.costSoFar)}%` }}
+ style={{ left: `${dot.x}%`, top: `${yPct(dot.cost)}%` }}
/>
)}
- {peak && peakStep && !hovered && (
+ {/* Fades rather than unmounts under the hover card, so entering and
+ leaving the chart does not blink it. */}
+ {peak && peakStep && (
<PeakLabel
run={peak}
+ className={cn("transition-opacity duration-150", hover && "opacity-0")}
style={{
left: `${peakX}%`,
top: `${yPct(peakStep.cost)}%`,
@@ -398,52 +452,67 @@ function RunTimelineChart({ timeline }: { timeline: RunTimeline }) {
)}
</div>
- <div className={cn("space-y-1.5", plotHeight > 0 && "mt-3")}>
+ {/* Rows, not tracks, carry `data-lane`, and they touch: moving from one
+ lane to the next never crosses a gap that belongs to no lane, which
+ would briefly hand the hover to every agent's runs. */}
+ <div className={cn(plotHeight > 0 && "mt-[9px]")}>
{timeline.lanes.map((lane) => (
- <div key={lane.agentId} data-lane={lane.agentId} className="relative h-3.5 rounded-xs bg-muted/60">
- {lane.runs.map((run) => (
- <span
- key={run.task.id}
- className={cn(
- "absolute inset-y-0.5 min-w-[3px] rounded-xs transition-opacity",
- runBarTone(run, run === peak),
- hovered && run !== hovered && "opacity-35",
- )}
- style={{
- left: `${xPct(run.startMs)}%`,
- width: `${xPct(run.endMs) - xPct(run.startMs)}%`,
- }}
- />
- ))}
+ <div key={lane.agentId} data-lane={lane.agentId} className="py-[3px]">
+ <div className="relative h-3.5 rounded-xs bg-muted/60">
+ {lane.runs.map((run) => (
+ <span
+ key={run.task.id}
+ className={cn(
+ "absolute inset-y-0.5 min-w-[3px] rounded-xs transition-opacity",
+ runBarTone(run, run === peak),
+ hovered && run !== hovered && "opacity-35",
+ )}
+ style={{
+ left: `${xPct(run.startMs)}%`,
+ width: `${xPct(run.endMs) - xPct(run.startMs)}%`,
+ }}
+ />
+ ))}
+ </div>
</div>
))}
</div>
- {hovered && (
+ {hover && (
<>
<span
aria-hidden
className="pointer-events-none absolute top-0 bottom-5 w-px bg-foreground/30"
style={{ left: `${hoverX}%` }}
/>
- {/* Beside the crosshair, on whichever side has room, so it never
- covers the point it describes. */}
+ {/* Beside the crosshair, on whichever side has room. */}
<div
aria-hidden
- className="pointer-events-none absolute top-0 z-20 w-max max-w-72 rounded-lg border bg-popover px-2.5 py-1.5 text-caption text-popover-foreground shadow-[var(--menu-shadow)]"
+ data-hover-card
+ className="pointer-events-none absolute z-20 w-max max-w-72 rounded-lg border bg-popover px-2.5 py-1.5 text-caption text-popover-foreground shadow-[var(--menu-shadow)]"
style={{
left: `${hoverX}%`,
- transform: hoverX > 55 ? "translateX(calc(-100% - 10px))" : "translateX(10px)",
+ top: cardTop,
+ transform: cardOnLeft ? "translateX(calc(-100% - 10px))" : "translateX(10px)",
}}
>
- <RunHoverCard run={hovered} />
+ {hovered ? (
+ <RunHoverCard run={hovered} />
+ ) : (
+ <IdleHoverCard
+ {...idleSpanAround(timeline.runs, hover.t, hover.lane)}
+ total={timeline.pricedCount > 0 ? cumulativeCostAt(steps, hover.t) : null}
+ />
+ )}
</div>
</>
)}
- <div className="relative mt-1 h-5" aria-hidden>
+ <div className="relative mt-px h-5" aria-hidden>
{ticks.map((tick) => {
const x = xPct(tick.t);
+ // The pointer's own time tag takes the axis where it stands.
+ if (hover && Math.abs(((x - hoverX) / 100) * hover.width) < TIME_TAG_HALF_PX) return null;
return (
<span
key={tick.t}
@@ -454,6 +523,14 @@ function RunTimelineChart({ timeline }: { timeline: RunTimeline }) {
</span>
);
})}
+ {hover && (
+ <span
+ className="pointer-events-none absolute top-0.5 z-20 whitespace-nowrap rounded-xs bg-foreground px-1 text-micro font-medium tabular-nums text-background"
+ style={{ left: `${hoverX}%`, transform: tagTransform }}
+ >
+ {pointerFormat(hover.t)}
+ </span>
+ )}
</div>
</div>
@@ -508,11 +585,19 @@ export function RunTriggerLabel({
return <WakeupRunLabel task={task} fallback={fallback} render={children} />;
}
-function PeakLabel({ run, style }: { run: TimelineRun; style: React.CSSProperties }) {
+function PeakLabel({
+ run,
+ className,
+ style,
+}: {
+ run: TimelineRun;
+ className?: string;
+ style: React.CSSProperties;
+}) {
const trigger = useTriggerText(run.task);
return (
<span
- className="absolute flex max-w-60 items-baseline gap-1 whitespace-nowrap text-micro"
+ className={cn("absolute flex max-w-60 items-baseline gap-1 whitespace-nowrap text-micro", className)}
style={style}
>
<span className="font-medium text-foreground">+{formatUsd(run.usage?.cost ?? 0)}</span>
@@ -564,6 +649,51 @@ function RunHoverCard({ run }: { run: TimelineRun }) {
);
}
+// Between runs: nothing ran here. Says so, with how long the quiet lasted and
+// what the issue had spent by then — the curve's reading under the crosshair.
+function IdleHoverCard({
+ fromMs,
+ toMs,
+ total,
+}: {
+ fromMs: number | null;
+ toMs: number | null;
+ /** Null when no run reported usage — there is no total to quote. */
+ total: number | null;
+}) {
+ const { t } = useT("issues");
+ const locale = useLocale();
+ const span = useMemo(() => {
+ if (fromMs == null || toMs == null) return null;
+ const sameDay = new Date(fromMs).toDateString() === new Date(toMs).toDateString();
+ const fmt = new Intl.DateTimeFormat(locale, {
+ ...(sameDay ? {} : { month: "short", day: "numeric" }),
+ hour: "2-digit",
+ minute: "2-digit",
+ hour12: false,
+ });
+ return `${fmt.format(fromMs)} → ${fmt.format(toMs)}`;
+ }, [fromMs, toMs, locale]);
+ return (
+ <div className="flex min-w-0 flex-col gap-1">
+ <span className="font-medium">{t(($) => $.runs_timeline.hover_no_run)}</span>
+ {span && fromMs != null && toMs != null && (
+ <span className="truncate text-micro tabular-nums text-muted-foreground">
+ {span} ·{" "}
+ {t(($) => $.runs_timeline.hover_idle, {
+ duration: formatDuration((toMs - fromMs) / 1000, UNDER_A_SECOND),
+ })}
+ </span>
+ )}
+ {total != null && (
+ <span className="text-micro tabular-nums text-muted-foreground">
+ {t(($) => $.runs_timeline.tooltip_total, { cost: formatUsd(total) })}
+ </span>
+ )}
+ </div>
+ );
+}
+
// ─── List ──────────────────────────────────────────────────────────────────
function RunDayList({ timeline, issueId }: { timeline: RunTimeline; issueId: string }) {
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index 50c6917939..b6fce19265 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -759,8 +759,9 @@
"open_timeline": "Open timeline",
"more_runs_one": "{{count}} more",
"more_runs_other": "{{count}} more",
- "strip_aria": "Cost of each run, oldest to newest — open the run timeline",
- "strip_no_usage": "No usage recorded"
+ "strip_aria": "Cumulative cost over time — open the run timeline",
+ "strip_no_usage": "No usage recorded",
+ "sparkline_now": "Now"
},
"runs_timeline": {
"title": "Runs",
@@ -790,6 +791,8 @@
"cost_breakdown_aria": "Cost breakdown: {{cost}}",
"no_usage": "No usage recorded",
"tooltip_total": "Total so far {{cost}}",
+ "hover_no_run": "No run",
+ "hover_idle": "Idle {{duration}}",
"note_unmapped": "No price on file for {{models}}; their tokens are counted but their cost is not.",
"note_estimate": "Cost is estimated from published model rates, except where the provider reported its own figure."
},
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index 3692209d3e..349c3f1626 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -759,8 +759,9 @@
"open_timeline": "Ouvrir la chronologie",
"more_runs_one": "{{count}} de plus",
"more_runs_other": "{{count}} de plus",
- "strip_aria": "Coût de chaque exécution, de la plus ancienne à la plus récente — ouvrir la chronologie",
- "strip_no_usage": "Aucune consommation enregistrée"
+ "strip_aria": "Coût cumulé dans le temps — ouvrir la chronologie",
+ "strip_no_usage": "Aucune consommation enregistrée",
+ "sparkline_now": "Maintenant"
},
"runs_timeline": {
"title": "Exécutions",
@@ -790,6 +791,8 @@
"cost_breakdown_aria": "Détail du coût : {{cost}}",
"no_usage": "Aucune consommation enregistrée",
"tooltip_total": "Cumul : {{cost}}",
+ "hover_no_run": "Aucune exécution",
+ "hover_idle": "Inactif {{duration}}",
"note_unmapped": "Aucun tarif connu pour {{models}} ; leurs tokens sont comptés, mais pas leur coût.",
"note_estimate": "Le coût est estimé d'après les tarifs publiés des modèles, sauf lorsque le fournisseur a communiqué son propre chiffre."
},
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index 2529c638be..34b2d42fe2 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -729,8 +729,9 @@
"latest": "最新",
"open_timeline": "タイムラインを開く",
"more_runs_other": "他 {{count}} 件",
- "strip_aria": "各実行の費用(古い順)— 実行タイムラインを開く",
- "strip_no_usage": "使用量の記録なし"
+ "strip_aria": "累計費用の推移 — 実行タイムラインを開く",
+ "strip_no_usage": "使用量の記録なし",
+ "sparkline_now": "現在"
},
"runs_timeline": {
"title": "実行履歴",
@@ -755,6 +756,8 @@
"cost_breakdown_aria": "費用の内訳:{{cost}}",
"no_usage": "使用量の記録なし",
"tooltip_total": "累計 {{cost}}",
+ "hover_no_run": "実行なし",
+ "hover_idle": "アイドル {{duration}}",
"note_unmapped": "{{models}} は価格が未登録です。トークンは集計されますが費用は含まれません。",
"note_estimate": "費用は公開モデル料金からの概算です(プロバイダーが独自の費用を返した分を除く)。"
},
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index a5b92ff6a1..394e2f2707 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -729,8 +729,9 @@
"latest": "최근",
"open_timeline": "타임라인 열기",
"more_runs_other": "{{count}}개 더",
- "strip_aria": "실행별 비용(오래된 순) — 실행 타임라인 열기",
- "strip_no_usage": "사용량 기록 없음"
+ "strip_aria": "시간에 따른 누적 비용 — 실행 타임라인 열기",
+ "strip_no_usage": "사용량 기록 없음",
+ "sparkline_now": "지금"
},
"runs_timeline": {
"title": "실행 기록",
@@ -755,6 +756,8 @@
"cost_breakdown_aria": "비용 내역: {{cost}}",
"no_usage": "사용량 기록 없음",
"tooltip_total": "누적 {{cost}}",
+ "hover_no_run": "실행 없음",
+ "hover_idle": "유휴 {{duration}}",
"note_unmapped": "{{models}}의 가격 정보가 없어 토큰은 집계되지만 비용은 포함되지 않습니다.",
"note_estimate": "비용은 공개된 모델 요금 기준 추정치이며, 제공자가 자체 비용을 보고한 경우는 그 값을 사용합니다."
},
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index 07cfb8030a..2387af78bf 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -729,8 +729,9 @@
"latest": "最近",
"open_timeline": "打开时间线",
"more_runs_other": "还有 {{count}} 次",
- "strip_aria": "每次运行的费用,从早到晚——打开运行时间线",
- "strip_no_usage": "没有用量记录"
+ "strip_aria": "累计费用随时间的变化——打开运行时间线",
+ "strip_no_usage": "没有用量记录",
+ "sparkline_now": "现在"
},
"runs_timeline": {
"title": "运行记录",
@@ -755,6 +756,8 @@
"cost_breakdown_aria": "费用明细:{{cost}}",
"no_usage": "没有用量记录",
"tooltip_total": "累计 {{cost}}",
+ "hover_no_run": "没有运行",
+ "hover_idle": "空闲 {{duration}}",
"note_unmapped": "{{models}} 没有维护价格,token 已计入,费用未计入。",
"note_estimate": "费用按各模型公开价目估算;供应商回报实际费用时以回报值为准。"
},