From e17f0db177fa6a5e4a3082a8d629bb286e50ca67 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Tue, 10 Nov 2026 11:06:08 -0800 Subject: [PATCH] Keep folder card controls usable while status is unavailable --- ...FolderWorkspaceSourceControlPanel.test.tsx | 1 - .../FolderWorkspaceSourceControlPanel.tsx | 7 ++ .../folder-worktree-section-header.tsx | 33 +++++-- .../source-control/listing/section-header.tsx | 10 +- .../listing/uncommitted-sections.tsx | 62 ++++++------ .../source-control/listing/use-selection.ts | 3 +- .../panel/header-overflow-menu.tsx | 97 +++++++++++-------- .../source-control/panel/header-toolbar.tsx | 7 +- 8 files changed, 128 insertions(+), 92 deletions(-) diff --git a/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.test.tsx b/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.test.tsx index 6f2969d4982..e749f5645d1 100644 --- a/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.test.tsx +++ b/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.test.tsx @@ -168,7 +168,6 @@ it('identifies same-repo cards by name and shows their branch when collapsed', a ...container.querySelectorAll('section button[aria-expanded]') ] expect(toggles.map((toggle) => toggle.textContent)).toEqual(['ChildChild 0', 'ChildChild 1']) - await act(async () => toggles.forEach((toggle) => toggle.click())) expect([...container.querySelectorAll('section')].map((section) => section.textContent)).toEqual([ 'ChildChild 0feature-0', 'ChildChild 1Detached HEAD · abc1234' diff --git a/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.tsx b/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.tsx index f6d189e3776..e64c97e5250 100644 --- a/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.tsx +++ b/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.tsx @@ -26,6 +26,7 @@ import { SourceControlScopeProvider, type SourceControlScope } from './source-control/panel/worktree-scope' +import { SourceControlHeaderOverflowMenu } from './source-control/panel/header-overflow-menu' import { SourceControlHeaderActionsSlot } from './source-control/panel/header-actions-slot' import { useWorktreeGitStatusObservation } from './source-control/sync/use-worktree-git-status-observation' import { useSourceControlWatchConsumer } from '@/hooks/source-control-watch-consumers' @@ -133,6 +134,12 @@ const WorktreeSection = memo( behind={remote?.behind} changeCount={entries.length} expanded={isExpanded} + showBranchInHeader={!bodyShown} + actions={ + isExpanded && (!bodyShown || !bodyMounted) ? ( + + ) : null + } onToggle={() => setExpanded(!isExpanded)} onOpen={() => useAppStore.getState().setActiveWorktree(id, owner.executionHostId)} actionsSlotRef={setActionsSlot} diff --git a/src/renderer/src/components/right-sidebar/folder-worktree-section-header.tsx b/src/renderer/src/components/right-sidebar/folder-worktree-section-header.tsx index f2756160dc2..fad2b07fa41 100644 --- a/src/renderer/src/components/right-sidebar/folder-worktree-section-header.tsx +++ b/src/renderer/src/components/right-sidebar/folder-worktree-section-header.tsx @@ -15,6 +15,8 @@ type FolderWorktreeSectionHeaderProps = { behind?: number changeCount: number expanded: boolean + showBranchInHeader?: boolean + actions?: React.ReactNode onToggle: () => void onOpen: () => void /** Receives the embedded panel's filter and overflow buttons while expanded. */ @@ -48,6 +50,8 @@ export function FolderWorktreeSectionHeader({ behind, changeCount, expanded, + showBranchInHeader = !expanded, + actions, onToggle, onOpen, actionsSlotRef @@ -59,7 +63,7 @@ export function FolderWorktreeSectionHeader({ ) const showWorktreeName = !!worktreeName && worktreeName !== branch // Expanded cards show the branch once, in the body's picker; collapsed cards have no body. - const showSummaryRow = !expanded && (!!branch || !!ahead || !!behind || changeCount > 0) + const showSummaryRow = showBranchInHeader && (!!branch || !!ahead || !!behind || changeCount > 0) return ( // Pinned within its own card, above the panel's sticky COMMITS dock.
@@ -77,10 +84,14 @@ export function FolderWorktreeSectionHeader({ className={`size-3 shrink-0 text-muted-foreground ${expanded ? 'rotate-90' : ''}`} /> - {repoName} + + {repoName} + {/* Same-repo worktrees are told apart by name, as main did. */} {showWorktreeName && ( - {worktreeName} + + {worktreeName} + )} @@ -88,11 +99,11 @@ export function FolderWorktreeSectionHeader({ {openLabel} @@ -106,19 +117,23 @@ export function FolderWorktreeSectionHeader({
+ > + {actions} +
{showSummaryRow && ( {branch && ( - {branch} + + {branch} + )} - - {changeCount > 0 && ( + {!expanded && } + {!expanded && changeCount > 0 && ( {t( 'auto.components.rightSidebar.FolderWorkspaceSourceControl.changeCount', diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/section-header.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/section-header.tsx index 19dc4ce17f2..fbc4039b863 100644 --- a/src/renderer/src/components/right-sidebar/source-control/listing/section-header.tsx +++ b/src/renderer/src/components/right-sidebar/source-control/listing/section-header.tsx @@ -33,19 +33,15 @@ export function SectionHeader({
) diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/use-selection.ts b/src/renderer/src/components/right-sidebar/source-control/listing/use-selection.ts index 9888f31b182..9cc0b17c0d0 100644 --- a/src/renderer/src/components/right-sidebar/source-control/listing/use-selection.ts +++ b/src/renderer/src/components/right-sidebar/source-control/listing/use-selection.ts @@ -190,7 +190,8 @@ export function useSourceControlSelection({ return } - const container = containerRef.current + const panel = containerRef.current + const container = panel?.closest('[data-source-control-worktree]') ?? panel const target = e.target if (!container || !(target instanceof Node) || container.contains(target)) { return diff --git a/src/renderer/src/components/right-sidebar/source-control/panel/header-overflow-menu.tsx b/src/renderer/src/components/right-sidebar/source-control/panel/header-overflow-menu.tsx index 79d8a38e076..ca28dbfcba8 100644 --- a/src/renderer/src/components/right-sidebar/source-control/panel/header-overflow-menu.tsx +++ b/src/renderer/src/components/right-sidebar/source-control/panel/header-overflow-menu.tsx @@ -8,6 +8,7 @@ import { Settings2, Unlink } from 'lucide-react' +import type { Worktree } from '../../../../../../shared/worktree/types' import type { SourceControlViewMode } from '../../../../../../shared/ui-chrome-types' import { Button } from '@/components/ui/button' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' @@ -23,16 +24,7 @@ import { useAppStore } from '@/store' import { unnestWorktrees } from '../../../sidebar/workspace-actions/parenting/worktree-unnest' import { useSourceControlScopeOwner } from './worktree-scope' -export function SourceControlHeaderOverflowMenu({ - sourceControlViewMode, - viewModeToggleDisabled, - onToggleViewMode, - onChangeBaseRef, - onRefreshBranchCompare, - branchCompareRefreshDisabled, - diffCommentCount, - onExpandNotes -}: { +type PanelActions = { sourceControlViewMode: SourceControlViewMode viewModeToggleDisabled: boolean onToggleViewMode: () => void @@ -41,11 +33,20 @@ export function SourceControlHeaderOverflowMenu({ branchCompareRefreshDisabled: boolean diffCommentCount: number onExpandNotes: () => void +} + +export function SourceControlHeaderOverflowMenu({ + panelActions, + worktree +}: { + panelActions?: PanelActions + worktree?: Worktree }): React.JSX.Element { const t = useTranslate() const scopeOwner = useSourceControlScopeOwner() + const ownerWorktree = worktree ?? scopeOwner?.worktree const viewModeLabel = - sourceControlViewMode === 'tree' + panelActions?.sourceControlViewMode === 'tree' ? t('auto.components.right.sidebar.SourceControl.a91f8e2b01', 'View as list') : t('auto.components.right.sidebar.SourceControl.b82e9f3c12', 'View as tree') @@ -58,13 +59,13 @@ export function SourceControlHeaderOverflowMenu({ type="button" variant="ghost" size="icon-xs" - className={`${scopeOwner ? 'size-6' : 'size-7'} text-muted-foreground hover:text-foreground`} + className={ownerWorktree ? 'size-6' : 'size-7'} aria-label={t( 'auto.components.right.sidebar.SourceControl.f71c4a8d90', 'More source control actions' )} > - + @@ -76,44 +77,54 @@ export function SourceControlHeaderOverflowMenu({ - - {sourceControlViewMode === 'tree' ? ( - - ) : ( - - )} - {viewModeLabel} - - - - {t('auto.components.right.sidebar.SourceControl.476b77745b', 'Change Base Ref')}… - - - - {t('auto.components.right.sidebar.SourceControl.ed34038d0d', 'Refresh branch compare')} - - {diffCommentCount > 0 ? ( + {panelActions ? ( <> - - - - {t('auto.components.right.sidebar.SourceControl.cc474e0b8c', 'Notes')} - - {diffCommentCount} - + + {panelActions.sourceControlViewMode === 'tree' ? ( + + ) : ( + + )} + {viewModeLabel} + + + {t('auto.components.right.sidebar.SourceControl.476b77745b', 'Change Base Ref')}… + + + + {t( + 'auto.components.right.sidebar.SourceControl.ed34038d0d', + 'Refresh branch compare' + )} + + {panelActions.diffCommentCount > 0 ? ( + <> + + + + {t('auto.components.right.sidebar.SourceControl.cc474e0b8c', 'Notes')} + + {panelActions.diffCommentCount} + + + + ) : null} ) : null} - {scopeOwner ? ( + {ownerWorktree ? ( <> - + {panelActions ? : null} {/* Same unlink as the sidebar's Parent & Children menu; the worktree itself stays. */} - void unnestWorktrees( - [scopeOwner.worktree], - useAppStore.getState().updateWorktreeLineage - ) + void unnestWorktrees([ownerWorktree], useAppStore.getState().updateWorktreeLineage) } > diff --git a/src/renderer/src/components/right-sidebar/source-control/panel/header-toolbar.tsx b/src/renderer/src/components/right-sidebar/source-control/panel/header-toolbar.tsx index de649dceb32..e17f587d6d8 100644 --- a/src/renderer/src/components/right-sidebar/source-control/panel/header-toolbar.tsx +++ b/src/renderer/src/components/right-sidebar/source-control/panel/header-toolbar.tsx @@ -64,7 +64,7 @@ function renderOverflowMenu( | 'onExpandNotes' > ): React.JSX.Element { - return + return } export function SourceControlHeaderToolbar({ @@ -142,6 +142,7 @@ export function SourceControlHeaderToolbar({ const reviewControl = hostedReview ? ( ) : suppressedGitHubPRNumber !== null ? ( @@ -257,7 +258,9 @@ export function SourceControlHeaderToolbar({ {filterExpanded || showBranchContext || reviewRowShown ? (
{filterExpanded ? ( -
{filterRow}
+
+ {filterRow} +
) : null} {showBranchContext ? branchContextRow(reviewControl) : null} {reviewRowShown ? (