MCPcopy Create free account
hub / github.com/WJX20/claude-code / MemoryUsageIndicator

Function MemoryUsageIndicator

src/components/MemoryUsageIndicator.tsx:5–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { Box, Text } from '../ink.js';
4import { formatFileSize } from '../utils/format.js';
5export function MemoryUsageIndicator(): React.ReactNode {
6 // Ant-only: the /heapdump link is an internal debugging aid. Gating before
7 // the hook means the 10s polling interval is never set up in external builds.
8 // USER_TYPE is a build-time constant, so the hook call below is either always
9 // reached or dead-code-eliminated — never conditional at runtime.
10 if (("external" as string) !== 'ant') {
11 return null;
12 }
13
14 // eslint-disable-next-line react-hooks/rules-of-hooks
15 // biome-ignore lint/correctness/useHookAtTopLevel: USER_TYPE is a build-time constant
16 const memoryUsage = useMemoryUsage();
17 if (!memoryUsage) {
18 return null;
19 }
20 const {
21 heapUsed,
22 status
23 } = memoryUsage;
24
25 // Only show indicator when memory usage is high or critical
26 if (status === 'normal') {
27 return null;
28 }
29 const formattedSize = formatFileSize(heapUsed);
30 const color = status === 'critical' ? 'error' : 'warning';
31 return <Box>
32 <Text color={color} wrap="truncate">
33 High memory usage ({formattedSize}) · /heapdump
34 </Text>
35 </Box>;
36}

Callers

nothing calls this directly

Calls 2

useMemoryUsageFunction · 0.85
formatFileSizeFunction · 0.85

Tested by

no test coverage detected