Add voice command auto-fill and server-side logging
Some checks failed
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled

- Add URL parameter reading to diaper tracking page for voice-extracted data
- Add comprehensive server-side logging in voice controller and service
- Log request type (Web Speech API vs MediaRecorder), input text/audio, GPT calls, and classification results
- Enable automatic form pre-filling when voice commands navigate to tracking pages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-02 07:53:21 +00:00
parent 8a342fa85b
commit db0ff8067a
4 changed files with 188 additions and 26 deletions

View File

@@ -143,23 +143,45 @@ export function VoiceFloatingButton() {
return;
}
// Show success message
// Handle unknown or low confidence
if (result.type === 'unknown' || (result.confidence && result.confidence < 0.3)) {
setSnackbar({
open: true,
message: 'Could not understand the command. Please try again or use manual entry.',
severity: 'warning',
});
return;
}
// Show success message with activity type
const activityLabel = result.type.charAt(0).toUpperCase() + result.type.slice(1);
setSnackbar({
open: true,
message: `Understood: ${result.intent} command`,
message: `${activityLabel} activity detected!`,
severity: 'success',
});
// Auto-close dialog and navigate
// Auto-close dialog and navigate with pre-filled data
setTimeout(() => {
handleClose();
if (result.intent === 'feeding') {
router.push('/track/feeding');
} else if (result.intent === 'sleep') {
router.push('/track/sleep');
} else if (result.intent === 'diaper') {
router.push('/track/diaper');
// Encode the details as URL parameters for pre-filling the form
const params = new URLSearchParams();
if (result.details) {
Object.entries(result.details).forEach(([key, value]) => {
if (value !== null && value !== undefined) {
params.set(key, String(value));
}
});
}
if (result.timestamp) {
params.set('timestamp', result.timestamp);
}
const queryString = params.toString();
const url = `/track/${result.type}${queryString ? `?${queryString}` : ''}`;
router.push(url);
}, 1500);
};