The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep sudo commands visible before password entry
brooklyn!d128ce2e2563
diff --git a/apps/desktop/DESIGN.md b/apps/desktop/DESIGN.mdindex 742a7aec0a2..e22dfde9e47 100644--- a/apps/desktop/DESIGN.md+++ b/apps/desktop/DESIGN.md@@ -177,6 +177,14 @@ Notes:`warn`, `destructive`, `outline`, `solid` (primary fill — icon-corner counts).Sizes: `default`, `xs`, `overlay` (titlebar glyph counts).+## Context-sensitive dialogs++Sudo password dialogs keep the backdrop unblurred (`DialogContent`'s+`blurBackdrop={false}`) and show the complete, selectable command before the+password field. Long commands wrap and scroll; missing backend context is+explicit, never inferred from another tool row. Other dialogs retain the shared+blurred backdrop.+## Form controls- **`controlVariants`** (`src/components/ui/control.ts`) is the shared shape fordiff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/server-requests.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/server-requests.tsindex e13b58edb88..04a504a28b5 100644--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/server-requests.ts+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/server-requests.ts@@ -208,7 +208,11 @@ const approval: Handler = ctx => {const sudo: Handler = ctx => {rememberServerRequest(ctx.request)- setSudoRequest({ requestId: ctx.request.id, sessionId: ctx.sessionId || null })+ setSudoRequest({+ command: str(ctx.request.params.command),+ requestId: ctx.request.id,+ sessionId: ctx.sessionId || null+ })markNeedsInput(ctx)notifyInput(ctx, translateNow('notifications.native.inputBody'))}diff --git a/apps/desktop/src/components/prompt-overlays.test.tsx b/apps/desktop/src/components/prompt-overlays.test.tsxindex f5f4730b54a..4198a79ad29 100644--- a/apps/desktop/src/components/prompt-overlays.test.tsx+++ b/apps/desktop/src/components/prompt-overlays.test.tsx@@ -1,7 +1,12 @@import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import {+ handleServerRequest,+ type ServerRequestContext+} from '@/app/session/hooks/use-message-stream/gateway-event/server-requests'import { I18nProvider } from '@/i18n'+import { createClientSessionState } from '@/lib/chat-runtime'import { $gateway } from '@/store/gateway'import { notifyError } from '@/store/notifications'import { $secretRequest, $sudoRequest, clearAllPrompts, setSecretRequest, setSudoRequest } from '@/store/prompts'@@ -35,6 +40,58 @@ afterEach(() => {})describe('PromptOverlays', () => {+ it('shows the full command from the sudo request before accepting a password', () => {+ const command = `sudo install -m 755 '${'/tmp/path segment/'.repeat(24)}helper' /usr/local/bin/helper\n&& sudo /usr/local/bin/helper --version`+ const respond = vi.fn()++ const deps: ServerRequestContext['deps'] = {+ activeSessionIdRef: { current: 's1' },+ sessionInterrupted: () => false,+ updateSessionState: (_sid, update) => update(createClientSessionState('s1')),+ upsertToolCall: () => undefined+ }++ $activeSessionId.set('s1')+ $gateway.set({ request: vi.fn() } as never)+ handleServerRequest(+ {+ fail: vi.fn(),+ id: 'sudo-command',+ method: 'sudo',+ params: { command, session_id: 's1' },+ profile: 'default',+ respond+ },+ deps,+ 's1'+ )+ renderPrompts()++ const preview = screen.getByRole('region', { name: 'Command' })+ const password = screen.getByPlaceholderText('sudo password')++ expect(preview.textContent).toBe(command)+ expect(preview.compareDocumentPosition(password) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()+ expect(respond).not.toHaveBeenCalled()++ fireEvent.keyDown(screen.getByRole('dialog'), { key: 'Escape' })+ expect(respond).toHaveBeenCalledExactlyOnceWith({ value: '' })+ })++ it('explains when an older backend omits command context without blocking cancellation', () => {+ $gateway.set({ request: vi.fn() } as never)+ const respond = vi.fn()+ rememberServerRequest({ fail: vi.fn(), id: 'legacy-sudo', method: 'sudo', params: {}, respond })+ setSudoRequest({ requestId: 'legacy-sudo', sessionId: 's1' })+ renderPrompts()++ expect(+ screen.getByText('This agent did not provide the command. Cancel if you cannot verify it in the conversation.')+ ).toBeTruthy()+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }))+ expect(respond).toHaveBeenCalledExactlyOnceWith({ value: '' })+ })+it('answers the live sudo request with an empty value on Cancel and clears the dialog', async () => {const respond = vi.fn()const request = vi.fn()diff --git a/apps/desktop/src/components/prompt-overlays.tsx b/apps/desktop/src/components/prompt-overlays.tsxindex 7831eb5afa3..9aff32f3e44 100644--- a/apps/desktop/src/components/prompt-overlays.tsx+++ b/apps/desktop/src/components/prompt-overlays.tsx@@ -15,6 +15,7 @@ import {} from '@/components/ui/dialog'import { Field } from '@/components/ui/field'import { Input } from '@/components/ui/input'+import { LogView } from '@/components/ui/log-view'import { useI18n } from '@/i18n'import { isMissingPendingPromptRequest } from '@/lib/gateway-rpc'import { triggerHaptic } from '@/lib/haptics'@@ -119,12 +120,29 @@ function SudoDialog({ sessionId }: { sessionId: string | null }) {return (<Dialog onOpenChange={onOpenChange} open>- <DialogContent showCloseButton={false}>+ <DialogContent blurBackdrop={false} showCloseButton={false}><DialogHeader><DialogTitle icon={Lock}>{copy.sudoTitle}</DialogTitle><DialogDescription>{copy.sudoDesc}</DialogDescription></DialogHeader>+ {request.command?.trim() ? (+ <Field label={t.assistant.approval.command}>+ <LogView+ aria-label={t.assistant.approval.command}+ className="max-h-48 text-xs text-foreground"+ role="region"+ tabIndex={0}+ >+ {request.command}+ </LogView>+ </Field>+ ) : (+ <p className="text-xs text-(--ui-text-secondary)" role="status">+ {copy.sudoCommandUnavailable}+ </p>+ )}+<form className="grid gap-3" onSubmit={onSubmit}><InputautoFocusdiff --git a/apps/desktop/src/components/ui/dialog.tsx b/apps/desktop/src/components/ui/dialog.tsxindex 62fb0d7f78e..1acd8d62b05 100644--- a/apps/desktop/src/components/ui/dialog.tsx+++ b/apps/desktop/src/components/ui/dialog.tsx@@ -23,11 +23,18 @@ function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Creturn <DialogPrimitive.Close data-slot="dialog-close" {...props} />}-function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {+function DialogOverlay({+ className,+ blur = true,+ ...props+}: React.ComponentProps<typeof DialogPrimitive.Overlay> & {+ blur?: boolean+}) {return (<DialogPrimitive.OverlayclassName={cn(- 'fixed inset-0 z-(--z-modal-backdrop) pointer-events-auto bg-black/22 backdrop-blur-[0.125rem] data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0',+ 'fixed inset-0 z-(--z-modal-backdrop) pointer-events-auto bg-black/22 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0',+ blur && 'backdrop-blur-[0.125rem]',className)}data-slot="dialog-overlay"@@ -68,12 +75,15 @@ function DialogContent({children,showCloseButton = true,fitContent = false,+ blurBackdrop = true,banner,bannerTone = 'error',onOpenAutoFocus,...props}: React.ComponentProps<typeof DialogPrimitive.Content> & {showCloseButton?: boolean+ // Keep the underlying task readable for context-sensitive prompts.+ blurBackdrop?: boolean// Size the dialog to its content (capped at the viewport) instead of the// default fixed `max-w-lg`. For content that has no intrinsic width (grids,// full-width inputs) pair it with a `min-w-*` in `className`.@@ -127,7 +137,7 @@ function DialogContent({if (banner) {return (<DialogPortal>- <DialogOverlay />+ <DialogOverlay blur={blurBackdrop} /><DialogPrimitive.ContentclassName={cn(// The same split as the plain variant. The shell must not clip,@@ -178,7 +188,7 @@ function DialogContent({return (<DialogPortal>- <DialogOverlay />+ <DialogOverlay blur={blurBackdrop} /><DialogPrimitive.ContentclassName={cn(// The SHELL: position, size, and skin. It has no overflow of its own,diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 28b079806db..f06a030c0e6 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -3075,7 +3075,8 @@ export const ar = defineLocale({sudoSendFailed: 'فشل إرسال كلمة مرور sudo',secretSendFailed: 'فشل إرسال السر',sudoTitle: 'مطلوب sudo',- sudoDesc: 'أدخل كلمة المرور لمتابعة الأمر.',+ sudoDesc: 'راجع الأمر قبل إدخال كلمة مرور sudo. تُرسل كلمة المرور إلى الوكيل الذي ينفّذه وتُحفظ مؤقتًا لهذه الجلسة.',+ sudoCommandUnavailable: 'لم يقدّم هذا الوكيل الأمر. ألغِ الطلب إذا لم تتمكن من التحقق منه في المحادثة.',sudoPlaceholder: 'كلمة المرور',secretTitle: 'مطلوب سر',secretDesc: 'أدخل القيمة المطلوبة لمتابعة المهمة.',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex d8a922232f3..30d44360e30 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -4060,7 +4060,8 @@ export const en: Translations = {sudoSendFailed: 'Could not send sudo password',secretSendFailed: 'Could not send secret',sudoTitle: 'Administrator password',- sudoDesc: 'Hermes needs your sudo password to run a privileged command. It is sent only to your local agent.',+ sudoDesc: 'Review the command before entering your sudo password. Your password is sent to the agent running it and cached for this session.',+ sudoCommandUnavailable: 'This agent did not provide the command. Cancel if you cannot verify it in the conversation.',sudoPlaceholder: 'sudo password',secretTitle: 'Secret required',secretDesc: 'Hermes needs a credential to continue.',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 980f7476de1..a6867ac7e3f 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -3481,7 +3481,8 @@ export const ja = defineLocale({secretSendFailed: 'シークレットを送信できませんでした',sudoTitle: '管理者パスワード',sudoDesc:- 'Hermes は特権コマンドを実行するために sudo パスワードが必要です。ローカルエージェントにのみ送信されます。',+ 'sudo パスワードを入力する前にコマンドを確認してください。パスワードは実行するエージェントに送信され、このセッション中キャッシュされます。',+ sudoCommandUnavailable: 'エージェントからコマンドが提供されていません。会話で確認できない場合はキャンセルしてください。',sudoPlaceholder: 'sudo パスワード',secretTitle: 'シークレットが必要です',secretDesc: 'Hermes は続行するための認証情報が必要です。',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex 0862449f1ba..501d7504b15 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -3773,7 +3773,8 @@ export const ru = defineLocale({secretSendFailed: 'Не удалось отправить секрет',sudoTitle: 'Пароль администратора',sudoDesc:- 'Hermes нужен ваш пароль sudo, чтобы выполнить команду с повышенными правами. Он отправляется только вашему локальному агенту.',+ 'Проверьте команду перед вводом пароля sudo. Пароль отправляется агенту, который её выполняет, и кэшируется на время сеанса.',+ sudoCommandUnavailable: 'Агент не предоставил команду. Отмените запрос, если не можете проверить её в разговоре.',sudoPlaceholder: 'пароль sudo',secretTitle: 'Требуется секрет',secretDesc: 'Hermes нужны учётные данные, чтобы продолжить.',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 3aebea58703..8d7f9faa8bf 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -3551,6 +3551,7 @@ export interface Translations {secretSendFailed: stringsudoTitle: stringsudoDesc: string+ sudoCommandUnavailable: stringsudoPlaceholder: stringsecretTitle: stringsecretDesc: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 217a6abff9c..7f076a766e0 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -3405,7 +3405,8 @@ export const zhHant = defineLocale({sudoSendFailed: '無法傳送 sudo 密碼',secretSendFailed: '無法傳送密鑰',sudoTitle: '管理員密碼',- sudoDesc: 'Hermes 需要您的 sudo 密碼來執行特權指令。它只會傳送給您的本機代理。',+ sudoDesc: '輸入 sudo 密碼前,請先確認指令。密碼會傳送給執行指令的代理,並在本次工作階段中快取。',+ sudoCommandUnavailable: '此代理未提供指令。如果無法在對話中確認,請取消。',sudoPlaceholder: 'sudo 密碼',secretTitle: '需要密鑰',secretDesc: 'Hermes 需要一個憑證才能繼續。',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 929178f2bca..36402d34733 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -4202,7 +4202,8 @@ export const zh = defineLocale({sudoSendFailed: '无法发送 sudo 密码',secretSendFailed: '无法发送密钥',sudoTitle: '管理员密码',- sudoDesc: 'Hermes 需要你的 sudo 密码来运行特权命令。它只会发送给你的本地 agent。',+ sudoDesc: '输入 sudo 密码前,请先检查命令。密码会发送给执行命令的 agent,并在本次会话中缓存。',+ sudoCommandUnavailable: '此 agent 未提供命令。如果无法在对话中确认,请取消。',sudoPlaceholder: 'sudo 密码',secretTitle: '需要密钥',secretDesc: 'Hermes 需要一个凭据才能继续。',diff --git a/apps/desktop/src/store/prompts.ts b/apps/desktop/src/store/prompts.tsindex 489b45d55db..5e4d5382c01 100644--- a/apps/desktop/src/store/prompts.ts+++ b/apps/desktop/src/store/prompts.ts@@ -103,6 +103,7 @@ interface PendingApprovalPayload {}export interface SudoRequest extends KeyedPrompt {+ command?: stringrequestId: string}