|
7 | 7 | import { useDraftStore } from "@features/message-editor/stores/draftStore"; |
8 | 8 | import { |
9 | 9 | cycleModeOption, |
10 | | - flattenSelectOptions, |
11 | 10 | useModeConfigOptionForTask, |
12 | 11 | usePendingPermissionsForTask, |
13 | 12 | } from "@features/sessions/stores/sessionStore"; |
@@ -102,28 +101,17 @@ export function SessionView({ |
102 | 101 | const currentModeId = modeOption?.currentValue; |
103 | 102 |
|
104 | 103 | 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 | + ); |
125 | 113 | } |
126 | | - }, [allowBypassPermissions, currentModeId, taskId, modeOption]); |
| 114 | + }, [allowBypassPermissions, currentModeId, taskId]); |
127 | 115 |
|
128 | 116 | const handleModeChange = useCallback(() => { |
129 | 117 | if (!taskId) return; |
@@ -246,7 +234,9 @@ export function SessionView({ |
246 | 234 | const selectedOption = firstPendingPermission.options.find( |
247 | 235 | (o) => o.optionId === optionId, |
248 | 236 | ); |
249 | | - if (selectedOption?.kind === "allow_always") { |
| 237 | + const isModeSwitch = |
| 238 | + firstPendingPermission.toolCall?.kind === "switch_mode"; |
| 239 | + if (selectedOption?.kind === "allow_always" && !isModeSwitch) { |
250 | 240 | getSessionService().setSessionConfigOptionByCategory( |
251 | 241 | taskId, |
252 | 242 | "mode", |
|
0 commit comments