Skip to content

The agent that grows with you

fix(desktop): show approvals for protected file writes

loulanyue04154a37d3d8
diff --git a/apps/desktop/src/components/assistant-ui/tool/approval.test.tsx b/apps/desktop/src/components/assistant-ui/tool/approval.test.tsx
index 910a436f81f..aa0bf399ca0 100644
--- a/apps/desktop/src/components/assistant-ui/tool/approval.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/tool/approval.test.tsx
@@ -75,6 +75,14 @@ describe('PendingToolApproval', () => {
expect(screen.getByRole('button', { name: /Reject/ })).toBeTruthy()
})
+ it.each(['patch', 'write_file'])('renders inline approval controls for protected %s writes', toolName => {
+ setRequest('Update protected agent instructions')
+ render(<PendingToolApproval part={part(toolName)} />)
+
+ expect(screen.getByRole('button', { name: /Run/ })).toBeTruthy()
+ expect(screen.getByRole('button', { name: /Reject/ })).toBeTruthy()
+ })
+
it('sends approval.respond {choice: "once"} and clears the request on Run', async () => {
const request = mockGateway()
setRequest()
diff --git a/apps/desktop/src/components/assistant-ui/tool/approval.tsx b/apps/desktop/src/components/assistant-ui/tool/approval.tsx
index d0b3647837e..f511fb0afbe 100644
--- a/apps/desktop/src/components/assistant-ui/tool/approval.tsx
+++ b/apps/desktop/src/components/assistant-ui/tool/approval.tsx
@@ -39,12 +39,12 @@ import type { ToolPart } from './fallback-model'
// Binding is POSITIONAL, not command-matched: the desktop `tool.start` payload
// carries no structured args (only tool_id/name/context — see
// tui_gateway/server.py::_on_tool_start), so we cannot join the approval to the
-// row by command string. But `approval.request` only ever fires from the
-// `terminal` / `execute_code` guards and the agent thread blocks on exactly one
+// row by command string. `approval.request` can fire from the command guards
+// and protected-instruction file writes. The agent thread blocks on exactly one
// approval at a time, so the single pending row of those tools IS the row that
// raised it. The command/description text comes from `$approvalRequest` (the
// event payload), which is the only place that data reliably exists.
-export const APPROVAL_TOOLS = new Set(['terminal', 'execute_code'])
+export const APPROVAL_TOOLS = new Set(['terminal', 'execute_code', 'patch', 'write_file'])
// Canonical gateway choices (ui-tui/src/components/prompts.tsx).
type ApprovalChoice = 'once' | 'session' | 'always' | 'deny'