Skip to content

fix(chat): Show what a permission ask is actually asking - #694

Merged
omesser merged 2 commits into
mainfrom
fix/678-permission-ask-detail
Sep 14, 2026
Merged

omesser merged 2 commits into
mainfrom
fix/678-permission-ask-detail

Conversation

@omesser

@omesser omesser commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Why

A permission ask showed the tool call's kind and title and nothing else. A real ask on macOS read, in full:

BUDDY BOT · ASKS
other: Question from MCP server
[ Allow ] [ Always allow ] [ Deny ] [ Cancel ]

The question was never forwarded. The user is asked to Allow or Deny with the subject withheld — and other is ToolKind::Other, the least informative field available, given top billing.

This is the one place the product asks the user to make a security decision, and it was the place that said least. Four buttons with the subject hidden is how people learn to click Allow reflexively.

permission_ask built PermissionAsk from exactly tool_call.fields.title and .kind. ACP's ToolCallUpdateFields also carries content, raw_input and locations — all dropped on the floor. The question lived in content.

What changed

PermissionAsk now carries content, input and locations, and a new src/chat-ask.js decides what the row says:

  • Content leads. raw_input is the fallback and never appears alongside content.
  • kind rides last, and other is dropped entirely — it is noise, not information.
  • locations render, so an ask that would touch a path says which.
  • An ask with nothing to show says so plainly, rather than (untitled) or a bare kind.
  • The whole row is bounded, title included, so no field can crowd out the question.

src/chat.js assigns the result with textContent. innerHTML appears nowhere in src/*.js — verified by grep before and after — which matters because content and raw_input are untrusted: they come from a Harness and can be steered by an MCP server.

The tool name is not used, and cannot be. The issue proposed it as better than other, but pub name sits behind #[cfg(feature = "unstable_tool_call_name")] in agent-client-protocol-schema-1.7.0 and this workspace is on default features (confirmed with cargo tree). That is recorded in the permission_ask doc rather than left as a silent omission.

How to verify

cargo test -p ai-buddy
cargo clippy --workspace --all-targets -- -D warnings
node --test tests/

424 Rust tests, 124 node tests, clippy clean.

Rust tests cover the forwarding; tests/chat-ask.test.js covers what the row says. Both halves were mutation-tested and the failures observed, not assumed:

Mutation Result
drop the ContentBlock::Text arm an_ask_forwards_the_question_the_arguments_and_the_paths and the harness integration test both FAIL
remove the row's clamp the two bound tests FAIL
remove the newline/control collapse untrusted text cannot forge a line of its own FAILS
clamp only the body, not the joined row the kind and the paths are inside the budget, not after it FAILS
drop the title clamp a verbose title cannot crowd out the question FAILS

Adversarial payloads (<img src=x onerror=alert(1)>, <script>alert(1)</script>, a javascript: value) come back as literal characters; no markup is produced anywhere in the module.

Notes

  • Two review findings were declined, with reasons. A path containing the row's own · separator can forge fields — but only fields the same server already controls, and locations is advisory, so the forgery buys nothing the honest field does not; the proposed fix (stripping commas from paths) would corrupt legitimate macOS paths. And Array.isArray() guards were declined because PermissionAsk is #[derive(Serialize)] only, with no Deserialize — it is built in Rust and serialized outward, never round-tripped, so a non-array is unrepresentable and the guards would be dead code.
  • A code comment stating the chat surface is "420 points tall" was corrected: main.rs is .inner_size(420.0, 560.0), so 420 is the width.
  • The Action Log is unchanged — it still records request/title/kind only, and does not gain the arguments.
  • No GUI run. Whether a maximal row displaces the answer buttons on screen rests on the .log overflow and autoscroll behaviour, not on an observed screenshot.
  • This renders with textContent and deliberately does not interpret the content as Markdown. feat(chat): Render Markdown in a reply instead of its source #677 is adding a Markdown renderer to the same surface; whether a consent row should ever render formatted content is a separate question, and the safe default until then is that it does not.

Closes #678

— Claude Code agent, on @omesser's behalf.

🤖 Generated with Claude Code

omesser and others added 2 commits September 14, 2026 18:30
The consent row built itself from a tool call's kind and title and dropped
the rest, so `other: Question from MCP server` was the whole of what a user
had to decide on. `acp_wire.rs` now forwards the call's content, arguments
and locations, and `chat-ask.js` decides what the row says: the question
first, the arguments when there is none, the paths and the kind last, a
sentence when there is genuinely nothing. All of it untrusted, all of it
still written with `textContent`. Closes #678.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DETAIL_LIMIT clamped the question but not the kind and paths drawn after
it, so a row could reach 975 characters against a 600 budget; the title
had no bound of its own and a verbose one spent all 600 before the
question arrived. Fixes #678's own failure mode from a chatty server.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

fix(chat): A permission ask names its kind, not the question

1 participant