Isolate branch switcher query from WorkspaceScreenContent to prevent 20ms re-renders
Move useBranchSwitcher into BranchSwitcher component so query state changes only re-render the small header widget instead of the entire workspace screen. Also memo-wrap AgentStatusBar to skip re-renders on keystroke.
This commit is contained in:
@@ -81,7 +81,6 @@ import type { ListTerminalsResponse } from "@server/shared/messages";
|
||||
import { upsertTerminalListEntry } from "@/utils/terminal-list";
|
||||
import { confirmDialog } from "@/utils/confirm-dialog";
|
||||
import { useArchiveAgent } from "@/hooks/use-archive-agent";
|
||||
import { useBranchSwitcher } from "@/hooks/use-branch-switcher";
|
||||
import { useStableEvent } from "@/hooks/use-stable-event";
|
||||
import { buildProviderCommand } from "@/utils/provider-command-templates";
|
||||
import { generateDraftId } from "@/stores/draft-keys";
|
||||
@@ -762,23 +761,6 @@ function WorkspaceScreenContent({ serverId, workspaceId }: WorkspaceScreenProps)
|
||||
? trimNonEmpty(checkoutQuery.data.currentBranch)
|
||||
: null;
|
||||
|
||||
const {
|
||||
branchOptions,
|
||||
isOpen: isBranchSwitcherOpen,
|
||||
setIsOpen: setIsBranchSwitcherOpen,
|
||||
handleBranchSelect,
|
||||
invalidateStashAndCheckout,
|
||||
} = useBranchSwitcher({
|
||||
client,
|
||||
normalizedServerId,
|
||||
normalizedWorkspaceId,
|
||||
currentBranchName,
|
||||
isGitCheckout,
|
||||
isConnected,
|
||||
toast,
|
||||
queryClient,
|
||||
});
|
||||
|
||||
const mobileView = usePanelStore((state) => state.mobileView);
|
||||
const desktopFileExplorerOpen = usePanelStore((state) => state.desktop.fileExplorerOpen);
|
||||
const toggleFileExplorer = usePanelStore((state) => state.toggleFileExplorer);
|
||||
@@ -1982,10 +1964,9 @@ function WorkspaceScreenContent({ serverId, workspaceId }: WorkspaceScreenProps)
|
||||
<BranchSwitcher
|
||||
currentBranchName={currentBranchName}
|
||||
title={workspaceHeader.title}
|
||||
branchOptions={branchOptions}
|
||||
isOpen={isBranchSwitcherOpen}
|
||||
onOpenChange={setIsBranchSwitcherOpen}
|
||||
onBranchSelect={handleBranchSelect}
|
||||
serverId={normalizedServerId}
|
||||
workspaceId={normalizedWorkspaceId}
|
||||
isGitCheckout={isGitCheckout}
|
||||
/>
|
||||
<Text
|
||||
testID="workspace-header-subtitle"
|
||||
|
||||
Reference in New Issue
Block a user