fix-tui-chat-2

Fix: TUI chat tab can't cancel a hung in-pane bash subprocess (Ctrl+C / Ctrl+] doesn't reach it)

Metadata

Statusdone
Assignedagent-2467
Agent identity02e879681e52e0a384106169be043416c4d946e850ab26b2269c57681b52a6e7
Modelcodex:gpt-5.5
Created2026-05-04T21:38:44.996177450+00:00
Started2026-05-04T21:40:57.715650160+00:00
Completed2026-05-04T21:58:56.051282193+00:00
Tagsfix,bug,tui,chat,input, eval-scheduled
Eval score0.78
└ blocking impact0.85
└ completeness0.75
└ constraint fidelity0.85
└ coordination overhead0.85
└ correctness0.80
└ downstream usability0.80
└ efficiency0.80
└ intent fidelity0.79
└ style adherence0.85

Description

Description

When a chat agent inside a TUI chat tab runs a bash subprocess that hangs (e.g., the agent invoked wg nex from bash and got stuck waiting on stdin per fix-agent-guide-nex), the user cannot cancel it. The user-visible freeze blocks the chat tab; Ctrl+C / Ctrl+] / etc. don't propagate to interrupt the hung subprocess.

User report 2026-05-04: 'I just got a freeze in this state and I can't even cancel it.'

What should happen

The chat tab is a tmux-wrapped PTY (per implement-tmux-wrapped). Sending an interrupt to the chat agent should:

  1. Reach the chat agent (claude/codex/nex CLI process)
  2. Propagate down to whatever bash subprocess it spawned (wg nex "..." in this case)
  3. Interrupt that subprocess

Investigate WHY this isn't happening. Possible causes:

  1. Ctrl+C in the chat tab is being captured by the TUI wrapper (treated as 'cancel chat input', not 'send SIGINT to PTY child')
  2. SIGINT reaches the chat agent process but isn't propagated to its bash subprocess (process group / session leadership issue)
  3. The hung wg nex subprocess is in a different process group from the chat agent and SIGINT doesn't reach it

Fix candidates

  • Ensure Ctrl+C in the chat pane sends SIGINT to the FOREGROUND PROCESS GROUP of the PTY (standard terminal behavior)
  • Verify chat agent's bash subprocesses inherit proper process group / can be signaled
  • Add a TUI-level keybinding for 'kill all subprocesses of the focused chat agent' (escape hatch when the standard signal path fails)

Validation

  • Failing repro: in a chat tab, have agent run sleep 999. Press Ctrl+C in the chat pane. Pre-fix: sleep doesn't terminate; chat tab feels frozen. Post-fix: sleep is interrupted; agent regains control.
  • Same test with the wg nex hang scenario
  • Chat agent itself is NOT killed (only its hung subprocess) — agent still runs and can process the next message
  • No regression of normal Ctrl+C behavior elsewhere in the TUI
  • cargo build + cargo test pass
  • cargo install --path . was run before claiming done

Coordinate

  • fix-agent-guide-nex (sibling task) — addresses WHY agents trigger this hang. This task addresses the user's recovery path WHEN it happens.
  • implement-tmux-wrapped — established the tmux+PTY wrap pattern; this task verifies signal propagation through that wrap

Depends on

Required by

Log