Repository navigation
feat(desktop): add an Insights page with pace, fixes, words, and streaks - #276
Merged
Merged
Conversation
The helper now sends speechMs on every transcript: the time from the first to the last chunk that sounds like speech, padded 200 ms each side. Leading and trailing quiet drop out, inner pauses stay. It is built from one RMS per accepted chunk while recording, so stopping does no extra scan. Protocol v8.
After each session that produced a transcript (inserted or not), main hands the raw text, the cleanup output it inserted, and the dictionary fixes to a new Insights store. The store counts on a later event-loop turn and saves numbers only to insights.json: words per local day, words cleanup corrected, dictionary fixes, and the last 100 pace samples. No text reaches the file or diagnostics. The hub reads it over its own channels and can clear it. rewrite() now counts dictionary matches that changed the words, and finalRewrite() replaces finalText() so the reducer knows which branch it inserted. saveSettings shares the atomic write with the new store.
A new Insights page after Home shows the user's speaking pace against the average typist, total words dictated, fixes Voice made (words cleanup corrected and dictionary fixes), the current and longest streak, and a daily-words heatmap sized to the window. Data and Privacy gets Clear insights, behind a confirmation.
- A file with a version other than 1 is now left untouched. Before, it was downgraded and rewritten, so going back to an older build after a newer one lost the newer data. A file that is not JSON is now logged. - The "faster than typing" multiple now uses the unrounded pace. Before, 51.5 to 54 WPM read "1.0x faster than typing". The line now shows only when the one-decimal multiple is above 1. - Curly and modifier apostrophes now count as straight ones, so cleanup that only curls an apostrophe no longer counts as a corrected word. - Tests now catch a Clear that skips an in-flight save, a month label past today, and a streak broken by a clock change. The streak test now runs in Europe/Warsaw, so it can fail when CI runs in UTC. - A Swift test now covers trimming noise far below the peak. - Removed the fake helper's unused speechMs option.
…heatmap west of UTC A version field with no string form made loading Insights throw, and every later read, record, and Clear failed until restart. The log line no longer quotes the version, and a load that throws now falls back to leaving the file alone, which Clear can recover from. The heatmap tests now run in Los Angeles, where a local-date slip moves cells a day early, and cover a month that starts on a Saturday.
…ge-plan Both sides bumped the helper protocol to 8: main for html on insert, this branch for speechMs on transcript. The merge carries both fields as protocol 9 in the TS client, the fake helper, the Swift helper, helper.mjs, and the protocol tests on both sides.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Users have no way to see how much they dictate or how fast. Wispr Flow shows this on its Insights page. This PR adds a local Insights page modelled on Wispr's "Your usage" tab: words per minute, fixes made by Voice, total words, current and longest streak, and a daily-words heatmap.
Wispr computes most of these numbers on its server. Voice keeps them on the Mac in
<userData>/insights.json, which holds numbers and day keys, never dictated text. Recording happens after insertion, on a later event-loop turn, so nothing runs on the dictation hot path. Formulas follow Wispr: words come from the raw transcript, and WPM is pooled over the last 100 sessions using the speech span, which excludes silence before and after speech.Scope
SpeechSpanmeasures the span from the first to the last chunk within 30 dB of the loudest and above -55 dBFS, with 200 ms padding.transcriptgains a nullablespeechMs. The helper protocol moves to v9, because main's feat(snippets): paste formatted snippets as rich text #273 took v8 forhtmlon insert.rewrite()countsdictionaryFixes(entry matches that changed the text).finalRewritereplacesfinalTextand reports which branch won. Theinsertingstate carriesinsertedCleanupanddictionaryFixes.dictation.tscalls a newonDictatedforinsertedandnotInsertedoutcomes only.SessionReportstays text-free.main/insights.tsis one store (record,get,clear,settled) with a single write chain.atomic-file.tsis extracted fromsaveSettings.getInsights,onInsights, andclearInsightschannels, kept out of the Snapshot. NewInsightspage after Home and a Clear insights row in Data and Privacy.Tradeoffs
Blast Radius
Insights touches the session reducer and the helper protocol. Rebuild the helper with the app. A mismatched helper and app fail the existing version check. Inserting Insights after Home moves Style, Snippets, and Dictionary to Cmd+3, Cmd+4, and Cmd+5.
Verification
SpeechSpanand the protocol./verifyend-to-end script passed 22 of 22 checks against the real app with synthetic fixtures. It dictated with Insights open and checked live updates. It checked counts against the raw transcripts, a dictionary fix, a silent session counting nothing, and the absence of dictated words in the file. It also checked persistence across restart, Clear from Settings, and a cleanmain.log. This run predates the review fixes and the merge, and it was not rerun.captureStarted. All four are fixed.