Skip to content

fix(tray): label the tooltip from the headline lane, not the raw primary - #357

Merged
Finesssee merged 1 commit into
nesszer:mainfrom
wu858430049:fix/tray-tooltip-informational-codex-primary
Aug 23, 2026
Merged

Finesssee merged 1 commit into
nesszer:mainfrom
wu858430049:fix/tray-tooltip-informational-codex-primary

Conversation

@wu858430049

Copy link
Copy Markdown

Summary

The native tray tooltip labelled snapshot.primary directly, so a Codex account on a weekly-only plan showed the informational placeholder — Codex: No active 5h session — instead of the real weekly window.

provider_status_label already routed Codex through codex_lane_headline_window to skip informational lanes (the F5 / upstream-0.48.0 fix). build_tooltip, 111 lines further down the same file, never got the same treatment: #277 covered the React surfaces and the FloatBar, and the Rust tray tooltip was left behind. That is why the icon, the tray menu rows, the Providers sidebar, the FloatBar and the CLI were all correct while only the hover tooltip was wrong.

Rather than repeat the provider_id == "codex" conditional at a second call site, this extracts it into headline_window and calls it from both, so the two surfaces cannot drift apart again. Net effect on behaviour is limited to the tooltip; provider_status_label keeps its existing semantics.

Before:

CodexBar
Codex: No active 5h session

After:

CodexBar
Codex: 16% • Resets in 3d 17h

Related issue

Fixes #356

Affected areas

  • Tray panel
  • Settings UI
  • Config file / settings persistence
  • CLI
  • Provider-specific behavior
  • Installer / release packaging
  • Startup / background behavior
  • Documentation
  • Other:

Validation

  • powershell.exe -ExecutionPolicy Bypass -NoProfile -File scripts\local-check.ps1 — not run. No Rust toolchain on my machine (no cargo/rustc, no MSVC Build Tools), and installing the MSVC stack plus a first full build of the Tauri dependency tree was not something I could do here. Flagging this openly rather than ticking a box I did not exercise.
  • For full pre-release validation — not applicable; no release artifacts touched.
  • For installer/release changes — not applicable.
  • Thermo-nuclear code quality review — not run as the linked skill. I did review the final diff for the structural issue it targets: the duplicated lane-selection conditional was the actual root cause here, so the fix removes the duplication instead of adding a second copy. Happy to rerun properly if you want the formal pass.
  • Other: hosted pr-check.yml is the validation path for this PR. The change is Rust-only in one file, so cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace cover it. Please let CI run before merging — if anything is red I will fix it.

UI / tray proof

  • Not applicable
  • CUA Driver visual proof attached
  • CUA Driver could not be used; equivalent manual proof and explanation attached

CUA Driver needs a built desktop shell, which needs the same toolchain I do not have. Manual proof instead, from the released v0.54.0 installer on a live weekly-only account:

The payload — codexbar-cli.exe usage -p codex --json, informational primary plus a real weekly secondary:

{
  "primary":   { "is_informational": true,  "used_percent": 0.0,  "window_minutes": 300,
                 "reset_description": "No active 5h session" },
  "secondary": { "is_informational": false, "used_percent": 14.0, "window_minutes": 10080,
                 "reset_description": "3d 17h", "resets_at": "2026-08-27T10:47:41Z" }
}

The split — same account, same moment, v0.54.0:

Surface Code path Rendered
Tray icon selected_tray_percents → selected_usage_window 16% ✅
Tray menu rows provider_status_label → codex_lane_headline_window 16% ✅
Providers sidebar / FloatBar shared policy from #277 16% ✅
Tray tooltip build_tooltip → &s.primary "No active 5h session" ❌

The regression test — tooltip_skips_informational_codex_primary builds the same shape (informational primary, weekly secondary at 16% resetting in 3d 17h) and asserts the tooltip reads CodexBar\nCodex: 16% • Resets in 3d 17h. On main that call returns the placeholder instead, so the test pins the regression. To be clear about what I actually did and did not do: I traced the expected string through compact_tray_status_label → normalize_reset_description → ResetsInShort by reading, but I have not executed the test (see Validation) — CI is the confirmation. The existing tooltip_uses_compact_status_labels only builds non-informational primaries, which is why this path was uncovered.

Notes for reviewers

  • The behaviour change is one line in build_tooltip; everything else is the extraction and the test.

  • headline_window deliberately keeps the provider_id == "codex" check rather than generalising to all providers. Widening it would change Claude and others too, and that is a bigger call than this bug needs — happy to widen it if you would rather the policy be provider-agnostic.

  • The tooltip still ignores provider_metrics, so pinning Codex to Weekly in Settings has no effect on it. Using usage_metric::selected_usage_window here instead would fix that too, but it changes the tooltip for every provider, so I kept this PR to the reported bug. Say the word and I will follow up separately.

  • Context on why the account has no 5h window: OpenAI switched this ChatGPT Plus account to a weekly-only limit shape in mid-July 2026. Scanning every token_count event in ~/.codex/sessions that carries a populated rate_limits.primary:

    last record with a 300-minute window : 2026-07-12T03:43:35.847Z   (1182 records, primary=300 + secondary=10080)
    first weekly-only record             : 2026-07-17T06:21:47.367Z   (1200+ records, primary=10080 + secondary=null)
    300-minute records after the switch  : 0
    

    The weekly-only count keeps growing with use; the two boundary timestamps and the zero do not. Same payload shape as [Bug]: Weekly usage and pace break when 5-hour limit is absent #267 and [Bug]: FloatBar shows informational 5h placeholder instead of weekly usage #275.

The native tray tooltip passed `snapshot.primary` straight to
`compact_tray_status_label`, so a Codex account on a weekly-only plan
rendered the informational placeholder ("No active 5h session") instead
of the real weekly window.

`provider_status_label` already skipped informational lanes through
`codex_lane_headline_window`, but `build_tooltip` never got the same
treatment: nesszer#277 covered the React surfaces and the FloatBar, and the
Rust tray tooltip was left behind.

Extract the shared lane choice into `headline_window` and call it from
both sites so the two cannot drift apart again, and add a regression
test for the tooltip path.

Fixes nesszer#356

Co-Authored-By: Claude Opus 5 <[email protected]>
@Finesssee

Copy link
Copy Markdown
Collaborator

Thanks for the PR, I will review this ASAP.

@Finesssee Finesssee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thermo-nuclear review passed. The extraction is the right fix — shared helper eliminates the drift that caused the bug. See the review comment above for the full audit.

@Finesssee

Copy link
Copy Markdown
Collaborator

Thermo-Nuclear Code Quality Review — Approve

Verdict

This PR is the code-judo move. It removes a duplicated conditional instead of adding a second copy.

Findings

1. Structural regression — None. +35/-10, one file. The PR deletes complexity by extracting a shared headline_window helper and calling it from both provider_status_label and build_tooltip. Before: two sites with different lane-selection logic (one had the codex special case, one didn't). After: one shared function. The two surfaces can no longer drift apart.

2. Code-judo — The PR itself IS the simplification. The root cause was a duplicated provider_id == "codex" conditional at two call sites in the same file. provider_status_label had it (F5/upstream-0.48.0 fix); build_tooltip 111 lines later didn't — it used &s.primary directly, producing the wrong tooltip for weekly-only Codex accounts. Instead of copying the conditional a second time (which would have been the spaghetti move), the author extracts headline_window and calls it from both. This is exactly right.

3. Spaghetti — Reduced. Conditional count for codex lane selection: before 2 (one correct, one missing), after 1 (shared). Net decrease in branching complexity.

4. Type/boundary — Clean. headline_window takes &ProviderUsageSnapshot, returns &RateWindowSnapshot — both existing types. No new types, no casts, no optionality churn. The function is 8 lines with a doc comment explaining the F5/upstream rationale.

5. File size — No concern. tray_bridge.rs was already ~1240 lines. This adds 25 net lines. Not the PR that pushes it over 1k — it was already there. The extracted helper is small and well-placed.

6. Test quality — Good. tooltip_skips_informational_codex_primary builds the exact scenario from the bug report: informational primary (0%, "No active 5h session"), real secondary (16%, "3d 17h"), asserts tooltip reads CodexBar\nCodex: 16% • Resets in 3d 17h. Would fail on main, passes after fix. Pins the regression.

7. Scope discipline — Commendable. Author explicitly notes two deliberate non-changes: (1) did not generalize headline_window to all providers (would change Claude and others), (2) did not wire provider_metrics into tooltip (would change every provider's tooltip). Both correct calls for a bug fix PR.

Approval

No structural regression, no missed simplification (the PR IS the simplification), no file-size explosion, no spaghetti growth. The shared helper eliminates the drift risk that caused the bug. Approve.

@Finesssee
Finesssee merged commit 8820e72 into nesszer:main Aug 23, 2026
1 of 2 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.

[Bug]: Tray tooltip still shows "No active 5h session" for Codex — the one surface #277 did not cover

2 participants