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

Function OverviewTab

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected