diff --git a/src/renderer/src/components/sidebar/worktree-card-agent-summary.test.ts b/src/renderer/src/components/sidebar/worktree-card-agent-summary.test.ts index 3aa1c857547..bbb115c8f65 100644 --- a/src/renderer/src/components/sidebar/worktree-card-agent-summary.test.ts +++ b/src/renderer/src/components/sidebar/worktree-card-agent-summary.test.ts @@ -1,6 +1,8 @@ -import { describe, expect, it } from 'vitest' +import { createElement } from 'react' +import { renderToStaticMarkup } from 'react-dom/server' +import { describe, expect, it, vi } from 'vitest' import type { DashboardAgentRow as DashboardAgentRowData } from '@/components/dashboard/useDashboardData' -import { getCompactAgentSecondary } from './worktree-card-compact-agent-row' +import { CompactAgentRow, getCompactAgentSecondary } from './worktree-card-compact-agent-row' import { getAgentDotState, summarizeAgents } from './worktree-card-agent-summary' function monitoringAgent(): DashboardAgentRowData { @@ -39,4 +41,18 @@ describe('worktree card agent summary', () => { expect(getCompactAgentSecondary(agent)).toBe('Monitoring background tasks') expect(summarizeAgents([agent], 'Agent')).toBe('Agent monitoring') }) + + it('keeps monitoring visible before a compact row prompt', () => { + const agent = monitoringAgent() + agent.entry.prompt = 'Run background checks' + + const markup = renderToStaticMarkup( + createElement(CompactAgentRow, { agent, now: 2000, onActivate: vi.fn() }) + ) + + expect(markup).toContain('title="Monitoring background tasks - Run background checks"') + expect(markup).toMatch( + /Monitoring background tasks<\/span>]*> - Run background checks<\/span>/ + ) + }) }) diff --git a/src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx b/src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx index 258869b07c3..63163bfe207 100644 --- a/src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx +++ b/src/renderer/src/components/sidebar/worktree-card-compact-agent-row.tsx @@ -123,6 +123,11 @@ export const CompactAgentRow = React.memo(function CompactAgentRow({ const primary = getCompactAgentPrimary(agent, conversationName) const isLineageChild = agent.lineage?.depth === 1 const secondary = getCompactAgentSecondary(agent) + // Why: sidebar truncation must preserve the passive-vs-active distinction. + const leadingText = dotState === 'monitoring' ? secondary : primary + const trailingText = + dotState === 'monitoring' ? (primary === secondary ? '' : primary) : secondary + const rowTitle = `${leadingText}${trailingText ? ` - ${trailingText}` : ''}` const model = agent.entry.model?.trim() ?? '' const shortTime = getCompactAgentTime(agent, now) const cacheTimer = usePromptCacheCountdownForPane(agent.paneKey, cacheTimerActive) @@ -205,12 +210,12 @@ export const CompactAgentRow = React.memo(function CompactAgentRow({ {/* Why: the selected-row fill is strong enough to wash out the dimmed prompt/secondary text, so lift both toward full foreground when focused. */} - {primary} + {leadingText} - {secondary && ( + {trailingText && ( {' '} - - {secondary} + - {trailingText} )} @@ -273,7 +278,7 @@ export const CompactAgentRow = React.memo(function CompactAgentRow({ role={agent.lineage ? 'treeitem' : undefined} aria-level={agent.lineage ? agent.lineage.depth + 1 : undefined} aria-expanded={hasChildDisclosure ? childAgentsExpanded : undefined} - title={sendTargetDisabledReason ?? `${primary}${secondary ? ` - ${secondary}` : ''}`} + title={sendTargetDisabledReason ?? rowTitle} > {rowBody}