From ca2b2eb5580e00ebd177c348b76a211d4c5a6a18 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Sun, 22 Mar 2026 18:29:36 +0200 Subject: [PATCH] tui: implement history navigation state initialization --- cmd/sidekick-tui/main.go | 9 ++++++--- cmd/sidekick-tui/tui_test.go | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/sidekick-tui/main.go b/cmd/sidekick-tui/main.go index 8ed97c6..ceda3c2 100644 --- a/cmd/sidekick-tui/main.go +++ b/cmd/sidekick-tui/main.go @@ -55,6 +55,8 @@ type model struct { agent *sidekick.Sidekick pool map[string]*sidekick.Sidekick history []sidekick.Message + historyIndex int + promptDraft string transientSteps []string currentStream string currentReasoning string @@ -178,9 +180,10 @@ func initialModel() model { } return model{ - textarea: ta, - agent: agent, - pool: pool, + textarea: ta, + agent: agent, + pool: pool, + historyIndex: -1, history: []sidekick.Message{ {Role: sidekick.MessageRoleSystem, Content: banner + "\n\nSidekick initialized. " + mcpStats + "\nType a message below."}, }, diff --git a/cmd/sidekick-tui/tui_test.go b/cmd/sidekick-tui/tui_test.go index 25e0cf9..a4dd884 100644 --- a/cmd/sidekick-tui/tui_test.go +++ b/cmd/sidekick-tui/tui_test.go @@ -32,6 +32,13 @@ func TestInitialModel(t *testing.T) { } } +func TestHistoryStateInitialization(t *testing.T) { + m := initialModel() + if m.historyIndex != -1 { + t.Errorf("expected historyIndex to be -1, got %d", m.historyIndex) + } +} + func TestModelUpdate(t *testing.T) { m := initialModel() m.ready = true