github / github/copilot-cli

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

Đang mở
#4,135 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

area:permissions area:terminal-rendering
Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện vấn đề thông qua một hook PreToolUse trả về quyết định ask cho việc tạo hoặc chỉnh sửa tệp nhiều dòng, sau đó so sánh hộp thoại Hook permission request với luồng ask-before-write mặc định. Truy vết điểm truy cập của hook permission request và diff/content view hiện có; hoàn tất khi đường đi của hook giữ nguyên lý do dễ đọc và sử dụng cùng rich view đó thay vì JSON thô bị ngắt dòng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
powershell, shell
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.