@@ -36,6 +36,10 @@ import {
3636import { useAppStore , useTheme , useAnalyticsEnabled } from '@/stores' ;
3737import { UpdateChecker } from './UpdateChecker' ;
3838import { getMetaToolsEnabled , setMetaToolsEnabled } from '@/lib/api/metaTools' ;
39+ import {
40+ getSessionOverridesRequireApproval ,
41+ setSessionOverridesRequireApproval ,
42+ } from '@/lib/api/sessionOverrides' ;
3943import { MetaToolAuditLog , MetaToolGrantsPanel } from '@/features/metaTools' ;
4044import { useGatewayControl } from '@/features/gateway/useGatewayControl' ;
4145import { CONTRIBUTE , openExternal } from '@/lib/contribute' ;
@@ -78,6 +82,10 @@ export function SettingsPage() {
7882 // Meta-tools master switch — gates the entire `mcpmux_*` namespace.
7983 const [ metaToolsEnabled , setMetaToolsEnabledState ] = useState < boolean > ( true ) ;
8084 const [ loadingMetaTools , setLoadingMetaTools ] = useState ( true ) ;
85+ const [ sessionOverridesRequireApproval , setSessionOverridesRequireApprovalState ] =
86+ useState < boolean > ( false ) ;
87+ const [ loadingSessionOverrideApproval , setLoadingSessionOverrideApproval ] =
88+ useState ( true ) ;
8189
8290 // Gateway port — persisted user override, the default the app ships
8391 // with, and the port the currently-running gateway is bound to. When
@@ -181,6 +189,12 @@ export function SettingsPage() {
181189 . then ( ( v ) => setMetaToolsEnabledState ( v ) )
182190 . catch ( ( e ) => console . error ( 'Failed to load meta_tools_enabled' , e ) )
183191 . finally ( ( ) => setLoadingMetaTools ( false ) ) ;
192+ getSessionOverridesRequireApproval ( )
193+ . then ( ( v ) => setSessionOverridesRequireApprovalState ( v ) )
194+ . catch ( ( e ) =>
195+ console . error ( 'Failed to load session_overrides_require_approval' , e )
196+ )
197+ . finally ( ( ) => setLoadingSessionOverrideApproval ( false ) ) ;
184198 } , [ ] ) ;
185199
186200 const handleToggleMetaTools = async ( next : boolean ) => {
@@ -200,6 +214,23 @@ export function SettingsPage() {
200214 }
201215 } ;
202216
217+ const handleToggleSessionOverrideApproval = async ( next : boolean ) => {
218+ const previous = sessionOverridesRequireApproval ;
219+ setSessionOverridesRequireApprovalState ( next ) ;
220+ try {
221+ await setSessionOverridesRequireApproval ( next ) ;
222+ success (
223+ next ? 'Session overrides require approval' : 'Session overrides auto-allowed' ,
224+ next
225+ ? 'mcpmux_enable_server / mcpmux_disable_server (session scope) will prompt before applying.'
226+ : 'Session-scope enable/disable applies immediately without a dialog.'
227+ ) ;
228+ } catch ( e ) {
229+ setSessionOverridesRequireApprovalState ( previous ) ;
230+ error ( 'Failed to save setting' , e instanceof Error ? e . message : String ( e ) ) ;
231+ }
232+ } ;
233+
203234 // Load logs path on mount
204235 useEffect ( ( ) => {
205236 const loadLogsPath = async ( ) => {
@@ -632,6 +663,29 @@ export function SettingsPage() {
632663 data-testid = "meta-tools-enabled-switch"
633664 />
634665 </ div >
666+ < div className = "flex items-center justify-between gap-4" >
667+ < div className = "flex items-start gap-3 flex-1 min-w-0" >
668+ < AlertCircle className = "h-5 w-5 mt-0.5 text-[rgb(var(--muted))] flex-shrink-0" />
669+ < div >
670+ < label className = "text-sm font-medium" >
671+ Require approval for session-scope overrides
672+ </ label >
673+ < p className = "text-xs text-[rgb(var(--muted))] mt-1" >
674+ When on,{ ' ' }
675+ < code className = "font-mono" > mcpmux_enable_server</ code > /{ ' ' }
676+ < code className = "font-mono" > mcpmux_disable_server</ code > with{ ' ' }
677+ < code className = "font-mono" > scope: "session"</ code > show the native
678+ approval dialog. Workspace-scope writes always require approval.
679+ </ p >
680+ </ div >
681+ </ div >
682+ < Switch
683+ checked = { sessionOverridesRequireApproval }
684+ onCheckedChange = { handleToggleSessionOverrideApproval }
685+ disabled = { loadingSessionOverrideApproval || ! metaToolsEnabled }
686+ data-testid = "session-overrides-require-approval-switch"
687+ />
688+ </ div >
635689 < MetaToolGrantsPanel />
636690 < MetaToolAuditLog />
637691 </ CardContent >
0 commit comments