@@ -161,6 +161,8 @@ function M.remove_permission(permission_id)
161161 else
162162 M ._setup_dialog () -- Setup dialog for next permission
163163 end
164+
165+ require (' opencode.ui.renderer.events' ).render_permissions_display ()
164166end
165167
166168--- Get currently selected permission (always the first one now)
@@ -274,6 +276,10 @@ function M._setup_dialog()
274276 end
275277
276278 local function on_select (index )
279+ if M ._processing then
280+ return
281+ end
282+
277283 if not check_focused () then
278284 return
279285 end
@@ -284,23 +290,21 @@ function M._setup_dialog()
284290 end
285291
286292 M ._processing = true
287- require (' opencode.ui.renderer.events' ).render_permissions_display ()
288- M ._clear_dialog ()
289293
290294 local api = require (' opencode.api' )
291295 local actions = { ' accept' , ' deny' , ' accept_all' }
292296 local action = actions [index ]
293297
294- vim .defer_fn (function ()
298+ vim .schedule (function ()
295299 if action then
296300 local api_func = api [' permission_' .. action ]
297301 if api_func then
298302 api_func (permission )
299303 end
300304 end
301- M .remove_permission (permission .id )
302305 M ._processing = false
303- end , 50 )
306+ M .remove_permission (permission .id )
307+ end )
304308 end
305309
306310 local function on_navigate ()
@@ -346,7 +350,8 @@ function M.restore_pending_permissions(session_id)
346350 return Promise .new ():resolve (nil )
347351 end
348352
349- return state .api_client :list_permissions ()
353+ return state .api_client
354+ :list_permissions ()
350355 :and_then (function (permissions )
351356 if not permissions or type (permissions ) ~= ' table' then
352357 return
0 commit comments