From 685ef06068f614e6c396b5244bf0c6893b6042ad Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Wed, 17 Jun 2026 19:59:12 -0700 Subject: [PATCH] Keep Child Workspace Cards Nested and Stable (#5652) --- .../WorktreeCard.affiliate-list-mode.test.tsx | 7 +- .../WorktreeCard.compact-hover.test.tsx | 40 +++- .../src/components/sidebar/WorktreeCard.tsx | 183 ++++++++++-------- .../sidebar/WorktreeCardStatusSlot.test.tsx | 70 ++++++- .../sidebar/WorktreeCardStatusSlot.tsx | 22 ++- ...ktreeList.lineage-child-real-card.test.tsx | 10 + 6 files changed, 234 insertions(+), 98 deletions(-) diff --git a/src/renderer/src/components/sidebar/WorktreeCard.affiliate-list-mode.test.tsx b/src/renderer/src/components/sidebar/WorktreeCard.affiliate-list-mode.test.tsx index 80b0f17ea..910fd31e1 100644 --- a/src/renderer/src/components/sidebar/WorktreeCard.affiliate-list-mode.test.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCard.affiliate-list-mode.test.tsx @@ -178,9 +178,12 @@ describe('WorktreeCard affiliate list mode', () => { }) const surface = container.querySelector('[data-worktree-card-surface="true"]') + const parentContent = container.querySelector( + '[data-worktree-card-parent-content=""]' + ) expect(surface).not.toBeNull() - expect(surface?.className).toContain('gap-0.5') - expect(surface?.className).toContain('pl-0') + expect(parentContent?.className).toContain('gap-0.5') + expect(parentContent?.className).toContain('pl-0') const statusSlot = container.querySelector('[data-worktree-card-status-slot]') expect(statusSlot?.className).toContain('px-1') expect(container.querySelector('[data-testid="context-menu-wrapper"]')).toBeNull() diff --git a/src/renderer/src/components/sidebar/WorktreeCard.compact-hover.test.tsx b/src/renderer/src/components/sidebar/WorktreeCard.compact-hover.test.tsx index 9fc2d0773..c3e8870cb 100644 --- a/src/renderer/src/components/sidebar/WorktreeCard.compact-hover.test.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCard.compact-hover.test.tsx @@ -155,11 +155,16 @@ function makeHostedReview(overrides: Partial = {}): HostedRevi } } -function expectCardSurfaceIsHoverTrigger(markup: string): void { +function expectParentBodyIsHoverTrigger(markup: string): void { const surfaceTag = markup.match(/]*data-worktree-card-surface="true"[^>]*>/)?.[0] + const triggerTag = markup.match(/]*data-worktree-card-hover-trigger=""[^>]*>/)?.[0] expect(surfaceTag).toBeDefined() - expect(surfaceTag).toContain('data-hover-card-trigger=""') + expect(surfaceTag).not.toContain('data-hover-card-trigger=""') + expect(surfaceTag).not.toContain('group/worktree-card') + expect(triggerTag).toBeDefined() + expect(triggerTag).toContain('data-hover-card-trigger=""') + expect(triggerTag).toContain('group/worktree-card') } describe('WorktreeCard compact hover details', () => { @@ -213,7 +218,7 @@ describe('WorktreeCard compact hover details', () => { ) expect(markup).toContain('data-worktree-title-inline-rename=""') - expectCardSurfaceIsHoverTrigger(markup) + expectParentBodyIsHoverTrigger(markup) expect(markup).toContain('data-hover-open-delay="100"') expect(markup).toContain('PR #456') expect(markup).toContain('Fix stale GH PR') @@ -265,7 +270,7 @@ describe('WorktreeCard compact hover details', () => { ) expect(markup).toContain('data-hover-open-delay="100"') - expectCardSurfaceIsHoverTrigger(markup) + expectParentBodyIsHoverTrigger(markup) expect(markup).toContain('Issue #123') expect(markup).toContain('Linear ENG-123') expect(markup).toContain('Reviewer handoff note') @@ -361,7 +366,7 @@ describe('WorktreeCard compact hover details', () => { ) expect(markup).toContain('data-worktree-card-meta-row=""') - expectCardSurfaceIsHoverTrigger(markup) + expectParentBodyIsHoverTrigger(markup) expect(markup.match(/data-hover-open-delay="100"/g)).toHaveLength(1) expect(markup).toContain('Reviewer handoff note') }) @@ -439,15 +444,38 @@ describe('WorktreeCard compact hover details', () => { lineageChildren={
Child card
} /> ) + const surfaceIndex = markup.indexOf('data-worktree-card-surface="true"') + const triggerIndex = markup.indexOf('data-worktree-card-hover-trigger=""') const hoverContentIndex = markup.indexOf('data-hover-card-content=""') const childIndex = markup.indexOf('data-lineage-child-card=""') - expectCardSurfaceIsHoverTrigger(markup) + expectParentBodyIsHoverTrigger(markup) expect(markup).toContain('data-worktree-lineage-children=""') + expect(markup).toContain('group/worktree-card') + expect(markup).not.toContain('group relative flex cursor-pointer') + expect(markup).not.toContain('group/worktree-card relative flex cursor-pointer') + expect(surfaceIndex).toBeGreaterThanOrEqual(0) + expect(triggerIndex).toBeGreaterThan(surfaceIndex) expect(hoverContentIndex).toBeGreaterThanOrEqual(0) expect(childIndex).toBeGreaterThan(hoverContentIndex) }) + it('uses a centered parent row and raised title size when no meta row is visible', async () => { + settings = { compactWorktreeCards: false, experimentalNewWorktreeCardStyle: true } + worktreeCardProperties = ['status'] + const { default: WorktreeCard } = await import('./WorktreeCard') + + const markup = renderToStaticMarkup( + + ) + + expect(markup).not.toContain('data-worktree-card-meta-row=""') + expect(markup).toContain('data-worktree-card-parent-content=""') + expect(markup).toContain('items-center') + expect(markup).toContain('w-5 items-center') + expect(markup).toContain('text-[13px] leading-5') + }) + it('shows the branch row for migrated Default cards with branch enabled', async () => { settings = { compactWorktreeCards: false } worktreeCardProperties = ['status', 'branch'] diff --git a/src/renderer/src/components/sidebar/WorktreeCard.tsx b/src/renderer/src/components/sidebar/WorktreeCard.tsx index 5d17394e8..5d77f34de 100644 --- a/src/renderer/src/components/sidebar/WorktreeCard.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCard.tsx @@ -1016,7 +1016,7 @@ const WorktreeCard = React.memo(function WorktreeCard({ }) || workspacePorts.length > 0 || showBranchIdentityHover) - // Why: the whole card now owns metadata hover; avoid stacking the title's + // Why: the parent row owns metadata hover; avoid stacking the title's // truncation tooltip on top of the richer details popover. const titleWrapper = newCardStyle ? hasHoverDetails @@ -1060,13 +1060,20 @@ const WorktreeCard = React.memo(function WorktreeCard({ : undefined // Why: sidebar rows need a small surface inset, while their content remains // aligned with the pre-inset layout and the repo header hierarchy. - const cardStyle = flushSurface - ? { - paddingLeft: getFlushWorktreeCardPaddingLeft(contentIndent) - } + const cardPaddingLeft = flushSurface + ? getFlushWorktreeCardPaddingLeft(contentIndent) : contentIndent > 0 - ? { paddingLeft: `calc(0.125rem + ${contentIndent}px)` } - : undefined + ? `calc(0.125rem + ${contentIndent}px)` + : null + const cardStyle = cardPaddingLeft ? { paddingLeft: cardPaddingLeft } : undefined + const lineageChildrenStyle = newCardStyle + ? { + // Why: nested child surfaces should start in the parent's title/chip + // column while remaining inside the parent card surface. + marginLeft: '0.5rem', + width: 'calc(100% - 0.5rem)' + } + : undefined const detailsAndPortsContent = hasDetails || hasPorts ? ( @@ -1115,55 +1122,24 @@ const WorktreeCard = React.memo(function WorktreeCard({ const titleRowIndicators = showTitleRowIndicators ? (
{detailsAndPorts}
) : null + const hasSecondaryCardContent = + hasMetaRow || !!remoteBranchConflict || showInlineAgentList || showLineageChildChip + const titleOnlyCard = !hasSecondaryCardContent - const cardBody = ( + const parentCardContent = (
- {isDeleting && ( -
-
- - {translate('auto.components.sidebar.WorktreeCard.691ccfd622', 'Deleting…')} -
-
- )} - {showCombinedStatusSlot ? (
{/* Header row: Title */} -
+
{showPinnedRepoIcon && ( @@ -1249,7 +1221,7 @@ const WorktreeCard = React.memo(function WorktreeCard({ displayName={visibleCardTitle} disabled={isDeleting || affiliateListMode} showUnreadEmphasis={showUnreadEmphasis} - className={compactCards && newCardStyle ? 'text-[13px] leading-5' : 'text-[12px]'} + className="text-[13px] leading-5" editingClassName="flex-1" titleWrapper={titleWrapper} onEditingChange={affiliateListMode ? undefined : setTitleRenaming} @@ -1390,7 +1362,7 @@ const WorktreeCard = React.memo(function WorktreeCard({ onClick={handleWorkspaceQuickAction} className={cn( 'inline-flex size-4 items-center justify-center rounded bg-transparent opacity-0 transition-colors transition-opacity', - 'group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100', + 'group-hover/worktree-card:opacity-100 group-focus-within/worktree-card:opacity-100 focus-visible:opacity-100', 'text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive' )} aria-label={translate( @@ -1559,17 +1531,13 @@ const WorktreeCard = React.memo(function WorktreeCard({
) - const lineageChildrenBlock = - newCardStyle && lineageChildren ? ( - // Why: child cards have their own metadata hover; keeping them outside the - // parent's hover trigger prevents hovering one child from opening every - // ancestor card popover. -
- {lineageChildren} -
- ) : null + const parentHoverTriggerBody = ( +
+ {parentCardContent} +
+ ) - const cardBodyWithHoverDetails = + const parentCardBodyWithHoverDetails = hasHoverDetails && !titleRenaming ? ( - {cardBody} + {parentHoverTriggerBody} ) : ( - cardBody + parentHoverTriggerBody ) + const cardBody = ( +
+ {isDeleting && ( +
+
+ + {translate('auto.components.sidebar.WorktreeCard.691ccfd622', 'Deleting…')} +
+
+ )} + {parentCardBodyWithHoverDetails} + + {newCardStyle && lineageChildren ? ( +
+ {lineageChildren} +
+ ) : null} +
+ ) + return ( <> {affiliateListMode ? ( - <> - {cardBodyWithHoverDetails} - {lineageChildrenBlock} - + cardBody ) : ( - <> - - {cardBodyWithHoverDetails} - - {lineageChildrenBlock} - + + {cardBody} + )} {repo?.connectionId && ( diff --git a/src/renderer/src/components/sidebar/WorktreeCardStatusSlot.test.tsx b/src/renderer/src/components/sidebar/WorktreeCardStatusSlot.test.tsx index d13236eba..1bc33db2c 100644 --- a/src/renderer/src/components/sidebar/WorktreeCardStatusSlot.test.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCardStatusSlot.test.tsx @@ -102,6 +102,7 @@ describe('WorktreeCardStatusSlot', () => { ) expect(markup).toContain('PR checks: Failed') + expect(markup).toContain('inline-flex size-5 items-center justify-center') expect(markup).toContain('text-rose-500/85') expect(markup).not.toContain('bg-emerald-500') }) @@ -126,7 +127,28 @@ describe('WorktreeCardStatusSlot', () => { expect(markup).not.toContain('bg-emerald-500') }) - it('keeps working activity ahead of PR status', () => { + it('uses PR status instead of the inactive dot when new card style is on', () => { + mocks.status = 'inactive' + const markup = renderToStaticMarkup( + + ) + + expect(markup).toContain('PR checks: Failed') + expect(markup).toContain('text-rose-500/85') + expect(markup).not.toContain('bg-neutral-500/40') + }) + + it('keeps working activity ahead of PR status in new card style', () => { mocks.status = 'working' const markup = renderToStaticMarkup( { onPointerDown={vi.fn()} onToggleUnread={vi.fn()} prDisplay={review} + newCardStyle /> ) expect(markup).toContain('Working') + expect(markup).toContain('inline-flex size-5 items-center justify-center') expect(markup).toContain('border-yellow-500') expect(markup).not.toContain('PR checks: Failed') }) + it('keeps permission activity ahead of PR status in new card style', () => { + mocks.status = 'permission' + const markup = renderToStaticMarkup( + + ) + + expect(markup).toContain('Needs permission') + expect(markup).toContain('bg-amber-500') + expect(markup).not.toContain('PR checks: Failed') + }) + it('keeps unread ahead of PR status by default', () => { const markup = renderToStaticMarkup( { expect(markup).toContain('aria-label="Mark as read"') expect(markup).toContain('Mark as read') expect(markup).toContain('PR checks: Failed · Mark as read') + expect(markup).toContain( + 'group/unread relative flex cursor-pointer items-center justify-center rounded transition-all size-5' + ) expect(markup).toContain('text-rose-500/85') expect(markup).toContain('absolute -right-1 -top-1 size-[13px] text-amber-500') expect(markup).not.toContain('bg-emerald-500') }) + + it('keeps the new style unread status dot in the stable lane footprint', () => { + const markup = renderToStaticMarkup( + + ) + + expect(markup).toContain('Active · Mark as unread') + expect(markup).toContain( + 'group/unread relative flex cursor-pointer items-center justify-center rounded transition-all size-5' + ) + }) }) diff --git a/src/renderer/src/components/sidebar/WorktreeCardStatusSlot.tsx b/src/renderer/src/components/sidebar/WorktreeCardStatusSlot.tsx index 8c8af6017..82b6fd2f2 100644 --- a/src/renderer/src/components/sidebar/WorktreeCardStatusSlot.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCardStatusSlot.tsx @@ -2,7 +2,7 @@ import React from 'react' import { Bell } from 'lucide-react' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' import { cn } from '@/lib/utils' -import { getWorktreeStatusLabel } from '@/lib/worktree-status' +import { getWorktreeStatusLabel, type WorktreeStatus } from '@/lib/worktree-status' import { FilledBellIcon } from './WorktreeCardHelpers' import StatusIndicator from './StatusIndicator' import { useWorktreeActivityStatus } from './use-worktree-activity-status' @@ -22,6 +22,8 @@ type WorktreeCardStatusSlotProps = { className?: string } +const QUIET_REVIEW_REPLACEABLE_STATUSES = new Set(['active', 'done', 'inactive']) + function getReviewStatusTooltip(review: WorktreeCardPrDisplay): string { const label = getReviewLabel(review) if (review.status === 'failure') { @@ -60,12 +62,13 @@ export function WorktreeCardStatusSlot({ const status = useWorktreeActivityStatus(worktreeId) const statusLabel = getWorktreeStatusLabel(status) || status const canShowReviewStatus = - newCardStyle && showStatus && prDisplay !== null && (status === 'active' || status === 'done') + newCardStyle && + showStatus && + prDisplay !== null && + QUIET_REVIEW_REPLACEABLE_STATUSES.has(status) const passiveStatusLabel = canShowReviewStatus && prDisplay ? getReviewStatusTooltip(prDisplay) : statusLabel - // Why: the PR/MR glyph has more visual weight below its center than the dot - // status indicator, so its status-lane instance needs a tiny optical lift. - const reviewStatusIconClassName = 'size-4 -translate-y-px' + const reviewStatusIconClassName = 'size-4' const passiveStatus = canShowReviewStatus && prDisplay ? ( @@ -79,6 +82,13 @@ export function WorktreeCardStatusSlot({ {passiveStatusLabel} + ) : newCardStyle && showStatus ? ( + <> + + + {statusLabel} + ) : ( <>