@@ -26,7 +26,13 @@ interface CommandExecutionProps {
2626
2727export const CommandExecution = ( { executionId, text, icon, title } : CommandExecutionProps ) => {
2828 const { t } = useAppTranslation ( )
29- const { terminalShellIntegrationDisabled = false , allowedCommands = [ ] , deniedCommands = [ ] } = useExtensionState ( )
29+ const {
30+ terminalShellIntegrationDisabled = false ,
31+ allowedCommands = [ ] ,
32+ deniedCommands = [ ] ,
33+ setAllowedCommands,
34+ setDeniedCommands,
35+ } = useExtensionState ( )
3036
3137 const { command, output : parsedOutput , suggestions } = useMemo ( ( ) => parseCommandAndOutput ( text ) , [ text ] )
3238
@@ -251,13 +257,15 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
251257 if ( isWhitelisted ) {
252258 // Remove from whitelist
253259 const updatedAllowedCommands = allowedCommands . filter ( ( p ) => p !== pattern )
260+ setAllowedCommands ( updatedAllowedCommands )
254261 vscode . postMessage ( {
255262 type : "allowedCommands" ,
256263 commands : updatedAllowedCommands ,
257264 } )
258265 } else {
259266 // Add to whitelist
260267 const updatedAllowedCommands = [ ...allowedCommands , pattern ]
268+ setAllowedCommands ( updatedAllowedCommands )
261269 vscode . postMessage ( {
262270 type : "allowedCommands" ,
263271 commands : updatedAllowedCommands ,
@@ -266,14 +274,15 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
266274 // If it's in the denied list, remove it
267275 if ( deniedCommands . includes ( pattern ) ) {
268276 const updatedDeniedCommands = deniedCommands . filter ( ( p ) => p !== pattern )
277+ setDeniedCommands ( updatedDeniedCommands )
269278 vscode . postMessage ( {
270279 type : "deniedCommands" ,
271280 commands : updatedDeniedCommands ,
272281 } )
273282 }
274283 }
275284 } ,
276- [ allowedCommands , deniedCommands ] ,
285+ [ allowedCommands , deniedCommands , setAllowedCommands , setDeniedCommands ] ,
277286 )
278287
279288 const handleDenyPatternChange = useCallback (
@@ -285,13 +294,15 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
285294 if ( isDenied ) {
286295 // Remove from deny list
287296 const updatedDeniedCommands = deniedCommands . filter ( ( p ) => p !== pattern )
297+ setDeniedCommands ( updatedDeniedCommands )
288298 vscode . postMessage ( {
289299 type : "deniedCommands" ,
290300 commands : updatedDeniedCommands ,
291301 } )
292302 } else {
293303 // Add to deny list
294304 const updatedDeniedCommands = [ ...deniedCommands , pattern ]
305+ setDeniedCommands ( updatedDeniedCommands )
295306 vscode . postMessage ( {
296307 type : "deniedCommands" ,
297308 commands : updatedDeniedCommands ,
@@ -300,14 +311,15 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
300311 // If it's in the allowed list, remove it
301312 if ( allowedCommands . includes ( pattern ) ) {
302313 const updatedAllowedCommands = allowedCommands . filter ( ( p ) => p !== pattern )
314+ setAllowedCommands ( updatedAllowedCommands )
303315 vscode . postMessage ( {
304316 type : "allowedCommands" ,
305317 commands : updatedAllowedCommands ,
306318 } )
307319 }
308320 }
309321 } ,
310- [ deniedCommands , allowedCommands ] ,
322+ [ deniedCommands , allowedCommands , setDeniedCommands , setAllowedCommands ] ,
311323 )
312324
313325 return (
0 commit comments