From a3e544fbe438e0f8333261d9739b85225aaa02a4 Mon Sep 17 00:00:00 2001 From: Heiko Joerg Schick Date: Thu, 26 Nov 2026 15:26:30 +0100 Subject: [PATCH] feat(panel): close with Esc without a click and render Markdown Esc: make the panel key when shown (closeWithEscape, default on) without activating the app; the source app stays frontmost and Replace still targets it. Handle Esc with SwiftUI's exit command, which also works from the popover and after clicking controls. Add TranslationPanel.canBecomeKey and amend ADR-009.\n\nMarkdown: add MarkdownPresentation in SprachmittlerText (Foundation inline parser plus a conservative block parser for headings, lists, quotes, fenced code and rules), a SwiftUI MarkdownTranslationView, and a renderMarkdown setting (default on). JSON, HTML and code sources are never rendered; only http/https links open; images become alt text; Copy and Replace keep the raw Markdown (ADR-021).\n\nVerified: make verify green; synthetic Esc closes the panel and closes an open language popover first; a live Markdown translation rendered heading, bold/italic, inline code, list, quote, code block and link; Copy returned the raw Markdown; Replace still changed the TextEdit selection with the panel key. --- App/AppEnvironment.swift | 2 + App/Panel/MarkdownTranslationView.swift | 136 +++++++++ App/Panel/PanelController.swift | 12 +- App/Panel/PanelView+Content.swift | 222 ++++++++++++++ App/Panel/PanelView.swift | 197 +------------ App/Panel/TranslationPanel.swift | 13 + App/Resources/de.lproj/Localizable.strings | 4 + App/Resources/en.lproj/Localizable.strings | 4 + App/Settings/SettingsView.swift | 20 ++ MANIFEST.sha256 | 272 +++++++++++++++--- Packages/SprachmittlerKit/Package.swift | 1 + .../SprachmittlerCore/AppSettings.swift | 21 +- .../SprachmittlerCore/PanelViewModel.swift | 8 + .../MarkdownPresentation.swift | 269 +++++++++++++++++ .../AppSettingsTests.swift | 6 + .../MarkdownPresentationTests.swift | 106 +++++++ docs/ARCHITECTURE.md | 6 +- docs/DECISIONS.md | 15 +- docs/PROGRESS.md | 2 + docs/TRANSLATION_OUTPUT.md | 2 +- docs/USER_GUIDE.md | 2 +- project.yml | 2 + 22 files changed, 1072 insertions(+), 250 deletions(-) create mode 100644 App/Panel/MarkdownTranslationView.swift create mode 100644 App/Panel/PanelView+Content.swift create mode 100644 App/Panel/TranslationPanel.swift create mode 100644 Packages/SprachmittlerKit/Sources/SprachmittlerText/MarkdownPresentation.swift create mode 100644 Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/MarkdownPresentationTests.swift diff --git a/App/AppEnvironment.swift b/App/AppEnvironment.swift index 5ba2655..d6026df 100644 --- a/App/AppEnvironment.swift +++ b/App/AppEnvironment.swift @@ -215,6 +215,8 @@ final class AppEnvironment { sampling: settings.samplingOptions, showSourcePreview: settings.showSourcePreview, translationFontSize: settings.translationFontSize, + renderMarkdown: settings.renderMarkdown, + closeWithEscape: settings.closeWithEscape, recentTargets: settings.recentTargets ) } diff --git a/App/Panel/MarkdownTranslationView.swift b/App/Panel/MarkdownTranslationView.swift new file mode 100644 index 0000000..7a487d0 --- /dev/null +++ b/App/Panel/MarkdownTranslationView.swift @@ -0,0 +1,136 @@ +import AppKit +import SprachmittlerText +import SwiftUI + +/// Renders a translation as formatted Markdown. Copy and Replace still use the raw translation. +struct MarkdownTranslationView: View { + let markdown: String + let fontSize: Int + let isRTL: Bool + + private let blocks: [MarkdownBlock] + + init(markdown: String, fontSize: Int, isRTL: Bool) { + self.markdown = markdown + self.fontSize = fontSize + self.isRTL = isRTL + blocks = MarkdownPresentation.blocks(in: markdown) + } + + var body: some View { + VStack(alignment: .leading, spacing: 8) { + ForEach(blocks.indices, id: \.self) { index in + block(blocks[index]) + } + } + .frame(maxWidth: .infinity, alignment: .leading) + .environment(\.layoutDirection, isRTL ? .rightToLeft : .leftToRight) + .environment(\.openURL, OpenURLAction { url in + guard MarkdownPresentation.isAllowedLink(url) else { return .discarded } + NSWorkspace.shared.open(url) + return .handled + }) + .accessibilityElement(children: .contain) + .accessibilityLabel(String(localized: "Translation")) + } + + private var baseSize: CGFloat { + CGFloat(fontSize) + } + + @ViewBuilder private func block(_ block: MarkdownBlock) -> some View { + switch block { + case let .paragraph(text): + inlineText(text, size: baseSize) + case let .heading(level, text): + inlineText(text, size: baseSize * headingScale(level), weight: .bold) + .accessibilityAddTraits(.isHeader) + case let .listItem(ordered, number, indent, text): + HStack(alignment: .firstTextBaseline, spacing: 6) { + Text(ordered ? "\(number)." : "•") + .font(.system(size: baseSize, weight: ordered ? .regular : .bold)) + .foregroundStyle(.secondary) + .frame(minWidth: ordered ? 18 : 12, alignment: .trailing) + .accessibilityHidden(true) + inlineText(text, size: baseSize) + } + .padding(.leading, CGFloat(indent) * 14) + case let .quote(text): + HStack(alignment: .top, spacing: 8) { + Rectangle() + .fill(.secondary.opacity(0.35)) + .frame(width: 3) + .accessibilityHidden(true) + inlineText(text, size: baseSize) + .foregroundStyle(.secondary) + } + case let .codeBlock(_, text): + ScrollView(.horizontal, showsIndicators: false) { + Text(verbatim: text) + .font(.system(size: baseSize * 0.95, design: .monospaced)) + .textSelection(.enabled) + .fixedSize(horizontal: true, vertical: false) + .padding(10) + } + .frame(maxWidth: .infinity, alignment: .leading) + .background(.primary.opacity(0.06), in: RoundedRectangle(cornerRadius: 8)) + .environment(\.layoutDirection, .leftToRight) + case .rule: + Divider() + .padding(.vertical, 2) + } + } + + private func inlineText(_ text: String, size: CGFloat, weight: Font.Weight = .regular) -> some View { + Text(styled(text, size: size)) + .font(.system(size: size, weight: weight)) + .textSelection(.enabled) + .fixedSize(horizontal: false, vertical: true) + .frame(maxWidth: .infinity, alignment: .leading) + } + + private func styled(_ text: String, size: CGFloat) -> AttributedString { + var attributed = MarkdownPresentation.inline(text) + let runs = attributed.runs.compactMap { run -> (Range, InlinePresentationIntent)? in + guard let intent = run.inlinePresentationIntent else { return nil } + let relevant = intent.contains(.stronglyEmphasized) + || intent.contains(.emphasized) + || intent.contains(.code) + return relevant ? (run.range, intent) : nil + } + + for (range, intent) in runs { + if intent.contains(.code) { + var font = Font.system(size: size * 0.95, design: .monospaced) + if intent.contains(.stronglyEmphasized) { + font = font.bold() + } + if intent.contains(.emphasized) { + font = font.italic() + } + attributed[range].font = font + } else { + var font = Font.system( + size: size, + weight: intent.contains(.stronglyEmphasized) ? .bold : .regular + ) + if intent.contains(.emphasized) { + font = font.italic() + } + attributed[range].font = font + } + } + return attributed + } + + private func headingScale(_ level: Int) -> CGFloat { + switch level { + case 1: 1.6 + case 2: 1.45 + case 3: 1.3 + case 4: 1.2 + case 5: 1.12 + default: 1.06 + } + } +} diff --git a/App/Panel/PanelController.swift b/App/Panel/PanelController.swift index 7bf3f34..167be28 100644 --- a/App/Panel/PanelController.swift +++ b/App/Panel/PanelController.swift @@ -2,16 +2,17 @@ import AppKit import SprachmittlerCore import SwiftUI -/// The non-activating floating panel. It never activates the app or steals focus. +/// The non-activating floating panel. It never activates the app. While visible it can be the key +/// window so Esc and the keyboard shortcuts work without a click. @MainActor final class PanelController: NSObject, NSWindowDelegate { - private let panel: NSPanel + private let panel: TranslationPanel private let viewModel: PanelViewModel /// Creates the panel and its SwiftUI content. init(viewModel: PanelViewModel) { self.viewModel = viewModel - panel = NSPanel( + panel = TranslationPanel( contentRect: NSRect(x: 0, y: 0, width: 540, height: 520), styleMask: [.titled, .fullSizeContentView, .nonactivatingPanel], backing: .buffered, @@ -21,7 +22,7 @@ final class PanelController: NSObject, NSWindowDelegate { panel.delegate = self panel.isFloatingPanel = true panel.isMovable = true - panel.becomesKeyOnlyIfNeeded = true + panel.becomesKeyOnlyIfNeeded = false panel.level = .floating panel.hidesOnDeactivate = false panel.isMovableByWindowBackground = true @@ -50,6 +51,9 @@ final class PanelController: NSObject, NSWindowDelegate { positionNearMouse() } panel.orderFrontRegardless() + if viewModel.configuration.closeWithEscape { + panel.makeKey() + } } /// Hides the panel and cancels/releases its content. diff --git a/App/Panel/PanelView+Content.swift b/App/Panel/PanelView+Content.swift new file mode 100644 index 0000000..340c49d --- /dev/null +++ b/App/Panel/PanelView+Content.swift @@ -0,0 +1,222 @@ +import AppKit +import SprachmittlerCore +import SprachmittlerText +import SwiftUI + +extension PanelView { + private var rendersMarkdown: Bool { + !model.translation.isEmpty + && model.configuration.renderMarkdown + && MarkdownPresentation.shouldRender( + source: model.source?.text ?? "", + translation: model.translation + ) + } + + var translationArea: some View { + ScrollView { + translationContent + .frame(maxWidth: .infinity, alignment: .leading) + } + .frame(minHeight: 120, maxHeight: 260) + .padding(10) + .background(.background.opacity(0.6), in: RoundedRectangle(cornerRadius: 8)) + .overlay(alignment: .topTrailing) { + if model.phase == .translating || model.phase == .streaming { + ProgressView() + .controlSize(.small) + .padding(8) + .accessibilityLabel(String(localized: "Translating")) + } + } + } + + @ViewBuilder var translationContent: some View { + if rendersMarkdown { + MarkdownTranslationView( + markdown: model.translation, + fontSize: model.configuration.translationFontSize, + isRTL: model.configuration.target.isRTL + ) + } else { + Text(translationText) + .font(.system(size: CGFloat(model.configuration.translationFontSize))) + .textSelection(.enabled) + .frame(maxWidth: .infinity, alignment: .leading) + .foregroundStyle(model.translation.isEmpty ? .secondary : .primary) + .environment( + \.layoutDirection, + model.configuration.target.isRTL ? .rightToLeft : .leftToRight + ) + .accessibilityLabel(String(localized: "Translation")) + } + } + + var translationText: String { + if !model.translation.isEmpty { + return model.translation + } + switch model.phase { + case .translating, .streaming: + return String(localized: "Translating…") + case .failed: + return String(localized: "No translation.") + case .idle, .ready: + return String(localized: "No translation yet.") + } + } + + @ViewBuilder var warningArea: some View { + if model.sameLanguageWarning != nil { + HStack(alignment: .top, spacing: 8) { + Image(systemName: "info.circle.fill").foregroundStyle(.blue) + Text("This text already appears to be in \(model.configuration.target.localizedDisplayName).") + .font(.callout) + Spacer() + Button(String(localized: "Translate anyway")) { + model.dismissSameLanguageWarning() + } + .controlSize(.small) + } + .padding(8) + .background(.blue.opacity(0.08), in: RoundedRectangle(cornerRadius: 8)) + } + + ForEach(Array(visibleWarnings.enumerated()), id: \.offset) { _, warning in + HStack(alignment: .top, spacing: 8) { + Image(systemName: warning.isBlocking ? "exclamationmark.triangle.fill" : "exclamationmark.circle") + .foregroundStyle(warning.isBlocking ? .orange : .secondary) + Text(warning.panelMessage) + .font(.callout) + Spacer() + } + .padding(8) + .background( + (warning.isBlocking ? Color.orange : Color.secondary) + .opacity(0.08), + in: RoundedRectangle(cornerRadius: 8) + ) + .accessibilityLabel(warning.panelMessage) + } + } + + var visibleWarnings: [TranslationWarning] { + model.warnings.filter { warning in + if case .sameLanguage = warning { + return false + } + return true + } + } + + @ViewBuilder var errorArea: some View { + if let message = model.errorMessage, model.phase == .failed { + HStack(alignment: .top, spacing: 8) { + Image(systemName: "exclamationmark.octagon.fill") + .foregroundStyle(.red) + VStack(alignment: .leading, spacing: 6) { + Text(message) + .font(.callout) + if let action = model.recoveryAction { + recoveryButton(action) + } + } + Spacer() + } + .padding(8) + .background(.red.opacity(0.08), in: RoundedRectangle(cornerRadius: 8)) + .accessibilityLabel(message) + } + } + + @ViewBuilder func recoveryButton(_ action: RecoveryAction) -> some View { + switch action { + case .startOllama: + if let url = URL(string: "https://ollama.com/download") { + Link(String(localized: "Download Ollama"), destination: url) + .controlSize(.small) + } + case let .pullModel(modelName): + Button(String(localized: "Copy pull command")) { + model.copy("ollama pull \(modelName)") + } + .controlSize(.small) + case .openSettings: + if model.error == .accessibilityNotTrusted, let url = accessibilitySettingsURL { + Button(String(localized: "Open Accessibility Settings")) { + NSWorkspace.shared.open(url) + } + .controlSize(.small) + } else { + Button(String(localized: "Open Settings")) { + openSettings() + } + .controlSize(.small) + } + case .copyInstead: + Button(String(localized: "Copy instead")) { + model.copyTranslation() + } + .controlSize(.small) + case .shortenText: + EmptyView() + case .retry: + Button(String(localized: "Retry")) { + Task { await model.retry() } + } + .controlSize(.small) + case .none: + EmptyView() + } + } + + var accessibilitySettingsURL: URL? { + URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility") + } + + var footer: some View { + HStack(spacing: 10) { + Button { + model.copyTranslation() + } label: { + Label( + model.didCopy ? String(localized: "Copied") : String(localized: "Copy"), + systemImage: "doc.on.doc" + ) + } + .keyboardShortcut("c", modifiers: .command) + .disabled(!model.canCopy) + .accessibilityLabel(String(localized: "Copy translation")) + + Button { + Task { await model.retry() } + } label: { + Label(String(localized: "Retry"), systemImage: "arrow.clockwise") + } + .keyboardShortcut("r", modifiers: .command) + .disabled(model.source == nil) + .accessibilityLabel(String(localized: "Retry translation")) + + Spacer() + + Button { + onClose() + } label: { + Text(String(localized: "Close")) + } + .keyboardShortcut(.cancelAction) + .accessibilityLabel(String(localized: "Close panel")) + + Button { + Task { await model.replaceSelection() } + } label: { + Text(String(localized: "Replace")) + } + .keyboardShortcut(.return, modifiers: .command) + .buttonStyle(.borderedProminent) + .disabled(!model.canReplace) + .help(model.replaceUnavailableReason ?? String(localized: "Replace the selection")) + .accessibilityLabel(String(localized: "Replace selection")) + } + } +} diff --git a/App/Panel/PanelView.swift b/App/Panel/PanelView.swift index fb1244f..29c9af3 100644 --- a/App/Panel/PanelView.swift +++ b/App/Panel/PanelView.swift @@ -1,5 +1,6 @@ import AppKit import SprachmittlerCore +import SprachmittlerText import SwiftUI /// The translation panel view. It never activates the app. @@ -7,7 +8,7 @@ struct PanelView: View { @Bindable var model: PanelViewModel let onClose: @MainActor () -> Void - @Environment(\.openSettings) private var openSettings + @Environment(\.openSettings) var openSettings @State private var showLanguagePicker = false @State private var showSource = true @@ -127,198 +128,4 @@ struct PanelView: View { .help(showSource ? String(localized: "Hide source") : String(localized: "Show source")) .accessibilityLabel(String(localized: "Source text")) } - - private var translationArea: some View { - ScrollView { - Text(translationText) - .font(.system(size: CGFloat(model.configuration.translationFontSize))) - .textSelection(.enabled) - .frame(maxWidth: .infinity, alignment: .leading) - .foregroundStyle(model.translation.isEmpty ? .secondary : .primary) - .environment( - \.layoutDirection, - model.configuration.target.isRTL ? .rightToLeft : .leftToRight - ) - .accessibilityLabel(String(localized: "Translation")) - } - .frame(minHeight: 120, maxHeight: 260) - .padding(10) - .background(.background.opacity(0.6), in: RoundedRectangle(cornerRadius: 8)) - .overlay(alignment: .topTrailing) { - if model.phase == .translating || model.phase == .streaming { - ProgressView() - .controlSize(.small) - .padding(8) - .accessibilityLabel(String(localized: "Translating")) - } - } - } - - private var translationText: String { - if !model.translation.isEmpty { - return model.translation - } - switch model.phase { - case .translating, .streaming: - return String(localized: "Translating…") - case .failed: - return String(localized: "No translation.") - case .idle, .ready: - return String(localized: "No translation yet.") - } - } - - @ViewBuilder private var warningArea: some View { - if model.sameLanguageWarning != nil { - HStack(alignment: .top, spacing: 8) { - Image(systemName: "info.circle.fill").foregroundStyle(.blue) - Text("This text already appears to be in \(model.configuration.target.localizedDisplayName).") - .font(.callout) - Spacer() - Button(String(localized: "Translate anyway")) { - model.dismissSameLanguageWarning() - } - .controlSize(.small) - } - .padding(8) - .background(.blue.opacity(0.08), in: RoundedRectangle(cornerRadius: 8)) - } - - ForEach(Array(visibleWarnings.enumerated()), id: \.offset) { _, warning in - HStack(alignment: .top, spacing: 8) { - Image(systemName: warning.isBlocking ? "exclamationmark.triangle.fill" : "exclamationmark.circle") - .foregroundStyle(warning.isBlocking ? .orange : .secondary) - Text(warning.panelMessage) - .font(.callout) - Spacer() - } - .padding(8) - .background( - (warning.isBlocking ? Color.orange : Color.secondary) - .opacity(0.08), - in: RoundedRectangle(cornerRadius: 8) - ) - .accessibilityLabel(warning.panelMessage) - } - } - - private var visibleWarnings: [TranslationWarning] { - model.warnings.filter { warning in - if case .sameLanguage = warning { - return false - } - return true - } - } - - @ViewBuilder private var errorArea: some View { - if let message = model.errorMessage, model.phase == .failed { - HStack(alignment: .top, spacing: 8) { - Image(systemName: "exclamationmark.octagon.fill") - .foregroundStyle(.red) - VStack(alignment: .leading, spacing: 6) { - Text(message) - .font(.callout) - if let action = model.recoveryAction { - recoveryButton(action) - } - } - Spacer() - } - .padding(8) - .background(.red.opacity(0.08), in: RoundedRectangle(cornerRadius: 8)) - .accessibilityLabel(message) - } - } - - @ViewBuilder private func recoveryButton(_ action: RecoveryAction) -> some View { - switch action { - case .startOllama: - if let url = URL(string: "https://ollama.com/download") { - Link(String(localized: "Download Ollama"), destination: url) - .controlSize(.small) - } - case let .pullModel(modelName): - Button(String(localized: "Copy pull command")) { - model.copy("ollama pull \(modelName)") - } - .controlSize(.small) - case .openSettings: - if model.error == .accessibilityNotTrusted, let url = accessibilitySettingsURL { - Button(String(localized: "Open Accessibility Settings")) { - NSWorkspace.shared.open(url) - } - .controlSize(.small) - } else { - Button(String(localized: "Open Settings")) { - openSettings() - } - .controlSize(.small) - } - case .copyInstead: - Button(String(localized: "Copy instead")) { - model.copyTranslation() - } - .controlSize(.small) - case .shortenText: - EmptyView() - case .retry: - Button(String(localized: "Retry")) { - Task { await model.retry() } - } - .controlSize(.small) - case .none: - EmptyView() - } - } - - private var accessibilitySettingsURL: URL? { - URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility") - } - - private var footer: some View { - HStack(spacing: 10) { - Button { - model.copyTranslation() - } label: { - Label( - model.didCopy ? String(localized: "Copied") : String(localized: "Copy"), - systemImage: "doc.on.doc" - ) - } - .keyboardShortcut("c", modifiers: .command) - .disabled(!model.canCopy) - .accessibilityLabel(String(localized: "Copy translation")) - - Button { - Task { await model.retry() } - } label: { - Label(String(localized: "Retry"), systemImage: "arrow.clockwise") - } - .keyboardShortcut("r", modifiers: .command) - .disabled(model.source == nil) - .accessibilityLabel(String(localized: "Retry translation")) - - Spacer() - - Button { - onClose() - } label: { - Text(String(localized: "Close")) - } - .keyboardShortcut(.cancelAction) - .accessibilityLabel(String(localized: "Close panel")) - - Button { - Task { await model.replaceSelection() } - } label: { - Text(String(localized: "Replace")) - } - .keyboardShortcut(.return, modifiers: .command) - .buttonStyle(.borderedProminent) - .disabled(!model.canReplace) - .help(model.replaceUnavailableReason ?? String(localized: "Replace the selection")) - .accessibilityLabel(String(localized: "Replace selection")) - } - } } diff --git a/App/Panel/TranslationPanel.swift b/App/Panel/TranslationPanel.swift new file mode 100644 index 0000000..63363bd --- /dev/null +++ b/App/Panel/TranslationPanel.swift @@ -0,0 +1,13 @@ +import AppKit + +/// The translation panel. It can become the key window without activating the app, so Esc and the +/// keyboard shortcuts work as soon as it is shown. +final class TranslationPanel: NSPanel { + override var canBecomeKey: Bool { + true + } + + override var canBecomeMain: Bool { + false + } +} diff --git a/App/Resources/de.lproj/Localizable.strings b/App/Resources/de.lproj/Localizable.strings index cb80c28..0bfa8f4 100644 --- a/App/Resources/de.lproj/Localizable.strings +++ b/App/Resources/de.lproj/Localizable.strings @@ -100,3 +100,7 @@ "Copy report" = "Bericht kopieren"; "Clear" = "Leeren"; "Open Diagnostics…" = "Diagnose öffnen…"; +"Render Markdown formatting" = "Markdown-Formatierung anzeigen"; +"Render bold, italic, headings, lists, code and links when the source is Markdown." = "Fett, kursiv, Überschriften, Listen, Code und Links anzeigen, wenn die Quelle Markdown ist."; +"Close with Esc without clicking" = "Mit Esc schließen, ohne zu klicken"; +"The panel takes keyboard focus while it is visible. The source app stays frontmost." = "Das Panel übernimmt die Tastatureingabe, solange es sichtbar ist. Die Quell-App bleibt im Vordergrund."; diff --git a/App/Resources/en.lproj/Localizable.strings b/App/Resources/en.lproj/Localizable.strings index 5de431d..604005d 100644 --- a/App/Resources/en.lproj/Localizable.strings +++ b/App/Resources/en.lproj/Localizable.strings @@ -100,3 +100,7 @@ "Copy report" = "Copy report"; "Clear" = "Clear"; "Open Diagnostics…" = "Open Diagnostics…"; +"Render Markdown formatting" = "Render Markdown formatting"; +"Render bold, italic, headings, lists, code and links when the source is Markdown." = "Render bold, italic, headings, lists, code and links when the source is Markdown."; +"Close with Esc without clicking" = "Close with Esc without clicking"; +"The panel takes keyboard focus while it is visible. The source app stays frontmost." = "The panel takes keyboard focus while it is visible. The source app stays frontmost."; diff --git a/App/Settings/SettingsView.swift b/App/Settings/SettingsView.swift index a79433d..481013b 100644 --- a/App/Settings/SettingsView.swift +++ b/App/Settings/SettingsView.swift @@ -103,6 +103,26 @@ struct SettingsView: View { ) } .accessibilityLabel(String(localized: "Translation text size")) + Toggle(String(localized: "Render Markdown formatting"), isOn: $draft.renderMarkdown) + .accessibilityLabel(String(localized: "Render Markdown formatting")) + Text( + String( + localized: """ + Render bold, italic, headings, lists, code and links when the source is Markdown. + """ + ) + ) + .font(.caption) + .foregroundStyle(.secondary) + Toggle(String(localized: "Close with Esc without clicking"), isOn: $draft.closeWithEscape) + .accessibilityLabel(String(localized: "Close with Esc without clicking")) + Text( + String( + localized: "The panel takes keyboard focus while it is visible. The source app stays frontmost." + ) + ) + .font(.caption) + .foregroundStyle(.secondary) } Section(String(localized: "Double copy")) { diff --git a/MANIFEST.sha256 b/MANIFEST.sha256 index c59395b..a4706e0 100644 --- a/MANIFEST.sha256 +++ b/MANIFEST.sha256 @@ -1,4 +1,4 @@ -f6951b1dfd3273d8b320f489125b01f6cdbac708f6e6a6a1af1c35fd43f224ce ./.gitignore +ac3b5df584dabe8c38d8dde42e1871198e11c0512e1ed57b45b8cbcdfc5e35f6 ./.gitignore b6f32f48809b596fa90c724e986bc78f220cac1928039eb57b8f7c13ea9a3081 ./.opencode/agents/architect.md a58c2194b2a853d0e418ea68b6816e8cde60a007b5fab596819a5cdf77dc4140 ./.opencode/agents/swift-reviewer.md f58fbb98fbe250169d903f3f3233564ebab9ec73db96418adf0a5d9db26ed389 ./.opencode/agents/test-engineer.md @@ -17,76 +17,274 @@ c989a2513d0b926f3a202b0616426c7443594ce72896ee91c29c4e83451d433c ./.opencode/sk 57f91677056a59e48748c63557672361cdb24bfa39264560df0209bcff0fd919 ./.swiftformat 2c0c375f3f6704a43e1042b250e0b633ba740aa7bc2fbf5518891a7b5464507e ./.swiftlint.yml 3222c8553505401c967cc302e2d46a99db95f98d92650f6b245e2a1dc901bea9 ./AGENTS.md -52b02a06a5fa40eb610a19c4e83564fb6c5b3592e25a63f271bc42eb75a25924 ./App/AppDelegate.swift -c36aade859ae4432a04f5fb050322e1c78a6e535c206a18b61971809c0fef4dd ./App/Info.plist +593745fab27436e91148de34b7e0e530cef5137e2c566cb479caed033602b949 ./App/AppDelegate.swift +57bb84de7d482ba5a4a51126b647a99f595b1af8e3739a5db63dd4d6006f28bd ./App/AppEnvironment.swift +dc41f554a88b5b499840f72ef676b31530e6ebfcc5da636155001c52ca48d8a1 ./App/Diagnostics/DiagnosticsView.swift +69f0c24937507ed7a9137abfa95fdcd2798cd909dd74642d4b5e6a859da94253 ./App/Info.plist +36aec6e936e6ffff104908b370a7231b9283e178df8d0a453639dca9c573460d ./App/LaunchAtLoginController.swift 553ade6c51a4532be13593e95684c0cc3403e7222f1208bb36200f96915d5e83 ./App/MenuBar/README.md +3099e4feba33120e9ce41e3b8701d8fb8f305b4fdd965336950c3bb7e0e38c50 ./App/MenuBar/StatusMenuState.swift +3b001166f13cac42136917cfde0277c6cd8cfa922280832a4065081b822b3f9d ./App/MenuBar/StatusMenuView.swift +c4a25b6c1207197109d12ea740dc15ad8aa75b6304d901110aa3e10570cd65a0 ./App/Onboarding/OnboardingView.swift ba9467153908c81fbb2497d5679642ae15c7b9fa23a10ca9b9ab678042aab222 ./App/Onboarding/README.md +eaf54c09c3df9847f456cb81f198df3b82fa53f02f1fad4918af5549e92ddc7c ./App/Panel/LanguagePickerView.swift +76dcf59e01ae8319d4f0aabc5e600c549adaf56b6db802794804c3215be9377c ./App/Panel/MarkdownTranslationView.swift +267c008ba680bc49f2397bf01a667fa7594177cdb2333ea190cfff36a5fa3174 ./App/Panel/PanelController.swift +aa364e7cb6373cdeaea0c24f59c959ebcdca228be21a27c6fae431463a6d2c04 ./App/Panel/PanelView+Content.swift +278b9bd96ffe8c322703dec7c660632351c8e9a1996b0ee5713299f3de4ae082 ./App/Panel/PanelView.swift bd37b327672595d55c263f109005b816406cce5928ac58c66286cee0f5d16531 ./App/Panel/README.md +9e09591204b9ca4518a031fc856b0cd01245fe8c4e14aa7238e75a83ab05d4c3 ./App/Panel/TranslationPanel.swift +9e8223452ecc9eb20a4e0395d225b93871c4fd2cccbdfe58880620c30d3bb047 ./App/Panel/WindowDragArea.swift +718f35bba5763975e162109095348661d4edfa1d8f167da04376fbdc71cfc7ad ./App/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json +183606ef4431a2099a26983fac8261ab4d8fbf5fb6ff0204367d3a51e11212ce ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128.png +5e90d81c2decbf8a5c4fd5624e976cd4591f4f53c4c4a40e146d8bb1872d2353 ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png +968a49a8667ed72ccb608b39fe28afc3f95cd4ee8689d567983ae0dafd6978aa ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16.png +f7fb7b04d7936a965befe202545fdaccb69d7c0c95a99449a27c9119d0326991 ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png +5e90d81c2decbf8a5c4fd5624e976cd4591f4f53c4c4a40e146d8bb1872d2353 ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256.png +182c8e94854779aefc2f19115d04abb2c66493537bd68f7c5448ae9b9161e38f ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png +f7fb7b04d7936a965befe202545fdaccb69d7c0c95a99449a27c9119d0326991 ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32.png +77e828091f2a32d6e233182320842921ae6770c33db8b1dd25800c2e88bfb835 ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png +182c8e94854779aefc2f19115d04abb2c66493537bd68f7c5448ae9b9161e38f ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512.png +2c8e82d99378ff2fe0ca98754a3ef29861f0130c54008634106532d0754760d6 ./App/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png +f23266b9672263c92ced1d26fe4dafa75a14d530eb9bc5fc1f599034d597ab48 ./App/Resources/Assets.xcassets/Contents.json +1da14ac15fda89935795e6a9faa5274cf6a2047de56f635be7d6da01699c2cdf ./App/Resources/de.lproj/Localizable.strings +3fcec362d3bd5776af97259d92f9e6349a927d8730fb06f3f8776c97b7a10606 ./App/Resources/en.lproj/Localizable.strings dcdaf8761f3b195e8c8d8889b2b792aa3dabbaa47b0c641fb4db4cdc09436026 ./App/Settings/README.md +13ded50c5202ce32bbe6d8432f0701f7d71bf9bc99e4b5e02e688b51416053b9 ./App/Settings/SettingsView.swift d3dcb4365c3d9ec39fa379b8e5cc0813745acc68dc851a85b4ab277896a2a5b1 ./App/Sprachmittler.entitlements -3a384017b5b54049c946a674f8263be61f445b8f1ff6f48cdefd70a4bfbe2b00 ./App/SprachmittlerApp.swift -8bad14fa182903bd8f17cca19edceb0b779246f9ce858ede63cd6b575c2b2265 ./Makefile +ddda3377a2e130e25195da349dd0964cfca8a401464b7b0cd8fcec6bfb575fa3 ./App/SprachmittlerApp.swift +c3d0de679f6d151f46cfdd11577eba65e1cff1f82be669be32e42a99fba302ba ./Makefile 0608007aa6ef1a3533d5e5b4d021e753efe89d24dea881d5ed443429a43a9de2 ./Packages/SprachmittlerKit/Package.resolved -8222951112a60723d1d9a65aa00a152f9138d10c4c8b3dc6e7c47bf2b5c46bf5 ./Packages/SprachmittlerKit/Package.swift +44627d4034cde7e11afff37e9b7b99b8384b2291db657f9914a5312ff8f5eac8 ./Packages/SprachmittlerKit/Package.swift +a6b0221a7c806cfbcb6007c960772ee1c063c0b85727a1d1fc42097baf6dcd70 ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/AXTextEditor.swift +9c7c19d9ea7d8369244447772a3fa0c3fac21cec0ec22b9df700555f4113a22f ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/AccessibilityPermission.swift +348b56aa312a253c6a4de1e1af51ca6b9b5c4e49b86aaf7525f43c180ed17937 ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/ClipboardSnapshot.swift +2386c6d9f5637e4be701eec1296240dad71211509c971bc7dcc334c975f4b9cf ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/DoubleCopyDetector.swift +ec2f66d1a2d8ebb308427802f54cc70c6bdead8c31a57ed87648446d6bda9ce1 ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/FrontmostTargetProvider.swift +85abecf8ca1b15fe1a9d5dbaa0caee16a38a4408e932f6115975d9823a2ac47c ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/InsertionCoordinator.swift +0b8a8223e67d0c94551c1dd68609858602069d0ecd4eda736f988880d1e04464 ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/PasteboardAccessing.swift +4ca88b4f08515057738a45c9ae475260e3a840c1d5bb3d4622a57ce04f5b8cb1 ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/PasteboardTicking.swift +543efb54825e2851528efd0c2a4b068929b79c3e0276c1314e6b5414480f893a ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/PasteboardWatcher.swift +26aeb81883b8216f364215602b804a2d6e6994a221f9c910c0ed52cc70d4c3aa ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/ServicesProvider.swift dada1b00037d12da0df03a24d1140e428beb9488fde7e0a9d99d0cca58d1a4ca ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/SprachmittlerCapture.swift +728ab857854f1f2bb46f032a13f6d47edd491ee0d6ca0aa8bf2b98f91ccb3c23 ./Packages/SprachmittlerKit/Sources/SprachmittlerCapture/SystemPasteboard.swift +7c580669d76ca3154889a2f3045a1e2689c8984398163496e0ce4cdcad9ae880 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/AppOllama.swift +ec9fea234c3ba2b1d3ef3b308537071bb1e72bd913da9271f4b291c26f62d5d8 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/AppSettings.swift +7921d56341b4b6fe4392989b30de91bb2aeb91a8d52d840dc9602a3d5a6134dd ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/CaptureLimits.swift +5159e03a08507c4d6f61479cd4ce389e9541a8df4540ef6540cedaba6e8133a1 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/CapturePolicy.swift +02421321864ecf0540a96b55a692e91eacb9364d579735d20b9ca94ebcf99a80 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/CaptureText.swift +3ce80227fe4f6cfb9efc00d83cb4bff28e870fd72aa29d8cc03a723e8694a34e ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/CapturedText.swift +2a8c7b261b3c955547fd88520a9582c5c31a1e86a4c13d8bebfbe1d4b8f752bc ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/DiagnosticsStore.swift +3275711919331a617e9db199e89d6ba5a9c28d518eea4a590fd9dac74c7bd876 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/DiagnosticsViewModel.swift +d81ffb9aedc1feef70af050f55f3d0bfd85a828bda80d54d32e5a0667e05bef9 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/InsertionTarget.swift +56037f9dc0096e9e5e0a44365fb29ecd3185e8c39bb7ee156f31ec08e1326ff5 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/LanguageAliases.swift +5d78b5e2aafd267d0e6eba66ae7257dabfc1dfb4b913e78754f7ae128bddfd4d ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/LanguageCatalogue.swift +c2fcbae9e59d203f90c7f21a92d3c46ffa9c04d916a1565d16b90e4fa1b361fb ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/LogCategory.swift +cc89553a898735a1288bdd1c67a04fbcd282f99ee812a83c8b18eff9627ab65d ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/LogRedaction.swift +39cec81db2748fd5e01c5d6ade00bae5babf4a68d7d472a69e98b20884585c5f ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/Loggers.swift +83b6c93fc950df1fa8e4942521187a0ee3ecb319b5ffec6deef6047ef8d2b171 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/OllamaErrorMapping.swift +b7dfab9b2c613071b97bc329378eae47b97305cae758221fba787c8be4eb52f5 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/OnboardingViewModel.swift +e46605bc2ff74d4a122ac23bce763b847b9930abbe2b9d2a5f1ea1ed0cb5d6e7 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/PanelViewModel.swift +c52e182fdc6806a06f7b516806140ef26aad8c44e72f9e5beb9135acbe28b878 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/PanelWarningMessages.swift +563d79ceae06a20e8a5b78e155bfe8489bac8f5267a8c3d064fd5c50ecc66cf5 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/PermissionProtocols.swift +761c20b4a1c063ac39648c3d24d8864a0329ff348eaf45db4fb27c573f15e44a ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/SettingsStore.swift +afd0db8a53c0afb37bafc8647e2da0a8f741e0b7396c018f95c63a80484ea80e ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/SettingsViewModel.swift +b126a8164e50da9c4f276efbc2f591fb94a587b9855a5c9379485ab7d334864e ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/SignpostInterval.swift +e33ebfeeeb27b88029c20f212769852c5c0a697abaeb1bc249d350e7ad649273 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/SignpostName.swift +20e3977534de6e1c1af8bcc3049318007213a034aa2e8d2d24032b22e1bacba0 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/Signposts.swift b6580ae5a0f5e18b6b527766cb5acd5de4d828df3badac44ae294dd72acfc436 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/SprachmittlerCore.swift -fa4aeb76903a93335817a71e80829c6a950288c3575deddc0dd3f89d7a59ce79 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/SprachmittlerEngines.swift +2864b92feb24a0616fa546ea2683fbdc9f73352ca64ab84da110e19fd7c6a926 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/SprachmittlerError.swift +c54f853a63db2f71fb5e574976e0f6b3ed39ae768adb644a0e245c5844fa2b5c ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/SprachmittlerErrorMessages.swift +f75ae67b262e18b53721d070acc0e8d7bdfca94698f10c1a5780ef948ef72912 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/TextInserting.swift +b7d4bf8d2a1ab24b26dfa3e091e9fa7e92f8460f8850f9f086af4814537b1f4a ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/TranslationPipeline.swift +d01aaf98c054bd3d14ce4d6055f576738d83b63037f246b0ec3cc302b130c12b ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/TranslationSession.swift +480503eea4bc64f3125560c91d47e56cd9905e957af189a54cdf8b816a380ec2 ./Packages/SprachmittlerKit/Sources/SprachmittlerCore/TranslationWarning.swift +5a721207611b9aa6228bc288f5f5e0c57dd26c593ab3aec9bd38c91f9a9e0fd2 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/HyMT3Adapter.swift +06bf6da9127b3a010cb33b3db091e4301b32aca44f8cc7181ed1c34b00ece7b5 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/HyMT3Languages.swift +0b5e6571d378577091f8ce3b86020545b45ca2c3400afe88ebeed7b4aa8b68f8 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/HyMT3ModelPreset.swift +dfbbd5cfa397340a38b844307621c26e28708eb36aa91095739e492838124c9f ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/HyMT3Options.swift +021919b8ff8e27bde4f02b4ada08e2b70463225afdc749d4604db6f84efa85cc ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/HyMT3Prompt.swift +34b21987ac51e045a4ce9d3aaa324f1e2a6a8abdf3f9f2908e9ceca3c0581862 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/LanguageMatching.swift +1ad2760062b723e41d46c38fe7b1b4cbe959af417f9657aa12c6f3a6c08f406f ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/ModelLanguage.swift +ab9d4fcd37731131646decc9bb9a25b1e2338613ee6b093427c89287a2e9b762 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/NumericTokenNormalizer.swift +f00f88c07fc06f2abbf5a17554cb3cb7915f4e60fd32cdf98cdeeb810875add6 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/OutputValidator.swift +c473fa0f2c89d4a4f75307e81a6a5d28f1f21f3bffcc8911bb30487d27f64486 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/PreambleDetector.swift +50394e1fd104b4fd85cd2b206b146addca15fa21d7cadc5e3cef4ea7f88436a9 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/PromptPolicy.swift +5c5b1bfa5f10e2be6ce52f13e7c13143cbcbd7ab3e2af53edd3b13badc228f5a ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/PromptVariant.swift +dfe9d284e76ae67a42418c69dae4f84810b9ac7e6d3af675ded1625dd083282b ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/RepetitionDetector.swift +5ddee40aab9a5e099ffdb3c7844ae9d19ea44c885a89a774335c66b6927de62d ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/SamplingOptions.swift +1a0d4d9149432f7771a84060377eda2589d14b9041d9f296b871dc4ae3e92718 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/TranslationAdapter.swift +8969928cf7b9a71d9aeb2ee36fd6a70cec1c7ba9fdd5f42c23d4bf28e49a43b6 ./Packages/SprachmittlerKit/Sources/SprachmittlerEngines/TranslationWarning.swift +418b1f3737fcf926815055c4f4f3409b292e6afcf0d6b81f37d1160b9f65ac35 ./Packages/SprachmittlerKit/Sources/SprachmittlerEval/EvaluationManifest.swift +43d7f19f92767fb2109dadf939ec4e829a58bd738f81c8abe7b8f3c92e58f9bd ./Packages/SprachmittlerKit/Sources/SprachmittlerEval/EvaluationMetrics.swift +dde82951a4e969628d80b224771124fa70caaa2ba0b447366343d5a99dc0361e ./Packages/SprachmittlerKit/Sources/SprachmittlerEval/EvaluationReportWriter.swift +dd445421272beed0c28e0c2f853d267fb6c8832a313cf836f6c2e47cf024b574 ./Packages/SprachmittlerKit/Sources/SprachmittlerEval/EvaluationRunner.swift 83f6c78029abb6c43c78039773f601752411f0f8f23ec3a9891e8008b70387b6 ./Packages/SprachmittlerKit/Sources/SprachmittlerEval/SprachmittlerEval.swift -887b767c70d1c765fc73553439980c4216bdc278d4b27f923bde04378cd6d6e9 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/SprachmittlerOllama.swift -a517bee61c90ae280f6d8893e998aeff3ea4ccdcfca08a006287e1b4750275fd ./Packages/SprachmittlerKit/Sources/SprachmittlerTestSupport/SprachmittlerTestSupport.swift +c5a26fded64056855f876a6a2c0c466afbc3f5fce1de2323eb073da9ec09f256 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/AsyncSleeper.swift +58160c8c41ba81d72aa96dee583fa0ffc5fc64654da3a56f608c67c62aa49352 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/ChatEvent.swift +0817f2102a866ce7c0bfc06fa8504a73294e75a6fca70ee0578ce78216b42147 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/ChatMessage.swift +363bb249519c2b2d67a6a0c516bb5b113298545cad1a575593b5212702418acd ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/ChatMetrics.swift +38a5c0272aff387a1ba70a073559a97d2b31b4b9c4550c0540a7ddbcd8a93705 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/ChatOptions.swift +7ecf5e465e8cb14182396e850ba8640c74d1a0d1fec3f8c39d288d0ff89cf750 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/ChatRequest.swift +f22c1caae9a722373605504cf9a3a268497f3d8683548e0b75b417042d3af9ed ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/ChatStreamContext.swift +9944f8e250c2b334a9129a82281fef45663043a5b0a3bf01acdb114b68c565bc ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/ChatTimeoutController.swift +4f850d29de8d81ff85e0a3602cc72029f675ea37d56481e75aea7d5b5e0d087d ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/ChatTimeouts.swift +f158a61553f38138d6e8a08e02c15de949b882898273d9c13b857401a01df7a5 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/EndpointPolicy.swift +eb3bdca89e3e15d2c9300e0f92ddd36dfde28d6105e87ee3c4ca29171ca2152d ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/EndpointRejection.swift +157abae634245d3646f16e2742ecaeae72adead8c10f6d1ab3dcaa02b5766ff6 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/InstalledModel.swift +312b3919d01d0128b57db111a579b0add5b89d7e8010ec270aecdd9a3ef38dac ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/LoadedModel.swift +88ea1a3e0617aef24ddcff51073fc30b27974b9bf8454ab8288e9f003240cc11 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/ModelDetails.swift +ab586304f68d4e46146577438db1560107eb8f713cd0f4244fb0ae3344496742 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaCatalog.swift +68491c3709467eb22a9d9c21ea72d7ef3a37ab04b6acde496a714e772fd3c3f8 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaCatalogClient.swift +1ff7419acc3a2401faa719eb0e8955a318ebade41b8718a8bf7c52abc5be2c7b ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaChatClient.swift +ba536c52aa94cf7e48dd98b741a41234b3f8709a38503ab264998da281d44dbe ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaChatting.swift +5f4ee95364526a59e0776207a1e93ce6cea5eed3473bd5686a8674a425824401 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaError.swift +711780019b33a02bf048968196f04b04a4f996ea9d0e1128140b153524a0ddf9 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaErrorBody.swift +0020db5fc620a8a188ec0e6feb8d903bd4d849c87808efb8b85449c4056e4bf7 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaHTTPClient.swift +d76d67d55efc70289aeed9626265c3f6d183b001c4d36047f4e8962180a18ce1 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaHTTPRequest.swift +c32d05b70ba04d525064a2ed71f5ea67d1655d72c56f9d185aefe4250840321b ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaHTTPResponse.swift +232e1e3d1eb070a353e72f301c82a4f3ce56c874f8754fddb98bf71a5a816798 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaHTTPTransport.swift +92753142b6151ff867de64d1ce93ef1e975c3b0e7cf15f36b23828f3346e0275 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaSessionFactory.swift +15038cb5553980b00888fb763a8950da29e9c976fdc5288c0421053e84aefe4d ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaVersion.swift +58d527fdb66f62fb6b7009bf454b94ba0f6ebd19c3686d91c5f598154533c830 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaWarmUpPolicy.swift +443eefc6de2a8196735ba2deb207bfc36f46b1217e7873db9115c69f6db26921 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/OllamaWarmUpRunner.swift +314982eecd8a75575e2c25fc776ac785c8d9e99d035a645480e68b946d007a43 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/RedirectRefusingDelegate.swift +2c4ec4c3422d65987661842420f313b48c17bb5785b6b8be28ea07cd8f95d02f ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/StreamLineAction.swift +54c856650277c61b2e6dde34120eaae59a7b354d0ed621f5ac8634684211b030 ./Packages/SprachmittlerKit/Sources/SprachmittlerOllama/TimeoutPhase.swift +9a8d1d437e08462d0f063ac0784812b0f8183dce5b4251b28c5c064e4a47d3fe ./Packages/SprachmittlerKit/Sources/SprachmittlerTestSupport/FakeOllamaCatalog.swift +54076808b76b6efd5ecb174403210c331d1b674b15120400323c0623e9e3ac85 ./Packages/SprachmittlerKit/Sources/SprachmittlerTestSupport/FakeOllamaChat.swift +1cd84966052430f540220cd7bd22203b8a77574540a66700288e588e9b8efb52 ./Packages/SprachmittlerKit/Sources/SprachmittlerTestSupport/FakeOllamaHTTPTransport.swift +524e816552afe34f8844a1c01bb56b6bc81fc5a83cc96889a25bd044e73dc0c0 ./Packages/SprachmittlerKit/Sources/SprachmittlerTestSupport/FakePasteboard.swift +03d570bc4022f205abb52da509bd68444879308b14f46bad497cadf9f80f3845 ./Packages/SprachmittlerKit/Sources/SprachmittlerTestSupport/FakeSettingsAndPermissions.swift +16e6ae7d693df1ee6532affec1fa687aeed1e709595b929f2a4e1f00e1b9d88a ./Packages/SprachmittlerKit/Sources/SprachmittlerTestSupport/ManualPasteboardTicker.swift +c0f87a5320fe715f5dbc7c9bbc7c0fb19a5b64d1c145c45b26f060c151eccada ./Packages/SprachmittlerKit/Sources/SprachmittlerTestSupport/ManualSleeper.swift +3443a4e2a7d3d493b9d604875f0abec2f3a515fd162f6af41e25f48c78185b57 ./Packages/SprachmittlerKit/Sources/SprachmittlerText/Chunker.swift +b639d452d78dcda9e9f3b5ac3298e8499a7837a955839ae5203b508944df2c63 ./Packages/SprachmittlerKit/Sources/SprachmittlerText/ContentClass.swift +b768d43f50bd4fcede0f3c654787771a605b6ea2648cac722d0e78dd913b4fa5 ./Packages/SprachmittlerKit/Sources/SprachmittlerText/ContentClassifier.swift +983997717ee3a06b7355a9611a27f7c93a631a8434fd9bcfc79f8497c4a3696d ./Packages/SprachmittlerKit/Sources/SprachmittlerText/LanguageDetector.swift +41aeff6d807caa027f9496a4bd6048bdde55d6eeb4a11b2acdf445dff39735bc ./Packages/SprachmittlerKit/Sources/SprachmittlerText/MarkdownPresentation.swift +c7591458a2fcf4813a166cf4f15aaca69688a85e319cf71ebd5c2dcffba756b8 ./Packages/SprachmittlerKit/Sources/SprachmittlerText/ProtectedToken.swift +2ec31538fe5a2ed98fcce6b815c1844cfd30a53073f4987eda8043bcd222d58d ./Packages/SprachmittlerKit/Sources/SprachmittlerText/ProtectedTokenScanner.swift 6ea915648616c12b9b2ae3bbb97838a512c6c3a91b2bccfc13e144d950d4bb6e ./Packages/SprachmittlerKit/Sources/SprachmittlerText/SprachmittlerText.swift -8a349b1fdbd3755bec2f6ef45ebec31af96be8857923e3d0f79696f5c98eeffb ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/SprachmittlerCLI.swift +4e05396e9e2f915d450af13f57dde523b961d1ba204bffdb5c94db4ba0d82941 ./Packages/SprachmittlerKit/Sources/SprachmittlerText/TextChunk.swift +f528068c473ed46c7daec43a1306b7bd50aec76bf3fc353bfd86fd5e18388854 ./Packages/SprachmittlerKit/Sources/SprachmittlerText/TextNormalization.swift +383da4ec8485cf7457d9e336978ec8b4a6d9f49cbfab8db70db45dc833decb56 ./Packages/SprachmittlerKit/Sources/SprachmittlerText/TextScript.swift +b2f837437ba28548e74d43a2a88bdc3f2e79d3d1e6ec16b381af04256909174d ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/CLIEnvironment.swift +d775cfc21b88687a443118fc0d12f6c4837f712ab674b12286f87470a33bee8f ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/CLIError.swift +7475168734bec7883f4f911af91e4a7184da55849b853eaf7429ae20171d3db9 ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/CLIOutput.swift +9c0e6beeffe1ac02e5f32d24f2fe78159183719414978a5c9bb9752313805777 ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/DetectCommand.swift +d4ea1f2538934b1c2ffa69fd905c42194760a535a54ac4d241daa616530f976e ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/EndpointOptions.swift +57a104206b2e662d3fd8e5040b422242744752a90133f2f902771d1d73e6d62e ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/EvalCommand.swift +48a9061c6c40d9bd32a55635873e64f5ed7f97edc97827f78979c7b74eb55a85 ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/LanguagesCommand.swift +aa686ae5d4b40d290b7963a2ba97dab4e3ae8c2054c0df09e9093448408dbcfc ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/ModelSummary.swift +97d119e9c05d62a527bb255ac67dff9049d76a7c11ac292b7ed0ce11b63c1cbe ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/ModelsCommand.swift +b8645b487845964dbc060c2a99081d7f89ca5026fb6ab5be82433bf1aa0c1b18 ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/ModelsRunner.swift +b0125112472bc642661bf0233f0b7cf1bce3ef7f511c333f73364152b0527213 ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/ShowCommand.swift +a2e96139102375e8586a1568f22d44317cb0034e62c977ae45fc691126c4114c ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/ShowRunner.swift +1c9b3e180e4ce78c5cf10bba99edd6c36fa9fbac85e4062dce84d396693e1776 ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/SprachmittlerCLI.swift +78d1933ed58d565c2cc5b5463e8c99b3dbcc379f77ec956c645085912441282c ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/TranslateCommand.swift +d0e8bf434a42ce93fba7e611b26797dd5b7d20cd0c9468524fc14ef84b3abcc1 ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/TranslateOutcome.swift +e7ec098ecc2e0c3f62ba53cd44afc0659b77b7baf2d5ab307cb4238c1f6efa5c ./Packages/SprachmittlerKit/Sources/sprachmittler-cli/TranslateRunner.swift +3466e030b39a884371d10ba4a2b9ea1a05b7b053af1bd0cb88aa046ba1af2067 ./Packages/SprachmittlerKit/Tests/SprachmittlerCLITests/CLITests.swift +57fbb191c4bf3a9325d5fdab1cdc950bc6e2579f12ea64442c8b2dbd56b79cf4 ./Packages/SprachmittlerKit/Tests/SprachmittlerCLITests/SmokeTests.swift +d4e110c510cac46c1acecc68f28ef8b30daaf1f9b623f0533ad359a6a13680aa ./Packages/SprachmittlerKit/Tests/SprachmittlerCaptureTests/ClipboardSnapshotTests.swift +23e0c52e3f5f9b5848ff9118bfe3baf474a21c830560be382b978328e794218e ./Packages/SprachmittlerKit/Tests/SprachmittlerCaptureTests/DoubleCopyDetectorTests.swift +efac77b258ef29cca1cc61311ef8d167e45ad5680a73396a1b4bc6d99d9a3f45 ./Packages/SprachmittlerKit/Tests/SprachmittlerCaptureTests/InsertionCoordinatorTests.swift +6ff42653fd8b3bf33407249c9a482397bd6fbf953b149ad51136ea2a16f29c45 ./Packages/SprachmittlerKit/Tests/SprachmittlerCaptureTests/PasteboardWatcherTests.swift 87e92d608b14675873a6554a3bcce951fb62b45b95ce32972df978cada697a43 ./Packages/SprachmittlerKit/Tests/SprachmittlerCaptureTests/PlaceholderTests.swift +d2d3507f437c7126bf15ebcba7be6d03794a73a637089c511c99096bc564cc5a ./Packages/SprachmittlerKit/Tests/SprachmittlerCaptureTests/ServicesProviderTests.swift +f7375e2cd08709d7b590ae4f6d70be3edb88f122f9fb3aeaac37c826ff637d12 ./Packages/SprachmittlerKit/Tests/SprachmittlerCaptureTests/SystemPasteboardTests.swift +4d5776174be0ae5a17d3414b410671c83b492029af47a9204311be066d0f9119 ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/AppSettingsTests.swift +4ca70a674a35b723f7608bfe9b250b8572586ce4923e9965245626588935bb6e ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/CapturePolicyTests.swift +2d5742a1fbbb65044455cea92b9f95b9d39f5236e92e4f152b141bcf964c639e ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/ErrorMappingTests.swift +c584df764e9fa0a029ed9f17c1a3b27cb4e3b91005f27171d5553aaf51edb48a ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/ErrorMessageTests.swift +95ca20f1c4cf0fd68f29a488770a1d6d7911c534913a0f88515ea1fe4f4cdb9e ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/LogRedactionTests.swift +6610797e6dd77401d1bce624d65e84db9bdda95820b1f56add1d24cea1f5df91 ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/LoggingContractTests.swift +8c0462d50ff3796aba6024349083d8b1ede654b495790d7610f95aecc8870001 ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/OnboardingAndSettingsTests.swift +caa6eb7016ecd217811761530af2dcc1f6abbc03548b4267e6a94ed691c2a0fd ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/PanelViewModelTests.swift e9fe1b63792e610bac81153c6bc79d4c836c36c4c9538b26887daf62e9684d80 ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/PlaceholderTests.swift +9a1a9671fdde945d3dd8356ea4dab8b6c30120d868970507883a77657701c500 ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/TranslationPipelineTests.swift +304cc5262dd6713041bb12cfa5502e5971c1c7e486c33be79818985bc0545232 ./Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/TranslationSessionTests.swift 988eb93a5d1483a6db061c1a11d5b06d7632157c076352c435418152f47910a5 ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/Fixtures/README.md 86bae20b590f03748a5b498a0ae402d7bb10fb0b7ba7bbccc821fcbbcba8ab37 ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/Fixtures/default-prompt.txt -86fafc88be2c581fb3eeaaace4320c9e6eb8bda2d89b757cfcb3ce1b4540fe74 ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/PlaceholderTests.swift +615de4459d2d77dac87809bb33af42d32ab624cb5367d1b3b9de6841d4935bc3 ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/Fixtures/delimiters-prompt.txt +4cb7a5de7d493e2b21826322dc38b4d31415352c609f3b68b4786bd12bbdac42 ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/Fixtures/structured-data-1-prompt.txt +cb657108c3f9b6f1b3a743313d2b6622ecf7b039ce80b8b2a1da3bce78451751 ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/HyMT3AdapterTests.swift +ada2bbfcf0213001077d55b475c3c2ec764623ddf6bd70e62d73d3dc08c99dad ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/LanguageCatalogueTests.swift +e56dc9de2741d731b02ff3bb39ee74532ac4350d232eb66fac86ffb770cb7a86 ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/OutputValidatorTests.swift +7d1c6fd3193bcd169be2421a56e42fca82e7e44a5a288dd6482957ab6c50af21 ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/PromptFixtureTests.swift +8bb2e2310a40e5923fa77014ac5209cf09cc8a52056a22cae9544f3468e1d2cc ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/PromptGoldenTests.swift +d93aa1ae54f4a6f49aba4f2badb065a86d29c335afb6efd0890684759718a3c3 ./Packages/SprachmittlerKit/Tests/SprachmittlerEnginesTests/PromptPolicyTests.swift b921811eb2bad2cde5a5c199b9c5e4fac710740193789d324d73580d2b8c7abf ./Packages/SprachmittlerKit/Tests/SprachmittlerEvalTests/PlaceholderTests.swift +78fd25235b625f82115f3d14c6a9863949055fbead95c9ef83668866bf255d10 ./Packages/SprachmittlerKit/Tests/SprachmittlerEvalTests/SprachmittlerEvalTests.swift e9fe1b63792e610bac81153c6bc79d4c836c36c4c9538b26887daf62e9684d80 ./Packages/SprachmittlerKit/Tests/SprachmittlerLiveTests/PlaceholderTests.swift +bf9501d4defd98c8249b5524c2113f00e27e05a279548a8cae4fd441b370d256 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/EndpointPolicyTests.swift +1581a9133daf1294fb224820af9c8c265a03b73eac959ff921b213107881940b ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/EphemeralSessionTests.swift +3552c16d0da451db9b8d9cad3375d9dc4d716003dfb6afb89b6ca92c99d4fa2d ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/FixtureContractTests.swift c48ac2946761e46da0d2eed81204e97a7fd96361b55b44a289ccb56587f6a83b ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/README.md -0c2d6cdb4ea5255e9266dee670a8a1d84ad4a27549c6e8a4f8d99eccf6677eab ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/capture-meta.json -4157b4206f99f974ce4a6d54f1816f8912f409368f63206d7cc65abf6426d50d ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/chat-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M-de-en.ndjson -944d0baa3a932e0bc42ed0eff59a055f2cf01e1a1e2cc66a051ba3a82e8e1f84 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/chat-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M-en-de.ndjson -398ae470bf8bc88df8a2d1c1f15289e62cc941f162774d3a5469dd6e3b907378 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/chat-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M-markdown.ndjson -e5a38a0283dad14969131052bd8daf60132c783af10945b6d03aff71b89e4b58 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/chat-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M-truncated.ndjson +4bafec6db42fb16e1901cb8f4de666c52d9a270c8fadb5e3359b10be7ebec80d ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/capture-meta.json +b735e23f9edd09a19969869fe5db53b9924214eabd57932a3a371f8cbafc30de ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/chat-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M-de-en.ndjson +7f6f9589c6ce4f4bc542d940f1eb72210acdab4ae39c93e79df40df1b87a2270 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/chat-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M-en-de.ndjson +568503e59cf16924996dbfb2ee50a944eed20768fa637d595caa358a91a4ce88 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/chat-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M-markdown.ndjson +1a9c3e41b0fc5dbd6d97f1b9bdff0d3db365ccb2621785b8ad34454381cafc99 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/chat-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M-truncated.ndjson 2f0cfe6365fe218b3c9ecb2f2a712bb53ebfea811982a5a0d9e4f32076ef3bfe ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/error-missing-model.json -a8f7899f295520b026b56e103486fe3ff8e66eb35db9c457f44e36c8a45d8fc2 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/ps.json -f1410d0bb4a28d89c049fd9f9cd7df5cef24780f246225de6f1a7c38db5f41d5 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/show-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M.json -4e7e6b8cc3ec35a6e3e69d96335ae12fff289374e9cbdedfe0563ec3db8941eb ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/tags.json +fbb02594028ba766fe5f93bf8a5b62236841fb9d051277e0dc633f87e2c2d396 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/ps.json +e3844615abca9419b448745038c8fe2f9813ea0a56eccb1e34c57be879071a1c ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/show-hf.co_tencent_Hy-MT3-7B-GGUF_Q4_K_M.json +dec441bad497eeb245c9b28d2a231a4859762b82b8a4b0b07ab0211f5595ea24 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/tags.json 672856105eb7e7811ecbae8fcd189743b8fd44aece7baad3a1a781b5a41c43eb ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Fixtures/version.json -a32b7bdc7476fc1521d3161560ee83a3c7c2ceb83c0ac7c2c0ee22d8c869240e ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/PlaceholderTests.swift +a4a387099e42bc0bf9ebc1ffb43e3a0aab843d70ef3d5a09590b72ec9d53fe15 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/OllamaCatalogTests.swift +da75e1c796f1889f594e9cd8bb4d32b1a11d7d4977647cae7e97d352b1545b55 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/OllamaChatClientTests.swift +6ed315b6389a479f0bc25865182e76ebe32a6bbca5c3be63c847a0ecac91ca90 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/OllamaErrorBodyTests.swift +ec4e2973a3933903563b1955da6213f2931b4e961fdc2bd8d40ab1d5577cff48 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/OllamaTransportTests.swift +4f388b8c70fb6b890d4b2fb86c338b837a7991a3592c3995038946c2df8e2e40 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/OllamaWarmUpPolicyTests.swift +4442060cc5810f0a0332a0abd05b1b9b54a73bf0045fe0fdc94b543a56238106 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/OllamaWarmUpRunnerTests.swift +deb3801d380aaa32228732c60b70ac576ebc2563f1dee8854215f2ee1a1004d7 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Support/ChatStubURLProtocol.swift +ecedbb779b022a8d87a385903040d49aa9d1ee144c2ffb58dc50ea58d297f630 ./Packages/SprachmittlerKit/Tests/SprachmittlerOllamaTests/Support/StubURLProtocol.swift +766a76be19e12928f2cc39cb1e905de6da07eea86a68f19247464af6a163708c ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/ChunkerTests.swift +a90dc29af451dac1557a88081a53defcffa8d21fdc0029d7fc19bc3a34d81598 ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/ContentClassifierTests.swift 74e7640a50e5cdc77207700b4a76b608abc88de48464ee76e40c07d9db8c4bf1 ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/Fixtures/de-sample.txt f9ede3201de7a3d092b2f114dd7f131dafd3b2d6614c0ba91d6181e326ab005b ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/Fixtures/en-sample.txt b0a7d3451d8830654fe79476b8d32d95709d956817a4436f58c0f73bbd8d3194 ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/Fixtures/markdown-sample.md 6ceff5d7b34dc4f4099c1ac8415f89b680f64608c3b9e140c4dee1737cf2477b ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/Fixtures/placeholders.txt +60f1c5ea4134593dc721650f32c48b9cf20c02fd6e8b692d8bb1da9e02490518 ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/LanguageDetectorTests.swift +80d28cb607b67a35cda89d86e2819e29e71b38e8234557683cb7c96f611037d1 ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/MarkdownPresentationTests.swift 8c5c21634d749ad05da8b6a0fc1d8e132a494177a697ba0a1338a7a6b5dba50c ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/PlaceholderTests.swift -dc45614d3b3268dd5081f8678f1bd4231dd73b067b49b088271b29362563bb8c ./README.md -de21f0e9556ed2d25289c10041a913d1ea55470a4951d05880921cc1e809d964 ./docs/ARCHITECTURE.md +67c0f9ba9e818267e99c1756b82643f7e59effa6783325675386aba0a1002cb3 ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/ProtectedTokenScannerTests.swift +c3294d486cfe44a6f0a69a1ec05cff33a8eccf090fce04fadffa96b6b2563d6f ./Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/TextNormalizationTests.swift +a212d7f39aadba95375bdc14786ee12ffc43b4555e4a591f60ce5da0dfd7c5b0 ./README.md +f1dbc2fb876d909b8486239e9b75b09ed68516c341d586e96d8626715c86a88c ./dist/Sprachmittler-0.1.0-local.dmg +38541779aa6190cc99d81ad16f98693a6fa00f14e9fa166dd36339cfe23865fc ./docs/ARCHITECTURE.md 018c5faf1a5d2e8d851ab209d45e64993cbd6b7976c4aa90c571359c83e83264 ./docs/CODING_STANDARDS.md -c17e0eee0e06c0ee1e3e073545b80eef55142cd1859cfc541e195447b00f68f1 ./docs/DECISIONS.md -0186c9d6ccd86c745b0d78068283c7dd786b4329185ef9022f4169e2d4ec1a60 ./docs/HYMT3_MODEL.md -7da97c74eb82432130e4cf91b3175504bd2c0fc3b1227be0efb872df922feaa6 ./docs/IMPLEMENTATION_PLAN.md +c39bba389cc023831dab2244f475eb7707320686f98633b6923ea04347b83aed ./docs/DECISIONS.md +5b80ea8994519f2be34aa10abb345ac3029d3d3a29705dcfa0a1cb344f4b95d2 ./docs/HYMT3_MODEL.md +d87fc9df926f6ba77ce67b2731b83f48f2b49848c637f12d0fdfb5f27f3c6775 ./docs/IMPLEMENTATION_PLAN.md c3a1838fb0a06acf6b7826f6ff278e15065af198dab22ffb1435dacdc064ad69 ./docs/KICKOFF.md 20a87dc7cf8cb593445c89d334e123f6275232524598ac71a21ca32766cedfb7 ./docs/LANGUAGES.md -96c63103091dc9c53c4629e5bc830b2ce92eae04e74096ac1ab15d6c3615528b ./docs/MODEL_EVALUATION.md -1abe88261cb0c46df94b195db3307ac2eff8ad0c610c1f3683b306eda67ae243 ./docs/OLLAMA_TRANSLATION_API.md +a28161210fbabe27d1348f3552851fe7b30c9dccc658272f2cc79af5e085ec40 ./docs/MODEL_EVALUATION.md +6f94dfe4f2146ce0b9e066198c9e05ce659faf4318513ce586c966989fd3d1c0 ./docs/OLLAMA_TRANSLATION_API.md e6dbccc3cb4c7a169a6daaa563066a6764a76b6b7649738b839dcbd9b2400ee5 ./docs/OPENCODE_V2.md -1251f24645cbe526b015c5b683e55073cd61a7ee9a34a1a613167b5d1fdba925 ./docs/PERFORMANCE.md +e2b785807ecb56eb1e7c02aaa6a487ce7c1be421865685bed4be2e973269bdce ./docs/PERFORMANCE.md 4a37cf1815071b3afdd10443ec9e05a5a78411d615c42f51117c5873922531c4 ./docs/PRD.md -8f73b8056f62e3310adaa0252dcab035888772f163e03792f88171e4039da5d4 ./docs/PROGRESS.md -d69d08cd64f6ae6c6779692c7e2e04dca6ede7729f53790c0e3e71b6fc8aa367 ./docs/SECURITY_PRIVACY.md -8707e5bd7db8f5981c49bdfe739be3ca2da9370efd39e8f3450db29b95ffcbb6 ./docs/SELECTION_AND_CLIPBOARD.md -c7609798be659d3d96c0b4e1226bbfd66cc0c0b0d583eaba47df37c3ddb70ddc ./docs/TESTING.md -381bf8425054d8b4eb6722ecbff4f6d4a4b0ec868bad8793441ed1246b5153e4 ./docs/TRANSLATION_OUTPUT.md +70b7be815282fa6d25beb4ce805f6ac47f45878b16621798ed6a4ac1e294011f ./docs/PROGRESS.md +7e55a36c4785c77009797f32ef0837be68168d35feab9bf4803484b4df8cd203 ./docs/SECURITY_PRIVACY.md +2e6c7ba67d857db7cddf1e31b5a6516f70b8094e9115094b58156f9e6626452c ./docs/SELECTION_AND_CLIPBOARD.md +8720e8bf79ba7ab051bb8bd09f55b7766f98941904f354cbe3ab7b88c941e860 ./docs/TESTING.md +d86aa67b08549ecce44e14d1e4fde0050ea5e89f77643733efd312fa42ef4e25 ./docs/TRANSLATION_OUTPUT.md +8a5dce4b34d9c4630dcf42006970c7cc624e16281af37b023e3563c946d1aa7a ./docs/USER_GUIDE.md 373b20746a6ed145ee598786458a97cead5cacd97a339db14b3e2341645c6c8d ./evaluation/README.md a60f1917c64ac8c3df0d01dd55818652ae100a6d750c34be24675b33226cad45 ./evaluation/corpus.example.json a5c4b95257aa02eca20ae98acf68dee329acb870f16fb3ac549038627327da71 ./evaluation/corpus.schema.json 6a54dadd3426cfc011c8b02b9c9b935f6ba4bbbdc5db38ee59377d71a8919833 ./opencode.json -2b065f1791c31305ba1e9c018ffd439a04f82110e96a55f05e67311926cfd6e0 ./project.yml +e0628748753d6c8952f05c7da78a632632c2fedd6c9632bc8d9c7bba42127e51 ./project.yml 749bfb269c22aed25e67b73abfda7055aee645b68a9907f292ef5c1c38366eae ./scripts/bootstrap.sh -443548848c9ce9edb9ce54efac6158e6cc63e69b40259dab4edb6ead89972373 ./scripts/capture-fixtures.sh +aa9531690d41071e34dfcb33241bb576f7349092d52c36242cedf55af7ca9c46 ./scripts/capture-fixtures.sh +495f78822630ac48a91e21a06c5d96f4ffbb4a38b8b7ee5b591faeaeb1fdbbd0 ./scripts/check-signature.sh +fb00d11b43730fd5a22a2b9c9d2bb19dda9933507972071d5cf68fe19f09d60f ./scripts/generate-app-icon.swift +ff66487399a93eb08890b8b85027df2db6572c85a183baec823b1f697014a7a7 ./scripts/make-dmg.sh 85eef8a97a24d834b7119788f11559c3fc5ab40be87ca2a244abae85801d8cac ./scripts/manifest.sh d8f5a7fd6907772e961e129920af66290257b3299beae867639abcf956d71fb8 ./scripts/opencode-check.sh -50d0a6b4f78eca45363a7dded4efd1e6332628127e5f634b0bbba1215a499830 ./scripts/privacy-check.sh +480dee8c4969ed231f5d58e8c66999940aae2fa707ac964fd19b4671ce1ad83a ./scripts/privacy-check.sh +eba6aa14e31e41da73792503e946251691d635a45124d7150433227a218dc330 ./scripts/privacy-self-test.sh +52a752481678227da453b0487043f2d0950862791ef75dab71f695f78950a514 ./scripts/release.sh 0cf1aee371a3a98429906be86de2832c5649e8212f2eb35a5433990a0b15ad5d ./scripts/smoke-ollama.sh -dca61cd7f7833ecb5c72347c526a69bafab7499fe05c21c67f0b8dee71d50245 ./scripts/verify.sh +1a17309daafb04fc4880d74df39ab711c33694b6405cc375681d4fdfd9af9f9c ./scripts/verify.sh diff --git a/Packages/SprachmittlerKit/Package.swift b/Packages/SprachmittlerKit/Package.swift index c5d8849..7347735 100644 --- a/Packages/SprachmittlerKit/Package.swift +++ b/Packages/SprachmittlerKit/Package.swift @@ -14,6 +14,7 @@ let package = Package( products: [ .library(name: "SprachmittlerCore", targets: ["SprachmittlerCore"]), .library(name: "SprachmittlerCapture", targets: ["SprachmittlerCapture"]), + .library(name: "SprachmittlerText", targets: ["SprachmittlerText"]), .executable(name: "sprachmittler-cli", targets: ["sprachmittler-cli"]), ], dependencies: [ diff --git a/Packages/SprachmittlerKit/Sources/SprachmittlerCore/AppSettings.swift b/Packages/SprachmittlerKit/Sources/SprachmittlerCore/AppSettings.swift index 18dfde5..a688290 100644 --- a/Packages/SprachmittlerKit/Sources/SprachmittlerCore/AppSettings.swift +++ b/Packages/SprachmittlerKit/Sources/SprachmittlerCore/AppSettings.swift @@ -61,6 +61,10 @@ public struct AppSettings: Codable, Sendable, Equatable { public var showSourcePreview: Bool /// Translation text size in points (12–28). public var translationFontSize: Int + /// Render Markdown formatting in the translation panel. + public var renderMarkdown: Bool + /// Make the panel key when shown so Esc and the shortcuts work without a click. + public var closeWithEscape: Bool /// Reflect the login-item setting. public var launchAtLogin: Bool /// Keep the last translation in memory for the panel. @@ -94,6 +98,8 @@ public struct AppSettings: Codable, Sendable, Equatable { autoCopy = false showSourcePreview = true translationFontSize = 17 + renderMarkdown = true + closeWithEscape = true launchAtLogin = false keepRecentTranslationInMemory = true hasCompletedOnboarding = false @@ -235,8 +241,9 @@ public struct AppSettings: Codable, Sendable, Equatable { case endpoint, allowRemoteEndpoint, model, fastModel, targetLanguage, recentTargetLanguages case doubleCopyWindowMs, maxCharactersLatin, maxCharactersCJK, numCtx, numPredict case temperature, topP, topK, repeatPenalty, keepModelLoaded, warmUpOnLaunch - case promptVariantPolicy, autoCopy, showSourcePreview, translationFontSize, launchAtLogin - case keepRecentTranslationInMemory, hasCompletedOnboarding, settingsVersion + case promptVariantPolicy, autoCopy, showSourcePreview, translationFontSize, renderMarkdown + case closeWithEscape, launchAtLogin, keepRecentTranslationInMemory, hasCompletedOnboarding + case settingsVersion } /// Decodes with v0 migration: missing or unknown fields fall back to defaults, and an old @@ -276,8 +283,7 @@ public struct AppSettings: Codable, Sendable, Equatable { let keep = try container.decodeIfPresent(String.self, forKey: .keepModelLoaded) ?? defaults.keepModelLoaded keepModelLoaded = ["5m", "30m", "1h", "0"].contains(keep) ? keep : defaults.keepModelLoaded - warmUpOnLaunch = try container.decodeIfPresent(Bool.self, forKey: .warmUpOnLaunch) - ?? defaults.warmUpOnLaunch + warmUpOnLaunch = try container.decodeIfPresent(Bool.self, forKey: .warmUpOnLaunch) ?? defaults.warmUpOnLaunch let policy = try container.decodeIfPresent(PromptVariantPolicy.self, forKey: .promptVariantPolicy) ?? defaults.promptVariantPolicy promptVariantPolicy = policy @@ -285,8 +291,9 @@ public struct AppSettings: Codable, Sendable, Equatable { autoCopy = false showSourcePreview = try container.decodeIfPresent(Bool.self, forKey: .showSourcePreview) ?? defaults.showSourcePreview - launchAtLogin = try container.decodeIfPresent(Bool.self, forKey: .launchAtLogin) - ?? defaults.launchAtLogin + renderMarkdown = try container.decodeIfPresent(Bool.self, forKey: .renderMarkdown) ?? defaults.renderMarkdown + closeWithEscape = try container.decodeIfPresent(Bool.self, forKey: .closeWithEscape) ?? defaults.closeWithEscape + launchAtLogin = try container.decodeIfPresent(Bool.self, forKey: .launchAtLogin) ?? defaults.launchAtLogin keepRecentTranslationInMemory = try container.decodeIfPresent( Bool.self, forKey: .keepRecentTranslationInMemory @@ -319,6 +326,8 @@ public struct AppSettings: Codable, Sendable, Equatable { try container.encode(autoCopy, forKey: .autoCopy) try container.encode(showSourcePreview, forKey: .showSourcePreview) try container.encode(translationFontSize, forKey: .translationFontSize) + try container.encode(renderMarkdown, forKey: .renderMarkdown) + try container.encode(closeWithEscape, forKey: .closeWithEscape) try container.encode(launchAtLogin, forKey: .launchAtLogin) try container.encode(keepRecentTranslationInMemory, forKey: .keepRecentTranslationInMemory) try container.encode(hasCompletedOnboarding, forKey: .hasCompletedOnboarding) diff --git a/Packages/SprachmittlerKit/Sources/SprachmittlerCore/PanelViewModel.swift b/Packages/SprachmittlerKit/Sources/SprachmittlerCore/PanelViewModel.swift index 8b70749..5087602 100644 --- a/Packages/SprachmittlerKit/Sources/SprachmittlerCore/PanelViewModel.swift +++ b/Packages/SprachmittlerKit/Sources/SprachmittlerCore/PanelViewModel.swift @@ -30,6 +30,10 @@ public struct PanelConfiguration: Sendable, Equatable { public var showSourcePreview: Bool /// Translation text size in points. public var translationFontSize: Int + /// Render Markdown formatting for Markdown sources. + public var renderMarkdown: Bool + /// Make the panel key when shown so Esc works without a click. + public var closeWithEscape: Bool /// Recent targets, most recent first. public var recentTargets: [ModelLanguage] @@ -41,6 +45,8 @@ public struct PanelConfiguration: Sendable, Equatable { sampling: SamplingOptions = .publisherDefault, showSourcePreview: Bool = true, translationFontSize: Int = 17, + renderMarkdown: Bool = true, + closeWithEscape: Bool = true, recentTargets: [ModelLanguage] = [] ) { self.target = target @@ -49,6 +55,8 @@ public struct PanelConfiguration: Sendable, Equatable { self.sampling = sampling self.showSourcePreview = showSourcePreview self.translationFontSize = translationFontSize + self.renderMarkdown = renderMarkdown + self.closeWithEscape = closeWithEscape self.recentTargets = recentTargets } } diff --git a/Packages/SprachmittlerKit/Sources/SprachmittlerText/MarkdownPresentation.swift b/Packages/SprachmittlerKit/Sources/SprachmittlerText/MarkdownPresentation.swift new file mode 100644 index 0000000..ff8e9be --- /dev/null +++ b/Packages/SprachmittlerKit/Sources/SprachmittlerText/MarkdownPresentation.swift @@ -0,0 +1,269 @@ +import Foundation + +/// A block-level element produced by the conservative Markdown presentation parser. +/// +/// The cases carry raw inline Markdown; the app parses that with +/// ``MarkdownPresentation/inline(_:)``. The parser is presentation-only: it never changes the +/// translation that is validated, copied or inserted. +public enum MarkdownBlock: Equatable, Sendable { + /// A paragraph, with soft line breaks preserved. + case paragraph(String) + /// An ATX heading (`#`…`######`). + case heading(level: Int, text: String) + /// One list item. `indent` is a display indentation in steps, `number` is the ordinal for ordered lists. + case listItem(ordered: Bool, number: Int, indent: Int, text: String) + /// A block quote, with one level of `>` removed. + case quote(String) + /// A fenced code block. + case codeBlock(language: String?, text: String) + /// A thematic break (`---`, `***`, `___`). + case rule +} + +/// Presentation-only Markdown parsing for the translation panel. +/// +/// Inline formatting comes from Foundation's Markdown parser. Block structure is parsed here with a +/// deliberately small set of rules: anything that is not recognised stays visible as plain text +/// rather than being silently dropped. +public enum MarkdownPresentation { + private static let classifier = ContentClassifier() + + private static let inlineDetectionPatterns = [ + #"\*\*[^*\n]+\*\*"#, + #"(? Bool { + let trimmed = source.trimmingCharacters(in: .whitespacesAndNewlines) + guard !trimmed.isEmpty else { return false } + + switch classifier.classify(trimmed) { + case .json, .html, .code: + return false + case .markdown: + return true + case .plain, .delimited: + break + } + + return hasInlineMarkdown(trimmed) || hasInlineMarkdown(translation) + } + + /// Splits `markdown` into display blocks. Unknown constructs stay in a paragraph. + public static func blocks(in markdown: String) -> [MarkdownBlock] { + let normalized = markdown + .replacingOccurrences(of: "\r\n", with: "\n") + .replacingOccurrences(of: "\r", with: "\n") + let lines = normalized.components(separatedBy: "\n") + var blocks: [MarkdownBlock] = [] + var paragraph: [String] = [] + var index = 0 + + func flushParagraph() { + guard !paragraph.isEmpty else { return } + let text = paragraph.joined(separator: "\n").trimmingCharacters(in: .whitespacesAndNewlines) + if !text.isEmpty { + blocks.append(.paragraph(text)) + } + paragraph.removeAll() + } + + while index < lines.count { + let raw = lines[index] + let line = raw.trimmingCharacters(in: .whitespaces) + + if line.isEmpty { + flushParagraph() + index += 1 + } else if let fence = fenceMarker(line) { + flushParagraph() + blocks.append(fencedBlock(lines, index: &index, opening: line, fence: fence)) + } else if let heading = heading(in: raw) { + flushParagraph() + blocks.append(heading) + index += 1 + } else if isRule(line) { + flushParagraph() + blocks.append(.rule) + index += 1 + } else if line.hasPrefix(">") { + flushParagraph() + blocks.append(quoteBlock(lines, index: &index)) + } else if let item = listItem(in: raw) { + flushParagraph() + blocks.append(item) + index += 1 + } else { + paragraph.append(line) + index += 1 + } + } + + flushParagraph() + return blocks + } + + private static func fencedBlock( + _ lines: [String], + index: inout Int, + opening: String, + fence: (marker: Character, count: Int) + ) -> MarkdownBlock { + var code: [String] = [] + var closed = false + index += 1 + while index < lines.count, !isClosingFence(lines[index], marker: fence.marker) { + code.append(lines[index]) + index += 1 + } + if index < lines.count { + index += 1 + closed = true + } + let info = opening.dropFirst(fence.count).trimmingCharacters(in: .whitespaces) + let language = info.split(separator: " ").first.map(String.init) + var text = code.joined(separator: "\n") + if !closed { + text = text.trimmingCharacters(in: .newlines) + } + return .codeBlock(language: language, text: text) + } + + private static func quoteBlock(_ lines: [String], index: inout Int) -> MarkdownBlock { + var quote: [String] = [] + while index < lines.count { + let line = lines[index].trimmingCharacters(in: .whitespaces) + guard line.hasPrefix(">") else { break } + var content = String(line.dropFirst()) + if content.hasPrefix(" ") { + content.removeFirst() + } + quote.append(content) + index += 1 + } + return .quote(quote.joined(separator: "\n").trimmingCharacters(in: .whitespacesAndNewlines)) + } + + /// Parses one inline Markdown fragment. Images are reduced to their alt text so no attachment + /// or remote resource can be requested; malformed input falls back to plain text. + public static func inline(_ text: String) -> AttributedString { + let cleaned = strippingImages(text) + let options = AttributedString.MarkdownParsingOptions( + interpretedSyntax: .inlineOnlyPreservingWhitespace, + failurePolicy: .returnPartiallyParsedIfPossible + ) + if let attributed = try? AttributedString(markdown: cleaned, options: options) { + return attributed + } + return AttributedString(cleaned) + } + + /// Only explicit web links may be opened. `file:`, `javascript:`, `data:` and app schemes stay inert. + public static func isAllowedLink(_ url: URL) -> Bool { + guard let scheme = url.scheme?.lowercased(), let host = url.host, !host.isEmpty else { + return false + } + return scheme == "http" || scheme == "https" + } + + private static func hasInlineMarkdown(_ text: String) -> Bool { + inlineDetectionPatterns.contains { pattern in + text.range(of: pattern, options: .regularExpression) != nil + } + } + + private static func strippingImages(_ text: String) -> String { + var result = text.replacingOccurrences( + of: #"!\[([^\]]*)\]\([^)]*\)"#, + with: "$1", + options: .regularExpression + ) + result = result.replacingOccurrences( + of: #"]*>"#, + with: "", + options: [.regularExpression, .caseInsensitive] + ) + return result + } + + private static func fenceMarker(_ line: String) -> (marker: Character, count: Int)? { + let stripped = line.drop(while: { $0 == " " }) + guard let first = stripped.first, first == "`" || first == "~" else { return nil } + let count = stripped.prefix(while: { $0 == first }).count + guard count >= 3 else { return nil } + return (first, count) + } + + private static func isClosingFence(_ line: String, marker: Character) -> Bool { + let stripped = line.trimmingCharacters(in: .whitespaces) + guard stripped.count >= 3 else { return false } + return stripped.allSatisfy { $0 == marker } + } + + private static func heading(in raw: String) -> MarkdownBlock? { + let leading = raw.prefix(while: { $0 == " " }).count + guard leading <= 3 else { return nil } + let trimmed = raw.dropFirst(leading) + let hashes = trimmed.prefix(while: { $0 == "#" }).count + guard (1 ... 6).contains(hashes) else { return nil } + let rest = trimmed.dropFirst(hashes) + guard rest.isEmpty || rest.first == " " || rest.first == "\t" else { return nil } + var text = rest.trimmingCharacters(in: .whitespaces) + if text.hasSuffix("#") { + text = String(text.reversed().drop(while: { $0 == "#" }).reversed()) + .trimmingCharacters(in: .whitespaces) + } + return .heading(level: hashes, text: text) + } + + private static func isRule(_ line: String) -> Bool { + let compact = line.replacingOccurrences(of: " ", with: "") + guard compact.count >= 3, let first = compact.first, "-*_".contains(first) else { + return false + } + return compact.allSatisfy { $0 == first } + } + + private static func listItem(in raw: String) -> MarkdownBlock? { + var columns = 0 + for character in raw { + if character == " " { + columns += 1 + } else if character == "\t" { + columns += 4 + } else { + break + } + } + let indent = min(columns / 2, 8) + let trimmed = raw.trimmingCharacters(in: .whitespaces) + + if let first = trimmed.first, "-*+".contains(first) { + let rest = trimmed.dropFirst() + guard rest.first == " " || rest.first == "\t" else { return nil } + let text = rest.trimmingCharacters(in: .whitespaces) + guard !text.isEmpty else { return nil } + return .listItem(ordered: false, number: 0, indent: indent, text: text) + } + + let digits = trimmed.prefix(while: { $0.isNumber }) + guard !digits.isEmpty, digits.count <= 9 else { return nil } + let afterDigits = trimmed.dropFirst(digits.count) + guard let delimiter = afterDigits.first, delimiter == "." || delimiter == ")" else { + return nil + } + let rest = afterDigits.dropFirst() + guard rest.first == " " || rest.first == "\t", let number = Int(digits) else { return nil } + let text = rest.trimmingCharacters(in: .whitespaces) + guard !text.isEmpty else { return nil } + return .listItem(ordered: true, number: number, indent: indent, text: text) + } +} diff --git a/Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/AppSettingsTests.swift b/Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/AppSettingsTests.swift index ebb838e..7de60cc 100644 --- a/Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/AppSettingsTests.swift +++ b/Packages/SprachmittlerKit/Tests/SprachmittlerCoreTests/AppSettingsTests.swift @@ -18,6 +18,8 @@ struct AppSettingsTests { #expect(settings.maxCharactersCJK == 2000) #expect(settings.numCtx == 8192) #expect(settings.translationFontSize == 17) + #expect(settings.renderMarkdown) + #expect(settings.closeWithEscape) #expect(!settings.autoCopy) #expect(!settings.hasCompletedOnboarding) } @@ -30,6 +32,8 @@ struct AppSettingsTests { settings.noteTarget(HyMT3Languages.german) settings.temperature = 0.2 settings.translationFontSize = 22 + settings.renderMarkdown = false + settings.closeWithEscape = false settings.launchAtLogin = true settings.hasCompletedOnboarding = true @@ -53,6 +57,8 @@ struct AppSettingsTests { #expect(decoded.settingsVersion == AppSettings.currentVersion) #expect(decoded.targetLanguage == "de") #expect(decoded.model == HyMT3ModelPreset.defaultModel) + #expect(decoded.renderMarkdown) + #expect(decoded.closeWithEscape) #expect(!decoded.autoCopy) } diff --git a/Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/MarkdownPresentationTests.swift b/Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/MarkdownPresentationTests.swift new file mode 100644 index 0000000..1210547 --- /dev/null +++ b/Packages/SprachmittlerKit/Tests/SprachmittlerTextTests/MarkdownPresentationTests.swift @@ -0,0 +1,106 @@ +import Foundation +import Testing +@testable import SprachmittlerText + +@Suite("Markdown presentation") +struct MarkdownPresentationTests { + @Test func parsesHeadingsParagraphsAndRules() { + let blocks = MarkdownPresentation.blocks(in: """ + # Title + + First paragraph. + Second line. + + --- + """) + #expect(blocks == [ + .heading(level: 1, text: "Title"), + .paragraph("First paragraph.\nSecond line."), + .rule, + ]) + } + + @Test func parsesOrderedAndUnorderedLists() { + let blocks = MarkdownPresentation.blocks(in: """ + - one + * two + 3. three + 4) four + """) + #expect(blocks == [ + .listItem(ordered: false, number: 0, indent: 0, text: "one"), + .listItem(ordered: false, number: 0, indent: 0, text: "two"), + .listItem(ordered: true, number: 3, indent: 0, text: "three"), + .listItem(ordered: true, number: 4, indent: 0, text: "four"), + ]) + } + + @Test func parsesQuotesAndFencedCode() { + let blocks = MarkdownPresentation.blocks(in: """ + > quoted **text** + > second + + ```swift + let value = 1 + ``` + """) + #expect(blocks == [ + .quote("quoted **text**\nsecond"), + .codeBlock(language: "swift", text: "let value = 1"), + ]) + } + + @Test func keepsUnclosedFenceAsCode() { + let blocks = MarkdownPresentation.blocks(in: "```\nstill code\n") + #expect(blocks == [.codeBlock(language: nil, text: "still code")]) + } + + @Test func recognisesInlineFormatting() { + let attributed = MarkdownPresentation.inline("**bold** and *italic* and `code`") + let intents = attributed.runs.compactMap(\.inlinePresentationIntent) + #expect(intents.contains { $0.contains(.stronglyEmphasized) }) + #expect(intents.contains { $0.contains(.emphasized) }) + #expect(intents.contains { $0.contains(.code) }) + } + + @Test func parsesLinksButNeverImages() throws { + let attributed = MarkdownPresentation + .inline("See [docs](https://example.com) and ![alt](https://example.com/x.png)") + let links = attributed.runs.compactMap(\.link) + #expect(try links == [#require(URL(string: "https://example.com"))]) + #expect(String(attributed.characters).contains("alt")) + #expect(!String(attributed.characters).contains("x.png")) + } + + @Test func malformedMarkdownFallsBackToText() { + let attributed = MarkdownPresentation.inline("**unclosed and

Hello

", translation: "x")) + #expect(!MarkdownPresentation.shouldRender(source: "```\nlet x = 1\n```", translation: "x")) + #expect(!MarkdownPresentation.shouldRender(source: "Just prose, no markers.", translation: "Nur Prosa.")) + #expect(!MarkdownPresentation.shouldRender(source: "", translation: "**bold**")) + } + + @Test func headingsWithDifferentLevelsAndClosingHashes() { + let blocks = MarkdownPresentation.blocks(in: "### Sub heading ###\n\n####### not a heading") + #expect(blocks == [ + .heading(level: 3, text: "Sub heading"), + .paragraph("####### not a heading"), + ]) + } +} diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 8d5f170..435afed 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -549,12 +549,12 @@ stateDiagram-v2 | Surface | Implementation | Contents | |---|---|---| | Status item | `MenuBarExtra` | Translate clipboard text, Target language submenu, Copy last translation, Replace last translation (if safe), Settings, Set up Sprachmittler, Diagnostics, Quit | -| Panel | `NSPanel` with `.nonactivatingPanel`, `becomesKeyOnlyIfNeeded = true` | Header (source → target, language picker, gear), collapsible source preview, streaming translation, warnings, Copy (left) and **Replace** (right, primary) | +| Panel | `NSPanel` with `.nonactivatingPanel`, `becomesKeyOnlyIfNeeded = false` | Header (source → target, language picker, gear), collapsible source preview, streaming translation (Markdown rendered when detected), warnings, Copy (left) and **Replace** (right, primary) | | Settings | SwiftUI `Settings` scene | General, Model, Translation, Privacy, Diagnostics | | Onboarding | `NSWindow` (not a SwiftUI `Window` scene) | Ollama reachable + version, Hy-MT3 installed, target language, optional Accessibility for Replace; each with a fix button | | Diagnostics | Window from the menu | Server version, model digests, last 50 timings and error kinds; copy as text; no text or translations | -Panel keyboard: **Esc** close, **⌘C** copy translation, **⌘↩** Replace, **⌘R** retry, **⌘,** Settings. The panel becomes key only when clicked; the source app keeps focus until then. The whole header bar (full width, flush with the top edge) moves the panel; the drag view moves the window itself from the screen-space mouse delta because `performDrag` does nothing while the app is inactive; moving it keeps its position while it stays open, and a newly shown panel is placed near the cursor (DeepL-like transient position). The translation text size is a Settings value. +Panel keyboard: **Esc** close, **⌘C** copy translation, **⌘↩** Replace, **⌘R** retry, **⌘,** Settings. The panel is made key when shown (unless the setting is off) so Esc and the shortcuts work without a click; the app is still not activated, the source app remains frontmost and owns the menu bar, and clicking the source app takes keyboard focus back. While the panel is key it receives keystrokes, so a user who types immediately after triggering should disable the Esc-on-show setting. The whole header bar (full width, flush with the top edge) moves the panel; the drag view moves the window itself from the screen-space mouse delta because `performDrag` does nothing while the app is inactive; moving it keeps its position while it stays open, and a newly shown panel is placed near the cursor (DeepL-like transient position). The translation text size is a Settings value. Accessibility: every control has an `accessibilityLabel`; the panel exposes source and translation as read-only text elements; full keyboard navigation; respects Reduce Motion and Increase Contrast. @@ -587,6 +587,8 @@ Accessibility: every control has an `accessibilityLabel`; the panel exposes sour | `autoCopy` | Bool | **false** (never copy automatically) | | `showSourcePreview` | Bool | true | | `translationFontSize` | Int | 17 pt (12–28) | +| `renderMarkdown` | Bool | true (presentation only; raw text is copied and replaced) | +| `closeWithEscape` | Bool | true (make the panel key on show; no app activation) | | `launchAtLogin` | Bool | false | | `keepRecentTranslationInMemory` | Bool | true (cleared on quit; no disk) | | `hasCompletedOnboarding` | Bool | false | diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 495f0f4..aa087b7 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -61,11 +61,11 @@ Decision: Ship with `hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M` as the provisional def Consequences: Until the gate, the 7B is labelled provisional in Settings. The decision is re-run when a model, Ollama or the prompt policy changes. ## ADR-009 — Menu-bar agent with a non-activating panel -Status: Accepted +Status: Accepted (amended 2026-11-26: Esc without a click) -Context: The app must be available over any app and must not take focus from the selection. A regular Dock app with a window would interrupt the workflow. -Decision: Use `LSUIElement = YES`, a `MenuBarExtra`, and a floating `NSPanel` with `.nonactivatingPanel` and `becomesKeyOnlyIfNeeded = true`. Never call `NSApp.activate` or `makeKeyAndOrderFront` for the translation panel. Onboarding and Settings are the only surfaces that activate the app. -Consequences: The source app keeps focus, so Replace can target it. Keyboard shortcuts inside the panel require a click first; every action also has a button. +Context: The app must be available over any app and must not activate itself or take application focus from the selection. A regular Dock app with a window would interrupt the workflow. Users also expect Esc to dismiss a transient panel immediately, which requires the panel to be the key window. +Decision: Use `LSUIElement = YES`, a `MenuBarExtra`, and a floating `NSPanel` with `.nonactivatingPanel` and `becomesKeyOnlyIfNeeded = false`. Never call `NSApp.activate` or `makeKeyAndOrderFront` for the translation panel. Onboarding and Settings are the only surfaces that activate the app. By default the panel calls `makeKey()` when shown, so Esc and the keyboard shortcuts work immediately; the setting `closeWithEscape` can restore click-first behaviour. The panel's SwiftUI exit command handles Esc and calls the same close path that cancels an in-flight request. +Consequences: The app stays unactivated: `NSWorkspace.frontmostApplication` and the menu bar stay with the source app, and Replace still re-verifies that app. While the panel is visible it holds keyboard focus, so keystrokes and shortcuts go to the panel until the user clicks back into the source app; the setting turns this off. Every action still has a button. ## ADR-010 — Native OpenCode 2.x configuration Status: Accepted @@ -143,3 +143,10 @@ Status: Accepted Context: Panel, Settings, Onboarding and Diagnostics contain branching worth testing, but their windows are AppKit/SwiftUI. The app target must stay thin. Decision: `PanelViewModel`, `SettingsViewModel`, `OnboardingViewModel` and `DiagnosticsViewModel` are `@MainActor @Observable` types in `SprachmittlerCore`; `SettingsStore` uses a `SettingsDataStoring` seam. `App` owns only `NSPanel`/`NSWindow` controllers, SwiftUI views, the composition root (`AppEnvironment`) and lifecycle glue. `TranslationSession` uses an injected pipeline factory so endpoint/settings changes apply on the next request without rebuilding the UI. Consequences: Logic is covered by package tests; AppKit remains untested by `make verify` and requires the manual checklist. + +## ADR-021 — Markdown is rendered as presentation only +Status: Accepted + +Context: Hy-MT3 preserves Markdown structure, but a plain `Text` showed `**bold**`, headings and lists literally. Users translating Markdown want the formatting rendered, while Copy and Replace must keep the Markdown that the model produced and the validator checked. +Decision: Parse presentation Markdown in `SprachmittlerText` with Foundation's inline Markdown parser plus a small, conservative block parser (headings, lists, quotes, fenced code, rules, paragraphs). `MarkdownPresentation.shouldRender` rejects JSON, HTML and code sources and otherwise requires block or inline Markdown markers. The panel renders only when the setting `renderMarkdown` is on (default). Copy and Replace use the raw translation unchanged. Only `http` and `https` links open, on an explicit click; image syntax is reduced to alt text and no remote resource is fetched. Tables, raw HTML and nested lists/quotes remain plain text in this pass. +Consequences: Rendering never rewrites the translation or weakens validation. Literal markers can be interpreted as formatting, so the setting is the escape hatch; Copy always returns the raw Markdown. The block layout makes text selection per block, while Copy remains the whole-translation path. No new dependency is added. \ No newline at end of file diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index f026cac..c3e8b5e 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -153,3 +153,5 @@ Legend: `[ ]` open · `[~]` in progress · `[x]` done · `[!]` blocked (explain) 2026-11-26 · M4 polish · Enlarged the drag surface to the whole left header block, with a visible grip backed by an AppKit `performDrag` area; the panel keeps a moved position while visible and only recenters near the cursor when shown again. Added a persisted `translationFontSize` setting (default 17 pt, 12–28) with a Settings stepper and applied it to the translation text. 2026-11-26 · Panel · The source section now stays available as a collapsed “Show source” disclosure row after the user collapses it, instead of disappearing. 2026-11-26 · Panel · Fixed dragging: `performDrag` was a no-op while the non-activating panel's app is inactive, so `WindowDragArea` now moves the window from the screen-space mouse delta. The drag surface is a full-width 56 pt header bar flush with the panel top; buttons stay clickable above it. Verified with synthetic drags from the title, top edge, empty header and grip while Finder was frontmost. +2026-11-26 · Panel · Esc now closes the panel without a click: `TranslationPanel` becomes key on show without activating the app (`frontmostApplication` and the menu bar stay with the source app), and `keyDown` handles keyCode 53. Added the `closeWithEscape` setting (default on) and amended ADR-009. +2026-11-26 · Panel · Markdown translations render with headings, bold/italic, inline code, lists, quotes, fenced code, rules and http/https links. `MarkdownPresentation` rejects JSON/HTML/code and only renders with the `renderMarkdown` setting (default on); Copy/Replace stay raw. Added ADR-021 and tests. diff --git a/docs/TRANSLATION_OUTPUT.md b/docs/TRANSLATION_OUTPUT.md index e76fbb9..9ad0977 100644 --- a/docs/TRANSLATION_OUTPUT.md +++ b/docs/TRANSLATION_OUTPUT.md @@ -62,7 +62,7 @@ Do not substitute tokens with sentinels in v1: sentinels can leak into the outpu | T3 | No spelling, grammar, style, terminology or punctuation edits. No de-duplication. No "cleanup" of model wording. | always | | T4 | Do not strip a preamble or explanation. Detect it, warn, keep the raw text, disable Replace by default. | always | -The panel shows the T1 output. There is no hidden rewrite. If the model returns a preamble, the user sees it. +The panel shows the T1 output. There is no hidden rewrite. If the model returns a preamble, the user sees it. Markdown rendering in the panel is presentation only: validation, Copy and Replace all use the raw T1 string, including its Markdown markers. See ADR-021. ## 6. Preamble detection diff --git a/docs/USER_GUIDE.md b/docs/USER_GUIDE.md index 8712eec..e73f67c 100644 --- a/docs/USER_GUIDE.md +++ b/docs/USER_GUIDE.md @@ -35,7 +35,7 @@ the Hy-MT3 model and the target language. You can reopen setup from the menu bar 1. Select text in any app. 2. Press **⌘C** twice quickly (within 500 ms). -3. The floating panel appears near the mouse. The source app keeps focus. +3. The floating panel appears near the mouse. The source app stays frontmost; the panel takes keyboard focus while it is visible so Esc and the shortcuts work immediately. Clicking the source app takes focus back. 4. The translation streams in. Use the language picker to change the target. 5. Click **Copy** to put the translation on the clipboard, or **Replace** to replace the selection. 6. **Esc** closes the panel. **⌘C** copies, **⌘↩** replaces, **⌘R** retries and **⌘,** opens Settings. diff --git a/project.yml b/project.yml index 1872ced..ce2ec15 100644 --- a/project.yml +++ b/project.yml @@ -59,6 +59,8 @@ targets: product: SprachmittlerCore - package: SprachmittlerKit product: SprachmittlerCapture + - package: SprachmittlerKit + product: SprachmittlerText schemes: Sprachmittler: