Skip to content

feat: add Settings toggle to show detailed remaining time#24

Open
carlosresu wants to merge 4 commits into
CodeZeno:mainfrom
carlosresu:feat/detailed-remaining-time
Open

feat: add Settings toggle to show detailed remaining time#24
carlosresu wants to merge 4 commits into
CodeZeno:mainfrom
carlosresu:feat/detailed-remaining-time

Conversation

@carlosresu
Copy link
Copy Markdown

Summary

Adds an opt-in Show detailed remaining time checkbox under the right-click Settings submenu. When enabled:

  • The 5h session row shows minutes alongside hours (e.g. 4h 12m instead of 4h)
  • The 7d weekly row shows hours alongside days (e.g. 3d 5h instead of 3d)
  • The countdown timer repaints on the finer-unit boundary so the value never goes stale
  • The widget grows from TEXT_WIDTH = 62 to TEXT_WIDTH_DETAILED = 95 per row — narrowest value that fits the worst-case 100% · 23h 59m display

Default is off, so existing installs see exactly today's behavior. The preference is persisted in %APPDATA%\ClaudeCodeUsageMonitor\settings.json as show_detailed_remaining and #[serde(default)] ensures older config files migrate cleanly.

Localization added for English, Dutch, Spanish, French, German, Japanese, Korean, Traditional Chinese.

Sub-hour behavior unchanged

The toggle only adds a sub-unit when the top unit is h or d. Minutes and seconds displays render identically in both modes:

Remaining Default (off) Detailed (on)
`>= 1 day` `Xd` (e.g. `3d`) `Xd Yh` (e.g. `3d 5h`)
`1h - 24h` `Xh` (e.g. `4h`) `Xh Ym` (e.g. `4h 23m`)
`1m - 59m` `Xm` (e.g. `45m`) `Xm` (e.g. `45m`)
`0s - 59s` `Xs` (e.g. `30s`) `Xs` (e.g. `30s`)
reset reached `now` `now`

Commits

The change is split into 4 atomic commits that each build cleanly:

  1. `feat: add "Show detailed remaining time" localization` — Strings field + 8 translations
  2. `refactor: thread detailed flag through countdown formatter` — `poller.rs` signature + window callers passing `false`
  3. `refactor: thread detailed flag through widget width and rendering` — `TEXT_WIDTH_DETAILED` const + plumbing through draw funcs, callers passing `false`
  4. `feat: add Settings toggle to show detailed remaining time` — state field, menu item, command handler, README mention; flips the `false` literals to read from state

Test plan

  • `cargo check` clean
  • `cargo build --release` clean (805 KB binary)
  • Default behavior unchanged with toggle off (still shows `4h`, `3d`)
  • Toggle on -> widget widens, detailed text renders (`4h 23m`, `2d 1h`)
  • Right-click -> Settings -> checkmark reflects current state
  • Setting persists across restart via `settings.json`
  • Verify on a fresh install with no prior `settings.json` (deserializes to `false`)
  • Verify in dual-model (Claude + Codex) mode

Adds the localized label that the upcoming Settings toggle will use.
Adds a `detailed: bool` parameter to `format_line`, `format_countdown`,
`format_countdown_from_secs`, `time_until_display_change`, and
`time_until_display_change_from_secs`. When `true`, sub-units are
surfaced (Xh Ym for hours, Xd Yh for days) and the display-change
tick fires on minute/hour boundaries to match.

All callers pass `false`, so behavior is unchanged. The toggle that
flips this is added in a later commit.
Adds `TEXT_WIDTH_DETAILED` (95 px, the narrowest value that fits the
worst-case `100% · 23h 59m` weekly display) alongside the existing
62 px default, plus a `text_width_for(detailed)` helper. Threads a
`detailed: bool` parameter through `total_widget_width_for`,
`model_usage_width`, `draw_usage_bar`, `draw_row`, and `paint_content`
so the widget can size and clip text appropriately.

All callers pass `false`, so behavior is unchanged. The toggle that
flips this is added in a later commit.
Adds a new "Show detailed remaining time" entry under the right-click
Settings submenu, off by default. When on, the 5h session window
shows minutes alongside hours (e.g. "4h 12m") and the 7d weekly
window shows hours alongside days (e.g. "3d 5h"). The widget grows
to TEXT_WIDTH_DETAILED (95 px per row) while toggled, and the
countdown timer repaints on the finer-unit boundary so the displayed
value is never stale.

The preference is persisted in settings.json as
`show_detailed_remaining` and is loaded on startup. Existing
settings.json files without the field deserialize to false.
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