From 6d3d8245b2f84d49decc482fea9eabced4fdabcf Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Tue, 10 Nov 2026 12:58:29 -0800 Subject: [PATCH] Clean up folder Source Control cards and add Remove from Parent (#40850) * wip(folder-sc): card header cleanup and Remove from Parent in card menu Work in progress handed to a Codex session; see ~/orca-qa/folder-sc-card/handoff-codex.md. * test(source-control): cover collapsed folder card identity * Keep folder card controls usable while status is unavailable * Retain branch before card body mounts and allow conflict rows to grow * Preserve source control label size and folder card parent actions --- ...FolderWorkspaceSourceControlPanel.test.tsx | 15 +- .../FolderWorkspaceSourceControlPanel.tsx | 18 +- ...folder-worktree-section-header.fixture.tsx | 4 + .../folder-worktree-section-header.tsx | 150 +++++++---- .../source-control/listing/section-header.tsx | 18 +- .../listing/uncommitted-sections.tsx | 62 ++--- .../source-control/listing/use-selection.ts | 3 +- .../panel/branch-context-row.tsx | 18 +- .../panel/header-actions-slot.ts | 8 + .../panel/header-overflow-menu.tsx | 116 ++++++--- .../source-control/panel/header-toolbar.tsx | 240 +++++++++++------- .../src/i18n/en-runtime-required.json | 4 + src/renderer/src/i18n/locales/en.json | 2 + 13 files changed, 420 insertions(+), 238 deletions(-) create mode 100644 src/renderer/src/components/right-sidebar/source-control/panel/header-actions-slot.ts diff --git a/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.test.tsx b/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.test.tsx index 34290b57abf..e749f5645d1 100644 --- a/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.test.tsx +++ b/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.test.tsx @@ -158,17 +158,20 @@ async function render(visible = true) { ) } -it('labels same-repo sections by worktree name and a detached section by its HEAD', async () => { +it('identifies same-repo cards by name and shows their branch when collapsed', async () => { const [onBranch, detached] = setup(2) useAppStore.setState({ worktreesByRepo: { repo: [onBranch!, { ...detached!, branch: '', head: 'abc1234def' }] } }) await render() - expect( - [...container.querySelectorAll('section button[aria-expanded]')].map( - (toggle) => toggle.textContent - ) - ).toEqual(['ChildChild 0feature-0', 'ChildChild 1Detached HEAD · abc1234']) + const toggles = [ + ...container.querySelectorAll('section button[aria-expanded]') + ] + expect(toggles.map((toggle) => toggle.textContent)).toEqual(['ChildChild 0', 'ChildChild 1']) + expect([...container.querySelectorAll('section')].map((section) => section.textContent)).toEqual([ + 'ChildChild 0feature-0', + 'ChildChild 1Detached HEAD · abc1234' + ]) }) function ScopedStatusObserver({ owner }: { owner: SourceControlScope }) { diff --git a/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.tsx b/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.tsx index b8424d28834..13cc391236b 100644 --- a/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.tsx +++ b/src/renderer/src/components/right-sidebar/FolderWorkspaceSourceControlPanel.tsx @@ -26,6 +26,8 @@ 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' import { useSectionOnScreen } from './source-control/panel/section-viewport-presence' @@ -112,6 +114,7 @@ const WorktreeSection = memo( : null ) const panel = useMemo(() => , []) + const [actionsSlot, setActionsSlot] = useState(null) const identity = getWorktreeGitIdentityDisplay(owner.worktree) return (
+ ) : null + } onToggle={() => setExpanded(!isExpanded)} onOpen={() => useAppStore.getState().setActiveWorktree(id, owner.executionHostId)} + actionsSlotRef={setActionsSlot} /> {isExpanded && (!connected ? ( @@ -154,9 +164,11 @@ const WorktreeSection = memo( // A read error renders the body's existing failure banner with Retry. )} diff --git a/src/renderer/src/components/right-sidebar/folder-worktree-section-header.fixture.tsx b/src/renderer/src/components/right-sidebar/folder-worktree-section-header.fixture.tsx index 9d82daa4d4a..d40e0025386 100644 --- a/src/renderer/src/components/right-sidebar/folder-worktree-section-header.fixture.tsx +++ b/src/renderer/src/components/right-sidebar/folder-worktree-section-header.fixture.tsx @@ -36,6 +36,7 @@ function Cards() { expanded onToggle={() => {}} onOpen={() => {}} + actionsSlotRef={() => {}} />
@@ -48,6 +49,7 @@ function Cards() { expanded onToggle={() => {}} onOpen={() => {}} + actionsSlotRef={() => {}} /> @@ -59,6 +61,7 @@ function Cards() { expanded={false} onToggle={() => {}} onOpen={() => {}} + actionsSlotRef={() => {}} /> @@ -82,6 +85,7 @@ export const narrow = defineFixture({ expanded={false} onToggle={() => {}} onOpen={() => {}} + actionsSlotRef={() => {}} /> 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 6df52b72b5d..66641f4b678 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,8 +15,31 @@ 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. */ + actionsSlotRef: (element: HTMLDivElement | null) => void +} + +function AheadBehind({ ahead, behind }: { ahead?: number; behind?: number }): React.JSX.Element { + return ( + <> + {!!ahead && ( + + + {ahead} + + )} + {!!behind && ( + + + {behind} + + )} + + ) } export function FolderWorktreeSectionHeader({ @@ -27,86 +50,101 @@ export function FolderWorktreeSectionHeader({ behind, changeCount, expanded, + showBranchInHeader = !expanded, + actions, onToggle, - onOpen + onOpen, + actionsSlotRef }: FolderWorktreeSectionHeaderProps): React.JSX.Element { const t = useTranslate() const openLabel = t( 'auto.components.rightSidebar.FolderWorkspaceSourceControl.openWorktree', 'Open this worktree' ) + const showWorktreeName = !!worktreeName && worktreeName !== branch + // Expanded cards show the branch once, in the body's picker; collapsed cards have no body. + const showSummaryRow = showBranchInHeader && (!!branch || !!ahead || !!behind || changeCount > 0) return ( // Pinned within its own card, above the panel's sticky COMMITS dock.
- + + + + + {openLabel} + + + {expanded && ( + + + + )} +
+ {actions} +
+
+ {showSummaryRow && ( + + {branch && ( + + + + {branch} + )} - - {(branch || !!ahead || !!behind) && ( - - {branch && ( - - - {branch} - - )} - {!!ahead && ( - - - {ahead} - - )} - {!!behind && ( - - - {behind} + + {!expanded && } + {!expanded && changeCount > 0 && ( + + {t( + 'auto.components.rightSidebar.FolderWorkspaceSourceControl.changeCount', + '{{count}} changes', + { count: changeCount, defaultValue_one: '{{count}} change' } + )} )} - )} - - - - - - {openLabel} - + + )}
) } 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 e6b95041d57..00a38832642 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 @@ -3,6 +3,7 @@ import { ChevronDown } from 'lucide-react' import { cn } from '@/lib/class-names' import { Button } from '@/components/ui/button' import { useTranslate } from '@/i18n/use-translate' +import { useSourceControlScope } from '../panel/worktree-scope' export function SectionHeader({ label, @@ -23,22 +24,27 @@ export function SectionHeader({ actions?: React.ReactNode }): React.JSX.Element { const t = useTranslate() + // Folder cards keep the gap above the first file equal to the one below the last. + const compact = useSourceControlScope() !== null // Share the rounded container so hover styling spans the whole row. return ( -
+
-
{actions}
+
+ {actions} +
) diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-sections.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-sections.tsx index c80dea85b36..6c77ceaf81a 100644 --- a/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-sections.tsx +++ b/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-sections.tsx @@ -14,6 +14,7 @@ import { import { ActionButton } from './action-button' import { SectionHeader } from './section-header' import { SourceControlSectionFileList } from './section-file-list' +import { useSourceControlScope } from '../panel/worktree-scope' import { getSourceControlSectionViewAction, type SourceControlDisplaySection, @@ -89,6 +90,7 @@ export function SourceControlUncommittedSections(props: { requestDiscardEntry: (entry: GitStatusEntry) => void diffCommentCountByPath: Map }): React.JSX.Element { + const embedded = useSourceControlScope() !== null const t = useTranslate() return ( <> @@ -176,35 +178,37 @@ export function SourceControlUncommittedSections(props: { } /> {!isCollapsed && ( - +
+ +
)}
) 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/branch-context-row.tsx b/src/renderer/src/components/right-sidebar/source-control/panel/branch-context-row.tsx index af4712d35a9..940a009f98c 100644 --- a/src/renderer/src/components/right-sidebar/source-control/panel/branch-context-row.tsx +++ b/src/renderer/src/components/right-sidebar/source-control/panel/branch-context-row.tsx @@ -103,6 +103,7 @@ export function SourceControlBranchContextRow({ headControl, manualReviewUrl, branchLineTotal, + reviewControl, onChangeBaseRef, onRetry }: { @@ -112,6 +113,7 @@ export function SourceControlBranchContextRow({ headControl?: React.ReactNode manualReviewUrl?: string | null branchLineTotal?: GitBranchLineTotal | null + reviewControl?: React.ReactNode onChangeBaseRef: () => void onRetry: () => void }): React.JSX.Element | null { @@ -124,8 +126,11 @@ export function SourceControlBranchContextRow({ return null } return ( -
- {headControl ?? } +
+ + {headControl ?? } + + {reviewControl}
) } @@ -159,7 +164,12 @@ export function SourceControlBranchContextRow({ onChangeBaseRef={onChangeBaseRef} changeBaseTitle={changeBaseTitle} leading={