The open source coding agent.
TypeScript
fix: disable history navigation when filepicker is open (#39)
Ed Zynda6e854a4df4e4
diff --git a/internal/app/app.go b/internal/app/app.goindex e7bbfbfa145..943f1b24e4a 100644--- a/internal/app/app.go+++ b/internal/app/app.go@@ -40,6 +40,9 @@ type App struct {watcherCancelFuncs []context.CancelFunccancelFuncsMutex sync.MutexwatcherWG 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 applicationfunc (app *App) Shutdown() {// Cancel all watcher goroutinesdiff --git a/internal/tui/components/chat/editor.go b/internal/tui/components/chat/editor.goindex dbaa0518118..212ad5529c1 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 numbercurrentLine := 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 linescurrentLine := m.textarea.Line()value := m.textarea.Value()diff --git a/internal/tui/tui.go b/internal/tui/tui.goindex 299c697939c..56be0461970 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 = falsea.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 = falsea.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 filepickera.showFilepicker = !a.showFilepickera.filepicker.ToggleFilepicker(a.showFilepicker)+ a.app.SetFilepickerOpen(a.showFilepicker)// Close other dialogs if opening filepickerif a.showFilepicker {