Add "Hey Shoppy" wake word detection for voice command activation#7
Add "Hey Shoppy" wake word detection for voice command activation#7
Conversation
Co-authored-by: akisma <332125+akisma@users.noreply.github.com>
Co-authored-by: akisma <332125+akisma@users.noreply.github.com>
Co-authored-by: akisma <332125+akisma@users.noreply.github.com>
…I text Co-authored-by: akisma <332125+akisma@users.noreply.github.com>
|
Why are there so many new tests? What are they covering? @copilot |
1 similar comment
|
Why are there so many new tests? What are they covering? @copilot |
The 69 new tests cover the wake word detection feature following TDD: WakeWordService (29 tests) - Core detection logic:
useWakeWord hook (16 tests) - React integration:
WakeWordContext (14 tests) - App-wide state:
Integration tests (10 tests) - UI components:
The high test count reflects TDD methodology and ensures each component works correctly in isolation and together. |
|
@copilot do the tests all pass? are there mocking issues? are any of the tests testing native behavior of frameworks or packages used? please revise & refactor. |
There was a problem hiding this comment.
Pull request overview
This PR implements wake word detection for "Hey Shoppy" voice command activation, allowing users to start voice command listening by saying the wake phrase in addition to pressing the microphone button. The implementation follows TDD principles with comprehensive test coverage.
Key Changes:
- Core wake word detection service with case-insensitive phrase matching and command extraction
- React integration layer with hooks and context provider for app-wide state management
- UI updates to settings toggle, voice activation banner, and voice status indicator to reflect wake word functionality
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
services/wake-word-service.ts |
Core service implementing wake word detection with status management (idle/listening/detected) |
services/wake-word-service.test.ts |
29 comprehensive tests for service logic including edge cases |
hooks/use-wake-word.ts |
React hook wrapper managing service lifecycle and state |
hooks/use-wake-word.test.ts |
16 tests for hook behavior and integration |
contexts/wake-word-context.tsx |
Context provider for app-wide wake word state sharing |
contexts/wake-word-context.test.tsx |
14 tests verifying provider and consumer behavior |
components/VoiceActivationBanner.tsx |
Updated to display dynamic state (listening vs. ready) |
components/VoiceActivationBanner.test.tsx |
Updated tests for new listening state display |
app/_layout.tsx |
Wraps app with WakeWordProvider for global availability |
app/_layout.test.tsx |
3 tests verifying provider integration in root layout |
app/(tabs)/settings.tsx |
Settings toggle now controls wake word enable/disable |
app/(tabs)/settings.test.tsx |
Updated tests for functional toggle behavior |
app/(tabs)/settings.wake-word.test.tsx |
6 integration tests for settings-wake word connection |
app/(tabs)/list-detail.tsx |
Integrates wake word context for voice status and controls |
app/(tabs)/index.tsx |
Integrates wake word context for voice status and controls |
.docs/TECHNICAL_DOCUMENTATION.md |
Added comprehensive documentation for wake word features |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private setStatus(newStatus: WakeWordStatus): void { | ||
| if (this.status !== newStatus) { | ||
| this.status = newStatus; | ||
| this.onStatusChange(newStatus); |
There was a problem hiding this comment.
The onStatusChange callback is not wrapped in error handling, unlike onWakeWordDetected. If the callback throws an error, it could crash the service or leave it in an inconsistent state. Consider wrapping the callback in a try-catch block similar to line 102-106.
| this.onStatusChange(newStatus); | |
| try { | |
| this.onStatusChange(newStatus); | |
| } catch { | |
| // Gracefully handle callback errors | |
| } |
|
|
||
| // Try to get wake word context, return null if not available | ||
| function useTryWakeWordContext() { | ||
| try { | ||
| return useWakeWordContext(); | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
The useTryWakeWordContext helper function is duplicated across three files (settings.tsx, list-detail.tsx, and index.tsx). Consider extracting this to a shared utility function or hook file to reduce duplication and ensure consistent behavior across the app.
| // Try to get wake word context, return null if not available | |
| function useTryWakeWordContext() { | |
| try { | |
| return useWakeWordContext(); | |
| } catch { | |
| return null; | |
| } | |
| } | |
| import { useTryWakeWordContext } from '../hooks/useTryWakeWordContext'; |
| function useTryWakeWordContext() { | ||
| try { | ||
| return useWakeWordContext(); | ||
| } catch { | ||
| return null; | ||
| } | ||
| } |
There was a problem hiding this comment.
This is a duplicate of the same helper function in settings.tsx and index.tsx. Extract to a shared utility to maintain DRY principle.
|
|
||
| // Try to get wake word context, return null if not available | ||
| function useTryWakeWordContext() { | ||
| try { | ||
| return useWakeWordContext(); | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
This is a duplicate of the same helper function in settings.tsx and list-detail.tsx. Extract to a shared utility to maintain DRY principle.
| // Try to get wake word context, return null if not available | |
| function useTryWakeWordContext() { | |
| try { | |
| return useWakeWordContext(); | |
| } catch { | |
| return null; | |
| } | |
| } | |
| import { useTryWakeWordContext } from '@/hooks/use-try-wake-word-context'; |
| * Tests for "Hey Shoppy" wake word detection service | ||
| */ | ||
|
|
||
| import { WakeWordService, WakeWordStatus } from './wake-word-service'; |
There was a problem hiding this comment.
Unused import WakeWordStatus.
| import { WakeWordService, WakeWordStatus } from './wake-word-service'; | |
| import { WakeWordService } from './wake-word-service'; |
Co-authored-by: akisma <332125+akisma@users.noreply.github.com>
All tests pass (152 tests). Refactored in commit 7fa0b86: Changes made:
What remains tested:
|
Test Refactoring Summary
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.