summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/components')
-rw-r--r--packages/cli/src/ui/components/Footer.tsx5
-rw-r--r--packages/cli/src/ui/components/MemoryUsageDisplay.tsx40
2 files changed, 45 insertions, 0 deletions
diff --git a/packages/cli/src/ui/components/Footer.tsx b/packages/cli/src/ui/components/Footer.tsx
index 04a2f96f..22615779 100644
--- a/packages/cli/src/ui/components/Footer.tsx
+++ b/packages/cli/src/ui/components/Footer.tsx
@@ -9,6 +9,8 @@ import { Box, Text } from 'ink';
import { Colors } from '../colors.js';
import { shortenPath, tildeifyPath } from '@gemini-code/server';
import { ConsoleSummaryDisplay } from './ConsoleSummaryDisplay.js';
+import process from 'node:process';
+import { MemoryUsageDisplay } from './MemoryUsageDisplay.js';
interface FooterProps {
model: string;
@@ -20,6 +22,7 @@ interface FooterProps {
corgiMode: boolean;
errorCount: number;
showErrorDetails: boolean;
+ showMemoryUsage?: boolean;
}
export const Footer: React.FC<FooterProps> = ({
@@ -31,6 +34,7 @@ export const Footer: React.FC<FooterProps> = ({
corgiMode,
errorCount,
showErrorDetails,
+ showMemoryUsage,
}) => (
<Box marginTop={1} justifyContent="space-between" width="100%">
<Box>
@@ -86,6 +90,7 @@ export const Footer: React.FC<FooterProps> = ({
<ConsoleSummaryDisplay errorCount={errorCount} />
</Box>
)}
+ {showMemoryUsage && <MemoryUsageDisplay />}
</Box>
</Box>
);
diff --git a/packages/cli/src/ui/components/MemoryUsageDisplay.tsx b/packages/cli/src/ui/components/MemoryUsageDisplay.tsx
new file mode 100644
index 00000000..5d9a7c49
--- /dev/null
+++ b/packages/cli/src/ui/components/MemoryUsageDisplay.tsx
@@ -0,0 +1,40 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import React, { useEffect, useState } from 'react';
+import { Box, Text } from 'ink';
+import { Colors } from '../colors.js';
+import process from 'node:process';
+import { formatMemoryUsage } from '../utils/formatters.js';
+
+export const MemoryUsageDisplay: React.FC = () => {
+ const [memoryUsage, setMemoryUsage] = useState<string>('');
+ const [memoryUsageColor, setMemoryUsageColor] = useState<string>(
+ Colors.SubtleComment,
+ );
+
+ useEffect(() => {
+ const updateMemory = () => {
+ const usage = process.memoryUsage().rss;
+ setMemoryUsage(formatMemoryUsage(usage));
+ setMemoryUsageColor(
+ usage >= 2 * 1024 * 1024 * 1024
+ ? Colors.AccentRed
+ : Colors.SubtleComment,
+ );
+ };
+ const intervalId = setInterval(updateMemory, 2000);
+ updateMemory(); // Initial update
+ return () => clearInterval(intervalId);
+ }, []);
+
+ return (
+ <Box>
+ <Text color={Colors.SubtleComment}>| </Text>
+ <Text color={memoryUsageColor}>{memoryUsage}</Text>
+ </Box>
+ );
+};