From c673a77ef78f52a048948039823c7ef9d5351ffc Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 14:15:59 -0700 Subject: [PATCH] perf: narrow terminal repo subscription (#3940) --- .../components/terminal-pane/TerminalPane.tsx | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/components/terminal-pane/TerminalPane.tsx b/src/renderer/src/components/terminal-pane/TerminalPane.tsx index c08e9bec7..064b17d63 100644 --- a/src/renderer/src/components/terminal-pane/TerminalPane.tsx +++ b/src/renderer/src/components/terminal-pane/TerminalPane.tsx @@ -89,6 +89,7 @@ import { subscribeTerminalPaneAttention } from './terminal-pane-attention-subscriptions' import { getCachedTerminalTabForWorktree } from './terminal-tab-lookup' +import { useRepoById } from '@/store/selectors' type TerminalPaneProps = { tabId: string @@ -106,6 +107,31 @@ type TerminalPaneProps = { onCloseTab: () => void } +type TerminalQuickCommandEditorDialogProps = { + command: TerminalQuickCommand + onOpenChange: (open: boolean) => void + onSave: (command: TerminalQuickCommand) => void +} + +function TerminalQuickCommandEditorDialog({ + command, + onOpenChange, + onSave +}: TerminalQuickCommandEditorDialogProps): React.JSX.Element { + const repos = useAppStore((store) => store.repos) + + return ( + + ) +} + function formatClipboardImagePasteError(error: unknown): string { const detail = error instanceof Error ? error.message : String(error) return `Image paste failed: ${detail}` @@ -359,7 +385,6 @@ export default function TerminalPane({ const openSpacePage = useAppStore((store) => store.openSpacePage) const refreshWorkspaceSpace = useAppStore((store) => store.refreshWorkspaceSpace) const settings = useAppStore((store) => store.settings) - const repos = useAppStore((store) => store.repos) const updateSettings = useAppStore((store) => store.updateSettings) const keybindings = useAppStore((store) => store.keybindings) // Why: Windows is the only platform where bare right-click is repurposed as @@ -393,7 +418,7 @@ export default function TerminalPane({ const quickCommandRepoId = worktreeId === FLOATING_TERMINAL_WORKTREE_ID ? null : getRepoIdFromWorktreeId(worktreeId) - const quickCommandRepo = repos.find((repo) => repo.id === quickCommandRepoId) ?? null + const quickCommandRepo = useRepoById(quickCommandRepoId) const quickCommandRepoLabel = quickCommandRepo ? quickCommandRepo.displayName || quickCommandRepo.path : quickCommandRepoId @@ -1764,14 +1789,14 @@ export default function TerminalPane({ onSetTitle={contextMenu.onSetTitle} onCopyPaneId={contextMenu.onCopyPaneId} /> - + {/* Why: repos is a broad store slice; only subscribe while the editor is visible. */} + {quickCommandEditorOpen ? ( + + ) : null} {/* Title bar overlays — portaled into each pane container that has a title or is currently being renamed (so the inline input appears even for untitled panes when "Set Title..." is triggered).