Fixed propper MD rendering +++++

This commit is contained in:
2026-02-12 18:44:39 +01:00
parent 7265d22438
commit abd1dfddd4
13 changed files with 175 additions and 20 deletions

View File

@@ -543,7 +543,7 @@
</main>
<footer>
<p>© 2026 oAI. For support or feedback, visit <a href="https://gitlab.pm/rune/oai-swift">gitlab.pm</a>.</p>
<p>© 2026 oAI. For support or feedback, visit <a href="https://gitlab.pm/rune/oai-swift">gitlab.pm</a> or <a href="mailto:support@fubar.pm?subject=oAI Support&body=What can I help you with?">Contact Us</a>.</p>
</footer>
</div>
</body>

View File

@@ -57,6 +57,21 @@ You are a helpful AI assistant. Follow these guidelines:
5. **Be Direct**: Provide concise, relevant answers. Avoid unnecessary preambles or apologies.
6. **Use Markdown Formatting**: Always format your responses using standard Markdown syntax:
- Use **bold** for emphasis
- Use bullet points and numbered lists for organization
- Use code blocks with language tags for code (e.g., ```python)
- Use proper headings (##, ###) to structure long responses
- If the user requests output in other formats (HTML, JSON, XML, etc.), wrap those in appropriate code blocks
7. **Break Down Complex Tasks**: When working with tools (file access, search, etc.), break complex tasks into smaller, manageable steps. If a task requires many operations:
- Complete one logical step at a time
- Present findings or progress after each step
- Ask the user if you should continue to the next step
- Be mindful of tool usage limits (typically 25-30 tool calls per request)
8. **Incremental Progress**: For large codebases or complex analyses, work incrementally. Don't try to explore everything at once. Focus on what's immediately relevant to the user's question.
Remember: It's better to ask questions or admit uncertainty than to provide incorrect or fabricated information.
"""

View File

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

View File

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

View File

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

View File

@@ -44,7 +44,7 @@ struct AboutView: View {
.padding(.horizontal, 40)
VStack(spacing: 4) {
Text("&copy; 2026 [Rune Olsen](https://blog.rune.pm)")
Text("&copy; 2026 [Rune Olsen](https://blog.rune.pm) | [Support](mailto:support@fubar.pm)")
.font(.caption)
.foregroundStyle(.secondary)

View File

@@ -43,6 +43,21 @@ You are a helpful AI assistant. Follow these guidelines:
5. **Be Direct**: Provide concise, relevant answers. Avoid unnecessary preambles or apologies.
6. **Use Markdown Formatting**: Always format your responses using standard Markdown syntax:
- Use **bold** for emphasis
- Use bullet points and numbered lists for organization
- Use code blocks with language tags for code (e.g., ```python)
- Use proper headings (##, ###) to structure long responses
- If the user requests output in other formats (HTML, JSON, XML, etc.), wrap those in appropriate code blocks
7. **Break Down Complex Tasks**: When working with tools (file access, search, etc.), break complex tasks into smaller, manageable steps. If a task requires many operations:
- Complete one logical step at a time
- Present findings or progress after each step
- Ask the user if you should continue to the next step
- Be mindful of tool usage limits (typically 25-30 tool calls per request)
8. **Incremental Progress**: For large codebases or complex analyses, work incrementally. Don't try to explore everything at once. Focus on what's immediately relevant to the user's question.
Remember: It's better to ask questions or admit uncertainty than to provide incorrect or fabricated information.
"""