Commit History
-
refactor(ui): extract shouldOfferOfflineAI() helper, DRY the modal guard
DONG-WEI-YANG +1: Claude Opus 4.7 (1M context)Replaces 4 inline copies (3 in AiFillButton, 1 in SmartTranscript) of the enabled/declined check with a single helper in deviceAI.ts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>dbfa411 -
feat(ui): wire offline-AI modal trigger + banner mount at App level
DONG-WEI-YANGa752482
-
feat: SmartTranscript vocab + device AI correction steps (Tasks 4+5)
DONG-WEI-YANG +1: Claude Sonnet 4.6Add two client-side correction steps before the server pipeline: Step 0 — instant vocabulary correction via loadRoleVocab/correctWithVocab; Step 1 — on-device AI correction via deviceAI.execute('correct'). Add optional `role` prop (default 'nurse') and propagate it to all 8 consumer pages/components. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>4837cc3
-
fix: comprehensive security hardening, iOS voice fallback, and UX resilience
DONG-WEI-YANG +1: Claude Opus 4.6 (1M context)- iOS voice fallback: MIME type detection + record-only mode when Web Speech API unavailable - HF Whisper fallback for audio transcription when Gemini fails - OpenCC s2twp layer in NLP pipeline for simplified→traditional Chinese conversion - localStorage draft autosave (useAutosave hook) across all 6 form pages - AI fill no longer overwrites user-entered fields (skip-if-filled pattern) - DB transaction wrapping for record creation (prevents orphaned data) - keyPrefix column for O(1) record lookup (replaces O(n) bcrypt scan) - Prompt injection fix: sanitizeForPrompt + Zod array/string constraints - Security headers: HSTS, X-Frame-Options, X-Content-Type-Options, Permissions-Policy - CSP: removed unsafe-eval, kept unsafe-inline for HF Spaces compatibility - AI-specific rate limiter (10 req/min), retrieve limiter tightened to 3/min - Crypto upgrades: bcrypt 10→12 rounds, key entropy 15→32 bytes - Role-recordType cross validation via Zod .refine() - fileName sanitization + file array .max(…94a07ff
-
feat: 4-layer NLP correction pipeline for STT error fixing
DONG-WEI-YANG +1: Claude Opus 4.6 (1M context)Adds multi-layer voice transcription correction between recording and AI extraction: Layer 1 — Punctuation restoration (regex): Inserts commas before kinship terms, transitions, age mentions. Critical for clause-context protection rules. Layer 2 — Homophone correction (dictionary): 80+ medical/LTC domain homophones (高血吧→高血壓, 居福→居服, 阿罵→阿嬤) Layer 3 — Medical term normalization: Abbreviations (BP→血壓), informal→formal (血壓高→高血壓), service name→code mapping (身體照顧→BA01) Layer 4 — HF model deep correction (Qwen2.5-72B): AI-powered final pass for remaining errors, with length validation to prevent hallucination. Pipeline integrated into SmartTranscript component — runs automatically after recording stops. Shows correction details to user (e.g., 「高血吧」→「高血壓」). New API endpoint: ai.correctTranscript for standalone use. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>9392a10 -
feat: upgrade STT quality + AI accuracy + smart UX for voice recording
DONG-WEI-YANG +1: Claude Opus 4.6 (1M context)Phase 1 — Wire audioBlob to Gemini Audio as primary STT: - Connect onAudioBlob across all 6 role pages - AiFillButton auto-switches to Gemini Audio mode when blob available - audioAndParse upgraded with multi-key rotation + JSON retry logic Phase 2 — Improve AI prompts for structured extraction accuracy: - Dynamic year calculation (no more hardcoded 2026) - Add ORAL_SPEECH_RULES for Taiwanese colloquial speech patterns - Strengthen anti-hallucination rules with specific prohibitions - All 5 prompt files updated Phase 3 — UX improvements: - SmartTranscript component: auto Gemini re-transcription, editable text, source indicator (browser/Gemini/user edit) - AiFilledNotice component: shows specific field names AI filled (replaces generic count message) - All 6 role pages upgraded with new components Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>182d832