Skip to content

Prevent large speech-alignment jumps when matchers disagree#68

Open
dustinogle wants to merge 1 commit into
f:masterfrom
dustinogle:fix/conservative-speech-alignment
Open

Prevent large speech-alignment jumps when matchers disagree#68
dustinogle wants to merge 1 commit into
f:masterfrom
dustinogle:fix/conservative-speech-alignment

Conversation

@dustinogle

Copy link
Copy Markdown

Summary

Makes word tracking more conservative when the fuzzy word matcher and character matcher disagree sharply. This bounds the word matcher relative to the character anchor, reducing large cursor jumps, awkward pauses, and lost tracking when speech recognition is imperfect.

Validation

  • Added 22 focused assertions covering agreement, disagreement, boundary, and commit behavior.
  • Built the full macOS app successfully with Xcode 26.6.
  • Manually used the build on macOS 26.5.1. Speech tracking was noticeably smoother, with fewer jumps ahead and fewer tracking stalls.

The normal responsive catch-up behavior remains intact for small disagreements.

@f
f requested a review from Copilot July 13, 2026 13:13

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.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Makes speech-text alignment more conservative when word- and character-level matchers disagree, preventing large cursor jumps caused by overly optimistic fuzzy word matches.

Changes:

  • Updates SpeechTextAlignment.bestOffset to cap how far the word matcher can lead the character anchor during disagreement.
  • Expands inline documentation describing the new agreement/disagreement behavior and rationale.
  • Adds a standalone Swift test runner with targeted assertions for bestOffset and shouldCommit.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
Textream/Textream/SpeechTextAlignment.swift Caps word-based offset advances in disagreement cases to prevent runaway jumps.
Tests/SpeechTextAlignmentTests.swift Adds an executable assertion-based test harness covering agreement/disagreement and commit gating scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +6
import Foundation

// Standalone tests for SpeechTextAlignment.bestOffset / shouldCommit.
//
// These can be run WITHOUT the Xcode project / project-file edits because
// SpeechTextAlignment.swift is a pure-Foundation enum. Compile & run:
Comment on lines +15 to +17
@main
struct SpeechTextAlignmentTests {
static func main() {
print("")
if failures.isEmpty {
print("All \(runCount) assertions passed.")
exit(0)
} else {
print("\(failures.count) of \(runCount) assertions failed:")
for f in failures { print(f) }
exit(1)
Comment on lines +15 to +17
@main
struct SpeechTextAlignmentTests {
static func main() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants