#14458: fix(voicewake): avoid crash on foreign transcript ranges
app: macos
scripts
stale
size: L
Cluster:
Voice Transcription Enhancements
## 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
#9703: feat(macos): Voice settings restructure + Whisper transcription sup...
by nsd97 · 2026-02-05
75.5%
#18235: macOS: prevent Voice Wake crash when no input device is available
by agisilaos · 2026-02-16
74.5%
#5656: fix(macos): prevent crash on launch when no microphone available
by sfo2001 · 2026-01-31
72.6%
#20053: feat(voicewake): trigger-based routing to agent/session
by longbiaochen · 2026-02-18
70.8%
#8048: Media: add regression test for audio text blocks (#7970)
by Abhishek-B-R · 2026-02-03
70.7%
#15896: fix(memory-lancedb): capture even with injected recall context
by aelaguiz · 2026-02-14
70.0%
#3337: fix(macos-app): patch SwiftPM Bundle.module accessor for app bundle
by skymoore · 2026-01-28
70.0%
#15909: Guard notifications on macOS; fix focus issue and build fixes
by jasonkneen · 2026-02-14
69.4%
#11101: fix: handle AbortError and WebSocket 1006 in unhandled rejection ha...
by Nipurn123 · 2026-02-07
68.7%
#10744: fix: update stale MoltbotProtocol paths to OpenClawProtocol
by marezgui · 2026-02-06
68.5%