Skip to content

The agent that grows with you

fix(desktop): explain read-only background terminals and offer a new shell

wangtao1063a6371693
diff --git a/apps/desktop/src/app/right-sidebar/terminal/instance.test.tsx b/apps/desktop/src/app/right-sidebar/terminal/instance.test.tsx
new file mode 100644
index 00000000000..9d7ccb4e255
--- /dev/null
+++ b/apps/desktop/src/app/right-sidebar/terminal/instance.test.tsx
@@ -0,0 +1,59 @@
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+
+import { en } from '@/i18n/en'
+import { $currentCwd } from '@/store/session'
+
+import { AgentTerminalInstance, TerminalInstance } from './instance'
+import { $activeTerminalId, $terminals } from './terminals'
+
+vi.mock('./use-agent-terminal', () => ({
+ useAgentTerminal: () => ({ hostRef: { current: null } })
+}))
+
+vi.mock('./use-terminal-session', () => ({
+ useTerminalSession: () => ({ hostRef: { current: null }, selection: '', status: 'ready' })
+}))
+
+describe('background terminal input guidance (#108233)', () => {
+ beforeEach(() => {
+ $terminals.set([{ id: 'agent-tab', title: 'installer', auto: false, cwd: '', kind: 'agent', procId: 'process-1' }])
+ $activeTerminalId.set('agent-tab')
+ $currentCwd.set('/workspace/project')
+ })
+
+ afterEach(() => {
+ cleanup()
+ $terminals.set([])
+ $activeTerminalId.set(null)
+ $currentCwd.set('')
+ })
+
+ it('explains the mirror and opens a separate interactive shell only when requested', () => {
+ const original = $terminals.get()[0]
+ render(<AgentTerminalInstance active id="agent-tab" procId="process-1" />)
+
+ expect(screen.getByText(en.rightSidebar.terminalReadOnly)).toBeTruthy()
+ expect(screen.getByText(en.rightSidebar.terminalReadOnlyHelp)).toBeTruthy()
+ expect($terminals.get()).toEqual([original])
+
+ fireEvent.click(screen.getByRole('button', { name: en.rightSidebar.terminalOpenInteractive }))
+
+ const shell = $terminals.get().find(term => term.id === $activeTerminalId.get())
+ expect(shell).toMatchObject({ kind: 'user', cwd: '/workspace/project', auto: true })
+ expect(shell?.procId).toBeUndefined()
+ expect($terminals.get()).toHaveLength(2)
+ expect($terminals.get()[0]).toBe(original)
+ })
+
+ it('does not create shells or change selection on background mount and does not label user shells read-only', () => {
+ const view = render(<AgentTerminalInstance active={false} id="agent-tab" procId="process-1" />)
+ expect($activeTerminalId.get()).toBe('agent-tab')
+ expect($terminals.get()).toHaveLength(1)
+
+ view.rerender(<TerminalInstance active cwd="/workspace/project" id="user-tab" onAddSelectionToChat={vi.fn()} />)
+ expect(screen.queryByText(en.rightSidebar.terminalReadOnly)).toBeNull()
+ expect(screen.queryByRole('button', { name: en.rightSidebar.terminalOpenInteractive })).toBeNull()
+ expect($terminals.get()).toHaveLength(1)
+ })
+})
diff --git a/apps/desktop/src/app/right-sidebar/terminal/instance.tsx b/apps/desktop/src/app/right-sidebar/terminal/instance.tsx
index 9d814956422..bd837558a40 100644
--- a/apps/desktop/src/app/right-sidebar/terminal/instance.tsx
+++ b/apps/desktop/src/app/right-sidebar/terminal/instance.tsx
@@ -6,7 +6,7 @@ import { Loader } from '@/components/ui/loader'
import { useI18n } from '@/i18n'
import { cn } from '@/lib/utils'
-import { reportTerminalShell } from './terminals'
+import { createTerminal, reportTerminalShell } from './terminals'
import { useAgentTerminal } from './use-agent-terminal'
import { useTerminalSession } from './use-terminal-session'
@@ -101,6 +101,7 @@ interface AgentTerminalInstanceProps {
/** Read-only mirror of an agent background process — a write-only xterm streamed
* live from the backend output (no PTY, no input). */
export function AgentTerminalInstance({ active, id, procId }: AgentTerminalInstanceProps) {
+ const { t } = useI18n()
const { hostRef } = useAgentTerminal({ active, id, procId })
return (
@@ -110,6 +111,15 @@ export function AgentTerminalInstance({ active, id, procId }: AgentTerminalInsta
// routes ⌘W here and closes the focused agent tab (not a preview).
data-terminal=""
>
+ <div className="flex shrink-0 flex-wrap items-center gap-2 py-2 text-xs text-(--ui-text-secondary)">
+ <div className="min-w-0 flex-1">
+ <p className="font-medium">{t.rightSidebar.terminalReadOnly}</p>
+ <p>{t.rightSidebar.terminalReadOnlyHelp}</p>
+ </div>
+ <Button onClick={() => createTerminal()} size="sm" type="button" variant="secondary">
+ {t.rightSidebar.terminalOpenInteractive}
+ </Button>
+ </div>
<div className={HOST_CLASS} ref={hostRef} />
</div>
)
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index 9c1b65c40f3..3102ae85c8c 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -3025,6 +3025,10 @@ export const ar = defineLocale({
}
},
rightSidebar: {
+ terminalReadOnly: 'مخرجات للقراءة فقط',
+ terminalReadOnlyHelp:
+ 'للرد على المطالبات، أوقف الأمر الذي يعمل في الخلفية وشغّله في طرفية جديدة. تفتح الطرفية الجديدة صدفة منفصلة ولا تتصل بهذه العملية.',
+ terminalOpenInteractive: 'فتح طرفية جديدة',
aria: 'الشريط الجانبي الأيمن',
panelsAria: 'لوحات الشريط الأيمن',
files: 'الملفات',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index f3439698267..11e74c33c4b 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -4798,6 +4798,10 @@ export const en: Translations = {
},
rightSidebar: {
+ terminalReadOnly: 'Read-only output',
+ terminalReadOnlyHelp:
+ 'To answer prompts, stop the background command and run it in a new terminal. The new terminal opens a separate shell; it does not connect to this process.',
+ terminalOpenInteractive: 'Open new terminal',
aria: 'Right sidebar',
panelsAria: 'Right sidebar panels',
files: 'File system',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index fffb761b772..9d7e830f4e9 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -3520,6 +3520,10 @@ export const ja = defineLocale({
},
rightSidebar: {
+ terminalReadOnly: '読み取り専用の出力',
+ terminalReadOnlyHelp:
+ 'プロンプトに応答するには、バックグラウンドのコマンドを停止し、新しいターミナルで実行してください。新しいターミナルは別のシェルを開き、このプロセスには接続しません。',
+ terminalOpenInteractive: '新しいターミナルを開く',
aria: '右サイドバー',
panelsAria: '右サイドバーパネル',
files: 'ファイルシステム',
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index a51fb67fb18..37204e6bef2 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -3754,6 +3754,10 @@ export const ru = defineLocale({
}
},
rightSidebar: {
+ terminalReadOnly: 'Вывод только для чтения',
+ terminalReadOnlyHelp:
+ 'Чтобы ответить на запрос, остановите фоновую команду и запустите её в новом терминале. Он откроет отдельную оболочку и не подключится к этому процессу.',
+ terminalOpenInteractive: 'Открыть новый терминал',
aria: 'Правая боковая панель',
panelsAria: 'Панели правой боковой панели',
files: 'Файловая система',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index b613caa65cf..e51603e5f01 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -4089,6 +4089,9 @@ export interface Translations {
terminalHide: string
terminalsAria: string
terminalNew: string
+ terminalReadOnly: string
+ terminalReadOnlyHelp: string
+ terminalOpenInteractive: string
terminalCloseOthers: string
terminalCloseAll: string
addToChat: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index a4d6d9c7781..98373973b64 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -3702,6 +3702,10 @@ export const zhHant = defineLocale({
},
rightSidebar: {
+ terminalReadOnly: '唯讀輸出',
+ terminalReadOnlyHelp:
+ '如需回應提示,請停止背景命令,再於新終端機中執行。新終端機會開啟獨立的 shell,不會連線至此程序。',
+ terminalOpenInteractive: '開啟新終端機',
aria: '右側邊欄',
panelsAria: '右側邊欄面板',
files: '檔案系統',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 0150c2786fc..22c0773ac14 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -4497,6 +4497,10 @@ export const zh = defineLocale({
},
rightSidebar: {
+ terminalReadOnly: '只读输出',
+ terminalReadOnlyHelp:
+ '如需回应提示,请停止后台命令,再在新终端中运行。新终端会打开独立的 shell,不会连接到此进程。',
+ terminalOpenInteractive: '打开新终端',
aria: '右侧边栏',
panelsAria: '右侧边栏面板',
files: '文件系统',