The open source coding agent.
TypeScript
fix: modal pastes (#1677)
Aiden Clinec6a46615c07c
diff --git a/packages/tui/internal/components/dialog/search.go b/packages/tui/internal/components/dialog/search.goindex cdb2b824ea4..b8fefd8b902 100644--- a/packages/tui/internal/components/dialog/search.go+++ b/packages/tui/internal/components/dialog/search.go@@ -131,10 +131,28 @@ func (s *SearchDialog) Init() tea.Cmd {return textinput.Blink}+func (s *SearchDialog) updateTextInput(msg tea.Msg) []tea.Cmd {+ var cmds []tea.Cmd+ oldValue := s.textInput.Value()+ var cmd tea.Cmd+ s.textInput, cmd = s.textInput.Update(msg)+ if cmd != nil {+ cmds = append(cmds, cmd)+ }+ if newValue := s.textInput.Value(); newValue != oldValue {+ cmds = append(cmds, func() tea.Msg {+ return SearchQueryChangedMsg{Query: newValue}+ })+ }+ return cmds+}+func (s *SearchDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd) {var cmds []tea.Cmdswitch msg := msg.(type) {+ case tea.PasteMsg, tea.ClipboardMsg:+ cmds = append(cmds, s.updateTextInput(msg)...)case tea.KeyMsg:switch msg.String() {case "ctrl+c":@@ -183,17 +201,7 @@ func (s *SearchDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}default:- oldValue := s.textInput.Value()- var cmd tea.Cmd- s.textInput, cmd = s.textInput.Update(msg)- if cmd != nil {- cmds = append(cmds, cmd)- }- if newValue := s.textInput.Value(); newValue != oldValue {- cmds = append(cmds, func() tea.Msg {- return SearchQueryChangedMsg{Query: newValue}- })- }+ cmds = append(cmds, s.updateTextInput(msg)...)}}diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.goindex f108971da31..7f5b48714b8 100644--- a/packages/tui/internal/tui/tui.go+++ b/packages/tui/internal/tui/tui.go@@ -612,6 +612,17 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {a.editor.SetExitKeyInDebounce(false)case dialog.FindSelectedMsg:return a.openFile(msg.FilePath)+ case tea.PasteMsg, tea.ClipboardMsg:+ // Paste events: prioritize modal if active, otherwise editor+ if a.modal != nil {+ updatedModal, cmd := a.modal.Update(msg)+ a.modal = updatedModal.(layout.Modal)+ return a, cmd+ } else {+ updatedEditor, cmd := a.editor.Update(msg)+ a.editor = updatedEditor.(chat.EditorComponent)+ return a, cmd+ }// APIcase api.Request:@@ -679,17 +690,17 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {cmds = append(cmds, cmd)a.status = s.(status.StatusComponent)- u, cmd := a.editor.Update(msg)- a.editor = u.(chat.EditorComponent)+ updatedEditor, cmd := a.editor.Update(msg)+ a.editor = updatedEditor.(chat.EditorComponent)cmds = append(cmds, cmd)- u, cmd = a.messages.Update(msg)- a.messages = u.(chat.MessagesComponent)+ updatedMessages, cmd := a.messages.Update(msg)+ a.messages = updatedMessages.(chat.MessagesComponent)cmds = append(cmds, cmd)if a.modal != nil {- u, cmd := a.modal.Update(msg)- a.modal = u.(layout.Modal)+ updatedModal, cmd := a.modal.Update(msg)+ a.modal = updatedModal.(layout.Modal)cmds = append(cmds, cmd)}