co-mono/todos/done/20250811-114520-agent-tui-interrupted-message-esc.md
Mario Zechner 1d9b77298c fix(agent): Properly handle ESC interrupt in TUI with centralized event emission
Fixed the interrupt mechanism to show "[Interrupted by user]" message when ESC is pressed:
- Removed duplicate UI cleanup from ESC key handler that interfered with event processing
- Added centralized interrupted event emission in exception handler when abort signal is detected
- Removed duplicate event emissions from API call methods to prevent multiple messages
- Added abort signal support to preflight reasoning check for proper cancellation
- Simplified abort detection to only check signal state, not error messages
2025-08-11 12:21:13 +02:00

1.2 KiB

Fix interrupted message not showing when ESC pressed in agent TUI

Status: Done Agent PID: 47968

Original Todo

agent/tui: not seeing a read "interrupted" mesage anymore if i press ESC while agnet works

Description

Fix the issue where the "interrupted" message is not displayed in the TUI when pressing ESC to interrupt the agent while it's processing. The root cause is duplicate UI cleanup in the ESC key handler that interferes with the asynchronous interrupted event handler.

Read analysis.md in full for detailed codebase research and context

Implementation Plan

Remove duplicate UI cleanup from ESC key handler and ensure interrupted event handler properly displays the message:

  • Remove duplicate loading animation cleanup from ESC key handler in tui-renderer.ts (lines 115-120)
  • Add explicit render request after adding interrupted message (line 280)
  • Fix core issue: Emit "interrupted" event when API call is aborted (agent.ts line 606-607)
  • Pass abort signal to preflight reasoning check
  • Test interruption during API call (e.g., "write a poem")
  • Verify "[Interrupted by user]" message appears and UI is restored

Notes

[Implementation notes]