MCPcopy Create free account
hub / github.com/Noumena-Network/code / renderStatsToAnsi

Function renderStatsToAnsi

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

Source from the content-addressed store, hash-verified

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

Callers 1

handleScreenshotFunction · 0.85

Calls 3

renderOverviewToAnsiFunction · 0.85
renderModelsToAnsiFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected