github / github/copilot-cli

PreToolUse hook permissionDecision: "ask" auto-approved by TUI since v1.0.53

Đang mở
#3,590 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
area:permissions area:plugins
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

When a `PreToolUse` hook returns `permissionDecision: "ask"`, the TUI permission dialog flashes on screen for milliseconds and is **immediately auto-approved** without user interaction. The hook fires correctly, the `permission.requested` event is emitted with `kind=hook`, but the prompt is resolved as `"approved"` before the user can interact with it.

**This is a regression introduced in v1.0.53 and persists in v1.0.56.** Version 1.0.52 works correctly — the permission dialog stays visible and waits for user input.

Additionally, since v1.0.53, **selection highlight colors** and **user question background colors** in the TUI appear broken (likely same root cause — a TUI rendering change).

### Affected version

- **Broken:** 1.0.53, 1.0.54, 1.0.55, 1.0.56 (all tested, all broken)
- - **Working:** 1.0.52 (prompts stay visible and wait for user interaction)

### Steps to reproduce the behavior

### Steps to reproduce

**1. Create a minimal hook (e.g. `~/.copilot/hooks/hooks.json`):**

```json
{
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"type": "command",
"command": "python3 -c \"import json,sys; d=json.load(sys.stdin); print(json.dumps({'permissionDecision':'ask','permissionDecisionReason':'Testing hook prompt'}) if d.get('toolName')=='bash' else json.dumps({}))\"",
"timeout": 5
}
]
}
]
}
}
```

**2. Start a new session:**

```bash
COPILOT_AUTO_UPDATE=false copilot
```

**3. Ask the agent to run any shell command:**

```
ls -l ~/
```

**4. Observe:** The permission dialog flashes on screen for ~50 ms and disappears. The command executes immediately without user approval.

### Expected behavior

The permission dialog should remain visible and wait for the user to select "Yes" or "No" before proceeding — exactly as it does on v1.0.52.

### Additional context

### Evidence from events.jsonl

Timing from a v1.0.56 session shows the prompt is resolved in 79ms:

```json
permission.requested → timestamp T
permission.completed → timestamp T + 79ms (result: "approved")
```

For comparison, in a session created under v1.0.51 , the same hook waits 3–5 seconds for user interaction:

```json
permission.requested → timestamp T
permission.completed → timestamp T + 4200ms (result: "approved" after user clicks Yes)
```

### Key observation

Sessions **created** under v1.0.52 or earlier continue to show prompts correctly, even when the binary has been auto-updated to v1.0.56. This suggests the regression is in the TUI session initialization or component mounting code, not in the hook execution pipeline itself.
### Additional context

- Tested with both **global hooks** (`~/.copilot/hooks/hooks.json`) and **plugin hooks** — same behavior
- The hook itself executes correctly — stdout returns valid JSON with `permissionDecision: "ask"`
- The `permission.requested` event shows `kind=hook` and `resolvedByHook=N/A` (correct)
- Non-hook permission prompts (e.g., native trust prompts for new directories) are NOT affected — they still wait for user input

### Environment

- OS: Linux (Ubuntu)
- Terminal: Standard terminal (no tmux)
- Shell: bash

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

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

Hướng nghiên cứu

Reproduce the issue with the provided PreToolUse hook on v1.0.52 and v1.0.56, then compare TUI session initialization and permission event timing across those versions. No source file or test is named; the fix is complete when permissionDecision "ask" remains interactive and selection and question colors render correctly without breaking native prompts.

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

Đánh giá

Công nghệ
linux, python, 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
48/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.