diff --git a/src/renderer/src/components/AgentStateDot.tsx b/src/renderer/src/components/AgentStateDot.tsx index 187b7492b03..8f22e957d55 100644 --- a/src/renderer/src/components/AgentStateDot.tsx +++ b/src/renderer/src/components/AgentStateDot.tsx @@ -59,6 +59,8 @@ type Props = { progress?: number /** Unread completion swaps the check for the workspace unread dot; live and needs-you glyphs keep precedence. */ unread?: boolean + /** 'label' keeps the check and only speaks unread, for rows whose card already draws the one dot. */ + unreadDisplay?: 'dot' | 'label' } type ProgressRing = { tone: AgentProgressRingTone; percent: number } @@ -97,15 +99,17 @@ export const AgentStateDot = React.memo(function AgentStateDot({ title, tooltipSide, progress, - unread = false + unread = false, + unreadDisplay = 'dot' }: Props): React.JSX.Element { const t = useTranslate() const box = size === 'md' ? 'h-3 w-3' : 'h-2.5 w-2.5' const inner = size === 'md' ? 'size-2' : 'size-1.5' const icon = size === 'md' ? 'size-3' : 'size-2.5' const ring = progressRing(state, progress) - const showUnreadDot = unread && state === 'done' - const label = showUnreadDot + const announceUnread = unread && state === 'done' + const showUnreadDot = announceUnread && unreadDisplay === 'dot' + const label = announceUnread ? t('workspace.activity.unreadLabel', '{{status}} · Unread', { status: agentStateLabel(state) }) @@ -154,7 +158,7 @@ export const AgentStateDot = React.memo(function AgentStateDot({ indicator = ( diff --git a/src/renderer/src/components/dashboard/DashboardAgentRow.tsx b/src/renderer/src/components/dashboard/DashboardAgentRow.tsx index a86997c77f4..cc31f8c37e0 100644 --- a/src/renderer/src/components/dashboard/DashboardAgentRow.tsx +++ b/src/renderer/src/components/dashboard/DashboardAgentRow.tsx @@ -48,6 +48,7 @@ import { import { translate } from '@/i18n/i18n' import { useTranslate, type Translate } from '@/i18n/use-translate' import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision' +import { useHasWorktreeCardUnreadRollup } from '@/components/sidebar/workspace-card/surface/worktree-card-title-status' function formatTimeAgo(ts: number, now: number, t: Translate = translate): string { const delta = now - ts @@ -130,6 +131,7 @@ const DashboardAgentRow = React.memo(function DashboardAgentRow({ onSendTargetClick }: Props) { const t = useTranslate() + const hasUnreadRollup = useHasWorktreeCardUnreadRollup() useUiLanguageRevision() const view = useClaudeAgentRowView(agent) const highlighted = view ? view.current && view.focused : isFocusedPane @@ -318,6 +320,7 @@ const DashboardAgentRow = React.memo(function DashboardAgentRow({ title={null} progress={presentation.progress} unread={isUnvisited} + unreadDisplay={hasUnreadRollup ? 'label' : 'dot'} /> diff --git a/src/renderer/src/components/sidebar/WorktreeCardExperimental.fixture.tsx b/src/renderer/src/components/sidebar/WorktreeCardExperimental.fixture.tsx index c488a120100..9893984923e 100644 --- a/src/renderer/src/components/sidebar/WorktreeCardExperimental.fixture.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCardExperimental.fixture.tsx @@ -179,6 +179,58 @@ const NESTED: WorkspaceSeed[] = [ } ] +const UNREAD_DOTS: WorkspaceSeed[] = [ + { + id: 'wt-dots-folded', + name: 'experimental-v2-sidebar', + agents: [ + { + agentType: 'claude', + state: 'done', + minutesAgo: 1, + unread: true, + message: 'Finished the card spacing pass' + }, + { agentType: 'codex', state: 'done', minutesAgo: 9, message: 'Ran the fixture suite' } + ] + }, + { + id: 'wt-dots-row', + name: 'docs-typo-sweep', + agents: [ + { + agentType: 'claude', + state: 'done', + minutesAgo: 6, + unread: true, + message: 'Fixed 14 typos across docs/ and opened PR #36955' + } + ] + }, + { + // A live agent owns the lane glyph; the unread dot must still ride its corner. + id: 'wt-dots-mixed', + name: 'terminal-resize-fix', + agents: [ + { agentType: 'codex', state: 'working', minutesAgo: 0, message: 'Running the resize suite' }, + { + agentType: 'claude', + state: 'done', + minutesAgo: 4, + unread: true, + message: 'Traced the reflow bug to the scrollback trim' + } + ] + }, + { + id: 'wt-dots-manual', + name: 'release-1.4-notes', + agents: [{ agentType: 'codex', state: 'done', minutesAgo: 30, message: 'Drafted the notes' }], + manualUnread: true, + lastActivityMinutesAgo: 27 + } +] + const FOLDER_WORKSPACE = folderWorkspaceToWorktree({ id: 'design-notes', projectGroupId: 'notes', @@ -253,19 +305,18 @@ function worktreesFor(seeds: readonly WorkspaceSeed[], now: number): Map() - ids.forEach((id) => - agentExpansion.seedWorktreeAgentExpansionStateForTests(id, { - expandedLineageParents: none, - expandedIdleChildGroups: none, - compactRootListExpanded: true - }) - ) + const state = { + expandedLineageParents: new Set(), + expandedIdleChildGroups: new Set(), + compactRootListExpanded: true + } + ids.forEach((id) => agentExpansion.seedWorktreeAgentExpansionStateForTests(id, state)) } const now = Date.now() const flatWorktrees = worktreesFor(FLAT, now) const nestedWorktrees = worktreesFor(NESTED, now) +const unreadDotWorktrees = worktreesFor(UNREAD_DOTS, now) FOLDER_WORKSPACE.isUnread = false FOLDER_WORKSPACE.lastActivityAt = now - 9 * MINUTE @@ -334,13 +385,37 @@ export const agentsExpanded = defineFixture({ width: SIDEBAR_WIDTH, setup: () => { seedWorkspaces(FLAT, now) - const none = new Set() - const state = { - expandedLineageParents: none, - expandedIdleChildGroups: none, - compactRootListExpanded: true - } - FLAT.forEach((seed) => agentExpansion.seedWorktreeAgentExpansionStateForTests(seed.id, state)) + seedOpenCards(FLAT.map((seed) => seed.id)) }, render: () => }) + +export const unreadDots = defineFixture({ + width: SIDEBAR_WIDTH, + setup: () => seedWorkspaces(UNREAD_DOTS, now), + render: () => ( + + {UNREAD_DOTS.map((seed) => ( + + ))} + + ) +}) + +export const classicUnreadDotsExpanded = defineFixture({ + ...unreadDots, + setup: () => { + seedWorkspaces(UNREAD_DOTS, now) + seedOpenCards(UNREAD_DOTS.map((seed) => seed.id)) + useAppStore.setState((state) => ({ + settings: state.settings + ? { ...state.settings, experimentalNewWorktreeCardStyle: false } + : state.settings + })) + } +}) + +export const classicUnreadDotsDetailed = defineFixture({ + ...classicUnreadDotsExpanded, + store: { agentActivityDisplayMode: 'full' } +}) diff --git a/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-agent-summary.ts b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-agent-summary.ts index 76f294edbed..e3beac60cd0 100644 --- a/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-agent-summary.ts +++ b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-agent-summary.ts @@ -7,7 +7,7 @@ import type { Translate } from '@/i18n/use-translate' export type SummaryAgentGroup = { state: AgentDotState - /** Done agents the user has not read yet; drawn as the unread dot ahead of every other group. */ + /** Unread completions, split out only for cards without a status-lane unread rollup. */ unread?: boolean agents: DashboardAgentRowData[] } @@ -193,6 +193,18 @@ export function formatAllAgentsInState( } } +/** Unread means an acknowledged-pending completion; live agents are never announced as unread. */ +export function isUnreadDoneAgent( + agent: DashboardAgentRowData, + isUnread: ((agent: DashboardAgentRowData) => boolean) | undefined +): boolean { + return isUnread !== undefined && getAgentDotState(agent) === 'done' && isUnread(agent) +} + +/** + * One group per state for the folded pill. Pass `isUnread` only when the card has no status-lane + * unread rollup: then unread completions lead as their own group so the folded pill still shows it. + */ export function buildSummaryAgentGroups( agents: DashboardAgentRowData[], isUnread?: (agent: DashboardAgentRowData) => boolean @@ -200,12 +212,11 @@ export function buildSummaryAgentGroups( const groups = new Map() const unreadDone: DashboardAgentRowData[] = [] for (const agent of agents) { - const dotState = getAgentDotState(agent) - // Split unread completions out so the collapsed pill names which agent holds the card's unread. - if (dotState === 'done' && isUnread?.(agent)) { + if (isUnreadDoneAgent(agent, isUnread)) { unreadDone.push(agent) continue } + const dotState = getAgentDotState(agent) const group = groups.get(dotState) if (group) { group.push(agent) diff --git a/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-compact-agent-row.tsx b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-compact-agent-row.tsx index b90f15b5a1c..1372643fb62 100644 --- a/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-compact-agent-row.tsx +++ b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-compact-agent-row.tsx @@ -28,6 +28,7 @@ import { } from '../../../../../../shared/program-status/presentation' import { resolveRowProgramStatus } from '@/lib/program-status/agent-row-presentation' import { useTranslate, type Translate } from '@/i18n/use-translate' +import { useHasWorktreeCardUnreadRollup } from '../surface/worktree-card-title-status' function getCompactAgentPrimary( agent: DashboardAgentRowData, @@ -132,6 +133,7 @@ export const CompactAgentRow = React.memo(function CompactAgentRow({ isUnvisited = false }: CompactAgentRowProps) { const t = useTranslate() + const hasUnreadRollup = useHasWorktreeCardUnreadRollup() const view = useClaudeAgentRowView(agent) const highlighted = view ? view.current && view.focused : isFocusedPane const hasChildDisclosure = @@ -242,6 +244,7 @@ export const CompactAgentRow = React.memo(function CompactAgentRow({ tooltipSide="right" progress={presentation.progress} unread={isUnvisited} + unreadDisplay={hasUnreadRollup ? 'label' : 'dot'} /> {!hideIcon && ( diff --git a/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-compact-agents.tsx b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-compact-agents.tsx index 330f876cbbc..704fe033624 100644 --- a/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-compact-agents.tsx +++ b/src/renderer/src/components/sidebar/workspace-card/activity/worktree-card-compact-agents.tsx @@ -11,11 +11,13 @@ import { formatAllAgentsInState, formatStateCount, formatSummaryStateLabel, + isUnreadDoneAgent, selectSummaryGroupIconAgents, summarizeAgentIdentities, summarizeAgents } from './worktree-card-agent-summary' import { useTranslate } from '@/i18n/use-translate' +import { useHasWorktreeCardUnreadRollup } from '../surface/worktree-card-title-status' import './worktree-card-compact-agent-row' @@ -90,12 +92,13 @@ export function CompactAgentSummaryButton({ unreadByPaneKey }: CompactAgentSummaryButtonProps): React.JSX.Element { const t = useTranslate() + const hasUnreadRollup = useHasWorktreeCardUnreadRollup() + const isUnread = unreadByPaneKey + ? (agent: DashboardAgentRowData) => unreadByPaneKey[agent.paneKey] ?? false + : undefined const groups: readonly (AgentGroupSummary & { unread?: boolean })[] = precomputedGroups ?? - buildSummaryAgentGroups( - agents, - unreadByPaneKey ? (agent) => unreadByPaneKey[agent.paneKey] ?? false : undefined - ).map((group) => ({ + buildSummaryAgentGroups(agents, hasUnreadRollup ? undefined : isUnread).map((group) => ({ state: group.state, unread: group.unread, count: group.agents.length, @@ -110,7 +113,9 @@ export function CompactAgentSummaryButton({ subject: subjectLabel, states: groups.map((group) => formatStateCount(group.state, group.count, t)).join(', ') }) - const unreadCount = groups.find((group) => group.unread)?.count ?? 0 + const unreadCount = isUnread + ? agents.reduce((count, agent) => count + (isUnreadDoneAgent(agent, isUnread) ? 1 : 0), 0) + : 0 const unreadSummary = unreadCount > 0 ? t('auto.components.activity.ActivityTitlebarControls.unreadCount', '{{count}} unread', { diff --git a/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardStatusSlot.tsx b/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardStatusSlot.tsx index 6ba501c6b3d..e1b5b76db13 100644 --- a/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardStatusSlot.tsx +++ b/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardStatusSlot.tsx @@ -187,9 +187,9 @@ export function WorktreeCardStatusSlot({ newCardStyle && isUnread ? t('workspace.activity.unreadLabel', '{{status}} · Unread', { status: reviewLabel }) : reviewLabel - // Working/permission own the lane; retain unread in accessible copy and restore its dot afterward. - const showNewCardUnreadAlert = - newCardStyle && isUnread && showStatus && status !== 'working' && status !== 'permission' + // The lane holds the card's only unread dot (agent rows and the folded pill draw none), so it + // stays on over working/permission glyphs; the corner ring keeps it legible against them. + const showNewCardUnreadAlert = newCardStyle && isUnread && showStatus const reviewStaleRef = isReviewStale ? observeOffscreenAnimation : undefined const reviewStatusIconClassName = cn( compactReviewAndBranchStatusIconClassName, diff --git a/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-title-status.tsx b/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-title-status.tsx index 51c4e6c7763..c2daa185542 100644 --- a/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-title-status.tsx +++ b/src/renderer/src/components/sidebar/workspace-card/surface/worktree-card-title-status.tsx @@ -51,6 +51,7 @@ type TitleStatus = { } const TitleStatusContext = createContext(null) +const UnreadRollupPresenceContext = createContext(false) function useSlotAgentSignals(agents: DashboardAgentRow[]): SlotAgentSignals { // Same acknowledgement records the agent rows read, so unread means the same in both places. @@ -150,7 +151,16 @@ export function WorktreeCardTitleStatusProvider({ () => ({ offline, exceptions, unread, lineageStatus, at, resolveTargets }), [at, exceptions, lineageStatus, offline, resolveTargets, unread] ) - return {children} + return ( + + {children} + + ) +} + +/** False on classic cards, which mount no rollup and so draw no status-lane unread dot. */ +export function useHasWorktreeCardUnreadRollup(): boolean { + return useContext(UnreadRollupPresenceContext) } /** True while the card holds an unread result: its own, any of its agents' or a collapsed child's. */