Skip to content

Conversation

@2witstudios
Copy link
Owner

@2witstudios 2witstudios commented Feb 10, 2026

Summary

Updated voice-mode error handling to show user-friendly, actionable failure messages (instead of technical/raw error text) for microphone permission/device issues, transcription failures, and TTS playback failures. This now explicitly informs users what failed and what to do next.
Removed the console-only onError logger from VoiceModeOverlay so failures are surfaced through existing UI error state rather than just dev logs.
Kept the prior activation behavior intact (auto-start listening on activation) so mic prompt + visual listening indicator still happen, while now also giving descriptive user-visible failure messaging when the flow fails.
Testing

✅ VoiceModeOverlay.tsx
⚠️ pnpm --filter web typecheck (fails due to existing repo-wide baseline issues with unresolved @pagespace/lib/* modules and unrelated strict type errors)


Codex Task

Summary by CodeRabbit

Release Notes

  • New Features

    • Added visible, user-friendly error messages for voice mode issues including microphone permissions, transcription, and speech synthesis failures.
  • Bug Fixes

    • Resolved voice mode activation race condition preventing intermittent state resets.
    • Improved microphone permission prompt reliability during voice mode initialization.
    • Enhanced Monaco editor stability and asset loading.
    • Strengthened content security policy protections.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 0de5823ce2

ℹ️ 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".

Comment on lines 74 to 76
if (!isEnabled || hasStartedOnActivateRef.current) return;
hasStartedOnActivateRef.current = true;
startListening();

Choose a reason for hiding this comment

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

P2 Badge Guard auto-start against concurrent listen attempts

Starting startListening() unconditionally on activation can race with a user pressing Space/tapping the mic before the first getUserMedia call resolves, because the UI still allows manual start while voiceState is still idle. In that case two startListening executions can run concurrently, and the later one overwrites streamRef/mediaRecorderRef, leaving the earlier recorder/track unmanaged and causing stuck mic capture or inconsistent state transitions. This regression is introduced by the new automatic start path and should be gated by an in-flight/listening check.

Useful? React with 👍 / 👎.

@2witstudios 2witstudios changed the title Codex-generated pull request codex/audit-audio-flow-for-voice-mode-issues Feb 10, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Voice mode reliability is enhanced through three key additions: a hasLoadedSettings state tracking completion of settings loading, auto-start logic for listening when voice mode activates with single-run guards, and standardized user-facing error messages for mic permissions, transcription, and synthesis failures, with proper state guards preventing invalid operations.

Changes

Cohort / File(s) Summary
Voice Mode Hook & Store
apps/web/src/hooks/useVoiceMode.ts, apps/web/src/stores/useVoiceModeStore.ts
Introduces hasLoadedSettings state to track when persisted settings complete loading. Adds three error-message helpers (mic permission, transcription, synthesis) for consistent user feedback. Enhances startListening with re-entrancy guards, settings-loaded checks, and early exit conditions to prevent invalid state transitions.
Voice Mode Component
apps/web/src/components/ai/voice/VoiceModeOverlay.tsx
Adds useRef-based guard (hasStartedOnActivateRef) to auto-start listening once per activation. Introduces effect to trigger listening when voice mode activates and settings are loaded, with cleanup to reset the guard on deactivation.
Documentation
docs/1.0-overview/changelog.md
Adds dated changelog entry documenting voice mode reliability fixes, auto-start improvements, visible error feedback, and Monaco worker stability with CSP hardening.

Sequence Diagram

sequenceDiagram
    participant Overlay as VoiceModeOverlay
    participant Hook as useVoiceMode Hook
    participant Store as useVoiceModeStore
    participant Media as Browser APIs

    Overlay->>Store: Check isEnabled && hasLoadedSettings
    activate Store
    Store-->>Overlay: true
    deactivate Store

    Overlay->>Overlay: Guard via hasStartedOnActivateRef<br/>(runs only once per activation)

    Overlay->>Hook: Call startListening()
    activate Hook
    
    Hook->>Hook: Check guards: isStartingListeningRef,<br/>not already listening/processing,<br/>feature still enabled
    
    Hook->>Media: Initialize MediaStream
    activate Media
    Media-->>Hook: Stream acquired
    deactivate Media
    
    Hook->>Media: Initialize MediaRecorder
    activate Media
    Media-->>Hook: Recorder ready
    deactivate Media
    
    Hook->>Hook: Set listening state
    Hook-->>Overlay: listening = true
    deactivate Hook
    
    Note over Overlay: If errors occur (mic permission,<br/>transcription, synthesis)
    Hook->>Hook: Use standardized error message helper
    Hook-->>Overlay: Display user-friendly error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #368: Shares direct code-level changes to voice-mode files (VoiceModeOverlay, useVoiceMode hook, useVoiceModeStore) implementing related auto-start guards and error-handling enhancements.

Poem

🐰 Whiskers twitch with delight,
Voice mode hops true, no more silent blight,
Settings loaded, listened with care,
Errors now speak—no more despair! 🎤✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title is vague and non-descriptive, using generic phrasing ('audit-audio-flow-for-voice-mode-issues') that doesn't clearly convey the main change to reviewers scanning history. Use a clearer, more specific title such as 'Add user-facing error messages for voice mode failures' or 'Improve voice mode reliability with error handling and activation guards' to better summarize the primary changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/audit-audio-flow-for-voice-mode-issues

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@docs/1.0-overview/changelog.md`:
- Around line 17-18: Add a blank line between the paragraph that ends with
"Intermittent "TTS but no listening indicator" behavior is reduced by keeping
state transitions explicit during activation." and the following heading "###
Monaco Worker Stability + CSP Hardening" so the two sections are visually and
semantically separated in Markdown.
🧹 Nitpick comments (1)
apps/web/src/hooks/useVoiceMode.ts (1)

302-305: Lint: implicit return value in forEach callback.

track.stop() returns void, but the concise arrow body still triggers Biome's useIterableCallbackReturn rule. Add braces to make the intent explicit.

🔧 Proposed fix
-        stream.getTracks().forEach((track) => track.stop());
+        stream.getTracks().forEach((track) => { track.stop(); });

Comment on lines +17 to 18
- Intermittent "TTS but no listening indicator" behavior is reduced by keeping state transitions explicit during activation.
### Monaco Worker Stability + CSP Hardening
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing blank line between changelog sections.

Line 17 runs directly into the ### Monaco Worker Stability heading on Line 18. Add a blank line between these two sections for proper Markdown rendering and visual separation.

📝 Proposed fix
 - Intermittent "TTS but no listening indicator" behavior is reduced by keeping state transitions explicit during activation.
+
 ### Monaco Worker Stability + CSP Hardening
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Intermittent "TTS but no listening indicator" behavior is reduced by keeping state transitions explicit during activation.
### Monaco Worker Stability + CSP Hardening
- Intermittent "TTS but no listening indicator" behavior is reduced by keeping state transitions explicit during activation.
### Monaco Worker Stability + CSP Hardening
🤖 Prompt for AI Agents
In `@docs/1.0-overview/changelog.md` around lines 17 - 18, Add a blank line
between the paragraph that ends with "Intermittent "TTS but no listening
indicator" behavior is reduced by keeping state transitions explicit during
activation." and the following heading "### Monaco Worker Stability + CSP
Hardening" so the two sections are visually and semantically separated in
Markdown.

@2witstudios 2witstudios merged commit 70e35b3 into master Feb 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant