From f07669dc1b0f7f0446af50b03d15904987af40c9 Mon Sep 17 00:00:00 2001 From: Charles Vien Date: Tue, 7 Apr 2026 08:11:26 -0700 Subject: [PATCH 1/4] Stop renderer from overriding plan approval permission mode --- .../renderer/features/sessions/components/SessionView.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/code/src/renderer/features/sessions/components/SessionView.tsx b/apps/code/src/renderer/features/sessions/components/SessionView.tsx index 2a4de53f1..9a24e251a 100644 --- a/apps/code/src/renderer/features/sessions/components/SessionView.tsx +++ b/apps/code/src/renderer/features/sessions/components/SessionView.tsx @@ -101,8 +101,12 @@ export function SessionView({ const { allowBypassPermissions } = useSettingsStore(); const currentModeId = modeOption?.currentValue; + const prevAllowBypass = useRef(allowBypassPermissions); useEffect(() => { + const wasEnabled = prevAllowBypass.current; + prevAllowBypass.current = allowBypassPermissions; if ( + wasEnabled && !allowBypassPermissions && (currentModeId === "bypassPermissions" || currentModeId === "full-access") && @@ -246,7 +250,9 @@ export function SessionView({ const selectedOption = firstPendingPermission.options.find( (o) => o.optionId === optionId, ); - if (selectedOption?.kind === "allow_always") { + const isModeSwitch = + firstPendingPermission.toolCall?.kind === "switch_mode"; + if (selectedOption?.kind === "allow_always" && !isModeSwitch) { getSessionService().setSessionConfigOptionByCategory( taskId, "mode", From af9660b0eeff05d7bc037392fc8e925714e26b59 Mon Sep 17 00:00:00 2001 From: Charles Vien Date: Tue, 7 Apr 2026 08:45:02 -0700 Subject: [PATCH 2/4] Update SessionView.tsx --- .../sessions/components/SessionView.tsx | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/apps/code/src/renderer/features/sessions/components/SessionView.tsx b/apps/code/src/renderer/features/sessions/components/SessionView.tsx index 9a24e251a..edc40ee49 100644 --- a/apps/code/src/renderer/features/sessions/components/SessionView.tsx +++ b/apps/code/src/renderer/features/sessions/components/SessionView.tsx @@ -7,7 +7,6 @@ import { import { useDraftStore } from "@features/message-editor/stores/draftStore"; import { cycleModeOption, - flattenSelectOptions, useModeConfigOptionForTask, usePendingPermissionsForTask, } from "@features/sessions/stores/sessionStore"; @@ -103,27 +102,19 @@ export function SessionView({ const prevAllowBypass = useRef(allowBypassPermissions); useEffect(() => { - const wasEnabled = prevAllowBypass.current; + const turnedOff = prevAllowBypass.current && !allowBypassPermissions; prevAllowBypass.current = allowBypassPermissions; - if ( - wasEnabled && - !allowBypassPermissions && - (currentModeId === "bypassPermissions" || - currentModeId === "full-access") && - taskId && - modeOption - ) { - const options = flattenSelectOptions(modeOption.options); - const safeOption = - options.find( - (opt) => - opt.value !== "bypassPermissions" && opt.value !== "full-access", - ) ?? options[0]; - if (safeOption) { + + const isBypass = + currentModeId === "bypassPermissions" || currentModeId === "full-access"; + + if (turnedOff && isBypass && taskId) { + const nextMode = cycleModeOption(modeOption, false); + if (nextMode) { getSessionService().setSessionConfigOptionByCategory( taskId, "mode", - safeOption.value, + nextMode, ); } } From 036f84c213c65775e1d3b46f7ff9f8990a20f3bf Mon Sep 17 00:00:00 2001 From: Charles Vien Date: Tue, 7 Apr 2026 08:47:44 -0700 Subject: [PATCH 3/4] Update SessionView.tsx --- .../sessions/components/SessionView.tsx | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/apps/code/src/renderer/features/sessions/components/SessionView.tsx b/apps/code/src/renderer/features/sessions/components/SessionView.tsx index edc40ee49..2499faa69 100644 --- a/apps/code/src/renderer/features/sessions/components/SessionView.tsx +++ b/apps/code/src/renderer/features/sessions/components/SessionView.tsx @@ -20,7 +20,7 @@ import { isJsonRpcNotification, isJsonRpcResponse, } from "@shared/types/session-events"; -import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { useCallback, useMemo, useRef, useState } from "react"; import { useHotkeys } from "react-hotkeys-hook"; import { getSessionService } from "../service/service"; import { @@ -100,26 +100,6 @@ export function SessionView({ const { allowBypassPermissions } = useSettingsStore(); const currentModeId = modeOption?.currentValue; - const prevAllowBypass = useRef(allowBypassPermissions); - useEffect(() => { - const turnedOff = prevAllowBypass.current && !allowBypassPermissions; - prevAllowBypass.current = allowBypassPermissions; - - const isBypass = - currentModeId === "bypassPermissions" || currentModeId === "full-access"; - - if (turnedOff && isBypass && taskId) { - const nextMode = cycleModeOption(modeOption, false); - if (nextMode) { - getSessionService().setSessionConfigOptionByCategory( - taskId, - "mode", - nextMode, - ); - } - } - }, [allowBypassPermissions, currentModeId, taskId, modeOption]); - const handleModeChange = useCallback(() => { if (!taskId) return; const nextMode = cycleModeOption(modeOption, allowBypassPermissions); From 1e43cf689a122c7e40db367efcbbb0f566802297 Mon Sep 17 00:00:00 2001 From: Charles Vien Date: Tue, 7 Apr 2026 08:57:59 -0700 Subject: [PATCH 4/4] Update SessionView.tsx --- .../features/sessions/components/SessionView.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/code/src/renderer/features/sessions/components/SessionView.tsx b/apps/code/src/renderer/features/sessions/components/SessionView.tsx index 2499faa69..5ce4716fc 100644 --- a/apps/code/src/renderer/features/sessions/components/SessionView.tsx +++ b/apps/code/src/renderer/features/sessions/components/SessionView.tsx @@ -20,7 +20,7 @@ import { isJsonRpcNotification, isJsonRpcResponse, } from "@shared/types/session-events"; -import { useCallback, useMemo, useRef, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useHotkeys } from "react-hotkeys-hook"; import { getSessionService } from "../service/service"; import { @@ -100,6 +100,19 @@ export function SessionView({ const { allowBypassPermissions } = useSettingsStore(); const currentModeId = modeOption?.currentValue; + useEffect(() => { + if (allowBypassPermissions) return; + const isBypass = + currentModeId === "bypassPermissions" || currentModeId === "full-access"; + if (isBypass && taskId) { + getSessionService().setSessionConfigOptionByCategory( + taskId, + "mode", + "default", + ); + } + }, [allowBypassPermissions, currentModeId, taskId]); + const handleModeChange = useCallback(() => { if (!taskId) return; const nextMode = cycleModeOption(modeOption, allowBypassPermissions);