From 5f84e6d5b53c0349ee43176b9a2cf40713fda3cd Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 14:26:12 -0700 Subject: [PATCH] perf: defer terminal menu pane lookups (#3946) --- .../terminal-pane/use-terminal-pane-context-menu.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts b/src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts index f3fc5b0bfec..9aad2b9dd7a 100644 --- a/src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts +++ b/src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts @@ -272,8 +272,11 @@ export function useTerminalPaneContextMenu({ setOpen(true) } - const paneCount = managerRef.current?.getPanes().length ?? 1 - const menuPaneId = resolveMenuPane()?.id ?? null + // Why: PaneManager.getPanes() allocates public pane wrappers. Closed menus + // do not need pane counts or target identity, so avoid that work on every + // render across hundreds of mounted terminal tabs. + const paneCount = open ? (managerRef.current?.getPanes().length ?? 1) : 1 + const menuPaneId = open ? (resolveMenuPane()?.id ?? null) : null return { open,