feat: enhance TUI with markdown, scrolling, and improved input handling

This commit is contained in:
Luxferre
2026-03-21 19:13:06 +02:00
parent 2ec2d2f45d
commit dd333a0bc7
4 changed files with 111 additions and 23 deletions
+11 -5
View File
@@ -23,6 +23,10 @@ func TestInitialModel(t *testing.T) {
if m.textarea.Value() != "" {
t.Errorf("expected empty textarea, got %s", m.textarea.Value())
}
if len(m.history) != 1 {
t.Errorf("expected 1 initial message in history, got %d", len(m.history))
}
}
func TestModelUpdate(t *testing.T) {
@@ -52,22 +56,24 @@ func TestModelUpdate(t *testing.T) {
if rm.isThinking != false {
t.Error("expected model to stop thinking after response")
}
if len(rm.messages) < 2 {
t.Error("expected message list to grow after response")
if len(rm.history) < 2 {
t.Error("expected history list to grow after response")
}
}
func TestMessageWrapping(t *testing.T) {
m := initialModel()
m.ready = true
m.width = 10
m.height = 20
m.viewport = viewport.New(10, 5) // Very narrow
longMsg := "This is a very long message that should be wrapped."
respModel, _ := m.Update(agentResponseMsg{response: longMsg})
rm := respModel.(model)
lastMsg := rm.messages[len(rm.messages)-1]
if !strings.Contains(lastMsg, "\n") {
t.Errorf("expected long message to be wrapped, but no newline found")
content := rm.viewport.View()
if !strings.Contains(content, "\n") {
t.Errorf("expected long message to be wrapped, but no newline found in viewport")
}
}