Repository navigation
Conversation
Stop always inserted into the focused field and closed the session. Add Pause/Resume, keep Stop as Save, and Clear that drops the current take without closing. Restarting dictation in the same window replaces a leftover session instead of throwing dictation_already_active. Fixes stablyai#19079
There was a problem hiding this comment.
ℹ️ No critical issues — a couple of minor suggestions inline.
Reviewed changes
- Pill controls —
DictationIndicatornow renders Pause/Resume, Save (was Stop), and Clear as ghosticon-xsbuttons from the first Starting frame; Clear flashes a "Cleared" label for ~1.2s. - Renderer session controls —
DictationControllerwas split intouseDictationTranscriptListenersanduseDictationUtteranceControls; pause is a renderer-onlypausedRefgate ononaudioprocess, with pause-during-start remembered and applied on ready. - Main STT clear + same-window replace — new
SttService.clearUtterance(workerclearmessage or cloudclear()),OpenAiTranscriptionSession.clear(), andconflictingDesktopOwner/startSettledso a new dictation in the same desktop window stops a leftover owner instead of throwing. - i18n + shared types —
DictationStategains'paused'andisDictationSessionOpen; six locales add the new control labels.
The refactor is clean, the new tests are meaningful (not theatre), and the clear/pause ordering is sound — the clearingUtteranceRef guard correctly suppresses transcript delivery during a clear, and IPC ordering keeps feeds before the clear message. Two rough edges worth a look inline.
ℹ️ Nitpicks
- The "Cleared" flash is optimistic:
setClearedHint(true)runs on click before the clear is known to have succeeded, so a failed or no-op clear (e.g. no worker/cloud session yet during Starting) still shows "Cleared". - The worker
clearpath (stt-worker-clear.ts/handleClear) has no direct unit test; the only coverage is the stt-service test asserting aclearmessage is posted, not that the worker actually resets its recognizer stream or offline chunker.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| } catch {} | ||
| } | ||
| } | ||
| return stream |
There was a problem hiding this comment.
For the offline branch, resetOfflineSessionState() mints a fresh stream on the module scope, but this function returns the local stream copy captured at entry, and handleClear reassigns that stale reference — discarding the freshly-created stream. It works today only because the offline stream is always fresh before clear (see decodeOfflineChunk's finally), so the reassignment is a no-op; but the return value is misleading for the offline path and relies on an undocumented invariant.
📝 WalkthroughWalkthroughThe change adds pause, resume, clear, and save controls to dictation. It adds paused-session state handling, clears local and cloud utterance buffers, and supports same-window session replacement. Renderer audio capture now supports pause, resume, and live-audio clearing. IPC, preload APIs, speech services, worker handling, localization, unit tests, and E2E tests are updated. Merge Risk: 🟡 Moderate · up to Clear can restore discarded text or prevent subsequent speech from reaching transcription, while restarting dictation during startup can be significantly delayed. These lifecycle regressions should be fixed before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 25 files. (6 skipped: 6 unsupported.)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 7df9b84c-b4ea-419a-b135-76e8e170f1ad
📒 Files selected for processing (31)
src/main/ipc/speech.tssrc/main/speech/openai-transcription-client.test.tssrc/main/speech/openai-transcription-client.tssrc/main/speech/stt-service.test.tssrc/main/speech/stt-service.tssrc/main/speech/stt-session-start.tssrc/main/speech/stt-session-state.tssrc/main/speech/stt-worker-clear.tssrc/main/speech/stt-worker.tssrc/preload/api/speech-api.tssrc/preload/api/speech-bridge.tssrc/renderer/src/components/dictation/DictationController.tsxsrc/renderer/src/components/dictation/DictationIndicator.test.tsxsrc/renderer/src/components/dictation/DictationIndicator.tsxsrc/renderer/src/components/dictation/dictation-control-actions.test.tssrc/renderer/src/components/dictation/dictation-control-actions.tssrc/renderer/src/components/dictation/dictation-control-events.tssrc/renderer/src/components/dictation/use-dictation-transcript-listeners.tssrc/renderer/src/components/dictation/use-dictation-utterance-controls.tssrc/renderer/src/components/native-chat/NativeChatComposer.tsxsrc/renderer/src/hooks/cleanup-audio-capture.tssrc/renderer/src/hooks/use-audio-capture.tssrc/renderer/src/hooks/use-capture-pause.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/speech-types.tstests/e2e/dictation-indicator.spec.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| const pendingStart = state.startSettled | ||
| await stopSttDictation(state, conflicting) | ||
| await pendingStart?.catch(() => undefined) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- target file ---'
sed -n '1,130p' src/main/speech/stt-session-start.ts
printf '%s\n' '--- bound stop/ready implementations ---'
rg -n -A35 -B10 'function stopSttDictation|const stopSttDictation|stopSttDictation|waitForSttWorkerReady|START_DICTATION_TIMEOUT_MS|ready|stopped' src/main/speech
printf '%s\n' '--- relevant tests ---'
rg -n -A45 -B15 'replacement|conflicting|startSettled|ready|START_DICTATION_TIMEOUT_MS|desktop:4' src/main/speech/*.test.tsRepository: stablyai/orca
Length of output: 50370
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 22740
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- start session worker path ---'
sed -n '80,180p' src/main/speech/stt-session-start.ts
printf '%s\n' '--- worker stop contract ---'
sed -n '1,240p' src/main/speech/stt-worker-stop.ts
printf '%s\n' '--- startup/stop tests ---'
rg -l 'startSttDictation|startDictation|stopDictation|stopped|waitForSttWorkerReady' src/main/speech --glob '*.test.ts' |
while read -r f; do
echo "--- $f ---"
rg -n -A35 -B15 'startSttDictation|startDictation|stopDictation|stopped|waitForSttWorkerReady|replacement|owner' "$f"
doneRepository: stablyai/orca
Length of output: 30446
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- remaining startup flow ---'
sed -n '145,245p' src/main/speech/stt-session-start.ts
printf '%s\n' '--- worker message handling ---'
rg -l 'type.*stop|stopped|postMessage.*stopped|message.*init' src/main --glob '*stt*worker*.ts' --glob '*.ts' |
while read -r f; do
echo "--- $f ---"
rg -n -A25 -B15 'type.*stop|stopped|postMessage.*stopped|message.*init' "$f"
done
printf '%s\n' '--- relevant state shape ---'
sed -n '1,180p' src/main/speech/stt-session-state.tsRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- startup tail ---'
sed -n '145,225p' src/main/speech/stt-session-start.ts
printf '%s\n' '--- stop handling in speech sources ---'
rg -n -A20 -B12 --glob '*.ts' "message\.type.*stop|type === ['\"]stop['\"]|type: ['\"]stopped['\"]|postMessage\(\{ type: ['\"]stopped['\"]" src/main/speechRepository: stablyai/orca
Length of output: 30421
Unblock same-window replacement during startup
waitForSttWorkerReady ignores stopped, while handleStop can emit stopped before ready. Therefore, stopSttDictation can finish while pendingStart remains pending until START_DICTATION_TIMEOUT_MS, delaying the replacement. Settle the startup wait when stopping a starting worker, and add the pending-start regression test.
| if (activeSessionIdRef.current === sessionId) { | ||
| clearingUtteranceRef.current = false | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- target file ---'
sed -n '1,180p' src/renderer/src/components/dictation/use-dictation-utterance-controls.ts
printf '%s\n' '--- clearUtterance definitions and callers ---'
rg -n -C 4 'clearUtterance|clearDictation|clearingUtteranceRef|transcript|partial' src/renderer/src src/main src -g '*.{ts,tsx,js}' | head -n 260Repository: stablyai/orca
Length of output: 29131
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 27100
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- dictation-related files ---'
git ls-files | rg '(^|/)(dictation|speech|stt|.*worker.*)\b|use-dictation|speech-types' | head -n 160
printf '%s\n' '--- exact symbol locations ---'
rg -n 'class SttService|clearUtterance|clearDictation|clearingUtteranceRef|setPartialTranscript|partialTranscript|transcript' src/main src/renderer/src src/shared -g '*.{ts,tsx}' | rg 'dictat|speech|stt|utterance|transcript|worker' | head -n 240Repository: stablyai/orca
Length of output: 40729
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- main IPC speech ---'
sed -n '1,260p' src/main/ipc/speech.ts
printf '%s\n' '--- speech IPC tests around clear ---'
rg -n -C 8 'clear|utterance|partial|transcript|worker|SttService' src/main/ipc/speech.test.ts src/main/runtime/rpc/methods/speech.ts src/main/runtime/rpc/methods/speech.test.ts
printf '%s\n' '--- renderer speech API and event consumers ---'
rg -n -C 6 'speech\.|clearDictation|dictation|partialTranscript|setPartialTranscript|clearingUtterance' src/renderer/src src/preload src/shared -g '*.{ts,tsx}' | head -n 320Repository: stablyai/orca
Length of output: 41233
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- speech implementation files ---'
git ls-files src/main/speech | sort
printf '%s\n' '--- clear and message symbols in speech implementation ---'
rg -n -C 10 'clearUtterance|feedAudio|onMessage|postMessage|worker|partial|final|SpeechStt|SttService' src/main/speech -g '*.{ts,tsx}' | head -n 360Repository: stablyai/orca
Length of output: 26788
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- worker clear and message loop ---'
sed -n '175,330p' src/main/speech/stt-worker.ts
sed -n '1,220p' src/main/speech/stt-worker-clear.ts
printf '%s\n' '--- service/session lifecycle wiring ---'
sed -n '1,220p' src/main/speech/stt-session-state.ts
sed -n '1,260p' src/main/speech/stt-session-start.ts
printf '%s\n' '--- renderer dictation files ---'
git ls-files src/renderer/src/components/dictation | sort
rg -n -C 8 'onPartialTranscript|onFinalTranscript|setPartialTranscript|clearingUtteranceRef|speech:partial|partial' src/renderer/src/components/dictation -g '*.{ts,tsx}'Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- worker dispatch ---'
sed -n '300,370p' src/main/speech/stt-worker.ts
printf '%s\n' '--- renderer transcript listener ---'
sed -n '1,280p' src/renderer/src/components/dictation/use-dictation-transcript-listeners.ts
printf '%s\n' '--- related tests ---'
rg -n -C 6 'clear|partial|final|stale|clearing' src/main/speech/stt-service.test.ts src/main/speech/stt-worker.test.ts src/renderer/src/components/dictation -g '*.{test.ts,test.tsx}'Repository: stablyai/orca
Length of output: 45529
Keep transcript suppression active until worker clear completes.
clearDictation() resolves after SttService.clearUtterance() posts { type: 'clear' }, not after the worker processes it. A pre-clear partial event can therefore arrive after the promise resolves. Lines 88–90 then allow useDictationTranscriptListeners to restore the stale transcript. Use a clear acknowledgment or generation boundary, and add a regression test for this ordering.
| const clearLiveAudio = useCallback(() => { | ||
| resetBufferedAudio() | ||
| capturedChunkCountRef.current = 0 | ||
| resetMeter() | ||
| }, [capturedChunkCountRef, resetBufferedAudio, resetMeter]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Description: Trace every write to bufferAudioRef and every clearLiveAudio caller.
set -euo pipefail
fd -t f 'use-audio-capture.ts|cleanup-audio-capture.ts|use-capture-pause.ts' src \
--exec rg -n -C 4 'bufferAudioRef|bufferedAudioGenerationRef|clearLiveAudio' {}
# Consumers of clearLiveAudio in the dictation controller layer.
rg -n -C 6 '\bclearLiveAudio\b' src --type=ts --type=tsxRepository: stablyai/orca
Length of output: 5040
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 5397
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- use-capture-pause.ts ---'
cat -n src/renderer/src/hooks/use-capture-pause.ts
printf '%s\n' '--- use-audio-capture.ts relevant sections ---'
sed -n '35,155p;200,350p' src/renderer/src/hooks/use-audio-capture.ts
printf '%s\n' '--- clearLiveAudio callers ---'
rg -n -C 8 '\bclearLiveAudio\b' src -g '*.ts' -g '*.tsx' || trueRepository: stablyai/orca
Length of output: 23574
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- flushDictationAudioBuffer implementation ---'
rg -n -C 12 'export async function flushDictationAudioBuffer|function flushDictationAudioBuffer' src/renderer/src
printf '%s\n' '--- startDictation and clearUtterance flow ---'
sed -n '1,125p' src/renderer/src/components/dictation/use-dictation-utterance-controls.ts
sed -n '125,240p' src/renderer/src/components/dictation/use-dictation-utterance-controls.ts
printf '%s\n' '--- all writes to bufferAudioRef ---'
rg -n -C 3 'bufferAudioRef\.current\s*=' src/renderer/src/hooks src/renderer/src/components/dictation -g '*.ts' -g '*.tsx'Repository: stablyai/orca
Length of output: 9175
Clear the buffering flag when clearing live audio.
If clearLiveAudio runs while flushDictationAudioBuffer awaits feedAudio, resetBufferedAudio changes bufferedAudioGenerationRef. The flush then skips its conditional cleanup, so bufferAudioRef.current remains true. Later onaudioprocess calls keep buffering audio and do not call window.api.speech.feedAudio.
🐛 Proposed fix: clear the buffering flag
export function useCapturePause(
resetMeter: () => void,
resetBufferedAudio: () => void,
- capturedChunkCountRef: MutableRefObject<number>
+ capturedChunkCountRef: MutableRefObject<number>,
+ bufferAudioRef: MutableRefObject<boolean>
) {
@@
const clearLiveAudio = useCallback(() => {
+ bufferAudioRef.current = false
resetBufferedAudio()
capturedChunkCountRef.current = 0
resetMeter()
- }, [capturedChunkCountRef, resetBufferedAudio, resetMeter])
+ }, [bufferAudioRef, capturedChunkCountRef, resetBufferedAudio, resetMeter])Pass bufferAudioRef from use-audio-capture.ts.
| "25f2b7a6a5": "말하는 중", | ||
| "74cc85c4c7": "일시 중지됨", | ||
| "88c56c1272": "일시 중지", | ||
| "7cbca0dff5": "다시 시작", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use state-specific Korean labels for the Resume control and Cleared status.
The repository uses "다시 시작" for actual restarts and "재개" for resumed sessions. DictationIndicator uses 7cbca0dff5 to resume paused dictation. It uses c9db4ce67c for the completed state after clearing. Use "재개" and "지워짐".
Proposed wording
- "7cbca0dff5": "다시 시작",
+ "7cbca0dff5": "재개",
...
- "c9db4ce67c": "지움"
+ "c9db4ce67c": "지워짐"|
Thanks for this, @ensp1re, and sorry it sat so long. We've since rebuilt the dictation pill (#40155, #40189). It now has a fixed-size pill with ✕ to cancel and a button to finish, and a failed dictation keeps the recording so you can retry. That covers most of what Pause/Save/Clear set out to do, and this branch no longer fits the new pill, so I'm closing it. The idea shaped the redesign. Thank you. |

ELI5
The dictation pill used to have one button: Stop, which always dumped what you said into the input and closed. It now has Pause/Resume, Save (the old Stop), and Clear. Clear throws away the current take, keeps the mic open, and flashes Cleared so you can talk again without deleting text by hand.
What Changed
dictation_already_active.Why
Stop-only dictation made a bad take expensive: the transcript always landed in the composer. Pause and Clear are the missing session controls. Same-window restart was failing after a leftover owner (
desktop:<webContentsId>:<sessionId>), which showed up asdictation_already_activeplusdictation_owner_mismatchon stop.Linked Issue
Fixes #19079
Visual Proof
Manually exercised on macOS in the local Electron dev app (
Orca: main,orca-devprofile): Pause/Resume, Save, Clear with the Cleared flash, and a second start after Save. Please attach a short before/after clip in review if you want it on the GitHub thread — I did not commit media into the repo.Testing
Automated:
oxlinton changed files — passpnpm typecheck— passDictationIndicator, localization, control actions,stt-service, openai transcription client)Not run: full
pnpm lint, fullpnpm test,pnpm build(Electron packaging). Pre-commitlint-staged(oxlint + oxfmt) passed on the commit.Platforms actually tested: macOS Apple Silicon, local (not SSH).
AI Disclosure
Grok 4.6 (xAI) was used to implement and verify this change.
Review
Agent review of this diff:
ScriptProcessorNode+ a ref; STT clear is workerreset/ offline chunker reset / OpenAI sessionclear(). No macOS-only APIs in the new controls. Shortcut chip still uses the existing platform-awareShortcutKeyCombo.isDictatingto includepaused.onaudioprocessfeed; Clear is a stream reset, not a worker teardown. Same-window restart stops the previous owner before starting.icon-xsbuttons, existing popover pill tokens, hashed i18n keys. Hold mode still omits the shortcut chip.speech:clearDictationon the existing speech handler, scoped todesktop:<senderId>:<sessionId>. Same-window takeover only matchesdesktop:<senderId>:owners; other windows and mobile still getdictation_already_active.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Desktop-only pill/session controls. Mobile long-press cancel is unchanged. Hold-to-talk still stops on release.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author: @0xEnsp1re