diff --git a/src/ccstatusline.ts b/src/ccstatusline.ts index a84dd68..0bc999d 100644 --- a/src/ccstatusline.ts +++ b/src/ccstatusline.ts @@ -59,6 +59,7 @@ async function renderMultipleLines(data: StatusJSON) { // Set global chalk level based on settings chalk.level = settings.colorLevel; + // Update color map after setting chalk level updateColorMap(); @@ -75,16 +76,19 @@ async function renderMultipleLines(data: StatusJSON) { const hasBlockTimer = lines.some(line => line.some(item => item.type === 'block-timer')); let tokenMetrics: TokenMetrics | null = null; - if (hasTokenItems && data.transcript_path) + if (hasTokenItems && data.transcript_path) { tokenMetrics = await getTokenMetrics(data.transcript_path); + } let sessionDuration: string | null = null; - if (hasSessionClock && data.transcript_path) + if (hasSessionClock && data.transcript_path) { sessionDuration = await getSessionDuration(data.transcript_path); + } let blockMetrics: BlockMetrics | null = null; - if (hasBlockTimer && data.transcript_path) - blockMetrics = getBlockMetrics(data.transcript_path); + if (hasBlockTimer) { + blockMetrics = getBlockMetrics(); + } // Create render context const context: RenderContext = { diff --git a/src/utils/jsonl.ts b/src/utils/jsonl.ts index 6a1ec4e..d00923c 100644 --- a/src/utils/jsonl.ts +++ b/src/utils/jsonl.ts @@ -9,6 +9,8 @@ import type { TranscriptLine } from '../types'; +import { getClaudeConfigDir } from './claude-settings'; + // Ensure fs.promises compatibility for older Node versions const readFile = promisify(fs.readFile); const readFileSync = fs.readFileSync; @@ -147,51 +149,14 @@ export async function getTokenMetrics(transcriptPath: string): Promise(); - - while (currentPath && !visitedPaths.has(currentPath)) { - visitedPaths.add(currentPath); - - const baseName = path.basename(currentPath); - if (baseName === '.claude') { - claudePath = currentPath; - break; - } - - const parentPath = path.dirname(currentPath); - // Stop if we've reached the root (parent is same as current) - if (parentPath === currentPath) { - break; - } - currentPath = parentPath; - } - } - - if (!claudePath) + if (!claudeDir) return null; try { - return findMostRecentBlockStartTime(claudePath); + return findMostRecentBlockStartTime(claudeDir); } catch { return null; }