Skip to content

test(dictation): cover clipboard and transcription flow - #88

Merged
trsdn merged 11 commits into
mainfrom
test/dictation-flow
Sep 22, 2026
Merged

trsdn merged 11 commits into
mainfrom
test/dictation-flow

Conversation

@trsdn

@trsdn trsdn commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add injectable production-default seams for clipboard, Cmd+V, audio capture, transcription, enhancement, pasting, and overlay presentation
  • add hardware-free tests for clipboard transactions and the primary dictation success/failure paths
  • preserve complete clipboard contents by cancelling auto-paste whenever any declared representation cannot be snapshotted safely
  • surface clipboard-preservation cancellation as a recoverable error instead of incorrectly showing success
  • use two-phase pasteboard writes so failed preparation cannot clear the current clipboard
  • cover stale captures, short-recording padding, enhancement fallback, error recovery, second-paste handling, external clipboard changes, empty clipboards, and auto-paste-off behavior
  • move S02 to pass with 38 tests and synchronized conformance evidence

Privacy tradeoff

For protected, promised, or otherwise unreadable clipboard representations, OpenWritr fails closed instead of restoring only a readable subset. This intentionally prefers preserving the user’s entire clipboard over completing automatic paste, and the overlay now explains the cancellation.

Validation

  • swift build -c release -Xswiftc -warnings-as-errors
  • swiftlint lint --strict
  • swift test — 38 tests
  • conformance check — Healthy, 85 passes
  • signed app bundle and synthetic self-test
  • targeted mutation checks for every new behavioral invariant

Closes #55
Closes #44

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4ea0580f-655c-457e-9b12-dd7e8dc1dfe5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4ea0580f-655c-457e-9b12-dd7e8dc1dfe5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4ea0580f-655c-457e-9b12-dd7e8dc1dfe5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4ea0580f-655c-457e-9b12-dd7e8dc1dfe5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4ea0580f-655c-457e-9b12-dd7e8dc1dfe5
Copilot AI lite review requested due to automatic review settings September 22, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved clipboard contract issues and required validation and documentation updates remain.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds injectable seams and hardware-free tests for dictation, transcription, enhancement, clipboard handling, and overlay presentation.

Changes:

  • Adds production-default dependency injection protocols.
  • Expands dictation and clipboard transaction coverage.
  • Adds padding, fallback, stale-capture, and paste behavior tests.
  • Updates S02 conformance evidence.
File Reviewed changes Findings
Tests/​OpenWritrTests/​PasteManagerTests.swift Clipboard transaction tests. No findings.
Tests/​OpenWritrTests/​AppViewModelDictationFlowTests.swift Dictation flow tests. No findings.
Sources/​OpenWritr/​TranscriptionManager.swift Transcription seam and padding helper. No findings.
Sources/​OpenWritr/​PasteManager.swift Clipboard and paste-command seams. Moderate (2 votes): Treat nil pasteboard items as empty. Moderate (1 vote): Reconcile fail-closed behavior with #55 acceptance criteria. Nit (1 vote): Add a changelog entry for the user-facing clipboard behavior.
Sources/​OpenWritr/​OverlayPanel.swift Overlay presentation seam. No findings.
Sources/​OpenWritr/​OpenWritrApp.swift Dependency injection and dictation-flow timing. Nit (1 vote): Add manual built-app runs for normal and Enhanced Mode dictation/paste.
Sources/​OpenWritr/​GrammarEnhancer.swift Enhancement seam. No findings.
Sources/​OpenWritr/​AudioEngine.swift Audio capture seam. No findings.
docs/​self-assessment.md S02 evidence update. Nit (1 vote): Document manual normal and Enhanced Mode runs before marking S02 complete.
.github/​conformance.yml Conformance status update. No findings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Sources/OpenWritr/PasteManager.swift Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4ea0580f-655c-457e-9b12-dd7e8dc1dfe5
Copilot AI review requested due to automatic review settings September 22, 2026 10:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Resolve the clipboard restore data-loss risk and reconcile the S02 acceptance criteria and evidence.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread Sources/OpenWritr/PasteManager.swift Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No high-confidence, actionable HIG defects were found. This PR is a pure protocol-extraction refactor for testability/dependency injection (AudioCapturing, TranscriptEnhancing, TextPasting/PasteboardManaging/PasteCommandPosting, OverlayPresenting, Transcribing), plus minor behavioral tweaks (transcript padding moved to a shared TranscriptionInput.paddedIfNeeded helper, doneDisplayDuration/transientErrorDisplayDuration made injectable constants, and clipboard-restore now cancels on any unreadable/incomplete representation instead of silently dropping it). None of the changed files (AudioEngine.swift, GrammarEnhancer.swift, OpenWritrApp.swift, OverlayPanel.swift, PasteManager.swift, TranscriptionManager.swift) touch SwiftUI view bodies, layout, colors, text styles, focus/keyboard handling, or accessibility labels; no Settings or About view source is modified. Rendered surfaces reviewed, all consistent between variants with no legibility, contrast, layout, or scaling regressions observed: Settings light, dark, and light with accessibility larger text; About light, dark, and dark with accessibility larger text; Overlay listening, transcribing, enhancing, done, and error in both light and dark. The clipboard-restore behavior change, cancelling the paste instead of partially restoring an incomplete snapshot, is a defensive improvement for clipboard-integrity privacy but has no visible UI surface to evaluate from screenshots alone, so it is not reported as a defect.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4ea0580f-655c-457e-9b12-dd7e8dc1dfe5
Copilot AI review requested due to automatic review settings September 22, 2026 11:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Resolve the clipboard acceptance-contract discrepancy and synchronize the documented evidence.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
Resolved since last review (1)

Comment thread docs/self-assessment.md Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4ea0580f-655c-457e-9b12-dd7e8dc1dfe5
Copilot AI review requested due to automatic review settings September 22, 2026 11:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved release metadata, paste-flow, requirements-alignment, and validation issues remain.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Low severity

Open (2)

Comment thread CHANGELOG.md
Copilot AI review requested due to automatic review settings September 22, 2026 11:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A critical delayed clipboard-restore failure and two moderate user-facing issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity · 1 Low severity

Open (4)

Comment thread Sources/OpenWritr/PasteManager.swift
Comment thread Sources/OpenWritr/OpenWritrApp.swift Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the rendered macOS UI evidence for this PR (Settings, About, and overlay surfaces in light/dark, plus larger accessibility-text Settings and About variants) against the diff.

No high-confidence, actionable HIG defects found.

The diff for this PR is almost entirely internal refactoring and logic hardening:

  • Protocol-oriented dependency injection for AudioEngine -> AudioCapturing, PasteManager -> TextPasting, TranscriptionManager -> Transcribing, GrammarEnhancer -> TranscriptEnhancing, and OverlayPanel -> OverlayPresenting (enables testability; no behavioral or visual change).
  • Clipboard-safety hardening in PasteManager.swift: paste now cancels (rather than silently proceeding) if any pasteboard representation can't be read/restored, surfaced via a new .paste RuntimeErrorKind and presentPasteCancelledError().
  • TranscriptionInput.paddedIfNeeded extraction (no behavior change) and configurable doneDisplayDuration/transientErrorDisplayDuration for test injection.

None of this touches the SwiftUI view code for Settings or About, so the corresponding screenshots are unaffected by this PR. The OverlayPanel diff only adds a protocol conformance with no rendering changes, and the new .paste error path reuses the existing .error(overlayMessage) overlay rendering already exercised by overlay-error-light.png/overlay-error-dark.png, which render with legible, appropriately contrasted text in both appearances.

The one user-facing change -- adding .paste alongside .transcription in MenuBarView.swift's error-menu switch, and its "Dismiss Error" button/transient auto-dismiss -- is not depicted in any of the provided screenshots (no menu-bar dropdown capture was included), so I can't verify its rendering and won't speculate on unrendered behavior.

Rendered surfaces and variants reviewed:

  • Settings: light, dark, light (accessibility text size)
  • About: light, dark, dark (accessibility text size)
  • Overlay: listening, transcribing, enhancing, done, error -- each in light and dark

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4ea0580f-655c-457e-9b12-dd7e8dc1dfe5
Copilot AI review requested due to automatic review settings September 22, 2026 12:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
Resolved since last review (4)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Reconcile unreadable clipboard behavior with acceptance criteria

Sources/​OpenWritr/​PasteManager.swift:272

The linked #55 acceptance criteria still explicitly requires the unreadable-clipboard case to paste successfully (issue #37) and excludes user-visible behavior changes, but this branch now returns .cancelled for any unreadable declared representation. Because this PR closes #55 and marks S02 healthy, please reconcile the requirement—either update the issue/evidence to record this intentional fail-closed scope change or preserve the required behavior.

Comment thread docs/self-assessment.md

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all prepared surfaces and variants: Settings (light, dark, light-accessibility-text), About (light, dark, dark-accessibility-text), and the six overlay states (listening, transcribing, enhancing, done, error) in light and dark. No high-confidence, actionable HIG defects were found that are introduced or exposed by this PR's rendered UI. Notes: Settings.swift and About.swift are not touched by this diff, so those screenshots show no PR-attributable regressions. The diff's UI-visible surface is the new .paste runtime-error kind (overlay error state plus the MenuBarView Dismiss Error action) and the doneDisplayDuration/transientErrorDisplayDuration injection. The new Clipboard could not be preserved; paste cancelled overlay message (the longest error string in the app) fits within the overlay's constrained error text region (lineLimit 2, truncationMode tail) without visible clipping or contrast loss in either light or dark, matching the existing error-state color, icon, and motion treatment used for other runtime errors. The underlying PasteManager cancellation-logic issues (nil pasteboardItems handling, restore-before-write ordering, delayed-restore failure tracking, and the recovery-suggestion text versus actual transcript availability) are already tracked in this PR's existing review threads and are not duplicated here. No further action requested from this pass.

@trsdn
trsdn merged commit 7bad393 into main Sep 22, 2026
16 checks passed
@trsdn
trsdn deleted the test/dictation-flow branch September 22, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants