From 5cf5dfc2d08ad3ebb83e2897cdbe292e2775e104 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Thu, 4 Dec 2025 12:47:31 +0000 Subject: [PATCH] fix: adjust how history loads to account for adjusted usage --- .../tui/components/chat/editor/history.go | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/tui/components/chat/editor/history.go b/internal/tui/components/chat/editor/history.go index f90810ec61e3fa31f391ca8c26207c105a2c86c0..eb707f3b94884c476b080c23a8649fb57d2b69d1 100644 --- a/internal/tui/components/chat/editor/history.go +++ b/internal/tui/components/chat/editor/history.go @@ -3,7 +3,6 @@ package editor type historyState struct { previouslyScrollingPromptHistory bool promptHistoryIndex int - existingValue string historyCache []string } @@ -15,22 +14,27 @@ type History interface { } func InitialiseHistory(existingValue string, messages []string) History { + msgs := messages + msgs = append(msgs, existingValue) return &historyState{ - existingValue: existingValue, - historyCache: messages, - promptHistoryIndex: len(messages) - 1, + historyCache: msgs, + promptHistoryIndex: len(msgs) - 1, } } func (h *historyState) Value() string { - if len(h.historyCache) == 0 { - return h.existingValue + if len(h.historyCache) > 1 { + return h.historyCache[h.promptHistoryIndex] } - return h.historyCache[h.promptHistoryIndex] + return h.ExistingValue() } func (h *historyState) ExistingValue() string { - return h.existingValue + index := len(h.historyCache) - 1 + if index < 0 { + return "" + } + return h.historyCache[index] } func (h *historyState) ScrollUp() {