The best way to control Claude Code, Codex and more from any computer or phone
fix(shared): durations under 10s drop a trailing .0 (#27316)
maria committed
Oct 30, 2026 at 02:36 UTC
c8a606c7b73e1e3586d5c06f76c69525f2d4c679
7 files changed
+30
-33
apps/mobile/src/lib/threadActivity.test.ts
+6
-6
@@ -846,7 +846,7 @@ describe("buildThreadFeed", () => {
846
expect(collapsed[1]).toMatchObject({
847
type: "run-fold",
848
createdAt: "2026-06-20T00:00:01.500Z",
849
- label: "Worked for 2.0s",
849
+ label: "Worked for 2s",
850
});
851
852
const expanded = deriveThreadFeedPresentation(feed, latestRun, new Set([runId]));
@@ -1100,10 +1100,10 @@ describe("buildThreadFeed", () => {
1100
const settled = deriveThreadFeedPresentation(feed(false), null, new Set());
1101
expect(shape(settled)).toEqual([
1102
"user:launch",
1103
- "fold:Worked for 8.0s",
1103
+ "fold:Worked for 8s",
1104
"assistant:launch-answer",
1105
"user:resume",
1106
- "fold:Worked for 8.0s",
1106
+ "fold:Worked for 8s",
1107
"assistant:resume-answer",
1108
]);
1109
const launchFold = settled.find((entry) => entry.type === "run-fold");
@@ -1112,11 +1112,11 @@ describe("buildThreadFeed", () => {
1112
shape(deriveThreadFeedPresentation(feed(false), null, new Set([launchFold.runId]))),
1113
).toEqual([
1114
"user:launch",
1115
- "fold:Worked for 8.0s",
1115
+ "fold:Worked for 8s",
1116
"activity-group",
1117
"assistant:launch-answer",
1118
"user:resume",
1119
- "fold:Worked for 8.0s",
1119
+ "fold:Worked for 8s",
1120
"assistant:resume-answer",
1121
]);
1122
@@ -1133,7 +1133,7 @@ describe("buildThreadFeed", () => {
1133
),
1134
).toEqual([
1135
"user:launch",
1136
- "fold:Worked for 8.0s",
1136
+ "fold:Worked for 8s",
1137
"assistant:launch-answer",
1138
"user:resume",
1139
"activity-group",
apps/server/src/cli/trace.ts
+2
-2
@@ -100,7 +100,7 @@ export function makeTraceSpanSummary(sinceMs = -Infinity) {
100
}
101
102
const formatMs = (ms: number) =>
103
- ms < 1_000 ? `${Math.round(ms)}ms` : `${(ms / 1_000).toFixed(1)}s`;
103
+ ms < 1_000 ? `${Math.round(ms)}ms` : `${Math.round(ms / 100) / 10}s`;
104
105
function formatTraceSummary(
106
summary: ReturnType<ReturnType<typeof makeTraceSpanSummary>["finish"]>,
@@ -127,7 +127,7 @@ function formatTraceSummary(
127
const widths = header.map((_, column) => Math.max(...table.map((row) => row[column]!.length)));
128
const formatIso = (ms: number) => DateTime.formatIso(DateTime.makeUnsafe(ms));
129
return [
130
- `${summary.spanCount} spans ended from ${formatIso(summary.firstEndMs)} to ${formatIso(summary.lastEndMs)} (${summary.minutes.toFixed(1)} min).`,
130
+ `${summary.spanCount} spans ended from ${formatIso(summary.firstEndMs)} to ${formatIso(summary.lastEndMs)} (${summary.minutes.toFixed(1).replace(/\.0+$/, "")} min).`,
131
...(summary.skippedLineCount > 0
132
? [`Skipped ${summary.skippedLineCount} lines that are not spans.`]
133
: []),
apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+6
-6
@@ -1841,10 +1841,10 @@ describe("deriveMessagesTimelineRows", () => {
1841
const settled = rows({ resume: "completed", working: false });
1842
expect(shape(settled)).toEqual([
1843
"user:launch",
1844
- "fold:Worked for 8.0s",
1844
+ "fold:Worked for 8s",
1845
"assistant:launch-answer",
1846
"user:resume",
1847
- "fold:Worked for 8.0s",
1847
+ "fold:Worked for 8s",
1848
"assistant:resume-answer",
1849
]);
1850
@@ -1857,17 +1857,17 @@ describe("deriveMessagesTimelineRows", () => {
1857
});
1858
expect(shape(expanded)).toEqual([
1859
"user:launch",
1860
- "fold:Worked for 8.0s",
1860
+ "fold:Worked for 8s",
1861
"work-toggle",
1862
"assistant:launch-answer",
1863
"user:resume",
1864
- "fold:Worked for 8.0s",
1864
+ "fold:Worked for 8s",
1865
"assistant:resume-answer",
1866
]);
1867
1868
expect(shape(rows({ resume: "running", working: true }))).toEqual([
1869
"user:launch",
1870
- "fold:Worked for 8.0s",
1870
+ "fold:Worked for 8s",
1871
"assistant:launch-answer",
1872
"user:resume",
1873
"working",
@@ -1876,7 +1876,7 @@ describe("deriveMessagesTimelineRows", () => {
1876
1877
expect(shape(rows({ resume: "failed", working: false }))).toEqual([
1878
"user:launch",
1879
- "fold:Worked for 8.0s",
1879
+ "fold:Worked for 8s",
1880
"assistant:launch-answer",
1881
"user:resume",
1882
"work",
apps/web/src/components/chat/WorktreeSetupCard.browser.test.tsx
+5
-5
@@ -53,13 +53,13 @@ it("ticks the running stage while finished stages keep their duration", async ()
53
// Assert synchronously: expect.element polls on timers these tests fake.
54
const section = screen.getByRole("region", { name: "Worktree setup" });
55
56
- expect(section.element().textContent).toContain("Fetch base branch3.0s");
57
- expect(section.element().textContent).toContain("Check out files7.0s");
56
+ expect(section.element().textContent).toContain("Fetch base branch3s");
57
+ expect(section.element().textContent).toContain("Check out files7s");
58
59
await act(async () => {
60
await vi.advanceTimersByTimeAsync(5_000);
61
});
62
- expect(section.element().textContent).toContain("Fetch base branch3.0s");
62
+ expect(section.element().textContent).toContain("Fetch base branch3s");
63
expect(section.element().textContent).toContain("Check out files12s");
64
});
65
@@ -70,9 +70,9 @@ it("stops a stage interrupted by the setup ending at the setup's end", async ()
70
await using screen = await render(card(failed));
71
const section = screen.getByRole("region", { name: "Worktree setup" });
72
73
- expect(section.element().textContent).toContain("Check out files2.0s");
73
+ expect(section.element().textContent).toContain("Check out files2s");
74
await act(async () => {
75
await vi.advanceTimersByTimeAsync(5_000);
76
});
77
- expect(section.element().textContent).toContain("Check out files2.0s");
77
+ expect(section.element().textContent).toContain("Check out files2s");
78
});
apps/web/src/components/settings/DiagnosticsSettings.tsx
+4
-4
@@ -48,7 +48,7 @@ function formatCount(value: number): string {
48
49
function formatDuration(value: number): string {
50
if (value < 1_000) return `${Math.round(value)} ms`;
51
- return `${(value / 1_000).toFixed(value >= 10_000 ? 1 : 2)} s`;
51
+ return `${(value / 1_000).toFixed(value >= 10_000 ? 1 : 2).replace(/\.0+$/, "")} s`;
52
}
53
54
function formatBytes(value: number): string {
@@ -438,10 +438,10 @@ const RESOURCE_HISTORY_WINDOWS = [
438
] as const;
439
440
function formatCpuTime(seconds: number): string {
441
- if (seconds < 60) return `${seconds.toFixed(seconds >= 10 ? 1 : 2)}s`;
441
+ if (seconds < 60) return `${seconds.toFixed(seconds >= 10 ? 1 : 2).replace(/\.0+$/, "")}s`;
442
const minutes = seconds / 60;
443
- if (minutes < 60) return `${minutes.toFixed(minutes >= 10 ? 1 : 2)}m`;
444
- return `${(minutes / 60).toFixed(2)}h`;
443
+ if (minutes < 60) return `${minutes.toFixed(minutes >= 10 ? 1 : 2).replace(/\.0+$/, "")}m`;
444
+ return `${(minutes / 60).toFixed(2).replace(/\.0+$/, "")}h`;
445
}
446
447
function formatShortProcessName(command: string): string {
apps/web/src/components/settings/ResourceTelemetryDiagnostics.tsx
+6
-6
@@ -74,16 +74,16 @@ function formatRate(value: number): string {
74
75
function formatCpuTime(valueMs: number): string {
76
const seconds = valueMs / 1_000;
77
- if (seconds < 60) return `${seconds.toFixed(seconds >= 10 ? 1 : 2)}s`;
77
+ if (seconds < 60) return `${seconds.toFixed(seconds >= 10 ? 1 : 2).replace(/\.0+$/, "")}s`;
78
const minutes = seconds / 60;
79
- if (minutes < 60) return `${minutes.toFixed(minutes >= 10 ? 1 : 2)}m`;
80
- return `${(minutes / 60).toFixed(2)}h`;
79
+ if (minutes < 60) return `${minutes.toFixed(minutes >= 10 ? 1 : 2).replace(/\.0+$/, "")}m`;
80
+ return `${(minutes / 60).toFixed(2).replace(/\.0+$/, "")}h`;
81
}
82
83
function formatDurationMicros(value: number): string {
84
if (value < 1_000) return `${Math.round(value)} µs`;
85
- if (value < 1_000_000) return `${(value / 1_000).toFixed(2)} ms`;
86
- return `${(value / 1_000_000).toFixed(2)} s`;
85
+ if (value < 1_000_000) return `${(value / 1_000).toFixed(2).replace(/\.0+$/, "")} ms`;
86
+ return `${(value / 1_000_000).toFixed(2).replace(/\.0+$/, "")} s`;
87
}
88
89
function formatSampleInterval(valueMs: number): string {
@@ -788,7 +788,7 @@ function AttributionTable({ entries }: { entries: ReadonlyArray<ResourceAttribut
788
</td>
789
<td className="px-3 py-2 text-right font-mono tabular-nums">{entry.count}</td>
790
<td className="px-3 py-2 text-right font-mono tabular-nums text-muted-foreground sm:pr-5">
791
- {(entry.durationMs / 1_000).toFixed(2)}s
791
+ {(entry.durationMs / 1_000).toFixed(2).replace(/\.0+$/, "")}s
792
</td>
793
</tr>
794
))}
packages/shared/src/orchestrationTiming.ts
+1
-4
@@ -22,10 +22,7 @@ export function deriveSubagentElapsedMs(
22
export function formatDuration(durationMs: number): string {
23
if (!Number.isFinite(durationMs) || durationMs < 0) return "0ms";
24
if (durationMs < 1_000) return `${Math.max(1, Math.round(durationMs))}ms`;
25
- if (durationMs < 10_000) {
26
- const tenths = Math.round(durationMs / 100) / 10;
27
- return tenths >= 10 ? "10s" : `${tenths.toFixed(1)}s`;
28
- }
25
+ if (durationMs < 10_000) return `${Math.round(durationMs / 100) / 10}s`;
26
const totalSeconds = Math.round(durationMs / 1_000);
27
// Choose the unit after rounding so 59.5 seconds never renders as "60s".
28
if (totalSeconds < 60) return `${totalSeconds}s`;