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

Function OverviewTab

src/components/Stats.tsx:356–578  ·  view source on GitHub ↗
({
  stats,
  allTimeStats,
  dateRange,
  isLoading
}: {
  stats: ClaudeCodeStats;
  allTimeStats: ClaudeCodeStats;
  dateRange: StatsDateRange;
  isLoading: boolean;
})

Source from the content-addressed store, hash-verified

354 return t4;
355}
356function OverviewTab({
357 stats,
358 allTimeStats,
359 dateRange,
360 isLoading
361}: {
362 stats: ClaudeCodeStats;
363 allTimeStats: ClaudeCodeStats;
364 dateRange: StatsDateRange;
365 isLoading: boolean;
366}): React.ReactNode {
367 const {
368 columns: terminalWidth
369 } = useTerminalSize();
370
371 // Calculate favorite model and total tokens
372 const modelEntries = Object.entries(stats.modelUsage).sort(([, a], [, b]) => b.inputTokens + b.outputTokens - (a.inputTokens + a.outputTokens));
373 const favoriteModel = modelEntries[0];
374 const totalTokens = modelEntries.reduce((sum, [, usage]) => sum + usage.inputTokens + usage.outputTokens, 0);
375
376 // Memoize the factoid so it doesn't change when switching tabs
377 const factoid = useMemo(() => generateFunFactoid(stats, totalTokens), [stats, totalTokens]);
378
379 // Calculate range days based on selected date range
380 const rangeDays = dateRange === '7d' ? 7 : dateRange === '30d' ? 30 : stats.totalDays;
381
382 // Compute shot stats data (ant-only, gated by feature flag)
383 let shotStatsData: {
384 avgShots: string;
385 buckets: {
386 label: string;
387 count: number;
388 pct: number;
389 }[];
390 } | null = null;
391 if (feature('SHOT_STATS') && stats.shotDistribution) {
392 const dist = stats.shotDistribution;
393 const total = Object.values(dist).reduce((s, n) => s + n, 0);
394 if (total > 0) {
395 const totalShots = Object.entries(dist).reduce((s_0, [count, sessions]) => s_0 + parseInt(count, 10) * sessions, 0);
396 const bucket = (min: number, max?: number) => Object.entries(dist).filter(([k]) => {
397 const n_0 = parseInt(k, 10);
398 return n_0 >= min && (max === undefined || n_0 <= max);
399 }).reduce((s_1, [, v]) => s_1 + v, 0);
400 const pct = (n_1: number) => Math.round(n_1 / total * 100);
401 const b1 = bucket(1, 1);
402 const b2_5 = bucket(2, 5);
403 const b6_10 = bucket(6, 10);
404 const b11 = bucket(11);
405 shotStatsData = {
406 avgShots: (totalShots / total).toFixed(1),
407 buckets: [{
408 label: '1-shot',
409 count: b1,
410 pct: pct(b1)
411 }, {
412 label: '2\u20135 shot',
413 count: b2_5,

Callers

nothing calls this directly

Calls 12

useTerminalSizeFunction · 0.85
generateFunFactoidFunction · 0.85
featureFunction · 0.85
bucketFunction · 0.85
pctFunction · 0.85
generateHeatmapFunction · 0.85
renderModelNameFunction · 0.85
formatNumberFunction · 0.85
formatPeakDayFunction · 0.85
entriesMethod · 0.80
valuesMethod · 0.80
formatDurationFunction · 0.50

Tested by

no test coverage detected