feat(capture): translate long selections in parts
The capture gate and the chunk size were the same number, so a selection above one chunk was rejected before the pipeline could split it; the Settings sliders moved both thresholds together. Add maximumPartsPerSelection (1-8, default 1, so existing behaviour is unchanged). The capture limit is now part size x parts and travels on TranslationSessionRequest, so the watcher, CapturePolicy and TranslationSession agree for that capture. TranslationStreaming gained an optional per-part callback; the session emits chunkStarted and the panel shows 'Part 2 of 4' while streaming and '2 parts' when finished. textTooLong now points at Settings and offers an Open Settings button. Lower the dense-script part-size maximum to 4000 because 5000 dense characters plus a 4096-token output can overflow the 8192-token context. Tests cover capture limits, watcher limits, pipeline part callbacks, session events and limits, panel progress, settings clamping and migration. Docs updated: ADR-011, TRANSLATION_OUTPUT, SELECTION_AND_CLIPBOARD, ARCHITECTURE, LANGUAGES and README. Verified: make verify green; live 4355-character German text showed Part 1 of 2, Part 2 of 2 and '2 parts'; with one part the panel showed the too-long message and Open Settings.
This commit is contained in:
1 parent
9f89000b0d
commit
2a601058f4
29 files changed
+607
-122
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import SprachmittlerCore
|
||||
import SwiftUI
|
||||
|
||||
/// The long-selection settings: part size and the number of parts one capture may use.
|
||||
struct LongSelectionsSettings: View {
|
||||
@Binding var draft: AppSettings
|
||||
|
||||
var body: some View {
|
||||
Section(String(localized: "Long selections")) {
|
||||
Stepper(
|
||||
String(localized: "Latin part size: \(draft.maxCharactersLatin)"),
|
||||
value: $draft.maxCharactersLatin,
|
||||
in: 1000 ... 10000,
|
||||
step: 500
|
||||
)
|
||||
Stepper(
|
||||
String(localized: "Dense-script part size: \(draft.maxCharactersCJK)"),
|
||||
value: $draft.maxCharactersCJK,
|
||||
in: 500 ... 4000,
|
||||
step: 250
|
||||
)
|
||||
Stepper(
|
||||
String(localized: "Maximum parts per selection: \(draft.maximumPartsPerSelection)"),
|
||||
value: $draft.maximumPartsPerSelection,
|
||||
in: 1 ... 8
|
||||
)
|
||||
Text(
|
||||
String(
|
||||
localized: """
|
||||
One part rejects text longer than a single part. Higher values translate \
|
||||
long selections one part at a time, which takes longer.
|
||||
"""
|
||||
)
|
||||
)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,20 +239,7 @@ struct SettingsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
Section(String(localized: "Chunking")) {
|
||||
Stepper(
|
||||
String(localized: "Latin limit: \(draft.maxCharactersLatin)"),
|
||||
value: $draft.maxCharactersLatin,
|
||||
in: 1000 ... 10000,
|
||||
step: 500
|
||||
)
|
||||
Stepper(
|
||||
String(localized: "Dense-script limit: \(draft.maxCharactersCJK)"),
|
||||
value: $draft.maxCharactersCJK,
|
||||
in: 500 ... 5000,
|
||||
step: 250
|
||||
)
|
||||
}
|
||||
LongSelectionsSettings(draft: $draft)
|
||||
|
||||
Section(String(localized: "Prompt policy")) {
|
||||
Text(String(localized: "Default translation is fixed for v1."))
|
||||
|
||||
Reference in new issue
Block a user