Skip to content

Show accepted word count badge in menu bar icon#203

Merged
FuJacob merged 2 commits into
mainfrom
feat/menu-bar-word-count-badge
May 25, 2026
Merged

Show accepted word count badge in menu bar icon#203
FuJacob merged 2 commits into
mainfrom
feat/menu-bar-word-count-badge

Conversation

@FuJacob
Copy link
Copy Markdown
Owner

@FuJacob FuJacob commented May 25, 2026

Summary

Surfaces the total accepted word count as a compact number to the right of the paw icon in the menu bar. The badge is hidden when the count is zero, so new users see a clean icon until they start accepting suggestions.

Validation

xcodebuild -project tabby.xcodeproj -scheme tabby -destination 'platform=macOS' test CODE_SIGNING_ALLOWED=NO
# Executed 253 tests, with 0 failures (0 unexpected)

swiftlint lint --quiet
# exit 0 (no new warnings)

Screenshot not included — requires manual testing to verify menu bar rendering since the label only updates after accepting a suggestion in a live text field.

Linked issues

N/A — new feature request.

Risk / rollout notes

  • tabby.xcodeproj/project.pbxproj updated to register WordCountFormatterTests.swift in the test target.
  • MenuBarStatusLabelView now takes SuggestionCoordinator as an @ObservedObject parameter. The coordinator was already public on AppDelegate.
  • WordCountFormatter is a pure helper in Support/ with 9 test cases covering all formatting tiers (raw, K, M).

Greptile Summary

This PR surfaces the total accepted word count as a compact badge to the right of the paw icon in the menu bar, hidden when the count is zero so new users see a clean icon until they start accepting suggestions.

  • WordCountFormatter is a new pure Support/ helper that maps integer word counts to compact strings (\"999\", \"1.5K\", \"10K\", \"1.0M\") with 9 unit tests covering all tiers, including the %.1f rounding boundary at 9,999.
  • MenuBarStatusLabelView is updated to accept SuggestionCoordinator as an @ObservedObject and conditionally render the formatted label next to the icon; the coordinator was already a public property on AppDelegate, so the wiring in CotabbyApp.swift is a one-line change.
  • project.pbxproj registers WordCountFormatterTests.swift in the test target's file-reference and build-sources sections following the existing GUID naming convention.

Confidence Score: 5/5

Safe to merge; the change adds a read-only display layer on top of an already-maintained counter without touching any acceptance, insertion, or state-machine logic.

The new WordCountFormatter is pure and thoroughly tested. The coordinator wiring is a one-line pass-through of an already-public object. The word-count property is @published on @mainactor so SwiftUI observation is safe. No data flow, persistence, or acceptance logic is altered by this PR.

No files require special attention.

Important Files Changed

Filename Overview
Cotabby/Support/WordCountFormatter.swift New pure helper; correctly segments raw, K, and M tiers with integer division for the coarser bands and %.1f for the fine-grained ones. No logic issues.
Cotabby/UI/MenuBarStatusLabelView.swift Adds a word-count badge next to the paw icon by observing the full SuggestionCoordinator; badge logic is correct but the view re-renders on every coordinator @published mutation, not just totalTabAcceptedWordCount changes.
Cotabby/App/Core/CotabbyApp.swift Minimal change: passes the existing long-lived coordinator instance into the label view; no ownership or lifecycle issues.
CotabbyTests/WordCountFormatterTests.swift Nine focused test cases covering nil, negative, raw, K one-decimal, K whole, M one-decimal, and M whole tiers; boundary rounding case (9,999 → "10.0K") is explicitly verified.
Cotabby.xcodeproj/project.pbxproj Registers WordCountFormatterTests.swift in both the file reference and test-target build sources sections; GUIDs follow the existing naming convention.

Sequence Diagram

sequenceDiagram
    participant User
    participant SuggestionCoordinator
    participant MenuBarStatusLabelView
    participant WordCountFormatter

    User->>SuggestionCoordinator: Tab accepted (acceptSuggestion)
    SuggestionCoordinator->>SuggestionCoordinator: recordAcceptedWords(from: chunk)
    SuggestionCoordinator->>SuggestionCoordinator: "totalTabAcceptedWordCount += n"
    SuggestionCoordinator->>SuggestionCoordinator: userDefaults.set(count)
    SuggestionCoordinator-->>MenuBarStatusLabelView: "objectWillChange fires (@Published)"
    MenuBarStatusLabelView->>WordCountFormatter: compactLabel(for: totalTabAcceptedWordCount)
    WordCountFormatter-->>MenuBarStatusLabelView: "42" / "1.5K" / nil
    MenuBarStatusLabelView-->>User: Menu bar badge updated (or hidden if nil)
Loading

Fix All in Codex Fix All in Claude Code

Reviews (3): Last reviewed commit: "Fix docstring: document rounding at 9,95..." | Re-trigger Greptile

Comment thread tabby/Support/WordCountFormatter.swift Outdated
Comment thread Cotabby/Support/WordCountFormatter.swift
FuJacob added 2 commits May 24, 2026 21:23
Displays the total accepted word count as a compact number to the right
of the paw icon in the menu bar. Hidden when the count is zero.

Uses WordCountFormatter for compact display (42, 1.5K, 10K, 1.0M).
MenuBarStatusLabelView now observes SuggestionCoordinator to update
the badge as words are accepted.
@FuJacob FuJacob force-pushed the feat/menu-bar-word-count-badge branch from 944f6d7 to 9d2cc8f Compare May 25, 2026 04:24
@FuJacob FuJacob merged commit dd716ab into main May 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant