The open source coding agent.
TypeScript
fix(tui): input feels laggy
adamdottv261e76e0a3e3
diff --git a/packages/tui/internal/components/textarea/textarea.go b/packages/tui/internal/components/textarea/textarea.goindex 0110ae824fb..6646d2a9782 100644--- a/packages/tui/internal/components/textarea/textarea.go+++ b/packages/tui/internal/components/textarea/textarea.go@@ -1161,8 +1161,6 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {}var cmd tea.Cmd- cmds = append(cmds, cmd)-newRow, newCol := m.cursorLineNumber(), m.colm.virtualCursor, cmd = m.virtualCursor.Update(msg)if (newRow != oldRow || newCol != oldCol) && m.virtualCursor.Mode() == cursor.CursorBlink {@@ -1171,7 +1169,6 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {}cmds = append(cmds, cmd)- m.SetHeight(m.ContentHeight())return m, tea.Batch(cmds...)}diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.goindex e1f3aa1b191..176960429ba 100644--- a/packages/tui/internal/tui/tui.go+++ b/packages/tui/internal/tui/tui.go@@ -70,9 +70,11 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {switch msg := msg.(type) {case tea.KeyPressMsg:+ keyString := msg.String()+// 1. Handle active modalif a.modal != nil {- switch msg.String() {+ switch keyString {// Escape always closes current modalcase "esc", "ctrl+c":a.modal = nil@@ -88,7 +90,6 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {// 2. Check for commands that require leaderif a.isLeaderSequence {matches := a.app.Commands.Matches(msg, a.isLeaderSequence)- // Reset leader statea.isLeaderSequence = falseif len(matches) > 0 {return a, util.CmdHandler(commands.ExecuteCommandsMsg(matches))@@ -96,44 +97,44 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}// 3. Handle completions trigger- switch msg.String() {- case "/":- if !a.showCompletionDialog {- a.showCompletionDialog = true-- initialValue := "/"- currentInput := a.editor.Value()- // if the input doesn't end with a space,- // then we want to include the last word- if !strings.HasSuffix(currentInput, " ") {- words := strings.Split(a.editor.Value(), " ")- if len(words) > 0 {- lastWord := words[len(words)-1]- lastWord = strings.TrimSpace(lastWord)- initialValue = lastWord + "/"- }+ if keyString == "/" && !a.showCompletionDialog {+ a.showCompletionDialog = true++ initialValue := "/"+ currentInput := a.editor.Value()++ // if the input doesn't end with a space,+ // then we want to include the last word+ // (ie, `packages/`)+ if !strings.HasSuffix(currentInput, " ") {+ words := strings.Split(a.editor.Value(), " ")+ if len(words) > 0 {+ lastWord := words[len(words)-1]+ lastWord = strings.TrimSpace(lastWord)+ initialValue = lastWord + "/"}- updated, cmd := a.completions.Update(- app.CompletionDialogTriggerdMsg{- InitialValue: initialValue,- },- )- a.completions = updated.(dialog.CompletionDialog)- cmds = append(cmds, cmd)-- updated, cmd = a.completions.Update(msg)- a.completions = updated.(dialog.CompletionDialog)- cmds = append(cmds, cmd)-- updated, cmd = a.editor.Update(msg)- a.editor = updated.(chat.EditorComponent)- cmds = append(cmds, cmd)- return a, tea.Sequence(cmds...)}++ updated, cmd := a.completions.Update(+ app.CompletionDialogTriggerdMsg{+ InitialValue: initialValue,+ },+ )+ a.completions = updated.(dialog.CompletionDialog)+ cmds = append(cmds, cmd)++ updated, cmd = a.completions.Update(msg)+ a.completions = updated.(dialog.CompletionDialog)+ cmds = append(cmds, cmd)++ updated, cmd = a.editor.Update(msg)+ a.editor = updated.(chat.EditorComponent)+ cmds = append(cmds, cmd)+ return a, tea.Sequence(cmds...)}if a.showCompletionDialog {- switch msg.String() {+ switch keyString {case "tab", "enter", "esc", "ctrl+c":context, contextCmd := a.completions.Update(msg)a.completions = context.(dialog.CompletionDialog)