Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix(traces): quit on Ctrl+C while entering a search (#821)

Rudy Mizrahi Celeklid710ebfb14e3
diff --git a/cli/beacon/internal/endpoint/traceview/search_quit_test.go b/cli/beacon/internal/endpoint/traceview/search_quit_test.go
new file mode 100644
index 00000000..b83a6599
--- /dev/null
+++ b/cli/beacon/internal/endpoint/traceview/search_quit_test.go
@@ -0,0 +1,35 @@
+package traceview
+
+import (
+ "testing"
+
+ tea "github.com/charmbracelet/bubbletea"
+)
+
+func TestSearchControlCQuitsTraceBrowser(t *testing.T) {
+ model := NewModel(fixtureStore())
+ model.loading = false
+ next, _ := model.Update(key("/"))
+ model = next.(Model)
+ if !model.searching {
+ t.Fatal("slash did not enter search")
+ }
+ _, cmd := model.Update(tea.KeyMsg{Type: tea.KeyCtrlC})
+ if cmd == nil {
+ t.Fatal("Ctrl+C while searching did not quit")
+ }
+ if _, ok := cmd().(tea.QuitMsg); !ok {
+ t.Fatal("Ctrl+C returned a command other than quit")
+ }
+ // q remains ordinary search input; Escape cancels search without quitting.
+ next, cmd = model.Update(key("q"))
+ model = next.(Model)
+ if cmd != nil || model.searchInput != "q" || !model.searching {
+ t.Fatal("q no longer stays in the search input")
+ }
+ next, cmd = model.Update(tea.KeyMsg{Type: tea.KeyEsc})
+ model = next.(Model)
+ if cmd != nil || model.searching {
+ t.Fatal("Escape no longer cancels search without quitting")
+ }
+}
diff --git a/cli/beacon/internal/endpoint/traceview/traceview.go b/cli/beacon/internal/endpoint/traceview/traceview.go
index 513d0188..29887be6 100644
--- a/cli/beacon/internal/endpoint/traceview/traceview.go
+++ b/cli/beacon/internal/endpoint/traceview/traceview.go
@@ -216,10 +216,13 @@ func (m Model) Update(message tea.Msg) (tea.Model, tea.Cmd) {
}
return m, nil
case tea.KeyMsg:
+ if msg.String() == "ctrl+c" {
+ return m, tea.Quit
+ }
if m.searching {
return m.updateSearch(msg)
}
- if msg.String() == "ctrl+c" || msg.String() == "q" {
+ if msg.String() == "q" {
return m, tea.Quit
}
if m.loading {