Fix assistant message text truncating with "…" instead of wrapping
Two contributing layout issues in the chat message bubble: 1. MessageRow's content VStack (icon + text HStack) had no .frame(maxWidth: .infinity), so it sized to its content's ideal width instead of the space actually available. 2. swift-markdown-ui renders paragraphs with mixed inline styling (bold/italic runs next to plain text) as concatenated Text(+) segments, which on macOS report their ideal unwrapped single-line size for height purposes instead of wrapping — truncating with "…" regardless of window width. Plain single-style paragraphs (a single Text) weren't affected, which is why some lines wrapped fine and others didn't. Fixed by adding .frame(maxWidth: .infinity, alignment: .leading) to the MessageRow content stack, and .fixedSize(horizontal: false, vertical: true) to the markdown paragraph label so height is recomputed for the width actually given instead of the ideal width. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,8 +61,15 @@ struct MarkdownContentView: View {
|
||||
.markdownBlockStyle(\.paragraph) { configuration in
|
||||
configuration.label
|
||||
.markdownMargin(top: 0, bottom: 8)
|
||||
// MarkdownUI builds mixed-style paragraphs (bold/italic runs alongside
|
||||
// plain text) as concatenated Text(+) segments, which on macOS report
|
||||
// their ideal (unwrapped, single-line) size instead of wrapping to the
|
||||
// width actually available — truncating with "…" mid-word. Forcing the
|
||||
// height to be recomputed for the given (flexible) width fixes it.
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
.textSelection(.enabled)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
// MARK: - Parsing
|
||||
|
||||
@@ -185,6 +185,7 @@ struct MessageRow: View {
|
||||
.foregroundColor(.oaiSecondary)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.padding(16)
|
||||
.background(Color.messageBackground(for: message.role))
|
||||
|
||||
Reference in New Issue
Block a user