PreToolUse hook permissionDecision: "ask" auto-approved by TUI since v1.0.53
- 主要語言
- Shell
- 星號
- 11.2k
- 分支
- 1.9k
- 平均合併
- 14 小時 16 分鐘
- 30 天內合併 PR
- 6
描述
### 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
貢獻指南
研究方向
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.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- linux, python, shell
- 領域
- cli
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100