The open source coding agent.
TypeScript
fix(tui): Allow modals to handle ESC key before force closing (#3279)
Walter6adc16ca8a98
diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.goindex 50b503c66b3..da77b42f219 100644--- a/packages/tui/internal/tui/tui.go+++ b/packages/tui/internal/tui/tui.go@@ -162,9 +162,15 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {// 1. Handle active modalif a.modal != nil {switch keyString {- // Escape always closes current modal+ // Escape closes current modal, but give modal a chance to handle it firstcase "esc":- cmd := a.modal.Close()+ // give the modal a chance to handle the esc+ updatedModal, cmd := a.modal.Update(msg)+ a.modal = updatedModal.(layout.Modal)+ if cmd != nil {+ return a, cmd+ }+ cmd = a.modal.Close()a.modal = nilreturn a, cmdcase "ctrl+c":