+ {AGENT_PROVIDER_KINDS.filter(p => enabledKinds.has(p)).map(p => (
+ {
+ if (p !== provider) invalidateResumeListing()
+ setProvider(p)
+ }}
+ // Still selectable when missing: the probe can be wrong, and
+ // the spawn re-resolves the CLI itself (see useMissingProviders).
+ title={missingProviders.has(p) ? MISSING_PROVIDER_HINT : undefined}
+ data-provider-missing={missingProviders.has(p) || undefined}
+ aria-pressed={provider === p}
+ className={`rounded-control
+ px-3 py-1 text-[11px] font-medium uppercase tracking-wider
+ border transition-colors duration-120 outline-none focus-visible:ring-1 focus-visible:ring-focus-ring
+ ${provider === p
+ ? 'bg-accent text-accent-fg border-accent'
+ : 'bg-transparent text-muted border-border hover:border-border-hi hover:text-ink'}
+ ${missingProviders.has(p) ? 'line-through decoration-muted' : ''}
+ `}
+ >
+ {getRendererProviderCapabilities(p).shortLabel}
+
+ ))}
+
+ )}
@@ -435,13 +502,15 @@ export function PathPickerModal({
{/* Resume section — shows the most recent sessions recorded in
the currently-typed cwd. Click a row to spawn with --resume. */}
-
+ {!noEnabledProviders && (
+
+ )}
{listingError && (
@@ -476,10 +545,12 @@ export function PathPickerModal({
confirmLabel={
preferred
? (preferred.current ? 'Stay Here' : 'Go to Tab')
- : pendingCreatePath ? 'Create & Open' : 'New Session'
+ : noEnabledProviders
+ ? (pendingCreatePath ? 'Create & Open Terminal' : 'Open Terminal')
+ : (pendingCreatePath ? 'Create & Open' : 'New Session')
}
confirmOnEnter={false}
- confirmDisabled={busy || (!preferred && value.trim() === '')}
+ confirmDisabled={busy || (!preferred && (value.trim() === '' || (noEnabledProviders && !onOpenTerminal)))}
onConfirm={() => {
if (preferred) onActivateTab?.(preferred.tabId)
else void submit({ forceNewTab: true })
@@ -487,7 +558,7 @@ export function PathPickerModal({
onCancel={onCancel}
cancelDisabled={busy}
escapeCancels={!busy}
- extraActions={preferred ? (
+ extraActions={preferred && (!noEnabledProviders || onOpenTerminal) ? (
void submit({ forceNewTab: true })} disabled={busy}>
New Tab Anyway
diff --git a/src/renderer/src/features/setup/firstRun.renderer.test.tsx b/src/renderer/src/features/setup/firstRun.renderer.test.tsx
index dfcc23560..4eedbb6c4 100644
--- a/src/renderer/src/features/setup/firstRun.renderer.test.tsx
+++ b/src/renderer/src/features/setup/firstRun.renderer.test.tsx
@@ -341,3 +341,68 @@ describe('the setup panel never strands the first run (#1047 review)', () => {
expect(spawnedKinds(spawnSession)).toEqual(['terminal'])
})
})
+
+describe('SetupGate UX dead-end fixes (#1553)', () => {
+ it('pressing Enter inside Enter Path Manually submits the path and never closes SetupGate', async () => {
+ const devCheck = loadFirstRunCheck('developer-machine')
+ const { api } = mountMachine([devCheck])
+ await waitFor(() => expect(projects()).toBe(1))
+ const setupSetToolPath = vi.fn(async () => ({ ok: false as const, reason: 'No file exists at that path.' }))
+ Object.assign(api, { setupSetToolPath })
+
+ // Reopen Setup (mustAnswer === false, so DialogActions binds Enter to Close).
+ await act(async () => {
+ setupCommands.find(command => command.id === 'open-setup')!.run({ ui: { closePalette: vi.fn() } } as unknown as CommandContext)
+ })
+ await screen.findByRole('dialog')
+
+ // Found provider rows expose Change Path… so users can override detected paths.
+ const changeButtons = screen.getAllByRole('button', { name: 'Change Path…' })
+ expect(changeButtons.length).toBeGreaterThan(0)
+ fireEvent.click(changeButtons[0]!)
+
+ const input = screen.getByRole('textbox')
+ fireEvent.change(input, { target: { value: '~/missing/claude' } })
+ fireEvent.keyDown(input, { key: 'Enter' })
+
+ expect(await screen.findByText('No file exists at that path.')).toBeTruthy()
+ expect(setupSetToolPath).toHaveBeenCalledWith(expect.any(String), '~/missing/claude')
+ // Dialog stayed open so the user sees the validation error.
+ expect(screen.getByRole('dialog')).toBeTruthy()
+ })
+
+ it('renders SetupGate error state with Retry when requested and the initial check failed', async () => {
+ const devCheck = loadFirstRunCheck('developer-machine')
+ let calls = 0
+ const setupCheck = vi.fn(async () => {
+ calls += 1
+ if (calls <= 2) throw new Error('login shell timed out')
+ return devCheck
+ })
+ Object.defineProperty(window, 'api', { configurable: true, value: {
+ loadWorkspace: async () => null,
+ defaultCwd: async () => '/Users/someone',
+ setupCheck,
+ setupSkipOptional: vi.fn(async () => devCheck),
+ setupAcknowledgeNoProviders: vi.fn(async () => devCheck),
+ spawnSession: vi.fn(async () => ({ sessionId: 's1' })),
+ onOrchestrationRequest: () => () => undefined,
+ onAgentManagementRequest: () => () => undefined,
+ reportSessionLifecycle: vi.fn(),
+ appendFeedDebugLog: async () => undefined,
+ } })
+ render()
+ await waitFor(() => expect(setupCheck).toHaveBeenCalledTimes(1))
+
+ // User opens Setup explicitly while check === null and error is set.
+ await act(async () => {
+ setupCommands.find(command => command.id === 'open-setup')!.run({ ui: { closePalette: vi.fn() } } as unknown as CommandContext)
+ })
+ expect(await screen.findByRole('dialog')).toBeTruthy()
+ expect(screen.getByText(/Could not inspect installed tools/)).toBeTruthy()
+
+ // Clicking Retry recovers once the check succeeds.
+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }))
+ expect(await screen.findByText('Agent providers')).toBeTruthy()
+ })
+})
diff --git a/src/renderer/src/features/setup/ui/SetupGate.tsx b/src/renderer/src/features/setup/ui/SetupGate.tsx
index 422931743..6b418efc8 100644
--- a/src/renderer/src/features/setup/ui/SetupGate.tsx
+++ b/src/renderer/src/features/setup/ui/SetupGate.tsx
@@ -52,8 +52,24 @@ export function SetupGate() {
const panelRef = useRef(null)
const [busy, setBusy] = useState('check')
const [actionError, setActionError] = useState(null)
+ // Tracks which provider rows currently have their inline "Enter Path
+ // Manually…" / "Change Path…" editor open (#1553). While any row is editing
+ // a path, DialogActions must NOT bind Enter to close/continue the dialog —
+ // otherwise pressing Enter inside the path input closes SetupGate instead
+ // of submitting the path.
+ const [editingTools, setEditingTools] = useState>(() => new Set())
const { showToast } = useGlobalToast()
+ const handleEditingChange = useCallback((tool: SetupToolId, open: boolean) => {
+ setEditingTools(prev => {
+ if (open === prev.has(tool)) return prev
+ const next = new Set(prev)
+ if (open) next.add(tool)
+ else next.delete(tool)
+ return next
+ })
+ }, [])
+
const refresh = useCallback(async () => {
setBusy('check')
setActionError(null)
@@ -92,7 +108,18 @@ export function SetupGate() {
((noProvider && !check.noProvidersAcknowledged)
|| missingOptional.some(tool => tool.installable && !tool.skipped)),
)
- const shouldShow = Boolean(check && (requested || automatic))
+ // WHY `|| (requested && error)` (#1553): if the initial prerequisite check
+ // failed (`check === null`, `error` set) and the user explicitly opens Setup
+ // from File › Setup… or the command palette, returning null silently hides
+ // both the failure and the Retry button. Showing the dialog with the error
+ // alert + Retry gives the user a way to recover.
+ const shouldShow = Boolean((check && (requested || automatic)) || (requested && error))
+
+ useEffect(() => {
+ if (!shouldShow && editingTools.size > 0) {
+ setEditingTools(new Set())
+ }
+ }, [shouldShow, editingTools.size])
// The one state that may not be dismissed by a stray key or click: a fresh
// install with nothing to run, whose bootstrap is parked on this answer.
// Everything else — a returning user, an optional helper, a panel the user
@@ -184,10 +211,10 @@ export function SetupGate() {
if (answerNotSaved) showToast(SETUP_ANSWER_NOT_SAVED)
}, [automatic, missingOptional, noProvider, showToast])
- if (!shouldShow || !check) return null
+ if (!shouldShow) return null
- const providers = Object.values(check.tools).filter(tool => tool.provider)
- const helpers = Object.values(check.tools).filter(tool => !tool.provider)
+ const providers = check ? Object.values(check.tools).filter(tool => tool.provider) : []
+ const helpers = check ? Object.values(check.tools).filter(tool => !tool.provider) : []
const shownError = actionError ?? error
// WHY the shared Dialog primitive and not a bare overlay div (#1047
@@ -228,26 +255,46 @@ export function SetupGate() {
{noProvider ? 'No agent provider is installed yet' : 'Agent Code Setup'}
- {noProvider
- ? 'Install one of the CLIs below in a terminal, then press Retry. Or continue with a terminal now and install from there. Setup stays available from the File menu and the command palette.'
- : 'The agent CLIs and helper tools on this Mac, and how to add the ones that are missing.'}
+ {!check
+ ? 'Could not inspect installed tools. Press Retry to try again.'
+ : noProvider
+ ? 'Install one of the CLIs below in a terminal, then press Retry. Or continue with a terminal now and install from there. Setup stays available from the File menu and the command palette.'
+ : 'The agent CLIs and helper tools on this Mac, and how to add the ones that are missing.'}
-
- Agent providers
-
- {providers.map(tool => (
-
- ))}
+ {check ? (
+
+ Agent providers
+
+ {providers.map(tool => (
+
+ ))}
+
+ Helper tools
+
+ {helpers.map(tool => (
+
+ ))}
+
- Helper tools
-
- {helpers.map(tool => (
-
- ))}
-
-
+ ) : (
+
+ )}
{shownError ? (
// Capped and scrollable: this can be the whole stdout+stderr of a
@@ -270,7 +317,8 @@ export function SetupGate() {
dead. Guards carried over (k3): both buttons wait while busy. */}
0 ? null : 'Enter'}
+ confirmOnEnter={editingTools.size === 0}
confirmDisabled={busy !== null}
onConfirm={() => void continueOn()}
legend={mustAnswer ? Escape is off until you choose. : undefined}
@@ -300,22 +348,30 @@ function SetupRow({
busy,
onInstall,
onSetPath,
+ onEditingChange,
}: {
tool: SetupToolStatus
busy: SetupInstallTarget | 'check' | null
onInstall: (target: SetupInstallTarget) => void
onSetPath: (tool: SetupToolId, path: string) => Promise
+ onEditingChange: (tool: SetupToolId, open: boolean) => void
}) {
const [overrideOpen, setOverrideOpen] = useState(false)
const [overridePath, setOverridePath] = useState('')
const [overrideError, setOverrideError] = useState(null)
const [copied, setCopied] = useState(false)
+ const setEditorOpen = (next: boolean) => {
+ setOverrideOpen(next)
+ onEditingChange(tool.id, next)
+ if (!next) setOverrideError(null)
+ }
+
const submitOverride = async () => {
const reason = await onSetPath(tool.id, overridePath)
setOverrideError(reason)
if (!reason) {
- setOverrideOpen(false)
+ setEditorOpen(false)
setOverridePath('')
}
}
@@ -339,10 +395,13 @@ function SetupRow({
? 'Shipped with Agent Code; no install required.'
: (tool.path ?? tool.detail ?? 'Not found')
const missingProvider = tool.provider && !tool.found && !isBundled
- // The manual override is for providers: a false "Not installed" is the one
- // probe error that costs the user an agent (#495 A1). Helpers have
- // Install/Skip and never gate anything.
- const canOverride = missingProvider
+ // WHY every provider row allows a manual path override (#1553): previously
+ // only missing providers showed "Enter Path Manually…", so a user whose
+ // provider resolved to an unwanted version (or bundled binary) had no UI way
+ // to point Agent Code at a different wrapper or install even though
+ // toolchain.ts already honors manual overrides above PATH and bundled.
+ const canOverride = tool.provider
+ const overrideButtonLabel = tool.found || isBundled ? 'Change Path…' : 'Enter Path Manually…'
const copy = async (command: string) => {
try {
@@ -372,9 +431,13 @@ function SetupRow({
{canOverride ? (
setOverrideOpen(open => !open)}
+ onClick={() => {
+ const next = !overrideOpen
+ if (next && !overridePath && tool.path) setOverridePath(tool.path)
+ setEditorOpen(next)
+ }}
>
- Enter Path Manually…
+ {overrideButtonLabel}
) : null}
{!isBundled && !tool.found && target && tool.installable ? (
@@ -416,12 +479,17 @@ function SetupRow({
setOverridePath(e.target.value)}
onKeyDown={e => {
- if (e.key === 'Enter' && overridePath.trim()) void submitOverride()
+ if (e.key === 'Enter') {
+ e.preventDefault()
+ e.stopPropagation()
+ if (busy === null && overridePath.trim()) void submitOverride()
+ }
}}
- placeholder={`/absolute/path/to/${tool.id}`}
+ placeholder={`/absolute/path/to/${tool.id} or ~/…`}
spellCheck={false}
aria-label={`Path to ${tool.id}`}
className="h-7 min-w-0 flex-1 text-[11px]"