fix: duplicate session saves and API key loss on fast app close #4733
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/voxlen/pull/68
Summary
Two critical data-integrity bugs fixed.
1. Duplicate history / flywheel / billable entries on Stop
DictationPanel.handleToggleDictationwas recording history, flywheel session, and billable time directly when the user clicked Stop. ThensetStatus("idle")triggered the autosave subscription inuseTauriEvents, which did exactly the same thing. The dedup guard (alreadyInHistorytext-equality check) failed whenever a grammar correction updatedcorrectedTextbetween the two saves — different strings, duplicate entries, double-billed time.Fix: removed the duplicate recording from the button handler entirely. The autosave subscription in
useTauriEventsis now the single source of truth for all session recording. Also removed the now-unuseduseHistoryStoreimport fromDictationPanel.2. API key silently lost if app closes within 500ms of entry
updateSetting()debounces all persistence 500ms viaschedulePersist(). Entering an API key and immediately closing the app (or the app crashing) cancelled the timer before the keychain write fired — key gone on next startup.Fix: for
sttApiKey,grammarApiKey, andvoxlenApiKey,updateSettingnow writes to the OS keychain immediately in addition to scheduling the debounced persist.Test plan
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ggw2m7nwT2HDNaQJqSX6Sp
Generated by Claude Code