anthropics / anthropics/claude-code

[Bug] Esc in the subagent view interrupts the running agent as well as dismissing the view

Open
#81,131 0 comments 1 reaction 0 assignees View on GitHub
area:tui
Dominant language
Python
Stars
145k
Forks
23.1k
PR merge metrics
PR metrics pending

Description

**Bug Description**
It is impossible to unbind "esc" within a subagent view. Pressing esc when selecting a subagent always interrupts it, even when the action to cancel is unbound.

Pressing Esc inside the subagent detail view both closes the view and interrupts the running agent.
Dismissing a read-only detail view should not cancel the work it was displaying.
Every other dismiss action in Claude Code (`help:dismiss`, `diff:dismiss`, `attachments:exit`, `transcript:exit`) is non-destructive, and `task:background` (`ctrl+b`) already exists as the intended "stop watching, keep working" path.
The interrupt is also unreachable from keybinding config, so it cannot be worked around.

**Environment Info**
- Platform: win32
- Terminal: windows-terminal
- Version: 2.1.220
- Feedback ID: bb5ea67a-24c7-42ba-b829-320a5484d527

**Errors**
```json
[]
```

**Steps to reproduce**

1. Start a long-running foreground subagent.
2. Open the subagent view.
3. Press Esc once.

**Expected:** the view closes and the agent keeps running, recoverable via the subagent view or a task notification.

**Actual:** the view closes and the agent is interrupted. Its work is lost.

**Why this is easy to hit**

You are in the subagent view precisely because you are watching a long run.
Esc is the reflex for "back out of this panel," and it is the same key that kills the run.
There is no confirmation and no undo.

**Interaction with keybinding config**

Unbinding `chat:cancel` protects the chat view but has no effect on the subagent view:

```json
{
"bindings": [
{ "context": "Chat", "bindings": { "escape": null } }
]
}
```

```
┌────────────────────────────────────────┬──────────────────────────────────┬──────────┐
│ Focus │ Single Esc │ Correct? │
├────────────────────────────────────────┼──────────────────────────────────┼──────────┤
│ Chat view, main loop working │ inert │ yes │
├────────────────────────────────────────┼──────────────────────────────────┼──────────┤
│ Chat view, foreground subagent running │ inert │ yes │
├────────────────────────────────────────┼──────────────────────────────────┼──────────┤
│ Subagent view, subagent running │ closes view AND interrupts agent │ no │
└────────────────────────────────────────┴──────────────────────────────────┴──────────┘
```

Adding a Task context override does not help:

```json
{ "context": "Task", "bindings": { "escape": null } }
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the behavior in the subagent detail view using the Esc key, then trace the subagent view's dismiss handling and the Task keybinding context. Done means Esc closes the read-only view without interrupting the running agent, while the existing cancellation path remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.