← Back to PRs

#14458: fix(voicewake): avoid crash on foreign transcript ranges

by guchang open 2026-02-12 05:20 View on GitHub →
app: macos scripts stale size: L
## What - avoid direct string slicing with segment ranges in WakeWordGate.commandText - build command text from post-trigger speech segments only, resilient even when segment ranges are foreign or invalid - add regression coverage for foreign range indices in both SwabbleKitTests and macOS VoiceWakeRuntimeTests ## Why A macOS crash report showed EXC_BREAKPOINT in VoiceWakeRuntime.handleRecognition with Collection.subscript.getter. One realistic failure mode is using a segment range index tied to a different transcript instance. This change removes that unsafe indexing path. ## Validation - Ran: swift test --package-path apps/macos --filter VoiceWakeRuntimeTests - Result: pass (8 tests) - Note: swift test --package-path Swabble --filter WakeWordGateTests currently fails in this environment due pre-existing availability issues in SwabbleCore/Support/AttributedString+Sentences.swift (unrelated to this patch) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This change removes `String.Index`-based slicing from `WakeWordGate.commandText` and instead builds the command text by joining normalized post-trigger speech segments. This avoids crashes when a segment’s `range` originates from a different transcript instance (foreign/invalid range indices). Tests were updated/added in both `SwabbleKitTests` and the macOS IPC runtime tests to cover the foreign-range scenario and assert that command extraction remains correct (e.g., returning `"do thing"`). <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - The change is narrowly scoped to avoid unsafe string slicing, preserves intended command extraction behavior, and adds targeted regression tests for the reported crash scenario. - No files require special attention <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs