From 6f5ceacb8620caa39ebc4ee536a8a333ac13c626 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sat, 16 May 2026 14:22:34 -0700 Subject: [PATCH] Collapse git graph by default Start the source control git graph section collapsed by default, including after worktree-switch reset. --- .../src/components/right-sidebar/SourceControl.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/right-sidebar/SourceControl.tsx b/src/renderer/src/components/right-sidebar/SourceControl.tsx index 44dab4518..66f5d65c8 100644 --- a/src/renderer/src/components/right-sidebar/SourceControl.tsx +++ b/src/renderer/src/components/right-sidebar/SourceControl.tsx @@ -190,6 +190,11 @@ const SOURCE_CONTROL_TREE_INDENT_PX = 12 const SOURCE_CONTROL_TREE_DIRECTORY_PADDING_PX = 8 const SOURCE_CONTROL_TREE_FILE_PADDING_PX = 20 const EMPTY_GIT_HISTORY_STATE: GitHistoryPanelState = { status: 'idle' } +const DEFAULT_COLLAPSED_SECTIONS = ['history'] as const + +function createDefaultCollapsedSections(): Set { + return new Set(DEFAULT_COLLAPSED_SECTIONS) +} // Why: the pure state-machine logic now lives in // ./source-control-primary-action.ts. It is imported directly by callers @@ -473,7 +478,9 @@ function SourceControlInner(): React.JSX.Element { ]) const [scope, setScope] = useState('all') - const [collapsedSections, setCollapsedSections] = useState>(new Set()) + const [collapsedSections, setCollapsedSections] = useState>( + createDefaultCollapsedSections + ) const [sourceControlViewMode, setSourceControlViewMode] = useState('list') const [collapsedTreeDirs, setCollapsedTreeDirs] = useState>(new Set()) const [baseRefDialogOpen, setBaseRefDialogOpen] = useState(false) @@ -901,7 +908,7 @@ function SourceControlInner(): React.JSX.Element { // worktree's UI state doesn't leak into the new one. useEffect(() => { setScope('all') - setCollapsedSections(new Set()) + setCollapsedSections(createDefaultCollapsedSections()) setCollapsedTreeDirs(new Set()) setBaseRefDialogOpen(false) setPendingDiscard(null)