* Persist denial tracking state. For async subagents with localDenialTracking, * mutate the local state in place (since setAppState is a no-op). Otherwise, * write to appState as usual.
( context: ToolUseContext, newState: DenialTrackingState, )
| 961 | * write to appState as usual. |
| 962 | */ |
| 963 | function persistDenialState( |
| 964 | context: ToolUseContext, |
| 965 | newState: DenialTrackingState, |
| 966 | ): void { |
| 967 | if (context.localDenialTracking) { |
| 968 | Object.assign(context.localDenialTracking, newState) |
| 969 | } else { |
| 970 | context.setAppState(prev => { |
| 971 | // recordSuccess returns the same reference when state is |
| 972 | // unchanged. Returning prev here lets store.setState's Object.is check |
| 973 | // skip the listener loop entirely. |
| 974 | if (prev.denialTracking === newState) return prev |
| 975 | return { ...prev, denialTracking: newState } |
| 976 | }) |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | /** |
| 981 | * Check if a denial limit was exceeded and return an 'ask' result |
no outgoing calls
no test coverage detected