Skip to content

Commit ded0a5e

Browse files
committed
Make command more prominent for Copilot #229
1. Show command in permission dialogs 2. Upgrade section titles when command is known
1 parent 8952d26 commit ded0a5e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

agent-shell.el

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,11 @@ otherwise returns COMMAND unchanged."
922922
"bash"))
923923
(command (map-nested-elt update '(rawInput command))))
924924
(list (cons :title command)))
925+
(when-let* ((title (or (map-nested-elt state `(:tool-calls ,.toolCallId :title)) ""))
926+
(command (or (map-nested-elt update '(rawInput command))
927+
(map-nested-elt state `(:tool-calls ,.toolCallId :command))))
928+
(should-upgrade-title (not (string-match command title))))
929+
(list (cons :title (concat command " " title))))
925930
(when-let ((diff (agent-shell--make-diff-info :tool-call update)))
926931
(list (cons :diff diff)))))
927932
(let* ((diff (map-nested-elt state `(:tool-calls ,.toolCallId :diff)))
@@ -3224,6 +3229,15 @@ For example:
32243229
(with-current-buffer shell-buffer
32253230
(agent-shell-interrupt t))))
32263231
map))
3232+
(title (let ((title (map-nested-elt request '(params toolCall title)))
3233+
(command (map-nested-elt request '(params toolCall rawInput command))))
3234+
;; Some agents don't include the command in the
3235+
;; permission/tool call title, so it's hard to know
3236+
;; what the permission is actually allowing.
3237+
;; Display command if needed.
3238+
(if (string-match command title)
3239+
title
3240+
(or command title))))
32273241
(diff-button (when diff
32283242
(agent-shell--make-permission-button
32293243
:text "View (v)"
@@ -3253,9 +3267,9 @@ For example:
32533267
(propertize "Tool Permission" 'font-lock-face 'bold)
32543268
(propertize agent-shell-permission-icon
32553269
'font-lock-face 'warning)
3256-
(if (map-nested-elt request '(params toolCall title))
3270+
(if title
32573271
(propertize
3258-
(format "\n\n\n %s" (map-nested-elt request '(params toolCall title)))
3272+
(format "\n\n\n %s" title)
32593273
'font-lock-face 'comint-highlight-input)
32603274
"")
32613275
(if diff-button

0 commit comments

Comments
 (0)