Skip to content

feat(web): dictation beta with mic button, cleanup and shortcut - #10195

Closed
Yclpaiva wants to merge 5 commits into
pingdotgg:mainfrom
Yclpaiva:feat/dictation-beta-v2
Closed

Yclpaiva wants to merge 5 commits into
pingdotgg:mainfrom
Yclpaiva:feat/dictation-beta-v2

Conversation

@Yclpaiva

@Yclpaiva Yclpaiva commented Sep 5, 2026 •

Copy link
Copy Markdown

What Changed

Dictation (Beta): microphone button next to the composer send button. Records via MediaRecorder, transcribes through an OpenAI-compatible /audio/transcriptions endpoint (default Groq + whisper-large-v3-turbo), optionally polishes with a chat-model cleanup pass (freeflow-inspired pipeline), and inserts the result as an editable composer draft. New global keybinding command composer.dictate (default mod+shift+D, remappable in Settings → Keybindings).

New Settings → Dictation (Beta) tab: enable toggle, API key (client-only, never hits the T3 server), base URL, transcription model, language, plus a Cleanup section (toggle, model, custom vocabulary, editable system prompt with reset).

Why

Voice input for the composer without a monthly subscription or server-side secrets — audio and API key stay between the browser and the user's own transcription provider, following the freeflow model (used as reference, reimplemented from scratch for the web).

UI Changes

Dictation (Beta) settings tab

Dictation settings

Mic button next to send

Composer mic button

Composer: Dictate keybinding

Dictate keybinding

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Add dictation beta to chat composer with mic button, settings, and shortcut

  • Adds ComposerDictationButton to ComposerFooterPrimaryActions and wires useComposerDictation in ChatComposer to record, transcribe, and append text; a default modifier-Shift-D shortcut toggles dictation outside terminal focus
  • Adds DictationSettingsPanel with provider key, base URL, model, language, and optional transcript cleanup configuration; credentials stay browser-local via client settings
  • Adds useComposerDictation hook handling mic permissions, MediaRecorder lifecycle, abort/cancel, direct browser upload to an OpenAI-compatible transcription endpoint, and optional cleanup pass with raw-transcript fallback
  • Adds ClientSettingsSchema fields and DraftTextarea for multiline settings editing; registers settings search entries and macOS microphone entitlements for desktop builds
  • Behavioral Change: dictation is disabled by default and blocked during command palette, approval, project selection, running, or disconnected composer states; active recordings remain stoppable. macOS signed builds now request the audio-input entitlement and NSMicrophoneUsageDescription

Macroscope summarized 40f012a.

@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Sep 5, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR adds a substantial microphone dictation workflow with external transcription and cleanup calls, persisted provider settings, and macOS permission/entitlement changes. It also introduces product defaults and has unresolved substantive findings around recorder lifecycle and settings behavior, so the blast radius warrants human review.

Not approved because:

  • 5 blocking correctness issues found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42d65eb025

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


void (async () => {
try {
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });

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 Badge Configure macOS microphone access before calling getUserMedia

In the packaged macOS desktop client, this capture request has no corresponding NSMicrophoneUsageDescription in the macOS build configuration (scripts/build-desktop-artifact.ts:2622-2642) and the signed entitlement document also omits com.apple.security.device.audio-input (scripts/build-desktop-artifact.ts:1286-1317). Consequently, the main desktop surface cannot obtain microphone access reliably even though it exposes the dictation control; add the usage description and signed audio-input entitlement as part of this feature.

AGENTS.md reference: AGENTS.md:L70-L70

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: macOS desktop packaging now declares NSMicrophoneUsageDescription and the audio-input entitlement. (agent on behalf of Yclpaiva)

Comment on lines +5698 to +5700
dictationEnabled &&
pendingPrimaryAction === null &&
!(pendingUserInputs.length === 0 && showPlanFollowUpPrompt)

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 Badge Keep the stop control available through pending states

If another client starts work on the same thread while this client is recording and the provider then requests user input, pendingPrimaryAction becomes non-null and this condition removes the microphone button; the shortcut handler also refuses activePendingProgress, approvals, and other pending states. The MediaRecorder therefore continues capturing with no available stop action until the remote state clears, potentially retaining an unbounded recording in memory. Keep the stop/cancel affordance available whenever dictation.phase is not idle, regardless of composer state.

AGENTS.md reference: AGENTS.md:L73-L74

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: same as above — stop stays available through pending states via the mounted control and shortcut path. (agent on behalf of Yclpaiva)

Comment on lines +249 to +252
useEffect(() => {
onTranscriptRef.current = onTranscript;
onErrorRef.current = onError;
}, [onTranscript, onError]);

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 Badge Bind an in-flight transcript to its original composer

When the user changes threads or environments while recording or transcribing, ChatComposer remains mounted and this effect replaces onTranscriptRef with the callback for the newly active composer. Completion then inserts speech recorded for the old thread into the new thread's draft. Capture the original composer target for each recording or cancel dictation when that target changes instead of retargeting the callback mid-flight.

AGENTS.md reference: AGENTS.md:L74-L74

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: recordings are bound to their composer target key — switching threads mid-flight cancels the session instead of inserting into the new draft. (agent on behalf of Yclpaiva)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: recordings are bound to their composer target key — switching threads mid-flight cancels the session. (agent on behalf of Yclpaiva)

Comment on lines +208 to +212
const cleaned = typeof content === "string" ? content.trim() : "";
if (cleaned.length === 0) {
throw new Error("Cleanup returned empty output. Using the raw transcript.");
}
return cleaned;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle the cleanup prompt's EMPTY sentinel

With cleanup enabled by default, the supplied system prompt explicitly tells the model to return EMPTY for filler-only recordings, but this code accepts that sentinel as ordinary nonempty text. A user who records only hesitation or silence therefore gets the literal word EMPTY inserted into the composer. Recognize the sentinel and treat it as no transcript rather than returning it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: the cleanup EMPTY sentinel is now treated as no transcript (falls back to raw, never inserts the literal word). (agent on behalf of Yclpaiva)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: the cleanup EMPTY sentinel is now treated as no transcript (falls back to raw, never inserts the literal word). (agent on behalf of Yclpaiva)

Comment on lines +34 to +36
discardedRef.current = true;
setDraft(null);
event.currentTarget.blur();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear both textarea draft states when Escape discards

handleChange writes the edit into both this component's draft and useCommitOnBlur's internal draft, but the Escape path clears only the former and deliberately skips bag.onBlur(). After blur, value={draft ?? bag.value} immediately reveals the supposedly discarded text again, and that stale internal draft can survive upstream value changes. Use a single draft owner or explicitly reset the hook's draft when discarding.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: single draft owner — Escape clears the only draft, nothing stale survives. (agent on behalf of Yclpaiva)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: single draft owner — Escape clears the only draft, nothing stale survives. (agent on behalf of Yclpaiva)

Comment on lines +8 to +12
const markup = renderToStaticMarkup(
<ComposerDictationButton phase="requesting" disabled={false} onToggle={() => {}} />,
);
expect(markup).toContain("disabled");
expect(markup).toContain('aria-label="Waiting for microphone..."');

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 Badge Exercise dictation behavior instead of static markup

This test renders the component to static HTML solely to assert disabled and aria-label attributes, so it cannot validate that clicking actually toggles recording or that the stop action remains usable across phase changes. Replace it with a behavioral test that exercises the observable interaction; the repository explicitly disallows static-markup prop and attribute assertions.

AGENTS.md reference: AGENTS.md:L106-L108

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: replaced the static-markup test with a behavioral react-test-renderer test covering click-to-toggle, recording stop label, and requesting disabled state. (agent on behalf of Yclpaiva)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed: replaced the static-markup test with a behavioral react-test-renderer test covering click-to-toggle, recording stop label, and requesting disabled state. (agent on behalf of Yclpaiva)

Comment on lines +369 to +374
recorder.addEventListener("dataavailable", (event: BlobEvent) => {
if (event.data.size > 0) chunksRef.current.push(event.data);
});
recorder.addEventListener("stop", () => {
const mimeType = recorder.mimeType || pickRecordingMimeType() || "audio/webm";
const audio = new Blob(chunksRef.current, { type: mimeType });

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.

🟡 Medium hooks/useComposerDictation.ts:369

An old recorder's queued stop event can consume the new session's chunksRef and call teardownCapture(), terminating the new microphone stream and losing its recording after an immediate restart or target change. Because MediaRecorder.stop() dispatches asynchronously, guard both recorder event handlers against recorderRef.current !== recorder before touching shared state.

         recorder.addEventListener("dataavailable", (event: BlobEvent) => {
-          if (event.data.size > 0) chunksRef.current.push(event.data);
+          if (recorderRef.current !== recorder) return;
+          if (event.data.size > 0) chunksRef.current.push(event.data);
         });
         recorder.addEventListener("stop", () => {
+          if (recorderRef.current !== recorder) return;
           const mimeType = recorder.mimeType || pickRecordingMimeType() || "audio/webm";
           const audio = new Blob(chunksRef.current, { type: mimeType });
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/hooks/useComposerDictation.ts around lines 369-374:

An old recorder's queued `stop` event can consume the new session's `chunksRef` and call `teardownCapture()`, terminating the new microphone stream and losing its recording after an immediate restart or target change. Because `MediaRecorder.stop()` dispatches asynchronously, guard both recorder event handlers against `recorderRef.current !== recorder` before touching shared state.

export function DraftTextarea({ value, onCommit, ...rest }: DraftTextareaProps) {
const [draft, setDraft] = useState<string | null>(null);
const discardedRef = useRef(false);
const focusedRef = useRef(false);

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.

🟡 Medium ui/draft-textarea.tsx:25

Pressing Ctrl/Cmd+Enter persists the edited value twice, because commit(draft ?? value) runs from the shortcut and then runs again from the synchronous onBlur handler. This causes each edited settings value to trigger onCommit twice; set a blur-suppression flag for the shortcut and clear it in handleBlur.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/ui/draft-textarea.tsx around line 25:

Pressing Ctrl/Cmd+Enter persists the edited value twice, because `commit(draft ?? value)` runs from the shortcut and then runs again from the synchronous `onBlur` handler. This causes each edited settings value to trigger `onCommit` twice; set a blur-suppression flag for the shortcut and clear it in `handleBlur`.

// An in-flight session is always stoppable, even if the setting
// flipped or a pending question landed mid-recording; the guards
// below only gate *starting* a new one.
if (dictationPhaseRef.current !== "idle") {

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.

🟡 Medium chat/ChatComposer.tsx:4169

Pressing the dictation shortcut while phase is "requesting" does not cancel the pending permission request, so granting permission afterward starts an unwanted recording. This branch calls dictationToggleRef.current(), but useComposerDictation.toggle() only stops when its captured phase is "recording"; make the pending request cancellation-aware so a second shortcut prevents recording from starting.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/chat/ChatComposer.tsx around line 4169:

Pressing the dictation shortcut while `phase` is `"requesting"` does not cancel the pending permission request, so granting permission afterward starts an unwanted recording. This branch calls `dictationToggleRef.current()`, but `useComposerDictation.toggle()` only stops when its captured phase is `"recording"`; make the pending request cancellation-aware so a second shortcut prevents recording from starting.

@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

Comment thread scripts/build-desktop-artifact.ts Resolved
Comment thread scripts/build-desktop-artifact.ts Resolved

Copy link
Copy Markdown
Member

Note

This comment is posted by Julius' dot

This introduces browser recording, external transcription and cleanup calls, a new settings section, and microphone permissions. Those implement a new dictation workflow, but the PR and discussion contain no maintainer approval of its direction and scope, as required by prior approval. Please agree on that workflow in an Ideas discussion, link the approval, then request reconsideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants