Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/host-list-render-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# This is a RATCHET: counts may only go DOWN. Draw host lists with HostCombobox or
# useBoundedHostRows. Prune after a fix: pnpm check:host-list-render-ratchet --prune
1 src/renderer/src/components/automations/AutomationRunsDashboard.tsx
1 src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsx
1 src/renderer/src/components/right-sidebar/AiVaultPanelControls.tsx
1 src/renderer/src/components/right-sidebar/SourceControlAgentActionDialogForm.tsx
1 src/renderer/src/components/settings/BrowserSessionCookiesSection.tsx
Expand Down
141 changes: 48 additions & 93 deletions src/renderer/src/components/editor/ReviewNotesSendMenuContent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ vi.mock('react', async () => {
useMemo<T>(factory: () => T): T {
return factory()
},
useSyncExternalStore<T>(_subscribe: unknown, getSnapshot: () => T): T {
return getSnapshot()
},
useEffect(effect: () => void | (() => void)): void {
const cleanup = effect()
if (typeof cleanup === 'function') {
Expand Down Expand Up @@ -199,21 +202,23 @@ function agentRow({
paneKey,
tabId,
title,
agentType,
agentType = 'claude',
state = 'done',
startedAt = harness.now
startedAt = harness.now,
prompt = ''
}: {
paneKey: string
tabId: string
title: string
agentType: TuiAgent
agentType?: TuiAgent
state?: AgentStatusState | 'idle'
startedAt?: number
prompt?: string
}): DashboardAgentRowData {
const entryState: AgentStatusState = state === 'idle' ? 'working' : state
return {
paneKey,
entry: agentEntry(paneKey, agentType, entryState, startedAt),
entry: { ...agentEntry(paneKey, agentType, entryState, startedAt), prompt },
tab: tab(tabId, { title }) as DashboardAgentRowData['tab'],
agentType,
state,
Expand Down Expand Up @@ -458,6 +463,45 @@ describe('ReviewNotesSendMenuContent', () => {
expect(collectText(items[1])).toContain('Claude')
})

it('leads each row with the name its sidebar row shows, so same-type agents differ', () => {
const paneKeyA = makePaneKey(TAB_A, LEAF_A)
const paneKeyB = makePaneKey(TAB_B, LEAF_B)
harness.worktreeAgentRows = [
agentRow({ paneKey: paneKeyA, tabId: TAB_A, title: 'Claude Code' }),
agentRow({ paneKey: paneKeyB, tabId: TAB_B, title: 'Claude Code', prompt: 'Fix the login' })
]
setStore({
tabsByWorktree: {
'wt-1': [
tab(TAB_A, { title: 'Claude Code', customTitle: 'Payments' }),
tab(TAB_B, { title: 'Claude Code' })
]
}
})
harness.noteTargets = [
[paneKeyA, TAB_A, LEAF_A],
[paneKeyB, TAB_B, LEAF_B]
].map(([paneKey, tabId, leafId]): NotesSendAgentTarget => ({
paneKey,
tabId,
messageTarget: { kind: 'terminal', tabId, leafId },
agentType: 'claude',
tabTitle: 'Claude Code',
status: 'eligible'
}))

const rowLines = findAllByType(render(), 'DropdownMenuItem').map((item) =>
findAllByType(item, 'span')
.filter((span) => String(span.props.className).includes('truncate'))
.map(collectText)
)

expect(rowLines).toEqual([
['Payments', 'Claude · Done · just now'],
['Fix the login', 'Claude · Done · just now']
])
})

it('shows a chat whose turn failed as failed, as its sidebar row does', () => {
const chatPaneKey = 'structured-agent-session-claude_1:chat'
const failedRow = agentRow({
Expand Down Expand Up @@ -573,86 +617,6 @@ describe('ReviewNotesSendMenuContent', () => {
expect(harness.sendMessageToAgent).not.toHaveBeenCalled()
})

it('does not offer a title-detected agent row after its live PTY has exited', () => {
const paneKey = makePaneKey(TAB_B, LEAF_B)
harness.worktreeAgentRows = [
agentRow({
paneKey,
tabId: TAB_B,
title: 'Codex',
agentType: 'codex',
state: 'done',
startedAt: harness.now - 60_000
})
]
setStore({
tabsByWorktree: { 'wt-1': [tab(TAB_B, { title: 'Codex' })] },
terminalLayoutsByTabId: { [TAB_B]: leafLayout(LEAF_B, 'pty-b') },
ptyIdsByTabId: { [TAB_B]: [] }
})

const tree = render()
const items = findAllByType(tree, 'DropdownMenuItem')

expect(items).toHaveLength(0)
expect(collectText(tree)).not.toContain('Active agent session')
})

it('does not render an active agent fallback alongside named targets', () => {
const listedPaneKey = makePaneKey(TAB_A, LEAF_A)
setStore({
tabsByWorktree: { 'wt-1': [tab(TAB_A), tab(TAB_B)] },
terminalLayoutsByTabId: {
[TAB_A]: leafLayout(LEAF_A, 'pty-a'),
[TAB_B]: leafLayout(LEAF_B, 'pty-b')
}
})
harness.noteTargets = [
{
paneKey: listedPaneKey,
tabId: TAB_A,
messageTarget: { kind: 'terminal', tabId: TAB_A, leafId: LEAF_A },
agentType: 'claude',
tabTitle: 'Terminal 1',
status: 'eligible'
}
]

const tree = render()
const items = findAllByType(tree, 'DropdownMenuItem')

expect(items).toHaveLength(1)
expect(collectText(items[0])).toContain('Claude')
expect(collectText(tree)).not.toContain('Active agent session')
expect(harness.sendMessageToAgent).not.toHaveBeenCalled()
})

it('does not render an active agent fallback when the matching derived row is disabled', () => {
const paneKey = makePaneKey(TAB_A, LEAF_A)
setStore({
tabsByWorktree: { 'wt-1': [tab(TAB_A, { title: 'Codex' })] },
terminalLayoutsByTabId: { [TAB_A]: leafLayout(LEAF_A, 'pty-a') }
})
harness.noteTargets = [
{
paneKey,
tabId: TAB_A,
messageTarget: { kind: 'terminal', tabId: TAB_A, leafId: LEAF_A },
agentType: 'codex',
tabTitle: 'Codex',
status: 'disabled',
disabledReason: 'Agent status is stale'
}
]

const tree = render()
const items = findAllByType(tree, 'DropdownMenuItem')

expect(items).toHaveLength(1)
expect(items[0].props.disabled).toBe(true)
expect(collectText(tree)).not.toContain('Active agent session')
})

it('sends notes to the chosen agent and tracks the send once it succeeds', async () => {
const statusPaneKey = makePaneKey(TAB_A, LEAF_A)
const onPromptDelivered = vi.fn()
Expand Down Expand Up @@ -854,15 +818,6 @@ describe('ReviewNotesSendMenuContent', () => {
})
})

it('does not render an active agent fallback when no agents are derived', () => {
const tree = render()
const items = findAllByType(tree, 'DropdownMenuItem')

expect(items).toHaveLength(0)
expect(collectText(tree)).not.toContain('Active agent session')
expect(harness.sendMessageToAgent).not.toHaveBeenCalled()
})

it('always offers the new-agent launcher', () => {
const onPromptHandedOff = vi.fn()
const tree = render({ onPromptHandedOff })
Expand Down
66 changes: 42 additions & 24 deletions src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import type { DashboardAgentRow as DashboardAgentRowData } from '@/components/da
import { lastEnteredDoneAt } from '@/components/dashboard/agent-finished-timestamp'
import { selectLivePtyIdsForWorktree } from '@/components/sidebar/worktree-card-status-inputs'
import { useWorktreeAgentRows } from '@/components/sidebar/useWorktreeAgentRows'
import { useAgentRowConversationName } from '@/components/dashboard/use-agent-row-conversation-name'
import { getAgentRowPrimaryText } from '../../../../shared/agent-row-primary-text'
import type { LaunchSource } from '../../../../shared/telemetry-events'
import { agentRowDisplayDotState } from '@/lib/agent-row-dot-state'
import { translate } from '@/i18n/i18n'
Expand Down Expand Up @@ -189,16 +191,19 @@ export function ReviewNotesSendMenuContent({
<DropdownMenuLabel>
{translate('auto.components.editor.ReviewNotesSendMenuContent.03378aea75', 'Send notes to')}
</DropdownMenuLabel>
{orderedSendTargets.map(({ target, agent }) => (
<AgentTargetMenuItem
key={target.paneKey}
target={target}
agent={agent}
now={now}
disabled={!hasPrompt || target.status !== 'eligible'}
onSend={sendToAgentTarget}
/>
))}
{orderedSendTargets.map(({ target, agent }) => {
const itemProps = {
target,
now,
disabled: !hasPrompt || target.status !== 'eligible',
onSend: sendToAgentTarget
}
return agent ? (
<AgentRowTargetMenuItem key={target.paneKey} {...itemProps} agent={agent} />
) : (
<AgentTargetMenuItem key={target.paneKey} {...itemProps} agent={null} name="" />
)
})}
<DropdownMenuSeparator />
<DropdownMenuLabel>
{translate('auto.components.editor.ReviewNotesSendMenuContent.a49800405b', 'New agent')}
Expand Down Expand Up @@ -249,20 +254,33 @@ function resolveCurrentSendTargetEligibility(
return { status: 'disabled', disabledReason: goneReason }
}

type AgentTargetMenuItemProps = {
target: NotesSendAgentTarget
agent: DashboardAgentRowData | null
now: number
disabled: boolean
onSend: (target: NotesSendAgentTarget) => void
}

function AgentRowTargetMenuItem(
props: AgentTargetMenuItemProps & { agent: DashboardAgentRowData }
): React.JSX.Element {
const conversationName = useAgentRowConversationName(props.agent)
// Same name as the agent's sidebar row, so same-type agents stay distinguishable.
const name = conversationName ?? getAgentRowPrimaryText(props.agent.entry)
return <AgentTargetMenuItem {...props} name={name} />
}

function AgentTargetMenuItem({
target,
agent,
name,
now,
disabled,
onSend
}: {
target: NotesSendAgentTarget
agent: DashboardAgentRowData | null
now: number
disabled: boolean
onSend: (target: NotesSendAgentTarget) => void
}): React.JSX.Element {
}: AgentTargetMenuItemProps & { name: string }): React.JSX.Element {
const tabTitle = target.tabTitle.trim()
const typeLabel = formatAgentTypeLabel(target.agentType ?? agent?.agentType)
// Use the sidebar’s display state so failed/stopped agents agree across surfaces.
const state = agent ? agentRowDisplayDotState(agent) : 'idle'
const timeAgo = agent ? formatAgentRelativeTime(agent, now) : null
Expand All @@ -271,16 +289,18 @@ function AgentTargetMenuItem({
? agentSendDisabledReasonLabel(target.disabledReason)
: undefined
const secondaryParts = [
...(name ? [typeLabel] : []),
agentStateLabel(state),
...(timeAgo ? [timeAgo] : []),
...(tabTitle ? [tabTitle] : [])
// Why: unnamed rows keep the raw tab title as their only differentiator.
...(!name && tabTitle ? [tabTitle] : [])
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
]
return (
<DropdownMenuItem
disabled={disabled}
onSelect={() => onSend(target)}
// Match dashboard tooltips for permission, stale-state and missing-terminal reasons.
title={disabledReason}
// Match dashboard tooltips for disabled reasons; otherwise show the full, possibly truncated, name.
title={disabledReason ?? (name || undefined)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '245,355p' src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsx
rg -n 'max-w-\\[300px\\]|truncate|tabTitle|AgentTargetMenuItem' src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsx

Repository: stablyai/orca

Length of output: 4712


Script executed:

set -u
echo "== head: unmatched render and secondary line =="
sed -n '196,212p' src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsx
echo "== base: merge-base component, tabTitle/truncate/title usage =="
git show 5cd7b5d52cc5ae825f08f0a7b89888ed032259e6:src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsx 2>&1 | rg -n 'tabTitle|truncate|title=|max-w|AgentTargetMenuItem|DropdownMenuItem' || test "$?" -eq 1
echo "== producers of tabTitle for send targets =="
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'tabTitle' -- src/renderer/src/lib src/shared 2>/dev/null || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 3608


Show the full tab title when the target has no agent row.

Targets without an agent row render with name="". Their tab title moves to the secondary line, which is clipped by the new 300px cap. The item has no title in this case, so the full text cannot be read on hover.

🐛 Suggested fix
--- "a/src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsx"
+++ "b/src/renderer/src/components/editor/ReviewNotesSendMenuContent.tsx"
@@ -299,8 +299,8 @@
     <DropdownMenuItem
       disabled={disabled}
       onSelect={() => onSend(target)}
-      // Match dashboard tooltips for disabled reasons; otherwise show the full, possibly truncated, name.
-      title={disabledReason ?? (name || undefined)}
+      // Match dashboard tooltips for disabled reasons; otherwise show the full, possibly truncated, name or tab title.
+      title={disabledReason ?? (name || tabTitle || undefined)}
       className="min-w-[240px] gap-2 rounded-[7px] px-2 py-1.5 text-[12px] leading-5 font-medium"
     >
       {/* Why: the ancestor's actionable disabled reason must win on every hit area. */}

className="min-w-[240px] gap-2 rounded-[7px] px-2 py-1.5 text-[12px] leading-5 font-medium"
>
{/* Why: the ancestor's actionable disabled reason must win on every hit area. */}
Expand All @@ -291,10 +311,8 @@ function AgentTargetMenuItem({
title={disabledReason ? null : undefined}
/>
<AgentTypeIcon agentType={target.agentType ?? agent?.agentType} size={14} />
<span className="grid min-w-0 flex-1 text-left">
<span className="truncate">
{formatAgentTypeLabel(target.agentType ?? agent?.agentType)}
</span>
<span className="grid max-w-[300px] min-w-0 flex-1 text-left">
<span className="truncate">{name || typeLabel}</span>
<span className="truncate text-[11px] font-normal text-muted-foreground">
{secondaryParts.join(' · ')}
</span>
Expand Down
Loading