From 6acb133efd2c07a50a5c7f18d1b05eb604fc53ce Mon Sep 17 00:00:00 2001 From: RomanBOGR Date: Fri, 11 Sep 2026 02:42:48 +0300 Subject: [PATCH] fix: show the question in AskUserQuestion permission notifications The preview in on-permission-request.sh handles .command and .file_path and falls back to tostring[0:80] for everything else. For AskUserQuestion that fallback dumps raw JSON, so the notification truncates before the question itself. Add an elif branch for .questions, plus four tests covering Bash, Write, AskUserQuestion and the unknown-tool fallback. Co-Authored-By: Claude Opus 5 (1M context) --- plugins/warp/scripts/on-permission-request.sh | 2 +- plugins/warp/tests/test-hooks.sh | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/plugins/warp/scripts/on-permission-request.sh b/plugins/warp/scripts/on-permission-request.sh index 7d46ed2..9726d88 100755 --- a/plugins/warp/scripts/on-permission-request.sh +++ b/plugins/warp/scripts/on-permission-request.sh @@ -22,7 +22,7 @@ TOOL_INPUT=$(echo "$INPUT" | jq -c '.tool_input // {}' 2>/dev/null) [ -z "$TOOL_INPUT" ] && TOOL_INPUT='{}' # Build a human-readable summary -TOOL_PREVIEW=$(echo "$INPUT" | jq -r '(.tool_input | if .command then .command elif .file_path then .file_path else (tostring | .[0:80]) end) // ""' 2>/dev/null) +TOOL_PREVIEW=$(echo "$INPUT" | jq -r '(.tool_input | if .command then .command elif .file_path then .file_path elif .questions then (.questions[0].question // "") else (tostring | .[0:80]) end) // ""' 2>/dev/null) SUMMARY="Wants to run $TOOL_NAME" if [ -n "$TOOL_PREVIEW" ]; then if [ ${#TOOL_PREVIEW} -gt 120 ]; then diff --git a/plugins/warp/tests/test-hooks.sh b/plugins/warp/tests/test-hooks.sh index 754bdd0..e679138 100755 --- a/plugins/warp/tests/test-hooks.sh +++ b/plugins/warp/tests/test-hooks.sh @@ -266,6 +266,36 @@ unset CLAUDE_CODE_VERSION HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../scripts" && pwd)" +echo "" +echo "=== Permission request preview ===" + +# Runs on-permission-request.sh end to end and pulls .summary back out of the +# OSC sequence, so the jq preview expression is covered by the suite. +permission_summary() { + echo "$1" | WARP_CLI_AGENT_PROTOCOL_VERSION=1 \ + WARP_CLIENT_VERSION="v9999.99.99.99.99.stable_99" \ + CLAUDE_CODE_VERSION="9999.0.0" \ + bash "$HOOK_DIR/on-permission-request.sh" 2>/dev/null | + jq -r '.terminalSequence // empty' | + sed 's/^.*warp:\/\/cli-agent;//' | tr -d '\007' | + jq -r '.summary // empty' +} + +echo "" +echo "--- Tool preview ---" + +assert_eq "Bash shows the command" "Wants to run Bash: git push origin main" \ + "$(permission_summary '{"tool_name":"Bash","tool_input":{"command":"git push origin main"}}')" + +assert_eq "Write shows the path" "Wants to run Write: /tmp/a.txt" \ + "$(permission_summary '{"tool_name":"Write","tool_input":{"file_path":"/tmp/a.txt","content":"hi"}}')" + +assert_eq "AskUserQuestion shows the question" "Wants to run AskUserQuestion: Deploy now or wait?" \ + "$(permission_summary '{"tool_name":"AskUserQuestion","tool_input":{"questions":[{"question":"Deploy now or wait?","header":"Deploy"}]}}')" + +assert_eq "unknown tool falls back to the raw input" 'Wants to run WebFetch: {"url":"https://example.com"}' \ + "$(permission_summary '{"tool_name":"WebFetch","tool_input":{"url":"https://example.com"}}')" + echo "" echo "=== Routing ==="