mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-13 21:07:00 -07:00
fix(cli): bound memory growth in high-volume components
This commit is contained in:
@@ -35,16 +35,17 @@ export const AnsiOutputText: React.FC<AnsiOutputProps> = ({
|
||||
? Math.min(availableHeightLimit, maxLines)
|
||||
: (availableHeightLimit ?? maxLines ?? DEFAULT_HEIGHT);
|
||||
|
||||
const MAXIMUM_ANSI_LINES_RENDERED = 1000;
|
||||
const lastLines = Array.isArray(data)
|
||||
? disableTruncation
|
||||
? data
|
||||
? data.slice(-MAXIMUM_ANSI_LINES_RENDERED)
|
||||
: numLinesRetained === 0
|
||||
? []
|
||||
: data.slice(-numLinesRetained)
|
||||
: [];
|
||||
return (
|
||||
<Box flexDirection="column" width={width} flexShrink={0} overflow="hidden">
|
||||
{(lastLines as AnsiLine[]).map((line: AnsiLine, lineIndex: number) => (
|
||||
{lastLines.map((line: AnsiLine, lineIndex: number) => (
|
||||
<Box key={lineIndex} height={1} overflow="hidden">
|
||||
<AnsiLineText line={line} />
|
||||
</Box>
|
||||
|
||||
@@ -86,8 +86,9 @@ export const SubagentProgressDisplay: React.FC<
|
||||
</Box>
|
||||
)}
|
||||
<Box flexDirection="column" marginLeft={0} gap={0}>
|
||||
{(historyOverrides ?? progress.recentActivity).map(
|
||||
(item: SubagentActivityItem) => {
|
||||
{(historyOverrides ?? progress.recentActivity)
|
||||
.slice(-100)
|
||||
.map((item: SubagentActivityItem) => {
|
||||
if (item.type === 'thought') {
|
||||
const isCancellation = item.content === 'Request cancelled.';
|
||||
const icon = isCancellation ? 'ℹ ' : '💭';
|
||||
@@ -155,8 +156,7 @@ export const SubagentProgressDisplay: React.FC<
|
||||
);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
)}
|
||||
})}
|
||||
</Box>
|
||||
|
||||
{progress.result && (
|
||||
|
||||
@@ -2779,7 +2779,29 @@ export function textBufferReducer(
|
||||
action: TextBufferAction,
|
||||
options: TextBufferOptions = {},
|
||||
): TextBufferState {
|
||||
const newState = textBufferReducerLogic(state, action, options);
|
||||
let newState = textBufferReducerLogic(state, action, options);
|
||||
|
||||
const MAX_TEXT_BUFFER_LINES = 10000;
|
||||
if (newState.lines.length > MAX_TEXT_BUFFER_LINES) {
|
||||
const excess = newState.lines.length - MAX_TEXT_BUFFER_LINES;
|
||||
const newLines = newState.lines.slice(excess);
|
||||
const newCursorRow = Math.max(0, newState.cursorRow - excess);
|
||||
let newExpandedPaste = newState.expandedPaste;
|
||||
if (newExpandedPaste) {
|
||||
const newStartLine = newExpandedPaste.startLine - excess;
|
||||
if (newStartLine < 0) {
|
||||
newExpandedPaste = null;
|
||||
} else {
|
||||
newExpandedPaste = { ...newExpandedPaste, startLine: newStartLine };
|
||||
}
|
||||
}
|
||||
newState = {
|
||||
...newState,
|
||||
lines: newLines,
|
||||
cursorRow: newCursorRow,
|
||||
expandedPaste: newExpandedPaste,
|
||||
};
|
||||
}
|
||||
|
||||
const newTransformedLines =
|
||||
newState.lines !== state.lines
|
||||
|
||||
Reference in New Issue
Block a user