Skip to content

feat(dictation): send chat messages when dictation ends - #32103

Closed
pelted wants to merge 12 commits into
stablyai:mainfrom
pelted:chris/dictation-auto-send
Closed

pelted wants to merge 12 commits into
stablyai:mainfrom
pelted:chris/dictation-auto-send

Conversation

@pelted

@pelted pelted commented Oct 22, 2026 •

Copy link
Copy Markdown

ELI5

When you dictate a message into the chat box, Orca can now send it for you. After you stop talking, a small countdown shows "Sending in 2s" with a Cancel button. If you do nothing, the message sends. If you type, click away, press Cancel or start talking again, it stays as a draft. The setting is off by default.

What Changed

Before: dictation put the transcript in the chat composer, and you still had to press Enter to send it.

After: with Settings > Voice > "Send when dictation ends" turned on, stopping dictation into the native chat composer starts a short countdown (1, 2, 3 or 5 seconds, default 2) in the dictation pill. When it ends, the composer sends through its normal send, the same path Enter uses, so goal mode, Orca / commands and image attachment holds behave as they do today.

Mechanism:

  • insertText now resolves true only when all of the dictated text landed in the field. In a contenteditable editor without execCommand, the fallback inserts only at a caret inside that editor and reports false otherwise. The countdown starts only after every insertion for the session was delivered and the composer still has focus. This keeps a skipped insertion from sending an older draft.
  • armDictationAutoSend listens on the composer editor from the moment dictation stops. A key press, paste, drop, IME composition or focus leaving the editor cancels it, including while the text is still landing. Edits cancel only once the countdown runs, since dictation's own insertion fires input.
  • useDictationAutoSend owns the one pending send and also cancels it when dictation starts again, when the setting or voice is turned off, and on the pill's Cancel button.
  • The composer's prompt editor carries a data-dictation-auto-send marker. A dictation:submit event reaches only the composer that owns that editor.
  • Terminal panes, inline queued-message edits and other inputs never auto-send. Sessions with no speech or an error never start a countdown. If the composer is disabled or empty when the countdown ends, nothing is sent and the text stays.
  • The composer mic button refocuses the composer when it stops dictation, so stopping with a click still counts as dictating into the composer.

Why

Issue #12157 asks for an opt-in way to send when dictation finishes, to remove the extra Enter after every dictated message. The delay with an obvious way out keeps a misheard transcript from going out by accident, which was the main concern raised in the issue thread. Sending through the composer's own send keeps one submit path instead of adding a second one that could drift.

This PR covers the desktop native chat composer only. Terminal panes and mobile are left for follow-ups: terminals because an automatic Enter can run a shell command, and mobile because it has its own composer and dictation flow.

Linked Issue

Part of #12157 (desktop composer). The issue also asks for terminal panes and mobile, which this PR does not cover. #32105 (merged) lets mobile start dictation from agent chat tabs, and #32656 adds the mobile side of this setting on top of this PR.

Visual Proof

Before: the Voice settings pane has no auto-send row, and the dictation pill disappears when dictation stops.

After:

image

Pill update when dictation stops:
pill-light

Testing

Tested on macOS in a dev build with real dictation: the message sends after the delay; typing, clicking away, Cancel and starting dictation again keep the draft; Enter during the countdown sends once; dictating into a terminal never sends. Not tested on Linux or Windows; the change has no platform-specific code. Not tested over SSH; the send uses the composer's existing send path.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

New tests cover the countdown (delivery gating; a key press, paste, edit, focus leaving, window blur or the page being hidden, while the text lands and while counting down; Cancel; a removed editor), contenteditable insertion through the real insertText (a caret in the editor sends, no caret or a caret outside it keeps the draft), the eligibility rules (setting off, no speech, errored session, terminal, non-composer field), and submit routing to the right composer when two are mounted. Starting dictation again and turning the setting off during a countdown have no automated test; the first was checked by hand.

Checks run locally on macOS, rebased on def1565846:

  • pnpm lint, pnpm typecheck and pnpm run check:code-quality:changed pass.
  • pnpm test: the dictation, native chat and settings suites pass. On the previous base (a6fdeda541), the full run failed in main-process, git, daemon and cross-version wire tests that need real processes or built artifacts. Those 68 files failed the same way on unmodified upstream main on this machine, and the 3 others passed when rerun alone (one, a file-timestamp test, only on some runs).
  • pnpm build: the desktop build passes. The native macOS computer-use helper step fails on this machine because its code-signing identity matches two certificates in the keychain; this PR touches no native code.

AI Disclosure

An AI coding agent helped write tests and review this change.

Review

  • Cross-platform: renderer-only, no platform branches, shortcuts or paths. Hold and toggle modes use the existing dictation shortcut handling.
  • SSH/remote/local: the send goes through the composer's existing structured and PTY paths. New settings fields are merged over defaults on load, and the mobile speech settings writer spreads the existing voice object, so older clients keep the new fields.
  • Agents and integrations: provider-neutral. It sends exactly what Enter would.
  • Performance: one timer and a few element listeners exist only while a send is pending, and are removed when it settles.
  • UI: uses the Switch, Select and Button primitives and existing tokens. Checked in light and dark mode. The countdown is announced once to screen readers instead of every second.
  • Security: no new IPC, network or file access. The send only fires from the composer that received the dictated text.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No mobile or remote protocol changes. The setting is off by default, so existing behavior is unchanged until a user turns it on.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

The change adds configurable, delayed sending for dictated native chat messages. Dictation insertion now reports delivery results, and the controller uses those results and session outcomes to determine whether to start auto-send. The countdown starts only for an eligible composer and can be canceled by user activity or app state changes. Native chat routes the submit event to the matching composer. Settings provide an enable toggle and delay choices, and the indicator displays the pending countdown.

Merge Risk: Low · previous review 65009

Opt-in auto-send has two bounded workflow defects: some error exits retain watcher state, and clicking away may still send the dictated draft. Fix these before relying on the feature broadly.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description is detailed and covers the change, rationale, issue, testing, AI disclosure, scope, compatibility, and checklist. However, the required visual proof is incomplete: it describes a befor… Attach a before screenshot or video alongside the after-state evidence, or write N/A with a valid explanation if visual proof is not applicable. Then check the corresponding checklist item.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: automatically sending chat messages when dictation ends.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, issue, testing, AI disclosure, scope, compatibility, and checklist. However, the required visual proof is incomplete: it describes a before state but provides only after-state images, and the checklist confirms that before/after proof is not attached.

Resolution

Attach a before screenshot or video alongside the after-state evidence, or write N/A with a valid explanation if visual proof is not applicable. Then check the corresponding checklist item.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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.

Share

@pelted
pelted force-pushed the chris/dictation-auto-send branch from be698bb to fb0ddc5 Compare October 23, 2026 14:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Cancel the pending auto-send synchronously when dictation… · use-dictation-auto-send.ts:74-80

src/renderer/src/components/dictation/use-dictation-auto-send.ts:74-80
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Cancel the pending auto-send synchronously when dictation starts.

DICTATION_CONTROL_EVENT can call startDictation() while the controller is idle. The current cancellation runs later in the dictationState === 'starting' effect. The existing timer can expire before that effect runs, dispatch dictation:submit, and make the native composer send its current draft.

Dispatch DICTATION_CANCEL_AUTO_SEND_EVENT at the start of startDictation(), after validation and before changing the dictation state. All start paths converge there.

Suggested fix
 import { useHoldDictationGesture } from './use-hold-dictation-gesture'
 import { DICTATION_CONTROL_EVENT, type DictationControlAction } from './dictation-control-events'
 import { publishDictationMeter } from './dictation-meter-store'
+import { DICTATION_CANCEL_AUTO_SEND_EVENT } from './dictation-auto-send'
 import { useDictationAutoSend } from './use-dictation-auto-send'
 ...
     if (!settings?.voice?.enabled) {
       toast('Voice dictation is disabled. Enable it in Settings > Voice.')
       return
     }

+    document.dispatchEvent(new Event(DICTATION_CANCEL_AUTO_SEND_EVENT))
     const runId = dictationRunRef.current + 1

ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 427a3c16-401b-437a-ba4f-707cb2e3316e
📥 Commits

Reviewing files that changed from the base of the PR and between be698bb58108a0c1dac991421758ddef50955b62 and fb0ddc5fc062b9662b9da1ee55026557a35dec3b.

📒 Files selected for processing: 2
  • src/renderer/src/components/native-chat/NativeChatComposerField.tsx
  • src/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes: 1
  • src/renderer/src/i18n/locales/en.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Cancel pending auto-send before persisting voice settings. · use-dictation-auto-send.ts:112-116

src/renderer/src/components/dictation/use-dictation-auto-send.ts:112-116
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cancel pending auto-send before persisting voice settings.

VoicePane.updateVoiceSettings starts the asynchronous settings write without canceling the active countdown. The persistence helper awaits window.api.settings.set(...) before publishing the new settings, so the hook's cancellation effect can run only after that write completes. The countdown can expire first, dispatch dictation:submit, and send the draft.

Dispatch DICTATION_CANCEL_AUTO_SEND_EVENT before updateSettings when enabled or autoSendAfterDictation becomes false.

Suggested fix
+import { DICTATION_CANCEL_AUTO_SEND_EVENT } from '../dictation/dictation-auto-send'

  const updateVoiceSettings = useCallback(
    (updates: Partial<VoiceSettings>): void => {
+      if (updates.enabled === false || updates.autoSendAfterDictation === false) {
+        document.dispatchEvent(new Event(DICTATION_CANCEL_AUTO_SEND_EVENT))
+      }
      updateSettings({
        voice: {
          ...voiceSettingsRef.current,
          ...updates
        }
      })
    },
    [updateSettings]
  )

ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5758795c-a894-4903-9b64-8576403781d0
📥 Commits

Reviewing files that changed from the base of the PR and between fb0ddc5fc062b9662b9da1ee55026557a35dec3b and 9deb6c652cbf163d90b6a36ccbf98363bcb0b30b.

📒 Files selected for processing: 7
  • src/renderer/src/components/dictation/DictationController.tsx
  • src/renderer/src/components/dictation/dictation-auto-send.test.ts
  • src/renderer/src/components/dictation/dictation-auto-send.ts
  • src/renderer/src/components/dictation/use-dictation-auto-send.test.tsx
  • src/renderer/src/components/dictation/use-dictation-auto-send.ts
  • src/renderer/src/components/native-chat/use-native-chat-dictation-submit.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-dictation-submit.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@pelted
pelted force-pushed the chris/dictation-auto-send branch 2 times, most recently from 33c182b to 65009e8 Compare October 27, 2026 18:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

Minor · Settle the watcher on startup and speech-error exits. · DictationController.tsx:260-267

src/renderer/src/components/dictation/DictationController.tsx:260-267
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Settle the watcher on startup and speech-error exits.

stopDictation discards the reporter returned by watchAutoSend. If startup then enters catch, or onError handles a speech error, neither path reports an outcome before clearing the target and resetting the session. The delivery promise therefore stays pending, so auto-send never reaches a settled no-send result and the element’s takeover, blur, and visibility listeners can remain installed.

Route both error paths through one helper that resolves the pending reporter with { finalTranscriptReceived: false, sessionErrored: true } before clearing the target.

Minor · Cancel the watcher on pointer activity outside the composer. · dictation-auto-send.ts:109-113

src/renderer/src/components/dictation/dictation-auto-send.ts:109-113
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cancel the watcher on pointer activity outside the composer.

USER_TAKEOVER_EVENTS includes focusout, but the watcher registers those events only on the composer element. A click on a non-focusable area outside the composer can leave focus unchanged, so no focusout occurs. The countdown then reaches its timer and dispatches dictation:submit, which routes the message to the composer instead of honoring the stated click-away cancellation behavior.

Suggested fix
   const handleUserEvent = (event: Event): void => {
     if (event.type === 'input' && !countingDown) {
       return
     }
@@
     }
     settle()
   }
+  const handleOutsidePointerDown = (event: Event): void => {
+    if (event.target instanceof Node && element.contains(event.target)) {
+      return
+    }
+    settle()
+  }
   const startCountdown = (): void => {
@@
     window.removeEventListener('blur', handleAppLeave)
     document.removeEventListener('visibilitychange', handleAppLeave)
+    document.removeEventListener('pointerdown', handleOutsidePointerDown, true)
     options.onSettled()
@@
   window.addEventListener('blur', handleAppLeave)
   document.addEventListener('visibilitychange', handleAppLeave)
+  document.addEventListener('pointerdown', handleOutsidePointerDown, true)

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 11d01417-bea7-4791-95d7-164e11f791e1
Commits

Reviewing files that changed from the base of the PR and between 33c182b and 65009e8.

Files selected for processing: 3
  • src/renderer/src/components/native-chat/NativeChatComposerField.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/shared/constants.ts
Files skipped from review as they are similar to previous changes: 1
  • src/renderer/src/i18n/locales/en.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@pelted
pelted force-pushed the chris/dictation-auto-send branch 2 times, most recently from 4bfa0d0 to 600e4c2 Compare October 29, 2026 17:20
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects sending in the desktop native chat composer.

Fix suggestion clicks before merging so editing a dictated message reliably stops automatic sending.

Findings

  1. P1 Suggestion clicks still send ▶

Summary

Adds opt-in automatic sending after desktop chat dictation ends.

  • Dictation sends a confirmed chat transcript after a cancelable countdown.
  • The owning chat composer sends a dictated draft through its usual send path.
  • Voice settings let people choose whether and when dictation sends.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Dictation stops] --> B[Watch for user takeover]
  B --> C{All text delivered without error?}
  C -->|No| D[Keep draft]
  C -->|Yes, editor focused| E[Show countdown]
  E -->|Typing, focus leaves, or Cancel| D
  E -->|Deadline| F[Notify owning composer]
  F --> G[Existing send function]
  E -->|Pick a suggestion| H[Draft changes but timer continues]
  H --> F
Loading

Reviews (1) · Last reviewed commit: "test(native-chat): keep queued-edit dict..." · Reviewed by Greptile

let settled = false
let countingDown = false
let timer: number | undefined
const listenedEvents = [...USER_TAKEOVER_EVENTS, 'input'] as const

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Suggestion clicks still send

Clicking a mention or skill suggestion during the countdown changes the draft without canceling the send. PickerOptionButton prevents focus from leaving the editor, and completion changes the draft through code rather than a DOM input event. None of the watched events fires, so the edited message still sends at the original deadline, even while the user is reviewing it.

Cancel the pending send when the user picks a suggestion, or watch draft changes while excluding dictation’s own inserts.

@pelted
pelted force-pushed the chris/dictation-auto-send branch from 600e4c2 to 0227721 Compare October 30, 2026 16:09
pelted added 12 commits November 4, 2026 12:15
Add an opt-in Voice setting, "Send when dictation ends", with a 1, 2, 3
or 5 second delay. When dictation into the native chat composer stops,
the dictation pill counts down and then sends through the composer's
normal send path, as if Enter were pressed.

Typing in the composer, moving focus away, pressing Cancel in the pill,
or starting dictation again cancels the send and keeps the draft.
Terminal panes and other inputs never auto-send, and a session with no
speech or an error does not start a countdown.

Part of stablyai#12157 (desktop composer only).
The dictation submit hook wrote its latest send into a ref during
render. useEffectEvent gives the listener the current send without a
render-time ref write.
Two ways auto-send could still send after the user stepped in:

- Switching to another app can keep the editor as the active element,
  so no focusout fired and the countdown sent anyway. The countdown now
  also stops on window blur and a hidden page, and checks that Orca has
  focus before it starts and before it sends.
- Takeover was only watched after the recognizer's stopped event, so
  typing while the final transcript was still on its way went unseen.
  The watch now starts when stopping begins, and the session outcome
  decides afterward whether there is anything to send.

The submit test now keeps its refs stable across renders, so it fails
if the hook reads a stale send.
Stopping while the mic was still starting took a separate path that only
began watching for takeover once startup finished, so typing or leaving
Orca in that interval was forgotten. The watch now starts wherever Stop
is first accepted, once per dictation, and the finish step reports the
outcome to that same watch.
…ide act

insertText now returns its delivery promise, which act would otherwise
treat as an unawaited async callback.
@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks for this, @pelted. Since you opened it, #40226 landed: pressing Enter or Send while you're still dictating now waits for the words to land and then sends once. Sending automatically after a countdown is still a good idea. We'd want to build it on top of that new send queue, though, and this branch no longer fits the new dictation pill, so I'm closing it for now. Thank you for the work and the idea.

@pelted

pelted commented Nov 11, 2026

Copy link
Copy Markdown
Author

Rebuilt on the #40226 send queue and the new dictation pill in #41198.

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