summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/components
diff options
context:
space:
mode:
authorYihui Khuu <[email protected]>2025-07-09 09:53:38 +1000
committerGitHub <[email protected]>2025-07-08 18:53:38 -0500
commit7893b8461495e9d1074c46d788b5007b29449736 (patch)
treed56dead7618f6c8ebac63f50f9acd73f76d54ff9 /packages/tui/internal/components
parentcfc715bd48be5460faf33d49a26abafc89c25c42 (diff)
downloadopencode-7893b8461495e9d1074c46d788b5007b29449736.tar.gz
opencode-7893b8461495e9d1074c46d788b5007b29449736.zip
Add debounce before exit when using non-leader exit command (#759)
Diffstat (limited to 'packages/tui/internal/components')
-rw-r--r--packages/tui/internal/components/chat/editor.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go
index 82b3bf71e..f4e6ab2f9 100644
--- a/packages/tui/internal/components/chat/editor.go
+++ b/packages/tui/internal/components/chat/editor.go
@@ -38,6 +38,7 @@ type EditorComponent interface {
Paste() (tea.Model, tea.Cmd)
Newline() (tea.Model, tea.Cmd)
SetInterruptKeyInDebounce(inDebounce bool)
+ SetExitKeyInDebounce(inDebounce bool)
}
type editorComponent struct {
@@ -45,6 +46,7 @@ type editorComponent struct {
textarea textarea.Model
spinner spinner.Model
interruptKeyInDebounce bool
+ exitKeyInDebounce bool
}
func (m *editorComponent) Init() tea.Cmd {
@@ -224,7 +226,10 @@ func (m *editorComponent) Content(width int) string {
Render(textarea)
hint := base(m.getSubmitKeyText()) + muted(" send ")
- if m.app.IsBusy() {
+ if m.exitKeyInDebounce {
+ keyText := m.getExitKeyText()
+ hint = base(keyText+" again") + muted(" to exit")
+ } else if m.app.IsBusy() {
keyText := m.getInterruptKeyText()
if m.interruptKeyInDebounce {
hint = muted(
@@ -365,6 +370,10 @@ func (m *editorComponent) SetInterruptKeyInDebounce(inDebounce bool) {
m.interruptKeyInDebounce = inDebounce
}
+func (m *editorComponent) SetExitKeyInDebounce(inDebounce bool) {
+ m.exitKeyInDebounce = inDebounce
+}
+
func (m *editorComponent) getInterruptKeyText() string {
return m.app.Commands[commands.SessionInterruptCommand].Keys()[0]
}
@@ -373,6 +382,10 @@ func (m *editorComponent) getSubmitKeyText() string {
return m.app.Commands[commands.InputSubmitCommand].Keys()[0]
}
+func (m *editorComponent) getExitKeyText() string {
+ return m.app.Commands[commands.AppExitCommand].Keys()[0]
+}
+
func (m *editorComponent) resetTextareaStyles() textarea.Model {
t := theme.CurrentTheme()
bgColor := t.BackgroundElement()