diff --git a/apps/code/src/renderer/features/sessions/components/SessionView.tsx b/apps/code/src/renderer/features/sessions/components/SessionView.tsx index 2a4de53f1..5ce4716fc 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"; @@ -102,28 +101,17 @@ export function SessionView({ const currentModeId = modeOption?.currentValue; useEffect(() => { - if ( - !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) { - getSessionService().setSessionConfigOptionByCategory( - taskId, - "mode", - safeOption.value, - ); - } + if (allowBypassPermissions) return; + const isBypass = + currentModeId === "bypassPermissions" || currentModeId === "full-access"; + if (isBypass && taskId) { + getSessionService().setSessionConfigOptionByCategory( + taskId, + "mode", + "default", + ); } - }, [allowBypassPermissions, currentModeId, taskId, modeOption]); + }, [allowBypassPermissions, currentModeId, taskId]); const handleModeChange = useCallback(() => { if (!taskId) return; @@ -246,7 +234,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",