uttrflow / uttrflow/uttrflow-swift
No test covers the history record saved after a dictation, inserted or failed
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
When a dictation ends, `AppDelegate.render(_:)` (`Sources/Uttrflow/AppDelegate.swift:1131-1176`) builds the history record inline:
- `.inserted(let outcome)` (lines 1134-1162) maps the outcome's text, destination app and identifier, `spokenFor`, every correction (heard, wrote, word range, entry id, reason, confidence), every snippet and `spokenWords` into a `DictationRecord`.
- `.failed(let notice)` (lines 1163-1173) saves the salvaged transcript, if there is one, as a bare `DictationRecord`.
`AppDelegate.swift` is excluded from coverage (`Scripts/coverage_report.py:78`), and no test checks either mapping. A field dropped here silently breaks History, undo of a correction, and Insights.
## Why it matters
This is where every dictation becomes something the user can see again. #145 lays out why the app target needs tests of exactly this kind.
## How to check
Search `Tests/` for `DictationRecord(` built from an insertion outcome: nothing covers this mapping.
## Acceptance criteria
- The two mappings move into a small, pure function the app target can test, for example `static func record(for state: DictationState, at date: Date) -> DictationRecord?` on `AppDelegate` or in a new file in `Sources/Uttrflow/`, returning `nil` for states that save nothing. `render(_:)` calls it, and its behaviour is unchanged.
- Tests in a new `Tests/UttrflowTests/DictationRecordMappingTests.swift` check: every field of an inserted outcome with at least one correction and one snippet; a failure with a salvaged transcript; a failure without one; and a non-final state.
- Mapping only. Don't change what is logged, or when the record is written.
## Where to start
- `Sources/Uttrflow/AppDelegate.swift:1131-1176`
- `Tests/UttrflowTests/MainIntentWiringTests.swift` shows how app-target tests are written here (`@testable import Uttrflow`).
- Tests to extend: a new file in `Tests/UttrflowTests/`.
- Before pushing, run `make verify` (export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer first). It is the same command CI runs, and it enforces the 95% coverage floor per module.
- Read [CONTRIBUTING.md](https://github.com/uttrflow/uttrflow-swift/blob/main/CONTRIBUTING.md) first, and say on this issue that you are taking it.
**Size:** M, about half a day.
Contributor guide
Research direction
Read CONTRIBUTING.md, then inspect the mapping logic in Sources/Uttrflow/AppDelegate.swift:1131-1176 and the app-target test style in Tests/UttrflowTests/MainIntentWiringTests.swift. Add Tests/UttrflowTests/DictationRecordMappingTests.swift covering inserted, salvaged and unsalvaged failures, and non-final states; run make verify with the specified DEVELOPER_DIR and confirm render behavior is unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- desktop, testing
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- Half a day
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100