The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): show the real command on plugin-rule approval cards
Hermes Agent96e036e326e5
diff --git a/apps/desktop/src/components/assistant-ui/tool/approval.test.tsx b/apps/desktop/src/components/assistant-ui/tool/approval.test.tsxindex 87f97f2349b..0efbffc18c9 100644--- a/apps/desktop/src/components/assistant-ui/tool/approval.test.tsx+++ b/apps/desktop/src/components/assistant-ui/tool/approval.test.tsx@@ -82,6 +82,45 @@ describe('PendingApprovalStack', () => {expect(screen.getByRole('button', { name: /Reject/ })).toBeTruthy()})+ it('renders the description instead of a synthetic plugin-rule placeholder', () => {+ // A pre_tool_call plugin returning {"action": "approve"} escalates through+ // the same gate with a synthetic display target; the real command lives in+ // the description. The card must show what would actually run.+ setRequest('<terminal> (plugin approval rule)', undefined, { requestId: 'apr-synth' })+ // setRequest stamps a generic description; overwrite with the plugin one.+ $approvalRequest.get() && setApprovalRequest({+ command: '<terminal> (plugin approval rule)',+ description: 'Plugin requires approval for terminal: run\npwd',+ requestId: 'apr-synth',+ sessionId: 'sess-1'+ })+ render(<PendingApprovalStack />)++ expect(screen.getByText(/Plugin requires approval for terminal: run/)).toBeTruthy()+ expect(screen.getByText(/pwd/)).toBeTruthy()+ expect(screen.queryByText(/plugin approval rule/)).toBeNull()+ })++ it('keeps showing the real command for ordinary dangerous-command approvals', () => {+ setRequest('chmod -R 777 /tmp/x')+ render(<PendingApprovalStack />)++ expect(screen.getByText('chmod -R 777 /tmp/x')).toBeTruthy()+ })++ it('falls back to the description when a request carries no command at all', () => {+ setRequest('', undefined, { requestId: 'apr-nocmd' })+ setApprovalRequest({+ command: '',+ description: 'Approve config change: allow SSH tunnel',+ requestId: 'apr-nocmd',+ sessionId: 'sess-1'+ })+ render(<PendingApprovalStack />)++ expect(screen.getByText('Approve config change: allow SSH tunnel')).toBeTruthy()+ })+it('answers the live approval request with {choice: "once"} and clears the request on Run', async () => {const request = mockGateway()const respond = liveApproval()diff --git a/apps/desktop/src/components/assistant-ui/tool/approval.tsx b/apps/desktop/src/components/assistant-ui/tool/approval.tsxindex e09492edc2c..03184dc3b50 100644--- a/apps/desktop/src/components/assistant-ui/tool/approval.tsx+++ b/apps/desktop/src/components/assistant-ui/tool/approval.tsx@@ -275,6 +275,15 @@ const ApprovalCard: FC<ApprovalCardProps> = ({ request, total, position, stack }const allowAlways = choices ? choices.includes('always') : allowPermanentconst hasMoreOptions = allowSession || allowAlwaysconst hasCommand = request.command.trim().length > 0+ // A plugin `approve` rule escalates through the same gate with a synthetic+ // display target (`<tool> (plugin approval rule)`) while the real command /+ // change lives in `description` — the user approves a label they cannot act+ // on otherwise. Show the description whenever the command is missing or one+ // of these synthetic labels; a real command keeps rendering as the command.+ const SYNTHETIC_COMMAND_RE = /^<[^>]+> \(/+ const showsDescription =+ !hasCommand || SYNTHETIC_COMMAND_RE.test(request.command.trim())+ const details = showsDescription ? request.description.trim() : request.command.trim()const respond = useCallback(async (choice: ApprovalChoice) => {@@ -318,16 +327,16 @@ const ApprovalCard: FC<ApprovalCardProps> = ({ request, total, position, stack }><div className="flex items-center gap-2 px-2.5 pt-2 text-xs text-(--ui-text-secondary)"><Codicon name="terminal" size="0.875rem" />- <span>{copy.command}</span>+ <span>{showsDescription ? copy.commandDetails : copy.command}</span>{total > 1 && (<span className="ml-auto text-[0.6875rem] tabular-nums text-(--ui-text-tertiary)">{position} / {total}</span>)}</div>- {hasCommand && (+ {details.length > 0 && (<pre className="m-0 max-h-40 overflow-auto whitespace-pre-wrap break-words px-2.5 py-2 font-mono text-xs leading-relaxed text-(--ui-text-primary)">- {request.command}+ {details}</pre>)}<div className="flex items-center justify-end gap-1.5 px-2 pb-2 pt-1" data-slot="tool-approval-actions">diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 9915fe36024..0496caa058f 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -5190,6 +5190,7 @@ export const en: Translations = {openSafetySettings: 'Open Safety settings',run: 'Run',command: 'Command',+ commandDetails: 'Command details',moreOptions: 'More approval options',allowSession: 'Allow this session',alwaysAllowMenu: 'Always allow…',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 201d9f95c37..9b9703682ef 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -4321,6 +4321,7 @@ export interface Translations {openSafetySettings: stringrun: stringcommand: string+ commandDetails: stringmoreOptions: stringallowSession: stringalwaysAllowMenu: string