From 61bc1d2eb9a834a5de7d7925d615d9471b795318 Mon Sep 17 00:00:00 2001 From: Bruno Bornsztein Date: Thu, 12 Feb 2026 06:35:19 -0600 Subject: [PATCH] Focus project field first on new task form - Changed initial focus from FieldTitle to FieldProject for new task forms - Project field is focused when showAdvanced is true (default behavior) - Title field is focused when showAdvanced is false (for backward compatibility) - Updated tests to reflect new behavior This aligns new task form behavior with edit task form, which already focuses on the project field first. The project field provides immediate context for the task being created. Co-Authored-By: Claude Sonnet 4.5 --- internal/ui/form.go | 10 +++++++--- internal/ui/form_test.go | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/internal/ui/form.go b/internal/ui/form.go index de55cde..58231ad 100644 --- a/internal/ui/form.go +++ b/internal/ui/form.go @@ -306,7 +306,7 @@ func NewFormModel(database *db.DB, width, height int, workingDir string, availab db: database, width: width, height: height, - focused: FieldTitle, // Start on Title for simpler first experience + focused: FieldProject, // Project first for immediate context autocompleteSvc: autocompleteSvc, autocompleteEnabled: autocompleteEnabled, taskRefAutocomplete: NewTaskRefAutocompleteModel(database, width-24), @@ -383,13 +383,17 @@ func NewFormModel(database *db.DB, width, height int, workingDir string, availab // Load last used executor for the selected project (overrides default if available) m.loadLastExecutorForProject() - // Title input - focused by default for simpler first experience + // Title input m.titleInput = textinput.New() m.titleInput.Placeholder = "What needs to be done?" m.titleInput.Prompt = "" m.titleInput.Cursor.SetMode(cursor.CursorStatic) m.titleInput.Width = width - 24 - m.titleInput.Focus() // Start with title focused + // Focus title only if project field is not visible (showAdvanced is false) + if !m.showAdvanced { + m.focused = FieldTitle + m.titleInput.Focus() + } // Body textarea m.bodyInput = textarea.New() diff --git a/internal/ui/form_test.go b/internal/ui/form_test.go index 212de0a..ade3e9a 100644 --- a/internal/ui/form_test.go +++ b/internal/ui/form_test.go @@ -875,14 +875,14 @@ func TestFormDefaultsToFirstAvailableExecutor(t *testing.T) { } func TestFormProgressiveDisclosure(t *testing.T) { - t.Run("new form starts in advanced mode focused on title", func(t *testing.T) { + t.Run("new form starts in advanced mode focused on project", func(t *testing.T) { m := NewFormModel(nil, 100, 50, "", []string{"claude"}) if !m.showAdvanced { t.Error("expected new form to start with showAdvanced=true") } - if m.focused != FieldTitle { - t.Errorf("expected focus on FieldTitle, got %d", m.focused) + if m.focused != FieldProject { + t.Errorf("expected focus on FieldProject, got %d", m.focused) } }) @@ -945,6 +945,7 @@ func TestFormProgressiveDisclosure(t *testing.T) { t.Run("focusNext skips hidden fields in simple mode", func(t *testing.T) { m := NewFormModel(nil, 100, 50, "", []string{"claude"}) m.showAdvanced = false // Switch to simple mode for this test + m.focused = FieldTitle // Manually set focus to first visible field for this test // Start on Title if m.focused != FieldTitle {