From dee296f6bf50dbfcf5d723b9369bd389c38b36fe Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sat, 7 Nov 2026 20:35:14 -0800 Subject: [PATCH] Improve worktree card interactions and spacing - Let users toggle cards by clicking their headers. - Delay details until the pointer rests to avoid accidental popups. - Add breathing room around card content. --- src/renderer/src/assets/main.css | 2 +- .../sidebar/WorktreeCardSlotContent.tsx | 15 ++++++++++++++- .../controller/worktree-card-model.ts | 2 +- .../details/WorktreeCardMeta.tsx | 19 ++++++++++++++++--- .../worktree-lineage-toggle-handler-cache.ts | 2 +- .../surface/worktree-card-frame-geometry.ts | 6 ++++-- .../surface/worktree-card-surface.tsx | 10 ++++++++-- .../sidebar/worktree-list/rows/indentation.ts | 9 ++++++--- 8 files changed, 51 insertions(+), 14 deletions(-) diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index 66c392c1239..af8fb7885b8 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -1732,7 +1732,7 @@ html.native-shell .app-layout { /* 2.0 leading icon: the latest tab in front, older tabs peeking above it as narrower, dimmer cards. The box is the front tile only, so it centers on the title; layers overflow upward, staying - within the card's 6px top padding because the card surface clips. */ + within the card's 8px top padding because the card surface clips. */ .worktree-card-leading-icon { position: relative; display: inline-block; diff --git a/src/renderer/src/components/sidebar/WorktreeCardSlotContent.tsx b/src/renderer/src/components/sidebar/WorktreeCardSlotContent.tsx index b4b025387a3..012bfb81dfe 100644 --- a/src/renderer/src/components/sidebar/WorktreeCardSlotContent.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCardSlotContent.tsx @@ -233,7 +233,7 @@ export function WorktreeCardSlotContent({ ) - const toggleCard = (event: React.MouseEvent): void => { + const toggleCard = (event: React.MouseEvent): void => { dispatchSuppressScrollAdjustment() // Opening a card shows everything it holds, its child workspaces included. if (!open && lineageCollapsed && onLineageToggle) { @@ -257,6 +257,19 @@ export function WorktreeCardSlotContent({
{ + if ( + canOpen && + !pickingSendTarget && + !event.defaultPrevented && + event.detail <= 1 && + !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) && + !window.getSelection()?.toString() + ) { + toggleCard(event) + } + }} >
) => void + onLineageToggle?: (event: React.MouseEvent) => void isLineageDropTarget?: boolean onActivate?: () => void onWorktreeCardClick?: () => void diff --git a/src/renderer/src/components/sidebar/workspace-card/details/WorktreeCardMeta.tsx b/src/renderer/src/components/sidebar/workspace-card/details/WorktreeCardMeta.tsx index 44a186e0e42..cdeb313aae8 100644 --- a/src/renderer/src/components/sidebar/workspace-card/details/WorktreeCardMeta.tsx +++ b/src/renderer/src/components/sidebar/workspace-card/details/WorktreeCardMeta.tsx @@ -25,6 +25,7 @@ import { WorktreeCardTaskDetailSection } from '../review/WorktreeCardTaskDetailS import { getWorktreeCardTaskActions } from '../review/worktree-card-task-actions' import { WorktreeCardHoverIdentityHeader } from './WorktreeCardHoverIdentityHeader' import { CommentMarkdownAsync, preloadCommentMarkdown } from '../../comment-markdown-lazy' +import { useActivityThreadHoverCardIntent } from '@/components/activity/activity-thread-hover-card-intent' const COMMENT_MARKDOWN_CLASS_NAME = 'text-[11.5px] text-foreground break-words leading-normal [&_.comment-md-p]:block [&_.comment-md-p+.comment-md-p]:mt-1' @@ -103,6 +104,12 @@ export function WorktreeCardDetailsHover({ }, [handleHoverOpenChange, workspaceTitleEditing] ) + // Same rest-to-peek intent as agent activity rows so passing pointers don't flash the card. + const hoverIntent = useActivityThreadHoverCardIntent({ + open: hoverOpen || workspaceTitleEditing, + onOpenChange: handleEffectiveHoverOpenChange, + openDelay + }) const dismissAndRun = React.useCallback( (handler: ((event: React.MouseEvent) => void) | undefined) => (event: React.MouseEvent) => { closeHover() @@ -143,8 +150,8 @@ export function WorktreeCardDetailsHover({ return ( event.stopPropagation()}> @@ -152,7 +159,13 @@ export function WorktreeCardDetailsHover({ { + hoverIntent.triggerHandlers.onPointerEnter(event) + if (hasComment(comment)) { + preloadCommentMarkdown() + } + }} > {children} diff --git a/src/renderer/src/components/sidebar/workspace-card/identity/worktree-lineage-toggle-handler-cache.ts b/src/renderer/src/components/sidebar/workspace-card/identity/worktree-lineage-toggle-handler-cache.ts index 7188ad9065f..b00337d3df9 100644 --- a/src/renderer/src/components/sidebar/workspace-card/identity/worktree-lineage-toggle-handler-cache.ts +++ b/src/renderer/src/components/sidebar/workspace-card/identity/worktree-lineage-toggle-handler-cache.ts @@ -1,6 +1,6 @@ import type React from 'react' -export type LineageToggleHandler = (event: React.MouseEvent) => void +export type LineageToggleHandler = (event: React.MouseEvent) => void // Cache one handler per lineage group so callback identity cannot defeat WorktreeCard memoization. export const createLineageToggleHandlerCache = ( diff --git a/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-frame-geometry.ts b/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-frame-geometry.ts index dfa643dc207..52e4c39b88a 100644 --- a/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-frame-geometry.ts +++ b/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-frame-geometry.ts @@ -8,14 +8,16 @@ import { export function getWorktreeCardFrameGeometry({ flushSurface, contentIndent, - statusLane + statusLane, + minContentInset }: { flushSurface: boolean contentIndent: number statusLane: boolean + minContentInset?: number }): { cardStyle: React.CSSProperties | undefined; parentContentMarginLeft: number } { const cardPaddingLeft = flushSurface - ? getFlushWorktreeCardPaddingLeft(contentIndent, statusLane) + ? getFlushWorktreeCardPaddingLeft(contentIndent, statusLane, minContentInset) : contentIndent > 0 ? `calc(0.125rem + ${contentIndent}px)` : null diff --git a/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-surface.tsx b/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-surface.tsx index da219539430..035b18a8c75 100644 --- a/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-surface.tsx +++ b/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-surface.tsx @@ -12,6 +12,7 @@ import type { WorktreeCardController } from '../controller/use-worktree-card-con import { useWorktreeCardOpen } from './worktree-card-open-state' import { getLineageChildrenInlineStyle, + SLOT_CARD_MIN_CONTENT_INSET, SLOT_LINEAGE_TITLE_COLUMN_SHIFT } from '../../worktree-list/rows/indentation' import { DEFAULT_WORKSPACE_CARD_TEMPLATE } from '../template/default-workspace-card' @@ -66,7 +67,12 @@ export function WorktreeCardSurface({ card }: { card: WorktreeCardController }): const isSleeping = useIsSleepingWorktree(worktree.id) const cardOpen = useWorktreeCardOpen(worktree, card.lineageDescendantIdentities, slotLayout) const geometryFor = (statusLane: boolean) => - getWorktreeCardFrameGeometry({ flushSurface, contentIndent, statusLane }) + getWorktreeCardFrameGeometry({ + flushSurface, + contentIndent, + statusLane, + minContentInset: slotLayout ? SLOT_CARD_MIN_CONTENT_INSET : undefined + }) const { content: templateContent, frame } = renderWorkspaceCardTemplate( card, DEFAULT_WORKSPACE_CARD_TEMPLATE, @@ -95,7 +101,7 @@ export function WorktreeCardSurface({ card }: { card: WorktreeCardController }): className={cn( 'relative flex cursor-pointer flex-col transition-[background-color,border-color,opacity,box-shadow] duration-200 outline-none select-none', 'pr-1.5', - titleOnlyCard ? 'py-2' : 'pt-1.25 pb-1.5', + titleOnlyCard ? 'py-2' : slotLayout ? 'pt-2 pb-1.5' : 'pt-1.25 pb-1.5', flushSurface ? 'ml-1 w-[calc(100%-0.25rem)]' : 'ml-1', 'overflow-hidden rounded-lg', // Navigation updates the live attribute before React; it must own the complete active style. diff --git a/src/renderer/src/components/sidebar/worktree-list/rows/indentation.ts b/src/renderer/src/components/sidebar/worktree-list/rows/indentation.ts index 5d1cda78e14..4364a8a45d3 100644 --- a/src/renderer/src/components/sidebar/worktree-list/rows/indentation.ts +++ b/src/renderer/src/components/sidebar/worktree-list/rows/indentation.ts @@ -7,6 +7,8 @@ export const FLUSH_CARD_CONTENT_PULLBACK = 4 export const NEW_CARD_STYLE_STATUS_LANE_EXTRA_PULLBACK = 8 // Why: keeps a zero-indent flush card off the sidebar edge. export const FLUSH_CARD_MIN_CONTENT_INSET = 2 +// Why: 2.0 nested cards have no indent, so their content needs its own breathing room off the card edge. +export const SLOT_CARD_MIN_CONTENT_INSET = 6 export const WORKTREE_CARD_SURFACE_MARGIN = 4 // Why: level-1 lineage keeps the grouped-card anchor; deeper levels advance evenly, not cumulatively. export const LINEAGE_IMMEDIATE_PARENT_STEP = @@ -134,14 +136,15 @@ export function getWorktreeCardSurfaceInset(args: { export function getFlushWorktreeCardPaddingLeft( contentIndent: number, - applyNewCardStyleStatusLaneOffset = false + applyNewCardStyleStatusLaneOffset = false, + minContentInset = FLUSH_CARD_MIN_CONTENT_INSET ): string { const pullback = FLUSH_CARD_CONTENT_PULLBACK + (applyNewCardStyleStatusLaneOffset ? NEW_CARD_STYLE_STATUS_LANE_EXTRA_PULLBACK : 0) return contentIndent > 0 - ? `max(${FLUSH_CARD_MIN_CONTENT_INSET}px, calc(${contentIndent}px - ${pullback}px))` - : `${FLUSH_CARD_MIN_CONTENT_INSET}px` + ? `max(${minContentInset}px, calc(${contentIndent}px - ${pullback}px))` + : `${minContentInset}px` } export function getNewCardStyleParentContentMarginLeft(contentIndent: number): number {