fix(tui): show selected chat message first

This commit is contained in:
Vincent Koc 2026-05-03 09:04:32 -07:00
parent 5d30d87305
commit 701411fac4
No known key found for this signature in database
2 changed files with 10 additions and 3 deletions

View File

@ -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 {

View File

@ -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) {