From 1bc2cf49ecc128beee37f58ce2e854dd78df9f14 Mon Sep 17 00:00:00 2001 From: simos Date: Fri, 31 Oct 2025 00:41:06 +0000 Subject: [PATCH] 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. --- src/components/ClaudeStatus.jsx | 7 +++++-- src/utils/websocket.js | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/ClaudeStatus.jsx b/src/components/ClaudeStatus.jsx index 05eaac2..2fb54ad 100644 --- a/src/components/ClaudeStatus.jsx +++ b/src/components/ClaudeStatus.jsx @@ -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); diff --git a/src/utils/websocket.js b/src/utils/websocket.js index 6c813ce..3f36e2a 100755 --- a/src/utils/websocket.js +++ b/src/utils/websocket.js @@ -41,7 +41,6 @@ export function useWebSocket() { // If the config returns localhost but we're not on localhost, use current host but with API server port if (wsBaseUrl.includes('localhost') && !window.location.hostname.includes('localhost')) { - console.warn('Config returned localhost, using current host with API server port instead'); const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; // For development, API server is typically on port 3002 when Vite is on 3001 const apiPort = window.location.port === '3001' ? '3002' : window.location.port;