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.
52 lines
1.6 KiB
Swift
52 lines
1.6 KiB
Swift
import Foundation
|
|
import SprachmittlerEngines
|
|
import SprachmittlerText
|
|
import Testing
|
|
@testable import SprachmittlerCore
|
|
|
|
@Suite("Panel chunk progress")
|
|
@MainActor
|
|
struct PanelChunkingTests {
|
|
private let longCaptured = CapturedText(
|
|
text: String(repeating: "a", count: 9000),
|
|
capturedAt: Date(timeIntervalSince1970: 0),
|
|
source: .doubleCopy
|
|
)
|
|
|
|
@Test func reportsPartsAndProgress() async {
|
|
let limits = CaptureLimits(maximumParts: 3)
|
|
let streaming = GatedMultiPartStreaming()
|
|
let (panel, _, _) = makePanel(streaming: streaming, captureLimits: limits)
|
|
|
|
await panel.begin(longCaptured)
|
|
await waitFor { panel.currentChunk == 1 && panel.totalChunks == 3 && !panel.translation.isEmpty }
|
|
|
|
#expect(panel.phase == .streaming)
|
|
#expect(panel.chunkCount == 1)
|
|
|
|
await streaming.release()
|
|
await waitFor { panel.phase == .ready }
|
|
|
|
#expect(panel.translation == "part1 part2 part3")
|
|
#expect(panel.chunkCount == 3)
|
|
#expect(panel.currentChunk == nil)
|
|
#expect(panel.totalChunks == nil)
|
|
#expect(await streaming.requests.first?.captureLimits == limits)
|
|
}
|
|
|
|
@Test func aSinglePartHasNoProgress() async {
|
|
let captured = CapturedText(
|
|
text: "Hallo.",
|
|
capturedAt: Date(timeIntervalSince1970: 0),
|
|
source: .doubleCopy
|
|
)
|
|
let (panel, _, _) = makePanel(streaming: EchoStreaming())
|
|
await panel.begin(captured)
|
|
await waitFor { panel.phase == .ready }
|
|
|
|
#expect(panel.chunkCount == 1)
|
|
#expect(panel.currentChunk == nil)
|
|
#expect(panel.totalChunks == nil)
|
|
}
|
|
}
|