summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-07-08 19:26:50 -0500
committeradamdottv <[email protected]>2025-07-08 19:26:50 -0500
commit58b1c58bc59e82ea05dfa5f4dfce8111c4e2995a (patch)
treee222192b78d9c05d0242febc71e6f1563c178a98
parentd80badc50ffc127c35e48c8d2be34d5cd79e2c77 (diff)
downloadopencode-58b1c58bc59e82ea05dfa5f4dfce8111c4e2995a.tar.gz
opencode-58b1c58bc59e82ea05dfa5f4dfce8111c4e2995a.zip
fix(tui): clear command priority
-rw-r--r--packages/tui/internal/components/chat/editor.go5
-rw-r--r--packages/tui/internal/tui/tui.go15
2 files changed, 15 insertions, 5 deletions
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go
index f4e6ab2f9..071f22d0e 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) string
Lines() int
Value() string
+ Length() int
Focused() bool
Focus() (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.go
index c0d7ca1b0..3dc71140c 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 interrupt
interruptCommand := 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 command
exitCommand := 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