Skip to content

Add optional remaining-time countdown to menu bar title#5

Open
DaniSchenk wants to merge 1 commit into
m13v:mainfrom
DaniSchenk:feat/title-reset-countdown
Open

Add optional remaining-time countdown to menu bar title#5
DaniSchenk wants to merge 1 commit into
m13v:mainfrom
DaniSchenk:feat/title-reset-countdown

Conversation

@DaniSchenk

@DaniSchenk DaniSchenk commented Jul 13, 2026

Copy link
Copy Markdown

What

Adds a "Show remaining time in window" menu toggle (persisted in config, off by default) that appends a compact reset countdown to each window's percentage in the menu bar title:

5h 37% (1h12m) · 7d 10% (3d4h)

Why

The percentages alone don't tell you when a window frees up. This surfaces the reset countdown inline for anyone pacing work against the 5h / 7d limits, without cluttering the bar for people who don't want it.

How it works

  • Config: new show_remaining_time field (defaults to false), toggled from the tray menu and saved to config.json.
  • Rendering: short_countdown renders finer than the menu's existing reset_suffix — minute precision above 2h, 2-unit max (3d4h, 1h12m, 45m). It returns None past the deadline so a stale percentage never sits next to a countdown implying the window is still blocked.
  • Refresh cadence: the countdown is time-driven, not data-driven — polls are 15–30 min apart, so nothing would otherwise repaint as the minute rolls. A dedicated once-a-minute MinuteTick event (mirroring the existing BlinkTick ticker pattern) repaints the title. The handler short-circuits unless the feature is on and the alarm isn't blinking. Cost is negligible: the native set_title already fingerprints segments and skips the AppKit call when nothing changed, so an unchanged repaint just rebuilds a small Vec once a minute.

Notes for reviewers

  • Single-file change (src/bin/menubar.rs); no new dependencies.
  • Feature is opt-in and off by default — no behavior change unless the user enables it.
  • Unit tests cover the countdown bucketing edges (short_countdown_buckets): day/hour/minute boundaries, sub-minute floor to 1m, expired → None.

🤖 Generated with Claude Code

image

resolves #1

Adds a "Show remaining time in window" toggle (persisted in config) that
appends a compact reset countdown to each window's percentage in the menu
bar title, e.g. "5h 37% (1h12m) · 7d 10% (3d4h)". Off by default.

The countdown is time-driven, not data-driven: polls are 15-30 min apart,
so a dedicated once-a-minute MinuteTick event (mirroring the existing blink
ticker pattern) repaints the title so the countdown rolls. The handler
short-circuits unless the feature is on and the alarm isn't blinking, and
the native set_title already fingerprints segments to skip redundant AppKit
work, so an unchanged repaint is effectively free.

short_countdown renders finer than the menu's reset_suffix (minute
precision above 2h, 2-unit max) and returns None past the deadline so a
stale percentage never sits next to a countdown implying it's still blocked.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Adding a hours left info

1 participant