From 4cc0139408eeda4fff1dad5281e15e6190141e37 Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 8 Apr 2026 01:01:49 +0000 Subject: [PATCH] fix(cli,core): address PR feedback regarding text-buffer bounds and recentActivity leak --- packages/cli/src/ui/components/shared/text-buffer.ts | 12 ++++++++++++ packages/core/src/agents/local-invocation.ts | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/packages/cli/src/ui/components/shared/text-buffer.ts b/packages/cli/src/ui/components/shared/text-buffer.ts index 56ab575c96..a896a98624 100644 --- a/packages/cli/src/ui/components/shared/text-buffer.ts +++ b/packages/cli/src/ui/components/shared/text-buffer.ts @@ -2795,11 +2795,23 @@ export function textBufferReducer( newExpandedPaste = { ...newExpandedPaste, startLine: newStartLine }; } } + let newSelectionAnchor = newState.selectionAnchor; + if (newSelectionAnchor) { + const newAnchorRow = newSelectionAnchor[0] - excess; + if (newAnchorRow < 0) { + newSelectionAnchor = null; + } else { + newSelectionAnchor = [newAnchorRow, newSelectionAnchor[1]]; + } + } newState = { ...newState, lines: newLines, cursorRow: newCursorRow, expandedPaste: newExpandedPaste, + selectionAnchor: newSelectionAnchor, + undoStack: [], + redoStack: [], }; } diff --git a/packages/core/src/agents/local-invocation.ts b/packages/core/src/agents/local-invocation.ts index 771be7b68a..310b69a6db 100644 --- a/packages/core/src/agents/local-invocation.ts +++ b/packages/core/src/agents/local-invocation.ts @@ -262,6 +262,13 @@ export class LocalSubagentInvocation extends BaseToolInvocation< } if (updated) { + const MAX_RECENT_ACTIVITY = 100; + if (recentActivity.length > MAX_RECENT_ACTIVITY) { + recentActivity.splice( + 0, + recentActivity.length - MAX_RECENT_ACTIVITY, + ); + } const progress: SubagentProgress = { isSubagentProgress: true, agentName: this.definition.name,