mirror of
https://github.com/siteboon/claudecodeui.git
synced 2025-12-18 10:19:38 +00:00
fix(ui): stabilize token rate calculation in status component
Calculate token rate once per timing session instead of recalculating on every interval tick. This prevents the simulated token count from jumping erratically due to random value changes. Also remove noisy console warning in websocket utility that was cluttering development logs without providing actionable information.
This commit is contained in:
@@ -15,11 +15,14 @@ function ClaudeStatus({ status, onAbort, isLoading, provider = 'claude' }) {
|
||||
}
|
||||
|
||||
const startTime = Date.now();
|
||||
// Calculate random token rate once (30-50 tokens per second)
|
||||
const tokenRate = 30 + Math.random() * 20;
|
||||
|
||||
const timer = setInterval(() => {
|
||||
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
||||
setElapsedTime(elapsed);
|
||||
// Simulate token count increasing over time (roughly 30-50 tokens per second)
|
||||
setFakeTokens(Math.floor(elapsed * (30 + Math.random() * 20)));
|
||||
// Simulate token count increasing over time
|
||||
setFakeTokens(Math.floor(elapsed * tokenRate));
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(timer);
|
||||
|
||||
Reference in New Issue
Block a user