Skip to content

Commit 87e229d

Browse files
committed
feat(chat): show tool approval feedback
1 parent 0fcc5aa commit 87e229d

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

lua/codecompanion/interactions/chat/helpers/approval_prompt.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local config = require("codecompanion.config")
2+
local labels = require("codecompanion.interactions.chat.tools.labels")
23
local log = require("codecompanion.utils.log")
34
local ui_utils = require("codecompanion.utils.ui")
45
local utils = require("codecompanion.utils")
@@ -83,6 +84,14 @@ function M.request(chat, opts)
8384
end
8485
resolved = true
8586
cleanup_keymaps(bufnr, opts.choices)
87+
local is_rejection = labels.is_rejection(choice_label)
88+
local icons = config.display.chat.icons
89+
local icon = is_rejection and icons.tool_failure or icons.tool_success
90+
local status = is_rejection and "failed" or "completed"
91+
chat:add_buf_message(
92+
{ content = fmt("%s%s\n\n", icon, choice_label) },
93+
{ _icon_info = { has_icon = true, status = status } }
94+
)
8695
utils.fire("ToolApprovalFinished", { bufnr = bufnr, choice = choice_label })
8796
end
8897

lua/codecompanion/interactions/chat/tools/labels.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ M.reject = "Reject"
77
M.reject_always = "Reject always"
88
M.cancel = "Cancel"
99

10+
---Check if a label represents a rejection
11+
---@param label string
12+
---@return boolean
13+
function M.is_rejection(label)
14+
return label == M.reject or label == M.reject_always or label == M.cancel
15+
end
16+
1017
---Get the resolved keymap keys from shared config
1118
---@return table<string, string>
1219
function M.keymaps()

0 commit comments

Comments
 (0)