github / github/copilot-cli

Hook `ask` decisions show raw JSON instead of diff view

Offen
#4,135 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

area:permissions area:terminal-rendering
Vorherrschende Sprache
Shell
Sterne
11.2k
Forks
1.9k
Ø Merge
14 Std. 16 Min.
Gemergte PRs (30 T.)
6

Beschreibung

Describe the bug

Copilot CLI normally shows a rich diff/content view when asking permission to create or edit a file. However, when the ask decision comes from a PreToolUse hook (i.e. the hook returns {"permissionDecision": "ask", "permissionDecisionReason": "..."}) rather than from the default built-in ask-before-write behavior, that rich diff view does not get triggered.

Instead, the "Hook permission request" dialog renders the permissionDecisionReason correctly as readable yellow text, but shows the proposed change as a single JSON line containing the raw tool input (file path plus the entire file content field), hard-wrapped at the current terminal width. For a file write/edit with non-trivial content this becomes a wall of wrapped JSON (quotes, escaped \n, braces, etc.) that is effectively unreadable, instead of the normal diff view Copilot CLI already has and uses elsewhere.

Affected version
$ copilot --version
GitHub Copilot CLI 1.0.70.
Steps to reproduce the behavior
  1. Configure a PreToolUse hook script for Copilot CLI (a hook that reads the tool-call JSON from stdin and can return a permission decision).
  2. Have the hook return an ask decision for a file create/edit tool call, e.g.:
    {
      "permissionDecision": "ask",
      "permissionDecisionReason": "Human review requested for this file write."
    }
    
  3. Trigger a tool call that creates or edits a file with non-trivial (multi-line) content.
  4. Observe the "Hook permission request" dialog that Copilot CLI shows: compare it to the normal ask-before-write dialog (without a hook forcing ask), which renders a proper diff/content view for the same kind of file change.
Expected behavior
  • The permissionDecisionReason should display as it currently does (readable yellow text) — this part works correctly.
  • When the ask decision is produced by a hook for a file create/edit tool, the dialog should render the proposed change using the same rich diff/content view Copilot CLI already uses for its default ask-before-write flow, instead of falling back to a single wrapped line of raw JSON tool input.
Additional context
  • OS: Windows 11
  • CPU architecture: x86_64
  • Terminal: Windows Terminal
  • Shell: PowerShell 7 — note that Copilot CLI runs its own tool calls (including file create/edit) via its internal PowerShell invocation regardless of the interactive shell, so this shouldn't affect reproduction

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das Problem über einen PreToolUse-Hook, der für das Erstellen oder Bearbeiten einer mehrzeiligen Datei eine ask-Entscheidung zurückgibt, und vergleiche den Hook permission request-Dialog mit dem standardmäßigen ask-before-write-Ablauf. Verfolge den Einstiegspunkt für hook permission request und die bestehende diff/content view; abgeschlossen ist die Aufgabe, wenn der Hook-Pfad den lesbaren Grund beibehält und dieselbe Rich View anstelle von umbrochenem rohem JSON verwendet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell, shell
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.