diff --git a/package.json b/package.json index d902651..b9094a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ccstatusline", - "version": "1.0.10", + "version": "1.0.11", "description": "A customizable status line formatter for Claude Code CLI", "module": "src/ccstatusline.ts", "type": "module", diff --git a/src/ccstatusline.ts b/src/ccstatusline.ts index dbd76b6..23338bd 100644 --- a/src/ccstatusline.ts +++ b/src/ccstatusline.ts @@ -203,7 +203,7 @@ async function getSessionDuration(transcriptPath: string): Promise= 0; i--) { try { - const data = JSON.parse(lines[i]); + const data = JSON.parse(lines[i]!); if (data.timestamp) { lastTimestamp = new Date(data.timestamp); break; @@ -308,8 +308,6 @@ async function getTokenMetrics(transcriptPath: string): Promise<{ function renderSingleLine(items: StatusItem[], settings: any, data: StatusJSON, tokenMetrics: any, sessionDuration: string | null): string { const detectedWidth = getTerminalWidth(); - console.error(`[DEBUG] Detected terminal width: ${detectedWidth}`); - // Calculate terminal width based on flex mode settings let terminalWidth: number | null = null; if (detectedWidth) { @@ -440,10 +438,6 @@ function renderSingleLine(items: StatusItem[], settings: any, data: StatusJSON, const text = item.rawValue ? sessionDuration : `Session: ${sessionDuration}`; elements.push({ content: color(text), type: 'session-clock' }); } - // Debug - let's see if we skip session-clock - if (process.env.CCSTATUSLINEDEBUG === 'true' && !sessionDuration) { - console.error('[DEBUG] Skipping session-clock - no duration'); - } break; case 'version': @@ -490,9 +484,7 @@ function renderSingleLine(items: StatusItem[], settings: any, data: StatusJSON, let statusLine = ''; if (hasFlexSeparator && terminalWidth) { - // Add debug at start of flex processing - console.error(`[DEBUG] Processing flex separator - Terminal width: ${terminalWidth}`); - // Split elements by flex separators +// Split elements by flex separators const parts: string[][] = [[]]; let currentPart = 0; @@ -518,11 +510,7 @@ function renderSingleLine(items: StatusItem[], settings: any, data: StatusJSON, const spacePerFlex = flexCount > 0 ? Math.floor(totalSpace / flexCount) : 0; const extraSpace = flexCount > 0 ? totalSpace % flexCount : 0; - // Debug output - console.error(`[DEBUG] Terminal width: ${terminalWidth}, Total content: ${totalContentLength}, Parts: ${partLengths.join(', ')}`); - console.error(`[DEBUG] Flex count: ${flexCount}, Space per flex: ${spacePerFlex}, Total space: ${totalSpace}`); - - // Build the status line with distributed spacing +// Build the status line with distributed spacing statusLine = ''; for (let i = 0; i < parts.length; i++) { const part = parts[i]; @@ -538,8 +526,7 @@ function renderSingleLine(items: StatusItem[], settings: any, data: StatusJSON, } else { // No flex separator OR no width detected if (hasFlexSeparator && !terminalWidth) { - console.error('[DEBUG] Flex separator present but no terminal width detected - falling back to normal separator'); - // Treat flex separators as normal separators when width detection fails +// Treat flex separators as normal separators when width detection fails statusLine = elements.map(e => e.type === 'flex-separator' ? chalk.dim(' | ') : e.content).join(''); } else { // Just join all elements normally @@ -633,11 +620,6 @@ async function renderStatusLine(data: StatusJSON) { console.log(line); } } - - // Add debug output if CCSTATUSLINEDEBUG environment variable is set to true - if (process.env.CCSTATUSLINEDEBUG === 'true' && data.transcript_path) { - console.log(chalk.dim(`[DEBUG] JSONL Path: ${data.transcript_path}`)); - } } async function main() { diff --git a/src/tui.tsx b/src/tui.tsx index 265b1f3..81b39f4 100644 --- a/src/tui.tsx +++ b/src/tui.tsx @@ -820,7 +820,7 @@ const FlexOptions: React.FC = ({ settings, onUpdate, onBack }) const menuItems = options.map(opt => ({ label: opt.label + (opt.value === selectedOption ? ' ✓' : ''), - value: opt.value + value: opt.value as string })); menuItems.push({ label: '← Back', value: 'back' }); @@ -1044,10 +1044,13 @@ const App: React.FC = () => { const newLines = settings.lines || [[]]; let flatIndex = 0; for (let lineIndex = 0; lineIndex < newLines.length; lineIndex++) { - for (let itemIndex = 0; itemIndex < newLines[lineIndex].length; itemIndex++) { - if (flatIndex < items.length) { - newLines[lineIndex][itemIndex] = items[flatIndex]; - flatIndex++; + const line = newLines[lineIndex]; + if (line) { + for (let itemIndex = 0; itemIndex < line.length; itemIndex++) { + if (flatIndex < items.length && items[flatIndex]) { + line[itemIndex] = items[flatIndex]!; + flatIndex++; + } } } }