From 5cbbf69b08016715ca5896f033e884a724ec7125 Mon Sep 17 00:00:00 2001 From: qer Date: Wed, 24 Jun 2026 11:03:45 +0800 Subject: [PATCH] fix(web): stop auto-approving plan reviews and sensitive files in yolo mode The web app ran a client-side policy that auto-approved every approval request in auto/yolo mode, including plan reviews, sensitive file access, and other asks the daemon intentionally sends for user confirmation. The daemon already resolves auto/yolo server-side, so drop the client-side auto-approve and let those requests reach the approval UI. --- .changeset/fix-web-yolo-auto-approve.md | 5 +++++ .../composables/client/useWorkspaceState.ts | 18 +++--------------- .../src/composables/useKimiWebClient.ts | 13 ------------- 3 files changed, 8 insertions(+), 28 deletions(-) create mode 100644 .changeset/fix-web-yolo-auto-approve.md diff --git a/.changeset/fix-web-yolo-auto-approve.md b/.changeset/fix-web-yolo-auto-approve.md new file mode 100644 index 0000000000..ef70158e48 --- /dev/null +++ b/.changeset/fix-web-yolo-auto-approve.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +Fix yolo mode in the web app auto-approving plan reviews and sensitive file access. diff --git a/apps/kimi-web/src/composables/client/useWorkspaceState.ts b/apps/kimi-web/src/composables/client/useWorkspaceState.ts index 80fbd96ec9..7d0098ec1f 100644 --- a/apps/kimi-web/src/composables/client/useWorkspaceState.ts +++ b/apps/kimi-web/src/composables/client/useWorkspaceState.ts @@ -1229,25 +1229,13 @@ export function useWorkspaceState(rawState: ExtendedState, deps: UseWorkspaceSta }); } - /** Persist and apply a new permission mode; auto-approve pending approvals if switching to auto/yolo */ + /** Persist and apply a new permission mode. Approval decisions are owned by + * the daemon (auto/yolo are resolved server-side), so any pending approvals + * are left for the user to answer explicitly. */ function setPermission(mode: PermissionMode): void { rawState.permission = mode; savePermissionToStorage(mode); persistSessionProfile({ permissionMode: mode }); - - // If switching to auto/yolo, auto-approve any currently-pending approvals for the active session - if (mode === 'auto' || mode === 'yolo') { - const sid = rawState.activeSessionId; - if (sid) { - const approvals = [...(rawState.approvalsBySession[sid] ?? [])]; - for (const a of approvals) { - void respondApproval(a.approvalId, { - decision: 'approved', - scope: mode === 'yolo' ? 'session' : undefined, - }); - } - } - } } /** Dismiss a warning by index */ diff --git a/apps/kimi-web/src/composables/useKimiWebClient.ts b/apps/kimi-web/src/composables/useKimiWebClient.ts index 1f04a3f563..377615cf3a 100644 --- a/apps/kimi-web/src/composables/useKimiWebClient.ts +++ b/apps/kimi-web/src/composables/useKimiWebClient.ts @@ -730,19 +730,6 @@ function connectEventsIfNeeded(): void { ) { onSessionIdle(appEvent.sessionId, appEvent.status); } - - // Permission auto-approve: CLIENT-SIDE POLICY until the daemon exposes a - // permission endpoint. When permission is 'auto' or 'yolo' and an approval - // request arrives, immediately respond with 'approved'. - if (appEvent.type === 'approvalRequested') { - const perm = rawState.permission; - if (perm === 'auto' || perm === 'yolo') { - void workspaceState.respondApproval(appEvent.approval.approvalId, { - decision: 'approved', - scope: perm === 'yolo' ? 'session' : undefined, - }); - } - } }, onResync(sessionId: string, currentSeq: number, epoch?: string) {