From 701411fac414ff45f620aafa6a5027eccc41fc67 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 3 May 2026 09:04:32 -0700 Subject: [PATCH] fix(tui): show selected chat message first --- tui/tui.go | 7 ++++--- tui/tui_test.go | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tui/tui.go b/tui/tui.go index 4254294..06eb028 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -3416,15 +3416,16 @@ func (m model) chatDetailLines(item Item, width int) []string { if meta := chatMetaLine(item); meta != "" { lines = append(lines, dim(meta)) } + if message := chatBodyText(item); message != "" { + lines = append(lines, "", dim(tuiRule(width)), bold("Message")) + lines = appendLimitedDetailLines(lines, chatBubbleLines(item, message, true, width), detailBodyLimit(m.compactDetail)) + } if title, thread := m.threadSection(item, width); len(thread) > 0 { lines = append(lines, "", dim(tuiRule(width)), bold(title)) lines = appendLimitedDetailLines(lines, thread, detailBodyLimit(m.compactDetail)) } else if title, conversation := m.conversationSection(item, width); len(conversation) > 0 { lines = append(lines, "", dim(tuiRule(width)), bold(title)) lines = appendLimitedDetailLines(lines, conversation, detailBodyLimit(m.compactDetail)) - } else if message := chatBodyText(item); message != "" { - lines = append(lines, "", dim(tuiRule(width)), bold("Message")) - lines = appendLimitedDetailLines(lines, chatBubbleLines(item, message, true, width), detailBodyLimit(m.compactDetail)) } if !m.compactDetail { if properties := chatPropertyLines(item); len(properties) > 0 { diff --git a/tui/tui_test.go b/tui/tui_test.go index b0c0ceb..d246341 100644 --- a/tui/tui_test.go +++ b/tui/tui_test.go @@ -467,6 +467,9 @@ func TestChatDetailUsesTranscriptShapeBeforeMetadata(t *testing.T) { t.Fatalf("chat detail missing %q:\n%s", want, joined) } } + if strings.Index(joined, "Message") > strings.Index(joined, "Thread 1-2/2") { + t.Fatalf("selected message should appear before thread context:\n%s", joined) + } if strings.Index(joined, "Thread") > strings.Index(joined, "Properties") { t.Fatalf("chat detail should put readable content before properties:\n%s", joined) } @@ -515,6 +518,9 @@ func TestChatDetailFallsBackToConversationWindow(t *testing.T) { t.Fatalf("conversation detail missing %q:\n%s", want, joined) } } + if strings.Index(joined, "Message") > strings.Index(joined, "Conversation 1-3/3") { + t.Fatalf("selected message should appear before conversation context:\n%s", joined) + } } func TestChatDetailDoesNotTreatMetadataAsMessageBody(t *testing.T) {