Skip to content

feat(desktop): add an Insights page with pace, fixes, words, and streaks - #276

Merged
hadrysm merged 7 commits into
mainfrom
research/insights-usage-plan
Oct 14, 2026
Merged

hadrysm merged 7 commits into
mainfrom
research/insights-usage-plan

Conversation

@hadrysm

@hadrysm hadrysm commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Helper: SpeechSpan measures the span from the first to the last chunk within 30 dB of the loudest and above -55 dBFS, with 200 ms padding. transcript gains a nullable speechMs. The helper protocol moves to v9, because main's feat(snippets): paste formatted snippets as rich text #273 took v8 for html on insert.
  • rewrite() counts dictionaryFixes (entry matches that changed the text). finalRewrite replaces finalText and reports which branch won. The inserting state carries insertedCleanup and dictionaryFixes.
  • dictation.ts calls a new onDictated for inserted and notInserted outcomes only. SessionReport stays text-free.
  • main/insights.ts is one store (record, get, clear, settled) with a single write chain. atomic-file.ts is extracted from saveSettings.
  • The store never writes over an Insights file from another version or one that fails to load. Insights shows empty for that file, and Clear removes it.
  • Hub: getInsights, onInsights, and clearInsights channels, kept out of the Snapshot. New Insights page after Home and a Clear insights row in Data and Privacy.
  • Out of scope: Wispr's percentile, leaderboard, per-app categories, mobile, and sync. The WPM card shows "N× faster than typing" against the 51.56 WPM typist average (Dhakal et al., CHI 2018) instead of a percentile.

Tradeoffs

  • Counting runs in the main process, not a worker. Counting and diffing a 2,000-word transcript plus serializing the file takes 2.3 ms median, once per session, after insertion.
  • The file stores daily totals and the last 100 pace samples, not a row per session. That is all the page reads, and it keeps no history beyond counts.
  • "Words corrected" is a word-multiset difference between the raw and cleaned text. It counts fillers and changed words, not capitalization or punctuation. A straight and a curly apostrophe count as the same word.
  • "N× faster than typing" uses the unrounded pace. The line shows only when the one-decimal multiple is above 1, so it stays hidden up to about 54 WPM rather than claim "1.0×".

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

  • After the merge with main, 1008 desktop tests and 114 Swift tests pass, and CI Check passes. The Swift tests include SpeechSpan and the protocol.
  • The heatmap date tests run in America/Los_Angeles, where a local-date slip moves cells a day early. The streak DST test runs in Europe/Warsaw. CI runs in UTC, which hides both.
  • Three review rounds by Opus 5.5, GPT-6.1-Sol, and GPT-6-Astra ran, and an adversarial check reproduced or disproved each finding before any fix. The third round found no P0-P2 issues.
  • A /verify end-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 clean main.log. This run predates the review fixes and the merge, and it was not rerun.
  • An earlier review by GPT-6.1-Sol and GPT-6-Astra found a stale publish, a stale "today" after midnight, heatmap keyboard access, and an extra RMS before captureStarted. All four are fixed.
  • Not checked: the focus ring and tooltip under a real Tab key press.

Insights after restart

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.
@github-actions github-actions Bot added the size:XXL 1,000+ effective changed lines (test files excluded in mixed PRs). label Oct 13, 2026
- 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.
@hadrysm
hadrysm merged commit 5f7b9fe into main Oct 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ effective changed lines (test files excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant