fix(sessions): Top tools counts each tool call once
The session analysis page's Top tools list counted every event carrying a tool_name, so each call was counted twice (its PreToolUse and its PostToolUse) while the Tool calls total beside it counted once — a session with 840 calls showed Bash at 1,533. The list now counts the same way as the total: PreToolUse, or PostToolUse in a session with none (imported).
This commit is contained in:
@@ -93,6 +93,12 @@ describe("GET /api/sessions/:id/stats tool totals", () => {
|
||||
assert.equal(body.tool_call_count, 2);
|
||||
assert.equal(body.distinct_tool_count, 1);
|
||||
});
|
||||
it("counts each call once in tools_used, not its Pre and Post events", async () => {
|
||||
const one = (await get("/api/sessions/ua-1/stats")).body.tools_used;
|
||||
assert.ok(one.every((t) => t.count === 1));
|
||||
const two = (await get("/api/sessions/ua-2/stats")).body.tools_used;
|
||||
assert.deepEqual(two, [{ tool_name: "Read", count: 2 }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("GET /api/events labels", () => {
|
||||
|
||||
Reference in New Issue
Block a user