github / github/copilot-cli

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

Ouverte
#4,135 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

area:permissions area:terminal-rendering
Langage dominant
Shell
Étoiles
11.2k
Forks
1.9k
Merge moyen
14 h 16 min
PR mergées (30 j)
6

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Reproduisez le problème via un hook PreToolUse qui renvoie une décision ask pour la création ou la modification d’un fichier multiligne, puis comparez la boîte de dialogue Hook permission request avec le flux ask-before-write par défaut. Suivez le point d’entrée de hook permission request et la diff/content view existante ; le travail est terminé lorsque le chemin du hook conserve la raison lisible et utilise cette même vue enrichie au lieu de JSON brut renvoyé à la ligne.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
powershell, shell
Domaine
cli
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
55/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.