The open source coding agent.
TypeScript
fix(tui): clear command priority
adamdottv58b1c58bc59e
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.goindex f4e6ab2f9e5..071f22d0ef1 100644--- a/packages/tui/internal/components/chat/editor.go+++ b/packages/tui/internal/components/chat/editor.go@@ -30,6 +30,7 @@ type EditorComponent interface {Content(width int) stringLines() intValue() string+ Length() intFocused() boolFocus() (tea.Model, tea.Cmd)Blur()@@ -295,6 +296,10 @@ func (m *editorComponent) Value() string {return m.textarea.Value()}+func (m *editorComponent) Length() int {+ return m.textarea.Length()+}+func (m *editorComponent) Submit() (tea.Model, tea.Cmd) {value := strings.TrimSpace(m.Value())if value == "" {diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.goindex c0d7ca1b0f0..3dc71140c86 100644--- a/packages/tui/internal/tui/tui.go+++ b/packages/tui/internal/tui/tui.go@@ -265,7 +265,13 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {return a, nil}- // 6. Handle interrupt key debounce for session interrupt+ // 6 Handle input clear command+ inputClearCommand := a.app.Commands[commands.InputClearCommand]+ if inputClearCommand.Matches(msg, a.isLeaderSequence) && a.editor.Length() > 0 {+ return a, util.CmdHandler(commands.ExecuteCommandMsg(inputClearCommand))+ }++ // 7. Handle interrupt key debounce for session interruptinterruptCommand := a.app.Commands[commands.SessionInterruptCommand]if interruptCommand.Matches(msg, a.isLeaderSequence) && a.app.IsBusy() {switch a.interruptKeyState {@@ -284,7 +290,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}}- // 7. Handle exit key debounce for app exit when using non-leader command+ // 8. Handle exit key debounce for app exit when using non-leader commandexitCommand := a.app.Commands[commands.AppExitCommand]if exitCommand.Matches(msg, a.isLeaderSequence) {switch a.exitKeyState {@@ -303,7 +309,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}}- // 8. Check again for commands that don't require leader (excluding interrupt when busy and exit when in debounce)+ // 9. Check again for commands that don't require leader (excluding interrupt when busy and exit when in debounce)matches := a.app.Commands.Matches(msg, a.isLeaderSequence)if len(matches) > 0 {// Skip interrupt key if we're in debounce mode and app is busy@@ -313,8 +319,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {return a, util.CmdHandler(commands.ExecuteCommandsMsg(matches))}- // 9. Fallback to editor. This is for other characters- // like backspace, tab, etc.+ // 10. Fallback to editor. This is for other characters like backspace, tab, etc.updatedEditor, cmd := a.editor.Update(msg)a.editor = updatedEditor.(chat.EditorComponent)return a, cmd