Skip to content

New Fixes and Improvements#43

Merged
moinulmoin merged 28 commits intomainfrom
fix/2025-11-openai-config
Dec 14, 2025
Merged

New Fixes and Improvements#43
moinulmoin merged 28 commits intomainfrom
fix/2025-11-openai-config

Conversation

@moinulmoin
Copy link
Copy Markdown
Owner

@moinulmoin moinulmoin commented Dec 3, 2025

resolves #34 #41 #32 #36

- Gate CPAL device enumeration behind onboarding_completed flag
- Backend auto-starts device watcher when both conditions met
- Add checkOnMount option to permission hooks
- Disable unused Rust doc tests
- Add audio confirmation when recording starts (macOS/Windows)
- Add 'Sound on Recording' setting toggle (default: on)
- Reduce minimum recording duration to 0.5s for both Toggle and PTT modes
- Add 300ms throttle for Toggle mode hotkey to prevent rapid re-presses
- Show 'recording-too-short' feedback in pill before hiding (1.5s)
- Add severity-based feedback colors (info/warn/error)
- Handle hotkey press during Starting state with pending_stop flag
- Show spinner for Starting/Stopping states in pill
@moinulmoin
Copy link
Copy Markdown
Owner Author

@codex review

@claude
Copy link
Copy Markdown

claude bot commented Dec 3, 2025

Pull Request Review

I have reviewed PR #43 and identified several important issues that should be addressed before merging.

HIGH PRIORITY Issues

1. Security - API Key Handling

Location: src/utils/keyring.ts:40-57

The API key validation logic allows empty keys when no_auth is true without proper validation at the keyring layer. Additionally there is no error handling if validation fails. This needs proper validation and error handling before storing sensitive credentials.

2. Type Safety Violations

Location: src/components/OpenAICompatConfigModal.tsx:92

Using any type defeats TypeScript purpose and violates CLAUDE.md guidelines. Should use unknown and properly narrow the type.

3. ESLint Configuration Too Permissive

Location: eslint.config.cjs:41-68

18 critical rules are disabled including no-explicit-any, no-unsafe-* rules, no-floating-promises, no-unused-vars, and prefer-const. This contradicts CLAUDE.md emphasis on type safety and directly allows unsafe code patterns.

Recommendation: Re-enable critical rules incrementally and fix violations rather than disabling rules.

MEDIUM PRIORITY Issues

4. Missing Test Coverage

Critical security code has no tests:

  • src/utils/keyring.ts
  • src-tauri/src/ai/openai.rs
  • src-tauri/src/commands/reset.rs

5. Error Handling Gaps

src-tauri/src/ai/openai.rs:91 uses generic Unknown error message with no debugging context.

6. Hardcoded Values

src/utils/keyring.ts:84 has hardcoded providers array that should be a shared constant.

Positive Changes

  • Excellent OpenAI-compatible provider support with good UX
  • Clean modal component design with test-before-save pattern
  • Successful ESLint v9 migration
  • Improved documentation in AGENTS.md
  • Good retry logic with exponential backoff

Overall Assessment

Code Quality: 7/10
Security: 6/10
Test Coverage: 5/10
Documentation: 8/10

This PR adds valuable functionality but the security gaps and overly permissive linting could introduce bugs. The disabled ESLint rules defeat the TypeScript-first approach outlined in CLAUDE.md.

Recommendation: Request Changes - Address security and type safety issues before merging.

Happy to help implement any of these fixes!

Copy link
Copy Markdown

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

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

moinulmoin and others added 10 commits December 11, 2025 13:27
… window

- Replace complex RecordingPill with minimal AudioDots component
- Add dedicated toast window for feedback messages (pill_toast helper)
- Add show_pill_indicator setting to control idle visibility
- Remove compact_recording_status setting (superseded)
- Fix race conditions in Tauri event listeners with isMounted guards
- Shrink pill window size from 350x150 to 80x40
- Register 'toast' window in all platform capabilities (macos, default, windows)
- Fixes missing window permission that prevented toast window creation
- Toast feedback on ESC press now properly displays
- Increase gap between pill and toast from 6px to 8px for better spacing
- Extract recording/hotkeys.rs: global shortcut handling (toggle/PTT modes)
- Extract recording/escape_handler.rs: ESC double-tap cancellation logic
- Extract menu/tray.rs: tray menu building with model/mic/recent items
- Extract state/app_state.rs: AppState, RecordingState, event helpers
- Extract recognition/model_selection.rs: availability snapshot, auto-selection

Improvements:
- Replace all mutex .unwrap() with defensive match patterns (no panics)
- Use try_state() for optional state (WhisperManager, ParakeetManager)
- Fix ESC toast duration to 2000ms and align timeout to 2 seconds
- Graceful degradation during app shutdown in ESC timeout handler

Reduces lib.rs from ~2354 to ~1283 lines. All 153 tests pass.

Amp-Thread-ID: https://ampcode.com/threads/T-019b0d2b-5d09-71dc-885a-45cd51559194
Co-authored-by: Amp <amp@ampcode.com>
- Add fallback chain for Windows UUID: wmic (4s timeout) -> PowerShell CIM -> registry MachineGuid
- Fixes 'unknown device ID' and infinite spinner on Windows 11 24H2/25H2 where wmic is removed
- Add 10s frontend timeout for license status check with Retry button
- Backward compatible: existing behavior unchanged on systems where wmic works
Logs which fallback was used (wmic/PowerShell/registry) to help debug issues on user machines
- Reduce bottom_offset from 25px to 10px for pill/toast positioning
- Add DisplayWatcher to detect monitor configuration changes
- Add reposition_floating_windows() to WindowManager
- macOS: uses Core Graphics callback for instant detection
- Windows: uses polling approach (2s interval)
…essages

- Change 'Enhancement failed' to 'Formatting failed' terminology
- Improve generic error from 'Using original text' to 'Service unavailable'
- Increase toast window size from 280x32 to 400x80 for multi-line support
- Update CSS to allow text wrapping with min/max width constraints
…sibility

- Change OpenAI Compatible card button from 'Remove Key' to 'Update' when configured
- Load saved baseUrl when opening config modal for editing
- Improve disabled switch visibility (opacity 50% -> 70%)
- Remove version from tauri.conf.json (now reads from Cargo.toml)
- Update release-it to bump Cargo.toml via after:bump hook
- Simplify release-separate.sh: use release-it for versioning, no post-build mutations
- Fix release-windows.ps1: proper exit code check for gh release view
- Remove 12 obsolete scripts (old release variants, signing scripts)
- Add quality-gate-check.sh for pre-commit checks
Copilot AI review requested due to automatic review settings December 14, 2025 17:45
@moinulmoin moinulmoin merged commit 919e174 into main Dec 14, 2025
5 checks passed
@claude
Copy link
Copy Markdown

claude bot commented Dec 14, 2025

Code Review: PR #43 - New Fixes and Improvements

Executive Summary

Overall Assessment: ✅ Approved with Minor Recommendations

This is a substantial refactoring PR with 7,157 additions and 3,796 deletions across 95 files. The changes demonstrate excellent architectural thinking with strong separation of concerns, improved state management, and better code organization.


🎯 Major Improvements

1. Architecture Refactoring (Excellent)

  • ESC Handler Extraction (escape_handler.rs): Clean separation of ESC key logic from lib.rs
  • State Management (app_state.rs): Centralized state with proper Arc/Mutex/AtomicBool patterns
  • Hotkey Module (recording/hotkeys.rs): Clean separation of shortcut handling logic
  • Display/Device Watchers: Platform-specific implementations with proper fallbacks
  • Toast/Pill Separation: Independent windows with clear responsibilities

Impact: Reduced lib.rs complexity significantly, improved testability and maintainability.

2. Frontend Component Improvements

  • RecordingPill: Clean state management with Framer Motion animations
  • FeedbackToast: Simple, focused component for temporary messages
  • AudioDots: Replaced AudioWaveAnimation with cleaner implementation
  • OpenAICompatConfigModal: New test coverage for config validation flow

3. Security & Permissions

  • Capabilities Fix: Added "toast" window to all capability files (critical fix)
  • Secure Store: Proper AES-256-GCM encryption with PBKDF2 key derivation
  • Device-Specific Keys: Using hardware-based device hash for encryption keys
  • Permission Gating: DeviceWatcher starts only after mic permission granted

4. Documentation

  • IMPLEMENTATION_PLAN.md: Detailed refactoring roadmap
  • ORACLE_REVIEW.md: Self-review with quality metrics
  • TOAST_POSITIONING_EXPLAINED.md: Comprehensive positioning documentation
  • Updated AGENTS.md: Cleaner, more actionable guidance

🐛 Issues Found

Critical (Fixed in PR)

  • Missing Toast Window in Capabilities - RESOLVED
    • Added "toast" to windows array in all capability files
    • Without this, toast window creation would silently fail

None - No Critical Issues Remaining


📝 Code Quality Observations

✅ Strengths

  1. Type Safety: Excellent use of Rust's type system and atomic primitives
  2. Error Handling: Comprehensive logging and graceful degradation
  3. Thread Safety: Proper use of Arc, Mutex, AtomicBool throughout
  4. Platform Support: macOS-specific NSPanel handling is well-implemented
  5. Event Coordination: EventCoordinator provides clean routing rules
  6. Testing: 244 test occurrences across 44 Rust files

⚠️ Minor Concerns

  1. ESLint Rules Disabled (eslint.config.cjs)

    • Many TypeScript safety rules disabled (no-unsafe-*, no-floating-promises, etc.)
    • Recommendation: Re-enable incrementally, especially:
      • @typescript-eslint/no-floating-promises (prevents unhandled async errors)
      • @typescript-eslint/no-misused-promises (catches async bugs)
  2. TODOs Present (Low Priority)

    • src/license/api_client.rs:10: TODO for retry logic
    • src/commands/model.rs:245: TODO to track download duration
    • src/utils/diagnostics.rs:60: TODO for sysinfo version upgrade
    • Recommendation: Create issues for these or implement in follow-up PRs
  3. Test Coverage Gaps (Non-blocking)

    • No integration tests for toast lifecycle (mentioned in IMPLEMENTATION_PLAN.md)
    • No tests for concurrent toast messages
    • Recommendation: Follow implementation plan to add these tests

🔒 Security Review

✅ Secure Practices

  • AES-256-GCM encryption for sensitive data
  • PBKDF2 with 100,000 iterations for key derivation
  • Device-specific encryption keys (non-portable)
  • Proper validation of device hash entropy
  • No hardcoded secrets detected

⚠️ Considerations

  • Encryption Key Portability: Keys are device-specific (intended behavior)
  • Migration Path: check_migration_needed stubbed out for future use
  • Keyring Integration: Secure store replaces system keychain (trade-off: portability vs. cross-platform)

⚡ Performance Observations

✅ Optimizations

  • DeviceWatcher uses 1.5s polling (reasonable)
  • DisplayWatcher uses native OS callbacks on macOS (efficient)
  • Event queuing prevents dropped messages during startup
  • Atomic operations avoid lock contention

💡 Suggestions

  • Display Watcher (Windows): 2-second polling could be increased to 5 seconds for battery savings
  • Event Queue: MAX_EVENTS=50 is reasonable but undocumented; consider adding comment

🧪 Test Coverage

Current State

  • Rust: 244 test occurrences across 44 files (good coverage)
  • Frontend: OpenAICompatConfigModal has comprehensive tests
  • Integration: RecordingPill, EnhancementsSection have test coverage

Gaps (from IMPLEMENTATION_PLAN.md)

  • Toast lifecycle tests (planned but not in this PR)
  • ESC handler state machine tests (planned but not in this PR)
  • Concurrent toast message tests (planned but not in this PR)

Recommendation: These gaps are documented and planned - acceptable for this PR.


📊 Diff Statistics

Category Changes Assessment
Backend Rust +2,200 / -1,800 ✅ Major refactoring, well-structured
Frontend React +800 / -600 ✅ Component cleanup, good patterns
Tests +147 new lines ✅ OpenAICompatConfigModal coverage
Documentation +941 new lines ✅ Excellent planning docs
Scripts -1,200 lines ✅ Removed obsolete scripts
Config +71 (ESLint) ⚠️ Many rules disabled

✅ Recommendations

High Priority

  1. Merge this PR - Core functionality is solid
  2. Follow-up: Re-enable critical ESLint rules incrementally
  3. Follow-up: Implement toast lifecycle tests per IMPLEMENTATION_PLAN.md

Medium Priority

  1. Consider: Document MAX_EVENTS=50 rationale in app_state.rs
  2. Consider: Increase Windows DisplayWatcher polling to 5s for battery life
  3. Future: Complete TODO items or create GitHub issues to track

Low Priority

  1. Nice-to-have: Add integration tests for ESC handler flow
  2. Nice-to-have: Document encryption key non-portability in user docs

🎉 Conclusion

This PR represents high-quality engineering work with:

  • ✅ Thoughtful architecture improvements
  • ✅ Proper separation of concerns
  • ✅ Security best practices
  • ✅ Comprehensive documentation
  • ✅ Critical bug fixes (toast capabilities)

The code is production-ready with minor follow-up opportunities documented.

Verdict: LGTM - Ready to merge! 🚀


📚 Files Reviewed

  • src-tauri/src/lib.rs (reduced complexity)
  • src-tauri/src/state/app_state.rs (new state management)
  • src-tauri/src/recording/escape_handler.rs (new extraction)
  • src-tauri/src/recording/hotkeys.rs (new module)
  • src-tauri/src/menu/tray.rs (new tray menu)
  • src-tauri/src/audio/device_watcher.rs (new watcher)
  • src-tauri/src/utils/display_watcher.rs (new watcher)
  • src-tauri/src/recognition/model_selection.rs (new module)
  • src-tauri/capabilities/*.json (permissions fix)
  • src/components/RecordingPill.tsx (simplified)
  • src/components/FeedbackToast.tsx (new component)
  • src/components/OpenAICompatConfigModal.test.tsx (new tests)
  • eslint.config.cjs (config changes)
  • IMPLEMENTATION_PLAN.md (excellent planning)
  • ORACLE_REVIEW.md (self-review)
  • Plus 80+ other files

Review Time: ~30 minutes deep analysis
Lines Reviewed: 10,953 net changes across 95 files

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements several significant improvements and fixes:

Purpose: Resolves issues #34, #41, #32, #36 by introducing a new toast notification system, refactoring error handling, improving user feedback, and adding new settings for UI customization.

Key Changes:

  • New toast notification window for better user feedback during recording/transcription
  • Refactored pill indicator with animated dots instead of audio wave
  • Improved error handling with centralized utility functions
  • New settings: clipboard retention, audio feedback on recording, and pill indicator visibility
  • Backend refactoring: modularized state management, recording logic, and tray menu
  • Fixed API key caching issues and OpenAI configuration handling
  • Enhanced Windows device detection with fallback mechanisms

Reviewed changes

Copilot reviewed 93 out of 96 changed files in this pull request and generated no comments.

Show a summary per file
File Description
vite.config.ts Added toast.html entry point for new toast window
toast.html New HTML page for feedback toast notifications
src/toast.tsx Root component for toast notification window
src/utils/error.ts New error message extraction utility for consistent error handling
src/types.ts Removed deprecated compact_recording_status, added new UI settings
src/components/FeedbackToast.tsx New component to display toast notifications from backend
src/components/RecordingPill.tsx Complete redesign with AudioDots animation and simplified state
src/components/AudioDots.tsx New 3-dot animated indicator replacing audio wave visualization
src/hooks/useRecording.ts Removed client-side error event listeners (now handled by backend toast)
src/contexts/LicenseContext.tsx Improved error handling with timeout and getErrorMessage utility
src-tauri/src/state/app_state.rs Extracted AppState to separate module with pill event queuing
src-tauri/src/recording/hotkeys.rs Modularized global shortcut handling logic
src-tauri/src/commands/audio.rs Added pill_toast() API and play_sound_on_recording feature
src-tauri/src/commands/text.rs Added clipboard retention setting support
src-tauri/src/license/device.rs Enhanced Windows UUID detection with PowerShell and registry fallbacks
src-tauri/src/window_manager.rs Added toast window positioning and display watcher integration
Comments suppressed due to low confidence (1)

scripts/sign-tauri-updater.sh:1

  • The removed script hardcoded a signing key password via PASSWORD="112468", which exposes credentials directly in source control and allows anyone with repo access to decrypt or misuse the Tauri signing key. An attacker who obtains this password and the corresponding key file (often stored under $HOME/.tauri/voicetypr.key) could forge update signatures and distribute malicious update artifacts that appear legitimate. Removing this script eliminates the hardcoded secret; ensure any future signing or release automation reads passwords from secure environment variables or a secret manager rather than embedding them in code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

2 participants