Refactor voice HUD with improved state management and settings #4036
ccantynzcommented Mar 23, 2026
Originally written by @vercel[bot] on GitHub.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Actions | Updated (UTC) |
|---|---|---|---|
| 48co-ai-pa | Preview, Comment | Mar 23, 2026 8:40pm |
Cross-repo impact
See what breaks downstream if this PR merges.
⮌ Merged
This pull request was merged into main.
c comment · e edit title · m merge · a approve · r request changes · ? shortcuts
Originally written by @ccantynz-alt on GitHub.
Imported from https://github.com/ccantynz-alt/48co.v1/pull/1
Summary
Refactored the main HUD component (
app/page.jsx) with improved state management, enhanced voice command processing, and a more robust settings system. The changes focus on better separation of concerns, cleaner transcript handling, and more reliable command execution.Key Changes
Improved State Management: Refactored transcript processing to use a ref-based approach (
transcriptRef) that ensures the latest transcript value is available in theonendcallback, fixing potential race conditions in voice command detection.Enhanced Voice Commands: Updated command prompts to be more descriptive and actionable (e.g., "Refactor the following code..." instead of emoji-based descriptions). Added support for the
__SUBMIT__command to simulate Enter key presses on focused elements.Settings Persistence: Converted settings from component-level state to a structured settings object with proper update handlers, enabling future persistence and more granular control over features like noise suppression, auto-coding mode, type speed, and auto-submit behavior.
Improved Coding Mode: Replaced the simple
modetoggle with a more flexiblecodingModeboolean andautoCodingsetting, allowing both manual override and automatic detection based on coding keywords.Better Transcript Handling: Enhanced the transcript processing flow to properly handle edge cases (empty transcripts, command cancellation) and improved the lifecycle management of the recording state.
UI/UX Refinements:
Component Cleanup: Refactored
MicTogglecomponent with clearer comments and improved accessibility. UpdatedWaveformcomponent with better animation organization and static bar height variation.Configuration Updates: Simplified
.gitignoreto focus on essential entries, updatedtailwind.config.jswith explicit color definitions, and improved CSS comments for clarity.Notable Implementation Details
transcriptRefpattern ensures that theonendcallback always has access to the latest transcript value, preventing stale closures.processTranscriptcallback that handles all command types (Claude prompts, submit, cancel) in a single flow.updateSettingfunction, making it easier to add new settings in the future.BAR_CLASSESarray for consistent animation staggering.https://claude.ai/code/session_01KRs33M5QaFJVw6ZqLYszUV