Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-294.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `tool_call_completed` events now report `duration_ms` in milliseconds (`(2.3s)` → `2300`) instead of passing the on-screen seconds figure through unchanged (#294).
3 changes: 2 additions & 1 deletion src/classifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const RESET_REL_RE = /in [0-9]+ (hour|minute|second)s?/;

function extractDuration(line: string): string {
const m = DURATION_RE.exec(line);
return m ? m[1] : '';
// Terminal displays seconds; event duration_ms field expects milliseconds.
return m ? String(Math.round(Number(m[1]) * 1000)) : '';
}

function extractResetTime(line: string): string {
Expand Down
10 changes: 9 additions & 1 deletion test/classifier-events.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ test('tool_call_completed: tool from ✓ bullet, duration from "(N.Ns)"', () =>
assert.ok(ev);
assert.equal(ev.type, 'tool_call_completed');
assert.equal(ev.data.tool, 'Read');
assert.equal(ev.data.duration_ms, '2.3');
assert.equal(ev.data.duration_ms, '2300');
});

test('tool_call_completed: sub-second duration is rounded to nearest millisecond', () => {
const ev = makeClassifier().classify('✓ Bash(make build) (0.45s)');
assert.ok(ev);
assert.equal(ev.type, 'tool_call_completed');
assert.equal(ev.data.tool, 'Bash');
assert.equal(ev.data.duration_ms, '450');
});

test('tool_call_completed: non-seconds parenthetical yields empty duration', () => {
Expand Down
Loading