Skip to content

Commit fee2ace

Browse files
authored
fix: Stop renderer from overriding plan approval permission mode (#1523)
1 parent f600d9a commit fee2ace

1 file changed

Lines changed: 13 additions & 23 deletions

File tree

apps/code/src/renderer/features/sessions/components/SessionView.tsx

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
import { useDraftStore } from "@features/message-editor/stores/draftStore";
88
import {
99
cycleModeOption,
10-
flattenSelectOptions,
1110
useModeConfigOptionForTask,
1211
usePendingPermissionsForTask,
1312
} from "@features/sessions/stores/sessionStore";
@@ -102,28 +101,17 @@ export function SessionView({
102101
const currentModeId = modeOption?.currentValue;
103102

104103
useEffect(() => {
105-
if (
106-
!allowBypassPermissions &&
107-
(currentModeId === "bypassPermissions" ||
108-
currentModeId === "full-access") &&
109-
taskId &&
110-
modeOption
111-
) {
112-
const options = flattenSelectOptions(modeOption.options);
113-
const safeOption =
114-
options.find(
115-
(opt) =>
116-
opt.value !== "bypassPermissions" && opt.value !== "full-access",
117-
) ?? options[0];
118-
if (safeOption) {
119-
getSessionService().setSessionConfigOptionByCategory(
120-
taskId,
121-
"mode",
122-
safeOption.value,
123-
);
124-
}
104+
if (allowBypassPermissions) return;
105+
const isBypass =
106+
currentModeId === "bypassPermissions" || currentModeId === "full-access";
107+
if (isBypass && taskId) {
108+
getSessionService().setSessionConfigOptionByCategory(
109+
taskId,
110+
"mode",
111+
"default",
112+
);
125113
}
126-
}, [allowBypassPermissions, currentModeId, taskId, modeOption]);
114+
}, [allowBypassPermissions, currentModeId, taskId]);
127115

128116
const handleModeChange = useCallback(() => {
129117
if (!taskId) return;
@@ -246,7 +234,9 @@ export function SessionView({
246234
const selectedOption = firstPendingPermission.options.find(
247235
(o) => o.optionId === optionId,
248236
);
249-
if (selectedOption?.kind === "allow_always") {
237+
const isModeSwitch =
238+
firstPendingPermission.toolCall?.kind === "switch_mode";
239+
if (selectedOption?.kind === "allow_always" && !isModeSwitch) {
250240
getSessionService().setSessionConfigOptionByCategory(
251241
taskId,
252242
"mode",

0 commit comments

Comments
 (0)