Fixed propper MD rendering +++++
This commit is contained in:
@@ -133,7 +133,12 @@ struct InputBar: View {
|
||||
}
|
||||
return .ignored
|
||||
}
|
||||
.onKeyPress(.return) {
|
||||
.onKeyPress(.return, phases: .down) { press in
|
||||
// Shift+Return: always insert newline (let system handle)
|
||||
if press.modifiers.contains(.shift) {
|
||||
return .ignored
|
||||
}
|
||||
|
||||
// If command dropdown is showing, select the highlighted command
|
||||
if showCommandDropdown {
|
||||
let suggestions = CommandSuggestionsView.filteredCommands(for: text)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import MarkdownUI
|
||||
#if canImport(AppKit)
|
||||
import AppKit
|
||||
#endif
|
||||
@@ -34,21 +35,16 @@ struct MarkdownContentView: View {
|
||||
|
||||
@ViewBuilder
|
||||
private func markdownText(_ text: String) -> some View {
|
||||
if let attrString = try? AttributedString(markdown: text, options: .init(interpretedSyntax: .full)) {
|
||||
Text(attrString)
|
||||
.font(.system(size: fontSize))
|
||||
.foregroundColor(.oaiPrimary)
|
||||
.lineSpacing(4)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.textSelection(.enabled)
|
||||
} else {
|
||||
Text(text)
|
||||
.font(.system(size: fontSize))
|
||||
.foregroundColor(.oaiPrimary)
|
||||
.lineSpacing(4)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
Markdown(text)
|
||||
.markdownTextStyle {
|
||||
FontSize(fontSize)
|
||||
ForegroundColor(.primary)
|
||||
}
|
||||
.markdownBlockStyle(\.paragraph) { configuration in
|
||||
configuration.label
|
||||
.markdownMargin(top: 0, bottom: 8)
|
||||
}
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
|
||||
// MARK: - Parsing
|
||||
|
||||
@@ -20,6 +20,16 @@ struct MessageRow: View {
|
||||
#endif
|
||||
|
||||
var body: some View {
|
||||
// Compact layout for system messages (tool calls)
|
||||
if message.role == .system && !isErrorMessage {
|
||||
compactSystemMessage
|
||||
} else {
|
||||
standardMessageLayout
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var standardMessageLayout: some View {
|
||||
HStack(alignment: .top, spacing: 12) {
|
||||
// Role icon
|
||||
roleIcon
|
||||
@@ -131,6 +141,34 @@ struct MessageRow: View {
|
||||
#endif
|
||||
}
|
||||
|
||||
// Close standardMessageLayout - the above closing braces close it
|
||||
// The body: some View now handles the split between compact and standard
|
||||
|
||||
// MARK: - Compact System Message
|
||||
|
||||
@ViewBuilder
|
||||
private var compactSystemMessage: some View {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "wrench.and.screwdriver")
|
||||
.font(.system(size: 11))
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text(message.content)
|
||||
.font(.system(size: 11))
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Spacer()
|
||||
|
||||
Text(message.timestamp, style: .time)
|
||||
.font(.system(size: 10))
|
||||
.foregroundColor(.secondary.opacity(0.7))
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 6)
|
||||
.background(Color.secondary.opacity(0.08))
|
||||
.cornerRadius(6)
|
||||
}
|
||||
|
||||
// MARK: - Message Content
|
||||
|
||||
@ViewBuilder
|
||||
@@ -158,7 +196,13 @@ struct MessageRow: View {
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
case .user:
|
||||
MarkdownContentView(content: message.content, fontSize: settings.dialogTextSize)
|
||||
// User messages: preserve line breaks as-is (plain text, not markdown)
|
||||
Text(message.content)
|
||||
.font(.system(size: settings.dialogTextSize))
|
||||
.foregroundColor(.oaiPrimary)
|
||||
.lineSpacing(4)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user