Skip to content

TT-6917 force the chosen device to be used (was a preference before) - #555

Open
sarahentzel wants to merge 3 commits into
developfrom
TT-6917
Open

TT-6917 force the chosen device to be used (was a preference before)#555
sarahentzel wants to merge 3 commits into
developfrom
TT-6917

Conversation

@sarahentzel

Copy link
Copy Markdown
Collaborator

No description provided.

# Conflicts:
#	src/renderer/public/localization/strings6254aa94.json
#	src/renderer/src/store/localization/model.tsx
#	src/renderer/src/store/localization/reducers.tsx
@sarahentzel
sarahentzel marked this pull request as ready for review August 28, 2026 21:22

@gtryus gtryus 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.

I made a comment on a potential improvement but it isn't required...


function delay(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

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.

The delay function (sometimes called sleep) may belong in our general utils folder?

Copilot AI 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.

Pull request overview

This PR updates the renderer’s audio-capture pipeline to more reliably honor the user-selected microphone (by requesting the device as an exact constraint), and adds handling for device-disconnect scenarios during recording.

Changes:

  • Enforce selected microphone usage by building capture constraints with deviceId: { exact: ... } and centralizing this logic in a new captureConstraints utility.
  • Add capture recovery helpers (unusable-stream detection, device-loss detection, retry/fallback wrapper around getUserMedia) and integrate them into useUserMedia / useWavRecorder.
  • Add a new localized warning string and surface it in WSAudioPlayer when a device-loss error is reported.

Reviewed changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/renderer/src/store/localization/reducers.tsx Adds new wsAudioPlayer.microphoneDisconnected string to the in-app localization defaults.
src/renderer/src/store/localization/model.tsx Extends IWsAudioPlayerStrings with microphoneDisconnected.
src/renderer/src/store/localization/exported-strings-name.json Updates exported strings bundle filename reference.
src/renderer/src/crud/useWavRecorder.tsx Uses shared capture-constraint utilities; improves robustness when streams/tracks are gone; flags device-loss errors to the UI.
src/renderer/src/crud/useUserMedia.tsx Wraps getUserMedia with retry/fallback logic and avoids reusing unusable streams.
src/renderer/src/crud/captureConstraints.ts New shared helper for building constraints, detecting device-loss/unusable streams, and retrying getUserMedia.
src/renderer/src/crud/captureConstraints.test.ts Adds unit tests covering exact-device constraints, device-loss detection, unusable-stream detection, and fallback behavior.
src/renderer/src/components/WSAudioPlayer.tsx Shows a localized warning when recording fails with deviceLost.
localization/TranscriberAdmin-en.xlf Adds the new string unit for translation.
localization/TranscriberAdmin-en-1.2.xliff Adds the new string unit for translation (xliff variant).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +102 to +106
const retryConstraints = requestedExactDeviceId(constraints)
? constraintsWithoutDeviceId(constraints)
: constraints;
if (isDeviceLossError(error)) {
await wait(CAPTURE_DEVICE_LOSS_RETRY_MS);
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.

3 participants