summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEd Zynda <[email protected]>2025-05-19 02:41:34 +0300
committerGitHub <[email protected]>2025-05-18 18:41:34 -0500
commit6e854a4df4e4933d478e5eb1d48ccb34db610194 (patch)
tree640d82c9d3ecd2c2cee9a4c40657ffb3d9c7d150
parent2f8984fadb24ba7b369d0d09c6ad4823f7f48a63 (diff)
downloadopencode-6e854a4df4e4933d478e5eb1d48ccb34db610194.tar.gz
opencode-6e854a4df4e4933d478e5eb1d48ccb34db610194.zip
fix: disable history navigation when filepicker is open (#39)
-rw-r--r--internal/app/app.go13
-rw-r--r--internal/tui/components/chat/editor.go5
-rw-r--r--internal/tui/tui.go3
3 files changed, 19 insertions, 2 deletions
diff --git a/internal/app/app.go b/internal/app/app.go
index e7bbfbfa1..943f1b24e 100644
--- a/internal/app/app.go
+++ b/internal/app/app.go
@@ -40,6 +40,9 @@ type App struct {
watcherCancelFuncs []context.CancelFunc
cancelFuncsMutex sync.Mutex
watcherWG sync.WaitGroup
+
+ // UI state
+ filepickerOpen bool
}
func New(ctx context.Context, conn *sql.DB) (*App, error) {
@@ -128,6 +131,16 @@ func (app *App) initTheme() {
}
}
+// IsFilepickerOpen returns whether the filepicker is currently open
+func (app *App) IsFilepickerOpen() bool {
+ return app.filepickerOpen
+}
+
+// SetFilepickerOpen sets the state of the filepicker
+func (app *App) SetFilepickerOpen(open bool) {
+ app.filepickerOpen = open
+}
+
// Shutdown performs a clean shutdown of the application
func (app *App) Shutdown() {
// Cancel all watcher goroutines
diff --git a/internal/tui/components/chat/editor.go b/internal/tui/components/chat/editor.go
index dbaa05181..212ad5529 100644
--- a/internal/tui/components/chat/editor.go
+++ b/internal/tui/components/chat/editor.go
@@ -247,7 +247,8 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
// Handle history navigation with up/down arrow keys
- if m.textarea.Focused() && key.Matches(msg, editorMaps.HistoryUp) {
+ // Only handle history navigation if the filepicker is not open
+ if m.textarea.Focused() && key.Matches(msg, editorMaps.HistoryUp) && !m.app.IsFilepickerOpen() {
// Get the current line number
currentLine := m.textarea.Line()
@@ -267,7 +268,7 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
- if m.textarea.Focused() && key.Matches(msg, editorMaps.HistoryDown) {
+ if m.textarea.Focused() && key.Matches(msg, editorMaps.HistoryDown) && !m.app.IsFilepickerOpen() {
// Get the current line number and total lines
currentLine := m.textarea.Line()
value := m.textarea.Value()
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 299c69793..56be04619 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -417,6 +417,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if a.showFilepicker {
a.showFilepicker = false
a.filepicker.ToggleFilepicker(a.showFilepicker)
+ a.app.SetFilepickerOpen(a.showFilepicker)
}
if a.showModelDialog {
a.showModelDialog = false
@@ -539,6 +540,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if a.showFilepicker {
a.showFilepicker = false
a.filepicker.ToggleFilepicker(a.showFilepicker)
+ a.app.SetFilepickerOpen(a.showFilepicker)
return a, nil
}
if a.currentPage == page.LogsPage {
@@ -571,6 +573,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Toggle filepicker
a.showFilepicker = !a.showFilepicker
a.filepicker.ToggleFilepicker(a.showFilepicker)
+ a.app.SetFilepickerOpen(a.showFilepicker)
// Close other dialogs if opening filepicker
if a.showFilepicker {