Skip to content

fix: address stats review follow-ups (persistence, UX, tokenization) - #170

Merged
jatinkrmalik merged 1 commit into
mainfrom
fix/stats-review-followups
Jul 1, 2026
Merged

fix: address stats review follow-ups (persistence, UX, tokenization)#170
jatinkrmalik merged 1 commit into
mainfrom
fix/stats-review-followups

Conversation

@jatinkrmalik

@jatinkrmalik jatinkrmalik commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to the review of #148 (stats feature) by @Mr-Sunglasses. Note that #148 is already merged, and #168 landed the two biggest review findings (UTC-vs-local timezone bucketing and the wall-clock streak dependency), along with tests. This PR cleans up the remaining review findings.

image

Changes

Persistence / data safety

  • UserStats now decodes leniently (decodeIfPresent + defaults). Synthesized Codable requires every non-optional key, so the day a new field is added, every existing stats.json would fail to decode and silently reset all history. Lenient decoding makes the schema forward/backward compatible. Also ignores now-removed legacy keys.
  • Dropped the unused dailyDurationSeconds field (written on every transcription but never read).

Correctness

  • Word counting now uses the system tokenizer (enumerateSubstrings(options: .byWords)) instead of splitting on whitespace, so space-less scripts (Chinese, Japanese, Thai) are no longer counted as a single word.
  • Date-key parsing in the stats view uses a fixed en_US_POSIX locale so the yyyy-MM-dd keys parse correctly regardless of the user's default calendar/locale.

UX

  • "Reset All Statistics" now asks for confirmation before wiping data (was a one-click irreversible destructive action).
  • The WPM caption is relabeled "Speaking Speed" — it measures words per minute of audio, not typing throughput.

Robustness / performance

  • Stats are encoded on the main actor (tiny payload) and written to disk off-main on a serial queue, so a busy disk can't hitch the UI on the transcription hot path.
  • Replaced the application-support-directory force-unwrap with a temp-dir fallback.

Tests

  • testStatsDecodeToleratesMissingAndUnknownKeys — missing keys fall back to defaults; unknown/legacy keys are ignored.
  • testWordCountHandlesSpacelessScripts — a Japanese sentence tokenizes to more than one word.
  • All existing StatsManager tests (including fix: use local calendar days for stats streaks #168's timezone/streak tests) still pass: swift test --filter StatsManagerTests → 11 passed.

Not changed

  • The averageWPM semantics (words per minute of audio) are unchanged — only the UI label was clarified.

Follow-up to the #148/#168 review. #168 already fixed the timezone and
streak bugs; this covers the remaining findings:

- UserStats: decode leniently via decodeIfPresent so future schema
  additions no longer fail to decode and silently wipe saved stats on
  upgrade (synthesized Codable requires every non-optional key).
- StatsManager: count words with the system tokenizer (.byWords) so
  space-less scripts (Chinese, Japanese, Thai) aren't undercounted as a
  single word; write stats off the main actor on a serial queue so a busy
  disk can't hitch the UI; drop the unused dailyDurationSeconds field; and
  guard the application-support force-unwrap.
- StatsSettingsTab: confirm before the destructive "Reset All Statistics";
  parse date keys with a fixed POSIX locale; relabel WPM as "Speaking
  Speed" to match what it measures (words per minute of audio).
- Tests for lenient decode and space-less word counting.
@github-actions github-actions Bot added the app label Jul 1, 2026
@jatinkrmalik

Copy link
Copy Markdown
Member Author

/build

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

PR Build started for a164b3b

Build signed & notarized DMG... this usually takes 10–20 minutes.

Watch the build →

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

PR Build ready!

DMG VocaMac-0.6.2-pr.170+a164b3b-arm64.dmg
Size 6.1M
Branch fix/stats-review-followups
Commit a164b3b
Signed ✅ Developer ID
Notarized ✅ Apple

📥 Install

  1. Click the DMG link above to download
  2. Open the DMG and drag VocaMac to Applications (replace existing)
  3. Open VocaMac — No Gatekeeper warnings, no permission resets
SHA-256 checksum
21f91d8bcdb15d65e878029aa92f3177f4a587f48fb7a8cb88ef87a52931ed01  VocaMac-0.6.2-pr.170+a164b3b-arm64.dmg

💡 Comment /build or /build-quick to rebuild.

@jatinkrmalik
jatinkrmalik merged commit 77e1a6c into main Jul 1, 2026
4 checks passed
jatinkrmalik added a commit that referenced this pull request Jul 2, 2026
* docs(web): document v0.7.0 features on the website

Adds website coverage for features shipped since v0.6.2 (audit found 4 of
5 uncovered; Homebrew was already fully covered, left untouched):

- New feature pages: Custom Vocabulary (#169) and Usage Statistics
  (#148/#168/#170), each with a landing-page grid card.
- Landing JSON-LD featureList: add custom vocabulary, local usage stats,
  and selectable audio input device (#156).
- Hotkey presets + custom recording (#139): fix stale "key combination"
  copy in fully-configurable.md, document the Record/custom-key capture
  and add the Right Control preset in push-to-talk.md, and update the FAQ.
- Audio input device (#156): expand fully-configurable.md (System Default,
  non-invasive pinning, auto-fallback on disconnect, Refresh Devices).
- Screenshots gallery: add a Stats tab entry.

Two screenshots still needed from a real capture (marked with SCREENSHOT
PLACEHOLDER comments): settings-stats.png and settings-vocabulary.png.
Verified with `hugo` (build succeeds; new pages render; JSON-LD valid).

* polish(web): refine features grid, fix mobile hero overflow, SEO pass

Features grid:
- Switch from a fixed 4-col grid (which left 2 orphan cards hanging and,
  via grid-auto-rows:1fr, forced every row to the tallest card's height)
  to a centered flex-wrap layout: uniform card heights, the short last
  row centers, and 4/2/1 columns at desktop/tablet/mobile.
- Apple-style polish: icon squircle tiles, tighter 1–2 line copy on every
  card, softer corners, refined heading type, gentler hover.

Mobile hero:
- The 380px mockup forced the hero column wider than small viewports,
  clipping the subtext/pills/buttons. Reset min-width and clip the
  decorative mockup so nothing overflows below ~420px.

SEO:
- og:type now "article" for content pages (was always "website").
- Enriched the home and features-list meta descriptions.
- Verified across all 18 pages: unique titles, one <h1> each, descriptions
  present, all <img> have alt, sitemap includes the new pages.

Screenshots: add settings-stats.png and settings-vocabulary.png (referenced
by the new feature pages) and refresh settings-general.png.
@jatinkrmalik
jatinkrmalik deleted the fix/stats-review-followups branch August 22, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant