From 53e892799a1e1338bb417be23fc8d2844b5e84ca Mon Sep 17 00:00:00 2001 From: booleanmaybe Date: Thu, 29 Jan 2026 18:34:40 -0500 Subject: [PATCH] empty search fix --- controller/plugin.go | 2 +- integration/plugin_view_test.go | 53 +++++++++++++++++++++++++++++++++ view/header/stats.go | 1 + 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/controller/plugin.go b/controller/plugin.go index 5c2beec..7a8bb07 100644 --- a/controller/plugin.go +++ b/controller/plugin.go @@ -222,7 +222,7 @@ func (pc *PluginController) HandleSearch(query string) { // Search across all tasks; pane membership is decided per pane results := pc.taskStore.Search(query, nil) if len(results) == 0 { - pc.pluginConfig.ClearSearchResults() + pc.pluginConfig.SetSearchResults([]task.SearchResult{}, query) return } diff --git a/integration/plugin_view_test.go b/integration/plugin_view_test.go index dd0d5fd..5acd5e3 100644 --- a/integration/plugin_view_test.go +++ b/integration/plugin_view_test.go @@ -299,6 +299,59 @@ func TestPluginView_Search(t *testing.T) { } } +// TestPluginView_SearchNoResults verifies search with no matches shows empty results +func TestPluginView_SearchNoResults(t *testing.T) { + ta := testutil.NewTestApp(t) + defer ta.Cleanup() + + if err := ta.LoadPlugins(); err != nil { + t.Fatalf("Failed to load plugins: %v", err) + } + + // Create a single task + if err := testutil.CreateTestTask(ta.TaskDir, "TIKI-1", "First Task", taskpkg.StatusReady, taskpkg.TypeStory); err != nil { + t.Fatalf("failed to create task: %v", err) + } + if err := ta.TaskStore.Reload(); err != nil { + t.Fatalf("failed to reload: %v", err) + } + + // Navigate to plugin view + ta.NavController.PushView(model.MakePluginViewID("Kanban"), nil) + ta.Draw() + + // Verify task is visible before search + foundBefore, _, _ := ta.FindText("TIKI-1") + if !foundBefore { + ta.DumpScreen() + t.Fatalf("TIKI-1 should be visible before search") + } + + // Start search + ta.SendKey(tcell.KeyRune, '/', tcell.ModNone) + + // Type non-matching search query + ta.SendText("xyznonexistent") + ta.SendKey(tcell.KeyEnter, 0, tcell.ModNone) + + // Verify task is NOT visible after no-match search + foundAfter, _, _ := ta.FindText("TIKI-1") + if foundAfter { + ta.DumpScreen() + t.Errorf("TIKI-1 should NOT be visible after no-match search") + } + + // Press Escape to clear search + ta.SendKey(tcell.KeyEscape, 0, tcell.ModNone) + + // Verify task reappears + foundCleared, _, _ := ta.FindText("TIKI-1") + if !foundCleared { + ta.DumpScreen() + t.Errorf("TIKI-1 should reappear after clearing search") + } +} + // TestPluginView_EmptyPlugin verifies plugin view with no matching tasks func TestPluginView_EmptyPlugin(t *testing.T) { ta := testutil.NewTestApp(t) diff --git a/view/header/stats.go b/view/header/stats.go index 356b72e..2631848 100644 --- a/view/header/stats.go +++ b/view/header/stats.go @@ -47,6 +47,7 @@ func NewStatsWidget() *StatsWidget { tv := tview.NewTextView() tv.SetDynamicColors(true) tv.SetTextAlign(tview.AlignLeft) + tv.SetWrap(false) sw := &StatsWidget{ TextView: tv,