The best way to control Claude Code, Codex and more from any computer or phone
fix(cli): trace summary no longer prints near-second durations as "1000ms" (#27266)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
MarcoDotIO committed
Oct 31, 2026 at 22:36 UTC
6866a2d0145d15675e1e0a2bdf813ee2371bbc1c
2 files changed
+13
-3
apps/server/src/cli/trace.test.ts
+11
-1
@@ -1,6 +1,6 @@
1
import { assert, it } from "@effect/vitest";
2
3
-import { makeTraceSpanSummary } from "./trace.ts";
3
+import { formatTraceSummary, makeTraceSpanSummary } from "./trace.ts";
4
5
const MINUTE_MS = 60_000;
6
@@ -62,3 +62,13 @@ it("reads failures and interrupts of browser spans from their OTLP status", () =
62
const [render] = summarizer.finish().spans;
63
assert.deepStrictEqual([render?.count, render?.interrupted, render?.failures], [4, 2, 1]);
64
});
65
+
66
+it("prints durations that round up to a second in seconds", () => {
67
+ const summarizer = makeTraceSpanSummary();
68
+ [span("rpc", 999.4, MINUTE_MS), span("rpc", 999.6, 2 * MINUTE_MS)].forEach(summarizer.addLine);
69
+
70
+ const row = formatTraceSummary(summarizer.finish(), 25)
71
+ .split("\n")
72
+ .find((line) => line.startsWith("rpc"));
73
+ assert.deepStrictEqual(row?.trim().split(/\s+/).slice(3, 6), ["999ms", "1s", "1s"]);
74
+});
apps/server/src/cli/trace.ts
+2
-2
@@ -100,9 +100,9 @@ export function makeTraceSpanSummary(sinceMs = -Infinity) {
100
}
101
102
const formatMs = (ms: number) =>
103
- ms < 1_000 ? `${Math.round(ms)}ms` : `${Math.round(ms / 100) / 10}s`;
103
+ Math.round(ms) < 1_000 ? `${Math.round(ms)}ms` : `${Math.round(ms / 100) / 10}s`;
104
105
-function formatTraceSummary(
105
+export function formatTraceSummary(
106
summary: ReturnType<ReturnType<typeof makeTraceSpanSummary>["finish"]>,
107
limit: number,
108
) {