(stats: ClaudeCodeStats, activeTab: 'Overview' | 'Models')
| 1066 | setTimeout(setStatus, 2000, null); |
| 1067 | } |
| 1068 | function renderStatsToAnsi(stats: ClaudeCodeStats, activeTab: 'Overview' | 'Models'): string { |
| 1069 | const lines: string[] = []; |
| 1070 | if (activeTab === 'Overview') { |
| 1071 | lines.push(...renderOverviewToAnsi(stats)); |
| 1072 | } else { |
| 1073 | lines.push(...renderModelsToAnsi(stats)); |
| 1074 | } |
| 1075 | |
| 1076 | // Trim trailing empty lines |
| 1077 | while (lines.length > 0 && stripAnsi(lines[lines.length - 1]!).trim() === '') { |
| 1078 | lines.pop(); |
| 1079 | } |
| 1080 | |
| 1081 | // Add "/stats" right-aligned on the last line |
| 1082 | if (lines.length > 0) { |
| 1083 | const lastLine = lines[lines.length - 1]!; |
| 1084 | const lastLineLen = getStringWidth(lastLine); |
| 1085 | // Use known content widths based on layout: |
| 1086 | // Overview: two-column stats = COL2_START(40) + COL2_LABEL_WIDTH(18) + max_value(~12) = 70 |
| 1087 | // Models: chart width = 80 |
| 1088 | const contentWidth = activeTab === 'Overview' ? 70 : 80; |
| 1089 | const statsLabel = '/stats'; |
| 1090 | const padding = Math.max(2, contentWidth - lastLineLen - statsLabel.length); |
| 1091 | lines[lines.length - 1] = lastLine + ' '.repeat(padding) + chalk.gray(statsLabel); |
| 1092 | } |
| 1093 | return lines.join('\n'); |
| 1094 | } |
| 1095 | function renderOverviewToAnsi(stats: ClaudeCodeStats): string[] { |
| 1096 | const lines: string[] = []; |
| 1097 | const theme = getTheme(resolveThemeSetting(getGlobalConfig().theme)); |
no test coverage detected