Skip to content

feat: Add configurable permission detail display for tool calls#636

Open
lazyskulptor wants to merge 1 commit into
xenodium:mainfrom
lazyskulptor:fix-617-permission-detail-display
Open

feat: Add configurable permission detail display for tool calls#636
lazyskulptor wants to merge 1 commit into
xenodium:mainfrom
lazyskulptor:fix-617-permission-detail-display

Conversation

@lazyskulptor

Copy link
Copy Markdown

Summary

Add support for displaying tool-specific details (like eval-elisp expressions) in permission dialogs with syntax-highlighted code fences.

Problem

When OpenCode (or other agents) sends tool calls like emacs_eval-elisp, the permission dialog only shows the tool title without the actual expression being evaluated. This makes it hard for users to understand what code will be executed.

The previous fix (#619) addressed the timing issue of rawInput arriving late, but didn't add support for displaying the expression field specifically.

Solution

Introduce configurable mappings to extract and display meaningful details from rawInput:

New defcustoms

  1. agent-shell-permission-detail-field-map: Maps tool call titles to their rawInput field names

    • Default: emacs_eval-elispexpression, org-searchmatch, org-roam-searchquery
  2. agent-shell-permission-language-map: Maps tool call titles to code fence languages

    • Default: Bashconsole, emacs_eval-elispelisp

Heuristic fallback

When no mapping exists, the code extracts the longest string value (≥20 chars, not a URL) from rawInput as a fallback.

Example

Before:

⚠ Tool Permission ⚠
emacs_eval-elisp

After:

⚠ Tool Permission ⚠
```elisp
(+ 100 200 300)

## Changes

- Add `agent-shell-permission-detail-field-map` defcustom
- Add `agent-shell-permission-language-map` defcustom  
- Add `agent-shell--extract-permission-detail` function
- Add `agent-shell--extract-detail-from-raw-input` function
- Add `agent-shell--get-permission-language` function
- Update `agent-shell--permission-title` to use the new functions

## Backward Compatibility

- Existing `command` and `filepath` handling is preserved
- Bash commands continue to work with `console` code fence
- The `(equal (map-elt tool-call :kind) "execute")` check is kept for tools without language mapping

Fixes #617

Add support for displaying tool-specific details (like eval-elisp
expressions) in permission dialogs with syntax-highlighted code fences.

New features:
- agent-shell-permission-detail-field-map: Maps tool titles to their
  rawInput field names for detail extraction
- agent-shell-permission-language-map: Maps tool titles to code fence
  languages for syntax highlighting
- Heuristic fallback: When no mapping exists, extracts the longest
  string value from rawInput as detail

Default mappings include:
- emacs_eval-elisp → expression field with elisp highlighting
- org-search → match field
- org-roam-search → query field
- Bash → console highlighting (backward compatible)

Fixes xenodium#617
@xenodium

xenodium commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR.

I'm a little worried about mering further logic (specially MCP-specific) into the permission dialog. Couldn't this be fixed by getting the MCPs to report details outside of rawInput? Maybe fix there instead?

@xenodium

xenodium commented Jun 8, 2026

Copy link
Copy Markdown
Owner

I've extended #632 in 718d338 which is more on the generic side of things. Please try that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants