MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / BuiltinStatusLineInner

Function BuiltinStatusLineInner

src/components/BuiltinStatusLine.tsx:45–126  ·  view source on GitHub ↗
({
  modelName,
  contextUsedPct,
  usedTokens,
  contextWindowSize,
  totalCostUsd,
  rateLimits,
}: BuiltinStatusLineProps)

Source from the content-addressed store, hash-verified

43}
44
45function BuiltinStatusLineInner({
46 modelName,
47 contextUsedPct,
48 usedTokens,
49 contextWindowSize,
50 totalCostUsd,
51 rateLimits,
52}: BuiltinStatusLineProps) {
53 const { columns } = useTerminalSize();
54
55 // Force re-render every 60s so countdowns stay current
56 const [tick, setTick] = useState(0);
57 useEffect(() => {
58 const hasResetTime = (rateLimits.five_hour?.resets_at ?? 0) || (rateLimits.seven_day?.resets_at ?? 0);
59 if (!hasResetTime) return;
60 const id = setInterval(() => setTick(t => t + 1), 60_000);
61 return () => clearInterval(id);
62 }, [rateLimits.five_hour?.resets_at, rateLimits.seven_day?.resets_at]);
63
64 // Suppress unused-variable lint for tick (it exists only to trigger re-renders)
65 void tick;
66
67 // Model display: use first two words (e.g. "Opus 4.6") instead of just first word
68 const modelParts = modelName.split(' ');
69 const shortModel = modelParts.length >= 2 ? `${modelParts[0]} ${modelParts[1]}` : modelName;
70
71 const narrow = columns < 60;
72
73 const hasFiveHour = rateLimits.five_hour != null;
74 const hasSevenDay = rateLimits.seven_day != null;
75
76 const fiveHourPct = hasFiveHour ? Math.round(rateLimits.five_hour!.utilization * 100) : 0;
77 const sevenDayPct = hasSevenDay ? Math.round(rateLimits.seven_day!.utilization * 100) : 0;
78
79 // Token display: "50k/1M"
80 const tokenDisplay = `${formatTokens(usedTokens)}/${formatTokens(contextWindowSize)}`;
81
82 return (
83 <Box>
84 {/* Model name */}
85 <Text>{shortModel}</Text>
86
87 {/* Context usage with token counts */}
88 <Separator />
89 <Text dimColor>Context </Text>
90 <Text>{contextUsedPct}%</Text>
91 {!narrow && <Text dimColor> ({tokenDisplay})</Text>}
92
93 {/* 5-hour session rate limit */}
94 {hasFiveHour && (
95 <>
96 <Separator />
97 <Text dimColor>Session </Text>
98 <Text>{fiveHourPct}%</Text>
99 {!narrow && rateLimits.five_hour!.resets_at > 0 && (
100 <Text dimColor> {formatCountdown(rateLimits.five_hour!.resets_at)}</Text>
101 )}
102 </>

Callers

nothing calls this directly

Calls 4

useTerminalSizeFunction · 0.85
formatTokensFunction · 0.85
formatCostFunction · 0.85
formatCountdownFunction · 0.70

Tested by

no test coverage detected