Skip to content

bug(tui): computeThroughput timestamp unit mismatch — throughput displayed 1000x too high #697

@JeremyDev87

Description

@JeremyDev87

Severity: CRITICAL

Summary

computeThroughput in live.pure.ts divides by 60000 (assuming milliseconds), but ActivitySample.timestamp is stored in seconds by the reducer (use-dashboard-state.ts:236 does Math.floor(action.payload.timestamp / 1000)). This causes throughput to be displayed 1000x higher than actual.

Reproduction

If 10 tool calls happen over 60 seconds, the timestamp difference is 60 (seconds). The function calculates 60 / 60000 = 0.001 min, yielding 10 / 0.001 = 10000.0/min instead of the correct 10.0/min.

Root Cause

File: apps/mcp-server/src/tui/components/live.pure.ts:60

// Current (bug) — assumes milliseconds
const durationMin = (last.timestamp - first.timestamp) / 60000;

// Fix — timestamps are in seconds
const durationMin = (last.timestamp - first.timestamp) / 60;

Why tests missed it: live.pure.spec.ts:152-176 uses millisecond values (60000, 30000) directly in test data, which don't match the reducer's actual output format (seconds).

Fix Plan

  1. Change /60000 to /60 in computeThroughput
  2. Update test data in live.pure.spec.ts to use second-based timestamps matching reducer output
  3. Add test for reverse-order samples (guard at durationMin <= 0)

Files to Modify

  • apps/mcp-server/src/tui/components/live.pure.ts:60
  • apps/mcp-server/src/tui/components/live.pure.spec.ts:152-176

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions