MCPcopy
hub / github.com/codeaashu/claude-code / renderStatsToAnsi

Function renderStatsToAnsi

src/components/Stats.tsx:1068–1094  ·  view source on GitHub ↗
(stats: ClaudeCodeStats, activeTab: 'Overview' | 'Models')

Source from the content-addressed store, hash-verified

1066 setTimeout(setStatus, 2000, null);
1067}
1068function 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}
1095function renderOverviewToAnsi(stats: ClaudeCodeStats): string[] {
1096 const lines: string[] = [];
1097 const theme = getTheme(resolveThemeSetting(getGlobalConfig().theme));

Callers 1

handleScreenshotFunction · 0.85

Calls 6

renderOverviewToAnsiFunction · 0.85
renderModelsToAnsiFunction · 0.85
stripAnsiFunction · 0.85
popMethod · 0.80
maxMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected