Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lua/opencode/ui/permission_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ function M.remove_permission(permission_id)
else
M._setup_dialog() -- Setup dialog for next permission
end

require('opencode.ui.renderer.events').render_permissions_display()
end

---Get currently selected permission (always the first one now)
Expand Down Expand Up @@ -274,6 +276,10 @@ function M._setup_dialog()
end

local function on_select(index)
if M._processing then
return
end

if not check_focused() then
return
end
Expand All @@ -284,23 +290,21 @@ function M._setup_dialog()
end

M._processing = true
require('opencode.ui.renderer.events').render_permissions_display()
M._clear_dialog()

local api = require('opencode.api')
local actions = { 'accept', 'deny', 'accept_all' }
local action = actions[index]

vim.defer_fn(function()
vim.schedule(function()
if action then
local api_func = api['permission_' .. action]
if api_func then
api_func(permission)
end
end
M.remove_permission(permission.id)
M._processing = false
end, 50)
M.remove_permission(permission.id)
end)
end

local function on_navigate()
Expand Down Expand Up @@ -346,7 +350,8 @@ function M.restore_pending_permissions(session_id)
return Promise.new():resolve(nil)
end

return state.api_client:list_permissions()
return state.api_client
:list_permissions()
:and_then(function(permissions)
if not permissions or type(permissions) ~= 'table' then
return
Expand Down
7 changes: 0 additions & 7 deletions lua/opencode/ui/renderer/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,6 @@ function M.on_permission_replied(properties)

permission_window.remove_permission(permission_id)
state.renderer.set_pending_permissions(vim.deepcopy(permission_window.get_all_permissions()))

if #state.pending_permissions == 0 then
flush.queue_part_removal('permission-display-part')
flush.queue_message_removal('permission-display-message')
else
M.render_permissions_display()
end
end

---Handle question.asked — show the question picker UI
Expand Down
Loading