Skip to content

The agent that grows with you

desktop: confirm before selecting a needs-setup terminal backend

Rook-CodeVoltd271bed15496
diff --git a/apps/desktop/src/app/settings/terminal-backend-panel.test.tsx b/apps/desktop/src/app/settings/terminal-backend-panel.test.tsx
index 84e8d3688a1..5c488f15b55 100644
--- a/apps/desktop/src/app/settings/terminal-backend-panel.test.tsx
+++ b/apps/desktop/src/app/settings/terminal-backend-panel.test.tsx
@@ -1,16 +1,22 @@
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { deferred } from '@/test/deferred'
import type { TerminalBackendsResponse } from '@/types/hermes'
const getTerminalBackends = vi.fn()
const selectTerminalBackend = vi.fn()
+const confirmMock = vi.fn()
vi.mock('@/hermes', () => ({
getTerminalBackends: () => getTerminalBackends(),
selectTerminalBackend: (backend: string) => selectTerminalBackend(backend)
}))
+vi.mock('@/store/confirm', () => ({
+ confirm: (...args: Parameters<typeof confirmMock>) => confirmMock(...args)
+}))
+
vi.mock('@/store/notifications', () => ({
notify: vi.fn(),
notifyError: vi.fn()
@@ -52,6 +58,7 @@ function backends(overrides: Partial<TerminalBackendsResponse> = {}): TerminalBa
beforeEach(() => {
getTerminalBackends.mockResolvedValue(backends())
selectTerminalBackend.mockResolvedValue({ ok: true, backend: 'ssh' })
+ confirmMock.mockReset()
})
afterEach(() => {
@@ -103,18 +110,44 @@ describe('TerminalBackendPanel', () => {
expect(ssh.getAttribute('aria-pressed')).toBe('true')
})
- it('allows selecting a needs_setup backend (guidance instead of blocking)', async () => {
+ it('gates a needs_setup backend behind a confirm dialog before selecting it', async () => {
+ const confirmGate = deferred<boolean>()
+ confirmMock.mockReturnValue(confirmGate.promise)
selectTerminalBackend.mockResolvedValue({ ok: true, backend: 'docker' })
const { TerminalBackendPanel } = await import('./terminal-backend-panel')
render(<TerminalBackendPanel onConfiguredChange={vi.fn()} />)
fireEvent.click(await screen.findByRole('button', { name: /Docker/ }))
+ await waitFor(() => expect(confirmMock).toHaveBeenCalled())
+ expect(confirmMock).toHaveBeenCalledWith(
+ expect.objectContaining({
+ title: expect.stringContaining('Docker'),
+ description: expect.stringContaining('Docker daemon not reachable')
+ })
+ )
+ // Must not select while the confirm dialog is still pending.
+ expect(selectTerminalBackend).not.toHaveBeenCalled()
+
+ confirmGate.resolve(true)
+
await waitFor(() => expect(selectTerminalBackend).toHaveBeenCalledWith('docker'))
// The guidance detail stays visible on the now-active row.
expect(screen.getByText(/Docker daemon not reachable/)).toBeTruthy()
})
+ it('does not select a needs_setup backend when the confirm dialog is declined', async () => {
+ confirmMock.mockResolvedValue(false)
+ const { TerminalBackendPanel } = await import('./terminal-backend-panel')
+ render(<TerminalBackendPanel onConfiguredChange={vi.fn()} />)
+
+ fireEvent.click(await screen.findByRole('button', { name: /Docker/ }))
+
+ await waitFor(() => expect(confirmMock).toHaveBeenCalled())
+ await new Promise(resolve => setTimeout(resolve, 50))
+ expect(selectTerminalBackend).not.toHaveBeenCalled()
+ })
+
it('does not re-select the already active backend', async () => {
const { TerminalBackendPanel } = await import('./terminal-backend-panel')
render(<TerminalBackendPanel onConfiguredChange={vi.fn()} />)
diff --git a/apps/desktop/src/app/settings/terminal-backend-panel.tsx b/apps/desktop/src/app/settings/terminal-backend-panel.tsx
index f2a55be9685..2e778d23a62 100644
--- a/apps/desktop/src/app/settings/terminal-backend-panel.tsx
+++ b/apps/desktop/src/app/settings/terminal-backend-panel.tsx
@@ -5,6 +5,7 @@ import { getTerminalBackends, selectTerminalBackend } from '@/hermes'
import { useI18n } from '@/i18n'
import { AlertTriangle, Check, Loader2, RefreshCw } from '@/lib/icons'
import { cn } from '@/lib/utils'
+import { confirm } from '@/store/confirm'
import { notify, notifyError } from '@/store/notifications'
import type { TerminalBackendInfo, TerminalBackendsResponse } from '@/types/hermes'
@@ -43,7 +44,10 @@ function StatusPill({ backend }: { backend: TerminalBackendInfo }) {
* (Docker daemon reachable, SSH host configured, Modal/Daytona credentials
* present) so users see Ready / Needs-setup guidance instead of a bare
* dropdown. Selecting a needs-setup backend is allowed — the row shows what's
- * missing rather than blocking, matching the CLI configurator.
+ * missing rather than blocking, matching the CLI configurator — but it is
+ * persisted immediately and every session that re-reads the config afterward
+ * inherits a backend that can't run anything, so we gate it behind an
+ * explicit confirm() first.
*/
export function TerminalBackendPanel({ onConfiguredChange }: TerminalBackendPanelProps) {
const { t } = useI18n()
@@ -73,6 +77,20 @@ export function TerminalBackendPanel({ onConfiguredChange }: TerminalBackendPane
return
}
+ if (backend.status === 'needs_setup') {
+ const proceed = await confirm({
+ title: copy.needsSetupConfirmTitle(backend.label),
+ description: backend.detail
+ ? copy.needsSetupConfirmDescription(backend.detail)
+ : copy.needsSetupConfirmDescriptionGeneric,
+ confirmLabel: copy.needsSetupConfirmAction
+ })
+
+ if (!proceed) {
+ return
+ }
+ }
+
setSelecting(backend.name)
try {
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 40fd801831f..ec075ee9e97 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -1689,6 +1689,12 @@ export const en: Translations = {
selectedMessage: backend => `Terminal commands now run via ${backend}. Applies to new sessions.`,
failedSelect: backend => `Failed to select ${backend}`,
needsSetupHint: 'You can select this option now — commands will fail until setup is complete.',
+ needsSetupConfirmTitle: backend => `Select ${backend} anyway?`,
+ needsSetupConfirmDescription: detail =>
+ `${detail} Sessions that start after this change will have no terminal or file tools until setup is finished.`,
+ needsSetupConfirmDescriptionGeneric:
+ "This backend isn't set up yet. Sessions that start after this change will have no terminal or file tools until setup is finished.",
+ needsSetupConfirmAction: 'Select anyway',
unavailableTitle: 'Terminal commands are unavailable',
unavailableMessage: backend =>
`Hermes can't run shell commands right now: ${backend} isn't ready. Switch to Local, or finish setting up ${backend} and try again.`,
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index 113b4e8101f..49f7405d48e 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -1463,7 +1463,13 @@ export const ja = defineLocale({
selectedTitle: 'バックエンドを選択しました',
selectedMessage: backend => `ターミナルコマンドは ${backend} で実行されます。新しいセッションに適用されます。`,
failedSelect: backend => `${backend} の選択に失敗しました`,
- needsSetupHint: 'このバックエンドは今すぐ選択できますが、セットアップが完了するまでコマンドは失敗します。'
+ needsSetupHint: 'このバックエンドは今すぐ選択できますが、セットアップが完了するまでコマンドは失敗します。',
+ needsSetupConfirmTitle: backend => `それでも ${backend} を選択しますか?`,
+ needsSetupConfirmDescription: detail =>
+ `${detail} この変更後に開始されるセッションは、セットアップが完了するまでターミナルとファイルツールを使用できません。`,
+ needsSetupConfirmDescriptionGeneric:
+ 'このバックエンドはまだセットアップされていません。この変更後に開始されるセッションは、セットアップが完了するまでターミナルとファイルツールを使用できません。',
+ needsSetupConfirmAction: 'それでも選択する'
},
browserRealProfile: {
label: '実際のブラウザプロファイルを使用',
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 7cfc88906d5..a79fe42aefc 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -1584,7 +1584,13 @@ export const ru = defineLocale({
selectedMessage: backend =>
`Команды терминала теперь выполняются через ${backend}. Применится к новым сеансам.`,
failedSelect: backend => `Не удалось выбрать ${backend}`,
- needsSetupHint: 'Этот бэкенд можно выбрать сейчас — команды будут падать, пока настройка не завершена.'
+ needsSetupHint: 'Этот бэкенд можно выбрать сейчас — команды будут падать, пока настройка не завершена.',
+ needsSetupConfirmTitle: backend => `Всё равно выбрать ${backend}?`,
+ needsSetupConfirmDescription: detail =>
+ `${detail} Сеансы, запущенные после этого изменения, останутся без терминала и файловых инструментов, пока настройка не завершена.`,
+ needsSetupConfirmDescriptionGeneric:
+ 'Этот бэкенд ещё не настроен. Сеансы, запущенные после этого изменения, останутся без терминала и файловых инструментов, пока настройка не завершена.',
+ needsSetupConfirmAction: 'Выбрать всё равно'
}
}
},
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 6469e3f8813..e140e76fc8a 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -1496,6 +1496,10 @@ export interface Translations {
selectedMessage: (backend: string) => string
failedSelect: (backend: string) => string
needsSetupHint: string
+ needsSetupConfirmTitle: (backend: string) => string
+ needsSetupConfirmDescription: (detail: string) => string
+ needsSetupConfirmDescriptionGeneric: string
+ needsSetupConfirmAction: string
unavailableTitle: string
unavailableMessage: (backend: string) => string
openBackendSettings: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index 1dfce3548f9..b0f8a46be5f 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -1479,7 +1479,11 @@ export const zhHant = defineLocale({
selectedTitle: '已選擇後端',
selectedMessage: backend => `終端命令現在透過 ${backend} 執行。將套用於新工作階段。`,
failedSelect: backend => `選擇 ${backend} 失敗`,
- needsSetupHint: '現在即可選擇此後端——但在完成設定前命令將會失敗。'
+ needsSetupHint: '現在即可選擇此後端——但在完成設定前命令將會失敗。',
+ needsSetupConfirmTitle: backend => `仍要選擇 ${backend} 嗎?`,
+ needsSetupConfirmDescription: detail => `${detail} 此變更生效後啟動的工作階段在設定完成前將沒有終端或檔案工具。`,
+ needsSetupConfirmDescriptionGeneric: '此後端尚未完成設定。此變更生效後啟動的工作階段在設定完成前將沒有終端或檔案工具。',
+ needsSetupConfirmAction: '仍然選擇'
},
browserRealProfile: {
label: '使用我的真實瀏覽器設定檔',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 37db3d43598..c2d09ec13b9 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -1862,7 +1862,11 @@ export const zh = defineLocale({
selectedTitle: '已选择后端',
selectedMessage: backend => `终端命令现在通过 ${backend} 运行。将应用于新会话。`,
failedSelect: backend => `选择 ${backend} 失败`,
- needsSetupHint: '现在即可选择此后端——但在完成设置前命令将会失败。'
+ needsSetupHint: '现在即可选择此后端——但在完成设置前命令将会失败。',
+ needsSetupConfirmTitle: backend => `仍要选择 ${backend} 吗?`,
+ needsSetupConfirmDescription: detail => `${detail} 此更改生效后启动的会话在设置完成前将没有终端或文件工具。`,
+ needsSetupConfirmDescriptionGeneric: '此后端尚未完成设置。此更改生效后启动的会话在设置完成前将没有终端或文件工具。',
+ needsSetupConfirmAction: '仍然选择'
},
browserRealProfile: {
label: '使用我的真实浏览器配置文件',