@@ -232,6 +232,7 @@ export function createRealPolicyWorkbenchState() {
232232
233233 const groupRules = ref < PolicyRuleRecord [ ] > ( [ ] )
234234 const userRules = ref < PolicyRuleRecord [ ] > ( [ ] )
235+ const explicitSystemRule = ref < PolicyRuleRecord | null > ( null )
235236
236237 const groups = ref < PolicyTargetOption [ ] > ( [ ] )
237238 const users = ref < PolicyTargetOption [ ] > ( [ ] )
@@ -278,25 +279,23 @@ export function createRealPolicyWorkbenchState() {
278279
279280 const policy = activePolicyState . value
280281 if ( ! policy ?. effectiveValue ) {
281- return null
282+ return explicitSystemRule . value
282283 }
283284
284- // A baseline "none" value means there is no explicit global rule persisted.
285- if ( activeDefinition . value . key === 'signature_flow' ) {
286- const mode = resolveSignatureFlowMode ( policy . effectiveValue )
287- const sourceScope = policy . sourceScope || 'system'
288- if ( mode === 'none' && sourceScope === 'system' ) {
289- return null
290- }
285+ const sourceScope = policy . sourceScope
286+ if ( sourceScope && sourceScope !== 'global' ) {
287+ return explicitSystemRule . value
291288 }
292289
293- return {
290+ explicitSystemRule . value = {
294291 id : 'system-default' ,
295292 scope : 'system' ,
296293 targetId : null ,
297294 allowChildOverride : inferSystemAllowOverride ( policy ) ,
298295 value : policy . effectiveValue ,
299296 }
297+
298+ return explicitSystemRule . value
300299 } )
301300
302301 const policyResolutionMode = computed < PolicyResolutionMode > ( ( ) => {
@@ -331,16 +330,20 @@ export function createRealPolicyWorkbenchState() {
331330 } )
332331
333332 const hasGlobalDefault = computed ( ( ) => {
333+ if ( explicitSystemRule . value !== null ) {
334+ return true
335+ }
336+
334337 const policy = activePolicyState . value
335338 if ( ! policy ) {
336339 return false
337340 }
338341
339- if ( policy . sourceScope === 'system' ) {
340- return false
342+ if ( ! policy . sourceScope ) {
343+ return inheritedSystemRule . value !== null
341344 }
342345
343- return inheritedSystemRule . value !== null
346+ return policy . sourceScope === 'global'
344347 } )
345348
346349 const effectiveSource = computed ( ( ) => {
@@ -551,6 +554,7 @@ export function createRealPolicyWorkbenchState() {
551554
552555 function openSetting ( key : string ) {
553556 activeSettingKey . value = key
557+ explicitSystemRule . value = null
554558 groupRules . value = [ ]
555559 userRules . value = [ ]
556560 void hydratePersistedGroupRules ( key )
@@ -786,6 +790,13 @@ export function createRealPolicyWorkbenchState() {
786790 try {
787791 if ( scope === 'system' ) {
788792 await policiesStore . saveSystemPolicy ( policyKey , value , allowChildOverride )
793+ explicitSystemRule . value = {
794+ id : 'system-default' ,
795+ scope : 'system' ,
796+ targetId : null ,
797+ allowChildOverride,
798+ value,
799+ }
789800 await policiesStore . fetchEffectivePolicies ( )
790801 cancelEditor ( )
791802 return
@@ -838,7 +849,8 @@ export function createRealPolicyWorkbenchState() {
838849 && editorDraft . value . ruleId === ruleId
839850
840851 if ( ruleId === 'system-default' || ( inheritedSystemRuleId !== null && ruleId === inheritedSystemRuleId ) ) {
841- await policiesStore . saveSystemPolicy ( policyKey , null as unknown as EffectivePolicyValue )
852+ await policiesStore . saveSystemPolicy ( policyKey , null as unknown as EffectivePolicyValue , false )
853+ explicitSystemRule . value = null
842854 highlightedRuleId . value = null
843855 await policiesStore . fetchEffectivePolicies ( )
844856 if ( shouldCloseSystemEditor ) {
0 commit comments