github / github/copilot-cli

copilot cli drops enter and other key events when the terminal pane is unfocused

未關閉
#4,213 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
area:input-keyboard area:terminal-rendering
主要語言
Shell
星號
11.2k
分支
1.9k
平均合併
14 小時 16 分鐘
30 天內合併 PR
6

描述

### describe the bug

i maintain [herdr](https://github.com/ogulcancelik/herdr), an agent multiplexer with roughly 20k stars and hundreds of thousands of downloads. herdr supports copilot cli alongside other agent harnesses and lets users automate any pane through its pty, including panes that are not currently focused.

copilot cli enables terminal focus reporting with `csi ? 1004 h`. after it receives focus-out (`csi o`), its main input box ignores normal key events written to the pty. pasted text may still appear, but enter is discarded, so an automation request looks delivered without ever being submitted. after focus-in (`csi i`), the same enter byte works immediately.

this breaks automation and orchestration tools that intentionally address background panes. herdr's report and investigation are here:

https://github.com/ogulcancelik/herdr/issues/1698

### affected version

```text
1.0.69
1.0.73
1.0.74-0
```

### steps to reproduce with herdr

1. create a tab with two split panes.
2. start copilot cli in the right pane:

```bash
herdr agent start copilot-test --kind copilot --pane
```

3. focus the left pane so copilot is an unfocused split sibling.
4. send a prompt:

```bash
herdr agent prompt "reply with exactly ok"
```

5. herdr accepts the request, and the text may appear in copilot's input box, but enter is ignored. copilot remains idle and never responds.
6. repeated enter through `agent send-keys` also does nothing:

```bash
herdr agent send-keys enter
```

7. focus the copilot pane and send enter again:

```bash
herdr agent focus
herdr agent send-keys enter
```

8. the existing prompt submits immediately and copilot responds.

using `agent prompt --wait` makes the failure observable as `agent_prompt_stalled`, but it cannot make copilot process enter.

### independent reproduction with tmux

this control experiment removes herdr from the input path.

1. start copilot cli inside a tmux pane and wait for its main input box.
2. enable focus events and send focus-out, text, and enter:

```bash
tmux set -g focus-events on
tmux send-keys -t -l $'\e[O'
tmux send-keys -t -l 'reply with exactly ok'
tmux send-keys -t enter
```

3. the text appears, but enter does nothing and no turn starts.
4. send focus-in followed by enter:

```bash
tmux send-keys -t -l $'\e[I'
tmux send-keys -t enter
```

5. the prompt submits immediately and copilot responds.

### expected behavior

terminal focus should control visual focus behavior such as cursor rendering and notifications. it should not prevent the application from processing valid input already delivered to its pty.

programmatic input addressed to an unfocused pane should behave the same as input addressed to a focused pane.

### additional context

this reproduces outside herdr with `tmux send-keys`, so it is not caused by herdr's pty delivery. the shipped bundle also shows that the main input handler returns early while terminal focus is false unless the event is paste, backspace, or delete.

the folder-trust dialog still accepts enter while unfocused, so the gate appears specific to the main input component.

the closest existing report is [#4180](https://github.com/github/copilot-cli/issues/4180), but that issue describes broader automated pty input failure and states that sending focus-in did not help. this report is narrower: focus-out deterministically disables normal key handling, and focus-in restores it.

tested independently with tmux 3.7b on linux x86_64. the original herdr reproduction used macos, ghostty, and herdr 0.7.5.

貢獻指南

開啟貢獻指南

研究方向

先使用 tmux 3.7b 重現 focus-out、text 和 enter 序列,然後將其與 focus-in 後接 enter 進行比較。檢查隨附 bundle 的 main input handler,特別是 terminal focus 為 false 時的提前返回,並驗證一般 pty 按鍵事件會提交 prompt,同時視覺焦點行為保持不變。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
linux, shell
領域
cli
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
活躍
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。