From 18bdef9ed0b75f7f4fc2212682d221a3538ecb56 Mon Sep 17 00:00:00 2001 From: Trevin Chow Date: Thu, 18 Jun 2026 18:06:58 -0700 Subject: [PATCH] refactor(sidebar): show more of repo, workspace, and group names (#4761) * refactor(sidebar): give repo and group names priority over header chrome Repo and group headers no longer show the workspace-count badge or the collapse chevron, and the trailing action buttons (project menu, add workspace) now collapse to zero width until the row is hovered, focused, or its menu is open. The name takes the full row width by default and only truncates once the actions reveal. The count was secondary and the chevron was redundant -- the whole header is already clickable to expand/collapse -- so both were spending horizontal space better given to the name. The now-unused count field and its subtree-counting logic are removed from the header row model. * refactor(sidebar): drop the rename-pending badge from workspace rows With auto-rename on, every freshly created workspace carried a "rename pending" badge beside its name until the first agent message landed. It was persistent clutter on the element we most want legible -- the workspace name -- so remove it and the no-longer-needed handler. * Remove unrelated formatting from PR 4761 merge --------- Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com> --- .../WorktreeCard.quick-actions.test.tsx | 1 + .../src/components/sidebar/WorktreeCard.tsx | 2 - .../src/components/sidebar/WorktreeList.tsx | 28 +++---- .../repo-header-action-button-class.ts | 4 + .../sidebar/worktree-list-groups.test.ts | 83 +++++++++---------- 5 files changed, 57 insertions(+), 61 deletions(-) create mode 100644 src/renderer/src/components/sidebar/repo-header-action-button-class.ts diff --git a/src/renderer/src/components/sidebar/WorktreeCard.quick-actions.test.tsx b/src/renderer/src/components/sidebar/WorktreeCard.quick-actions.test.tsx index c8d822bbd..841804f45 100644 --- a/src/renderer/src/components/sidebar/WorktreeCard.quick-actions.test.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCard.quick-actions.test.tsx @@ -216,6 +216,7 @@ describe('WorktreeCard quick actions', () => { /> ) + expect(markup).not.toMatch(/Will be renamed from first agent message|rename pending/) expect(markup).not.toContain( 'aria-label="This worktree will be renamed from the first agent message"' ) diff --git a/src/renderer/src/components/sidebar/WorktreeCard.tsx b/src/renderer/src/components/sidebar/WorktreeCard.tsx index dbb74f9e7..2652df00f 100644 --- a/src/renderer/src/components/sidebar/WorktreeCard.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCard.tsx @@ -831,7 +831,6 @@ const WorktreeCard = React.memo(function WorktreeCard({ event.stopPropagation() setShowRenameErrorDialog(true) }, []) - const unreadTooltip = worktree.isUnread ? 'Mark read' : 'Mark unread' const lineageChildAriaLabel = lineageChildCount === 1 @@ -1338,7 +1337,6 @@ const WorktreeCard = React.memo(function WorktreeCard({ ) : null} - {!compactCards && worktree.isMainWorktree && !isFolder && ( diff --git a/src/renderer/src/components/sidebar/WorktreeList.tsx b/src/renderer/src/components/sidebar/WorktreeList.tsx index a471ff553..c4978c19f 100644 --- a/src/renderer/src/components/sidebar/WorktreeList.tsx +++ b/src/renderer/src/components/sidebar/WorktreeList.tsx @@ -176,6 +176,10 @@ import { type WorktreeSidebarDropPreview } from './worktree-sidebar-drop-preview' import { resolveProjectGroupHeaderColor } from './project-header-color' +import { + REPO_HEADER_ACTION_BUTTON_CLASS, + REPO_HEADER_ACTION_REVEAL_CLASS +} from './repo-header-action-button-class' import { areWorktreeSelectionsEqual, getWorktreeSelectionIntent, @@ -3475,7 +3479,6 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp isRepoHeader || isProjectGroupHeader ? getProjectGroupHeaderPaddingLeft(projectGroupDepth) : WORKTREE_SECTION_HEADER_PADDING_LEFT - const isCollapsed = collapsedGroups.has(row.key) return (
-
-
- -
- {isProjectGroupHeader && !row.repo && row.projectGroup?.id ? ( @@ -3618,8 +3611,8 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp type="button" variant="ghost" size="icon-xs" + className={REPO_HEADER_ACTION_BUTTON_CLASS} data-repo-header-action="" - className="size-5 shrink-0 rounded-md text-muted-foreground can-hover:opacity-0 transition-opacity hover:bg-accent/70 hover:text-foreground focus:opacity-100 group-hover:opacity-100 data-[state=open]:opacity-100" aria-label={translate( 'auto.components.sidebar.WorktreeList.79465e9034', 'Group actions for {{value0}}', @@ -3688,7 +3681,7 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp size="icon-xs" data-repo-header-action="" className={cn( - 'size-5 shrink-0 rounded-md text-muted-foreground can-hover:opacity-0 transition-opacity hover:bg-accent/70 hover:text-foreground focus:opacity-100 group-hover:opacity-100', + REPO_HEADER_ACTION_BUTTON_CLASS, folderWorkspaceCreateDisabled && 'cursor-not-allowed text-muted-foreground/60 hover:bg-transparent hover:text-muted-foreground/60' )} @@ -3739,8 +3732,8 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp type="button" variant="ghost" size="icon-xs" + className={REPO_HEADER_ACTION_BUTTON_CLASS} data-repo-header-action="" - className="size-5 shrink-0 rounded-md text-muted-foreground can-hover:opacity-0 transition-opacity hover:bg-accent/70 hover:text-foreground focus:opacity-100 group-hover:opacity-100 data-[state=open]:opacity-100" aria-label={translate( 'auto.components.sidebar.WorktreeList.609633a9e6', 'Project actions for {{value0}}', @@ -3894,8 +3887,11 @@ const VirtualizedWorktreeViewport = React.memo(function VirtualizedWorktreeViewp {createState?.disabled ? ( { it('emits Pinned and All headers in groupBy none', () => { const rows = buildRows('none', [unpinned1, pinned, unpinned2], repoMap, null, new Set()) - expect(rows[0]).toMatchObject({ type: 'header', key: 'pinned', label: 'Pinned', count: 1 }) + expect(rows[0]).toMatchObject({ type: 'header', key: 'pinned', label: 'Pinned' }) expect(rows[1]).toMatchObject({ type: 'item', worktree: { id: 'wt-pinned' } }) expect(rows[2]).toMatchObject({ type: 'header', key: 'all', label: 'All', count: 3 }) expect(rows[2]).toMatchObject({ type: 'header', icon: ALL_GROUP_META.icon }) @@ -215,7 +223,7 @@ describe('buildRows with pinned worktrees', () => { const rows = buildRows('none', [unpinned1, unpinned2], repoMap, null, new Set()) expect(rows).toMatchObject([ - { type: 'header', key: 'all', label: 'All', count: 2 }, + { type: 'header', key: 'all', label: 'All' }, { type: 'item', worktree: { id: 'wt-1' } }, { type: 'item', worktree: { id: 'wt-2' } } ]) @@ -225,7 +233,7 @@ describe('buildRows with pinned worktrees', () => { const rows = buildRows('none', [unpinned1, pinned, unpinned2], repoMap, null, new Set()) expect(rows).toMatchObject([ - { type: 'header', key: 'pinned', count: 1 }, + { type: 'header', key: 'pinned' }, { type: 'item', worktree: { id: 'wt-pinned' } }, { type: 'header', key: 'all', count: 3 }, { type: 'item', worktree: { id: 'wt-1' } }, @@ -238,7 +246,7 @@ describe('buildRows with pinned worktrees', () => { const rows = buildRows('none', [unpinned1, pinned, unpinned2], repoMap, null, new Set(['all'])) expect(rows).toMatchObject([ - { type: 'header', key: 'pinned', count: 1 }, + { type: 'header', key: 'pinned' }, { type: 'item', worktree: { id: 'wt-pinned' } }, { type: 'header', key: 'all', count: 3 } ]) @@ -280,8 +288,7 @@ describe('buildRows with pinned worktrees', () => { expect(rows[0]).toMatchObject({ type: 'header', key: 'workspace-status:in-progress', - label: 'In progress', - count: 2 + label: 'In progress' }) expect(rows[1]).toMatchObject({ type: 'item', worktree: { id: 'wt-1' } }) expect(rows[2]).toMatchObject({ type: 'item', worktree: { id: 'wt-2' } }) @@ -634,7 +641,7 @@ describe('buildRows with pinned worktrees', () => { ) expect(rows).toMatchObject([ - { type: 'header', key: 'repo:repo-1', count: 0 }, + { type: 'header', key: 'repo:repo-1' }, { type: 'imported-worktrees-card', key: 'imported-worktrees-card:repo-group:repo-1', @@ -663,7 +670,7 @@ describe('buildRows with pinned worktrees', () => { ) expect(rows).toMatchObject([ - { type: 'header', key: 'repo:repo-1', label: 'orca', count: 0 }, + { type: 'header', key: 'repo:repo-1', label: 'orca' }, { type: 'imported-worktrees-card', key: 'imported-worktrees-card:repo-group:repo-1', @@ -873,7 +880,6 @@ describe('buildRows with pinned worktrees', () => { type: 'header', key: 'repo:folder-1', label: 'design-assets', - count: 1, repo: folderRepo }) expect(rows[1]).toMatchObject({ type: 'item', worktree: { id: folderWorktree.id } }) @@ -884,10 +890,8 @@ describe('buildRows with pinned worktrees', () => { const rows = buildRows('workspace-status', [review], repoMap, null, new Set()) expect( - rows - .filter((r) => r.type === 'header') - .map((r) => ({ key: r.key, label: r.label, count: r.count })) - ).toEqual([{ key: 'workspace-status:in-review', label: 'In review', count: 1 }]) + rows.filter((r) => r.type === 'header').map((r) => ({ key: r.key, label: r.label })) + ).toEqual([{ key: 'workspace-status:in-review', label: 'In review' }]) }) it('uses customized workspace status labels and order', () => { @@ -909,12 +913,10 @@ describe('buildRows with pinned worktrees', () => { ) expect( - rows - .filter((r) => r.type === 'header') - .map((r) => ({ key: r.key, label: r.label, count: r.count })) + rows.filter((r) => r.type === 'header').map((r) => ({ key: r.key, label: r.label })) ).toEqual([ - { key: 'workspace-status:blocked', label: 'Blocked', count: 1 }, - { key: 'workspace-status:in-progress', label: 'Doing', count: 1 } + { key: 'workspace-status:blocked', label: 'Blocked' }, + { key: 'workspace-status:in-progress', label: 'Doing' } ]) }) }) @@ -1166,13 +1168,12 @@ describe('project groups', () => { type: 'header', key: 'project-group:group-1', label: 'Platform', - count: 0, projectGroup: group }) ]) }) - it('counts grouped repos before their visible worktrees are loaded', () => { + it('renders grouped repos before their visible worktrees are loaded', () => { const group: ProjectGroup = { id: 'group-1', name: 'Platform', @@ -1206,14 +1207,12 @@ describe('project groups', () => { expect(rows[0]).toMatchObject({ type: 'header', - key: 'project-group:group-1', - count: 1 + key: 'project-group:group-1' }) expect(rows[1]).toMatchObject({ type: 'header', key: 'repo:repo-1', - projectGroupDepth: 1, - count: 0 + projectGroupDepth: 1 }) }) @@ -1251,7 +1250,7 @@ describe('project groups', () => { expect(rows.filter((row) => row.type === 'header').map((row) => row.key)).toEqual([ 'project-group:group-1' ]) - expect(rows[0]).toMatchObject({ count: 0 }) + expect(rows[0]).toMatchObject({ label: 'Platform' }) }) it('renders ungrouped repos as top-level repo rows when Project Groups exist', () => { @@ -1628,7 +1627,6 @@ describe('project groups', () => { type: 'item', groupDepth: 2 }) - expect(rows[0]).toMatchObject({ count: 1 }) }) it('renders folder workspaces under their owning folder-backed Project Group', () => { @@ -1909,9 +1907,9 @@ describe('project groups', () => { 'repo:repo-service-a', 'repo:repo-service-b' ]) - expect(rows.filter((row) => row.type === 'header').map((row) => row.count)).toEqual([ - 2, 2, 2, 0, 0 - ]) + expect(rows.filter((row) => row.type === 'header').map((row) => row.projectGroupDepth)).toEqual( + [0, 1, 2, 3, 3] + ) }) it('returns both parent Project Group and repo keys for grouped repo reveals', () => { @@ -2159,28 +2157,27 @@ describe('buildRows workspace lineage nesting', () => { describe('WorktreeList header styles', () => { it('does not title-case workspace group labels', () => { - const source = readFileSync( - fileURLToPath(new URL('./WorktreeList.tsx', import.meta.url)), - 'utf8' - ) + const source = readWorktreeListSource() expect(source).not.toContain('leading-none capitalize') }) - it('shows a pointer cursor over the disclosure chevron path', () => { - const source = readFileSync( - fileURLToPath(new URL('./WorktreeList.tsx', import.meta.url)), - 'utf8' + it('collapses repo header actions without reserving title width', () => { + expect(REPO_HEADER_ACTION_REVEAL_CLASS).toContain('min-w-0 max-w-0 -ml-1.5') + expect(REPO_HEADER_ACTION_REVEAL_CLASS).toContain('focus:ml-0 focus:max-w-5 focus:opacity-100') + expect(REPO_HEADER_ACTION_REVEAL_CLASS).toContain( + 'group-hover:ml-0 group-hover:max-w-5 group-hover:opacity-100' + ) + expect(REPO_HEADER_ACTION_BUTTON_CLASS).toContain( + 'transition-[margin,max-width,opacity,background-color,color]' + ) + expect(REPO_HEADER_ACTION_BUTTON_CLASS).toContain( + 'data-[state=open]:ml-0 data-[state=open]:max-w-5 data-[state=open]:opacity-100' ) - - expect(source).toContain('[&_path]:cursor-pointer') }) it('resolves repo header color from project group headers only', () => { - const source = readFileSync( - fileURLToPath(new URL('./WorktreeList.tsx', import.meta.url)), - 'utf8' - ) + const source = readWorktreeListSource() expect(source).toContain('resolveProjectGroupHeaderColor({') expect(source).toContain('headerKey: row.key')