Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4e3c9cb
fix: report agent launch failures once with actionable recovery
brennanb2025 Nov 1, 2026
075c7d0
fix: keep terminal launch controls shown but waiting while the host c…
brennanb2025 Nov 1, 2026
e36b732
fix: keep launch readiness and failure ownership consistent across pi…
brennanb2025 Nov 2, 2026
7fa2f5a
fix: keep the handoff dialog open when a host-waiting launch opens no…
brennanb2025 Nov 2, 2026
b7ae5ef
fix: let the handoff dialog close while its session is starting
brennanb2025 Nov 2, 2026
7a46da7
Merge origin/main into brennanb2025/launch-double-toast-1101
brennanb2025 Nov 2, 2026
d0522f9
test: replace type assertions in launch refusal tests with typed fixt…
brennanb2025 Nov 2, 2026
cec443d
refactor: name the setup panel's launch helper launchSurface
brennanb2025 Nov 2, 2026
2306fa5
perf: resolve a picker's terminal host only when ownership changes
brennanb2025 Nov 2, 2026
2d1f8da
perf: word a declined chat's fallback failure without re-saving launches
brennanb2025 Nov 2, 2026
e86606d
test: narrow refused launch outcomes where tests read the opened tab
brennanb2025 Nov 2, 2026
25c3bca
fix: keep Configure usable and show one reason on a waiting agent row
brennanb2025 Nov 2, 2026
a85cb56
test: cover distinct repo targets and host freshness in the picker pe…
brennanb2025 Nov 2, 2026
43fc2c2
fix: mark a waiting agent launch unavailable while Configure and chat…
brennanb2025 Nov 2, 2026
e793514
Merge origin/main into brennanb2025/launch-double-toast-1101
brennanb2025 Nov 2, 2026
dca591a
fix: release the agent row button's press listeners when a press is c…
brennanb2025 Nov 2, 2026
3e20604
fix: give the agent launch row item its own menu item variant
brennanb2025 Nov 2, 2026
9a02755
Merge origin/main into brennanb2025/launch-double-toast-1101
brennanb2025 Nov 2, 2026
dc35f8e
fix: route the menu's terminal host by owner and repair the e2e and j…
brennanb2025 Nov 2, 2026
46f0bf3
test: count a launch as opened only when it returned a surface
brennanb2025 Nov 2, 2026
ff0cc19
perf: keep menu readiness on the workspace's owner and index the twin…
brennanb2025 Nov 2, 2026
a76283e
test: assert which readiness pickers render on each detected-twin update
brennanb2025 Nov 2, 2026
f60ce6c
test: give the structured chat fixture's owner stub the menu's resour…
brennanb2025 Nov 2, 2026
ec44184
Merge main into launch failure handling
brennanb2025 Nov 6, 2026
7f53876
Keep launch failures with one action owner on current menus
brennanb2025 Nov 6, 2026
a55dff7
Align Start work regression with its remote launch target
brennanb2025 Nov 6, 2026
94b0ac1
Narrow refused launch outcomes in current contract tests
brennanb2025 Nov 6, 2026
024daa7
Assert notified refusals in existing launch regressions
brennanb2025 Nov 6, 2026
e97f6a5
Assert the refused keyboard launch receipt
brennanb2025 Nov 6, 2026
f2003a0
Narrow successful web runtime launches in tests
brennanb2025 Nov 6, 2026
5b5b5b8
Keep agent menu labels left aligned
brennanb2025 Nov 6, 2026
a963a04
Merge main and preserve single-owner launch failures
brennanb2025 Nov 7, 2026
bc9d01c
Merge origin/main into launch-double-toast-1101
brennanb2025 Nov 7, 2026
cc25a31
Keep merged launch reporting within existing checks
brennanb2025 Nov 7, 2026
02c15d6
Merge origin/main into launch-double-toast-1101
brennanb2025 Nov 7, 2026
c2b0608
Merge origin/main to resolve launch reporting conflict
brennanb2025 Nov 7, 2026
20b941a
Merge origin/main with registry lint correction
brennanb2025 Nov 7, 2026
401335a
Merge origin/main and retain launch reporting imports
brennanb2025 Nov 7, 2026
5f4e112
Merge main and preserve approved launch failure reporting
brennanb2025 Nov 8, 2026
15d9748
Keep direct launch argument reads within the file limit
brennanb2025 Nov 8, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,23 @@ export function AgentSessionContinuationDialog({
request: AgentSessionContinuationRequest | null
mode: AgentSessionContinuationContextMode
} | null>(null)
// One start's own token: a closed or reopened dialog no longer waits on a start it left behind.
const [startingFor, setStartingFor] = useState<{
request: AgentSessionContinuationRequest
} | null>(null)
if (!open) {
if (pick) {
setPick(null)
}
if (contextPick) {
setContextPick(null)
}
if (startingFor) {
setStartingFor(null)
}
}
const contextMode = contextPick?.request === request ? contextPick.mode : 'focused'
const [starting, setStarting] = useState(false)
const starting = open && startingFor?.request === request
const [showStarting, setShowStarting] = useState(false)
const disabledAgents = settings?.disabledTuiAgents ?? EMPTY_DISABLED_AGENTS

Expand Down Expand Up @@ -188,7 +195,10 @@ export function AgentSessionContinuationDialog({
if (!prompt) {
return
}
setStarting(true)
const start = { request }
// Aborts when the dialog closes or moves to another request; a sent launch still settles.
const signal = abortRef.current?.signal
setStartingFor(start)
const launched = await launchAgentSessionContinuation({
agent: selectedAgent,
prompt,
Expand All @@ -207,10 +217,11 @@ export function AgentSessionContinuationDialog({
)
: {}),
launchSource: request.launchSource,
signal: abortRef.current?.signal
signal
})
setStarting(false)
if (launched) {
setStartingFor((current) => (current === start ? null : current))
// A late finish is reported by the launch's own owners, never by a dialog it no longer holds.
if (launched && !signal?.aborted) {
onOpenChange(false)
onStarted?.()
}
Expand All @@ -225,14 +236,7 @@ export function AgentSessionContinuationDialog({
const workingDirectory = sourceWorkingDirectory ?? request?.initialCwd

return (
<Dialog
open={open}
onOpenChange={(nextOpen) => {
if (!starting) {
onOpenChange(nextOpen)
}
}}
>
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="min-w-0 sm:max-w-lg">
<DialogHeader>
<DialogTitle className="flex items-center gap-2 text-sm">
Expand Down Expand Up @@ -389,12 +393,7 @@ export function AgentSessionContinuationDialog({
</div>

<DialogFooter>
<Button
type="button"
variant="ghost"
disabled={starting}
onClick={() => onOpenChange(false)}
>
<Button type="button" variant="ghost" onClick={() => onOpenChange(false)}>
{translate('components.native-chat.question.cancel', 'Cancel')}
</Button>
<Button
Expand Down
11 changes: 1 addition & 10 deletions src/renderer/src/components/agent-tab-shortcut-launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,14 @@ function launchAgentTab(
agent: TuiAgent,
{ groupId, focusIntent }: AgentTabLaunchContext
): void {
const result = launchAgentInNewTab({
launchAgentInNewTab({
requestId: newAgentLaunchRequestId(),
focusIntent,
agent,
worktreeId,
groupId,
launchSource: 'shortcut'
})
if (!result) {
toast.error(
translate(
'auto.components.Terminal.e57db40c11',
'Could not build launch command for {{value0}}.',
{ value0: agent }
)
)
}
}

/** Launch a resolved new-agent-tab shortcut in the pane it was pressed in, waiting on detection if needed. */
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/components/agent/AgentCombobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
SurfaceAgentItems,
surfaceCommandValues,
useSurfaceRowArming,
surfaceAnswerPending,
type AgentComboboxSurfaceRows
} from './agent-combobox-surface-items'

Expand Down Expand Up @@ -266,7 +267,7 @@ export default function AgentCombobox({
aria-expanded={open}
onKeyDown={handleTriggerKeyDown}
// Why: the "(CLI)" suffix depends on the host's answer; it never pops in on a settled field.
disabled={disabled || (surfaceRows?.selection.ready === false && value !== null)}
disabled={disabled || (surfaceAnswerPending(surfaceRows) && value !== null)}
className={cn(
// Retain room for long labels; py-0 clears default vertical padding to center content in h-8/h-9.
'h-8 justify-between px-3 py-0 text-xs font-normal',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import { changePrompt } from '../native-chat/composer/editor/native-chat-prompt-editor.test-support'
// @vitest-environment happy-dom
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { afterEach, expect, it, vi } from 'vitest'
import { AgentLaunchPickerMenu } from './AgentLaunchPickerMenu'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import { TooltipProvider } from '@/components/ui/tooltip'
import type { AgentPickerEntry } from '../../../../shared/agent-launch/picker/agent-launch-picker'
vi.mock('@/hooks/useShortcutLabel', () => ({ useOptionalShortcutLabel: () => null }))
afterEach(cleanup)
it('keeps the terminal launch shown but waiting while the host connects, with chat usable and setup stable', async () => {
const entry: AgentPickerEntry = {
agent: 'codex',
label: 'Codex',
defaultSurface: 'terminal',
surfaces: ['chat', 'terminal'],
terminal: {},
structured: {},
catalog: { origin: 'probe', fetchedAt: 1, models: [] },
rows: [{ kind: 'cli', agent: 'codex', chat: true }]
}
// Chat is not offered over this SSH host, so the row's own reason would be "No chat over SSH".
const sshOnly: AgentPickerEntry = {
...entry,
agent: 'claude',
label: 'Claude',
surfaces: ['terminal'],
defaultSurface: 'terminal',
rows: [{ kind: 'chat-unavailable', agent: 'claude', reason: 'ssh' }]
}
const launch = vi.fn()
const menu = (terminalPending: boolean) => (
<TooltipProvider>
<DropdownMenu defaultOpen modal={false}>
<DropdownMenuTrigger>New tab</DropdownMenuTrigger>
<DropdownMenuContent>
<AgentLaunchPickerMenu
entries={[entry, sshOnly]}
runLaunch={launch}
model={{
state: 'settled',
rows: entry.rows,
terminalPending,
detection: {
detectedIds: ['codex', 'claude'],
isLoading: false,
detectionFailed: false,
isRefreshing: false,
needsServerUpdate: false,
refresh: async () => ['codex', 'claude']
}
}}
/>
</DropdownMenuContent>
</DropdownMenu>
</TooltipProvider>
)
const view = render(menu(true))
const row = screen.getByRole('menuitem', { name: /Codex/ })
// The waiting launch reads as unavailable, says why, and stays focusable.
const primary = screen.getByRole('button', { name: /^Codex/ })
expect(primary.getAttribute('aria-disabled')).toBe('true')
expect(document.getElementById(primary.getAttribute('aria-describedby') ?? '')?.textContent).toBe(
'Connecting…'
)
act(() => row.focus())
expect(document.activeElement).toBe(row)
fireEvent.keyDown(row, { key: 'Enter' })
fireEvent.click(row)
expect(launch).not.toHaveBeenCalled()
expect(screen.queryByRole('menu')).not.toBeNull()
// Configure sits beside it with its own enabled state, reached from the row by ArrowRight.
const configure = screen.getByRole('button', { name: 'Configure Codex' })
expect(configure.closest('[aria-disabled="true"], [disabled]')).toBeNull()
fireEvent.keyDown(row, { key: 'ArrowRight' })
expect(screen.getByRole('menu', { name: 'Configure Codex' })).not.toBeNull()
// One reason per row: the wait, not also the missing chat.
const reason = () => screen.getByRole('menuitem', { name: /^Claude/ }).textContent
expect(reason()).toBe('ClaudeConnecting…')
expect(screen.getByRole('menu', { name: 'Configure Codex' })).not.toBeNull()
const user = userEvent.setup()
fireEvent.keyDown(screen.getByRole('menu', { name: 'Configure Codex' }), { key: 'Escape' })
expect(document.activeElement).toBe(configure)
await user.keyboard('{Enter}')
expect(screen.getByRole('menu', { name: 'Configure Codex' })).not.toBeNull()
expect(launch).not.toHaveBeenCalled()
const editor = document.querySelector<HTMLElement>('[contenteditable]')!
changePrompt(editor, 'first line')
const editingKey = vi.fn()
editor.addEventListener('keydown', editingKey)
fireEvent.keyDown(editor, { key: 'Enter', shiftKey: true })
expect(editingKey).toHaveBeenCalledOnce()
expect(launch).not.toHaveBeenCalled()
editor.removeEventListener('keydown', editingKey)
const buttons = () =>
screen.getAllByRole('button', { name: /^Launch / }).map((button) => ({
name: button.getAttribute('aria-label'),
disabled: button.hasAttribute('disabled')
}))
// The terminal default stays the default and stays mounted; only its launch waits.
expect(buttons()).toEqual([
{ name: 'Launch chat', disabled: false },
{ name: 'Launch terminal', disabled: true }
])
const args = () => document.querySelector<HTMLTextAreaElement>('textarea[aria-label="Arguments"]')
fireEvent.change(args()!, { target: { value: '--search' } })
view.rerender(menu(false))
expect(reason()).toBe('ClaudeNo chat over SSH')
expect(args()?.value).toBe('--search')
expect(buttons()).toEqual([
{ name: 'Launch chat', disabled: false },
{ name: 'Launch terminal', disabled: false }
])
// A reconnect waits again; the explicit chat still starts.
view.rerender(menu(true))
expect(buttons()[1]).toEqual({ name: 'Launch terminal', disabled: true })
await user.click(screen.getByRole('button', { name: 'Launch chat' }))
expect(launch).toHaveBeenCalledExactlyOnceWith(
expect.objectContaining({ kind: 'chat', agent: 'codex' }),
expect.objectContaining({ surface: 'chat' }),
expect.anything()
)
// The chat closes the menu as a chosen item would, without the waiting row being chosen.
expect(screen.queryByRole('menu')).toBeNull()
})

it.each(['launch', 'select'] as const)(
'pending terminal readiness preserves %s mode semantics',
(mode) => {
const entry: AgentPickerEntry = {
agent: 'codex',
label: 'Codex',
defaultSurface: 'terminal',
surfaces: ['terminal'],
terminal: {},
structured: {},
catalog: { origin: 'probe', fetchedAt: 1, models: [] },
rows: [{ kind: 'cli', agent: 'codex' }]
}
const launch = vi.fn(() => false)
render(
<DropdownMenu defaultOpen>
<DropdownMenuTrigger>New tab</DropdownMenuTrigger>
<DropdownMenuContent>
<AgentLaunchPickerMenu
entries={[entry]}
mode={mode}
setupDisabled
runLaunch={launch}
model={{
state: 'settled',
rows: entry.rows,
terminalPending: true,
detection: {
detectedIds: ['codex'],
isLoading: false,
detectionFailed: false,
isRefreshing: false,
needsServerUpdate: false,
refresh: async () => ['codex']
}
}}
/>
</DropdownMenuContent>
</DropdownMenu>
)
const row = screen.getByRole('menuitem', { name: 'Codex' })
expect(row.getAttribute('aria-disabled')).toBe(mode === 'launch' ? 'true' : null)
fireEvent.click(row)
expect(launch).toHaveBeenCalledTimes(mode === 'launch' ? 0 : 1)
expect(screen.getByRole('menu')).not.toBeNull()
}
)
4 changes: 4 additions & 0 deletions src/renderer/src/components/agent/AgentLaunchPickerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
} from '../../../../shared/agent-launch/picker/agent-launch-picker'

export function AgentLaunchPickerMenu({
model,
draftScope,
shortcutLabels,
disabled,
Expand Down Expand Up @@ -85,6 +86,7 @@ export function AgentLaunchPickerMenu({
mode
)
}, [entries, draftScope, mode, setupDisabled])
const terminalBlocked = mode !== 'select' && model?.state === 'settled' && model.terminalPending
const [query, setQuery] = useState(initialQuery)
const [searchFocused, setSearchFocused] = useState(false)
const [activeSetup, setActiveSetup] = useState<{
Expand Down Expand Up @@ -195,6 +197,7 @@ export function AgentLaunchPickerMenu({
selected={value?.agent === setup.entry.agent ? value : undefined}
onSelectAgent={onSelectAgent}
disabled={disabled}
terminalBlocked={terminalBlocked}
runLaunch={runLaunch}
/>
)
Expand All @@ -214,6 +217,7 @@ export function AgentLaunchPickerMenu({
openSetup={openSetup}
onSetupOpenChange={setActiveSetup}
disabled={disabled}
terminalBlocked={terminalBlocked}
runLaunch={runLaunch}
onSelectAgent={onSelectAgent}
isDefault={defaultAgent === entry.agent}
Expand Down
Loading
Loading