Repository navigation
Conversation
… outcome Engine, processors, polish, insert and their timing move into a value built at release; the coordinator keeps every state flip and turns the outcome into the event and the state after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #73, point 2 (first half: the finish pipeline). Stacked on #77 (
cli/bench-coordinator), which provides the harness for the before/after.What
finish(...)leavesDictationCoordinatorand becomesSources/PladderCore/DictationFinish.swift: a@MainActorvalue withrun(_:onStage:) async -> Outcome.Input: the captured tail, the samples already fed, the source (.utterance(engine, handle)or.whole(engine)),submit, the capture-stop time and the feed wait.Stage:.polishing, and.inserting(Transcript). The second is reported beforeinsert, so the coordinator setslastTranscriptto the processed text there. That keeps 07e6d2f's fix: a paste that fails still leaves the processed text.Outcome:.tooShort,.empty,.inserted(Insertion),.failed(DictationFailure).The coordinator keeps every state flip (
.transcribing,.polishing,.inserting,becomeIdle,showCopied,fail),lastTranscript,willPolish,cycleEngine,pendingUnloads,inFlight,endRecording,beginCanceland the hotkey/gesture code.hotkeyReleasedbuilds the finish, waits for the feed hand-over and the capture stop as before, runs the finish with a stage closure, and turns the outcome into the event and the state after (finished(_:)).Isolation.
runstays@MainActor, with the same awaits in the same order: feed hand-over →capture.stop→ engine → pipeline → refiner → insert. Nothing is detached or made nonisolated.Settings read at release (as decided). The finish is built in
hotkeyReleased, so the pipeline,disabledProcessors,appendTrailingSpace,minimumDurationandminimumPolishWordsare the values at release. Before, they were read when the engine returned, a few hundred milliseconds later. A setting changed inside that window now applies to the next dictation.Deviation from the plan.
DictationFinishhas awillPolish: Boolbesiderefiner. The old code had a case wherewillPolishis set but there is no refiner, and theretiming.polishmust be.zero, notnil; passingrefiner: willPolish ? refiner : nilwould have changed that.OutcomeandStageareEquatablefor the tests.DictationCoordinator.swiftgoes from 676 to 644 lines;DictationFinish.swiftis 92.Tests
The existing coordinator tests are unchanged and pass. New
Tests/PladderCoreTests/DictationFinishTests.swift, 11 tests:aRecordingUnderTheMinimumAbandonsTheUtteranceAndInsertsNothingfedSamplesCountTowardsTheMinimumprocessedTextEmptyInsertsNothingAndReportsEmptypolishRunsFromTheMinimumWordCountAndReportsItsStageunderTheMinimumPolishIsZeroNotNilwithoutPolishTheTimingHasNoPolishStagetheInsertingStageCarriesTheProcessedTranscriptBeforeTheInserttimingSumsTheStagesAndFeedWaitCountsAsEngineTimeaTrailingSpaceIsAppendedOnlyWhenMissingaThrowingInsertBecomesAFailureaThrowingEngineBecomesAFailureBeforeAnyStageswift build(no warnings) andswift test(612) are green;CoordinatorHandOverTests,CoordinatorRegressionTestsandDictationFinishTestspassed 20 runs in a row.Benchmark (critical path)
swift run -c release pladder-cli bench-coordinator --runs 101, Apple M1, 16 GB, macOS 27.0. The two builds ran back to back from copies of their release products.Before,
cli/bench-coordinator(d43924b), load 2.81 → 1.79:After, this branch (5a5a80f), load 1.72 → 1.46:
No difference. The 0.02 ms in the share median is well under the noise line.
For the developer
swift run -c release pladder-cli bench bench/fixtures --paced --runs 2 --pause 2release-to-pastelog lines:/usr/bin/log show --last 1h --style compact --predicate 'subsystem == "de.dinooo13.pladder"'🤖 Generated with Claude Code