[PR #3278] fix(tui): Allow modals to handle ESC key before force closing #10588

Closed
opened 2026-02-16 18:15:17 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3278

State: closed
Merged: No


Summary

Fixes the issue where pressing ESC in modal dialogs (like /agent and /model) appeared to do nothing.

Problem

Previously, the TUI would immediately close any modal when ESC was pressed, without giving the modal component a chance to handle the key event first. This prevented search dialogs from properly processing the ESC key and emitting the SearchCancelledMsg.

Solution

This change makes ESC handling consistent with Ctrl+C by:

  • Passing the ESC key event to the modal first
  • Only force-closing the modal if the modal doesn't handle it
  • Allowing SearchDialog to emit SearchCancelledMsg before closing

Testing

Tested on Windows by:

  1. Opening /agent dialog
  2. Pressing ESC
  3. Confirming the dialog closes properly

Related Files

  • packages/tui/internal/tui/tui.go - Modified ESC key handling logic
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3278 **State:** closed **Merged:** No --- ## Summary Fixes the issue where pressing ESC in modal dialogs (like `/agent` and `/model`) appeared to do nothing. ## Problem Previously, the TUI would immediately close any modal when ESC was pressed, without giving the modal component a chance to handle the key event first. This prevented search dialogs from properly processing the ESC key and emitting the `SearchCancelledMsg`. ## Solution This change makes ESC handling consistent with Ctrl+C by: - Passing the ESC key event to the modal first - Only force-closing the modal if the modal doesn't handle it - Allowing SearchDialog to emit `SearchCancelledMsg` before closing ## Testing Tested on Windows by: 1. Opening `/agent` dialog 2. Pressing ESC 3. Confirming the dialog closes properly ## Related Files - `packages/tui/internal/tui/tui.go` - Modified ESC key handling logic
yindo added the pull-request label 2026-02-16 18:15:17 -05:00
yindo closed this issue 2026-02-16 18:15:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10588