Conversation
useProviders armed one setTimeout for the soonest provider reset and then called the forced refreshProviders(). WebView2 stores a timer delay as a signed 32-bit integer, so a reset 24.9 to 49.7 days away wrapped to a negative delay and refreshed at once, and every snapshot merge re-armed it. A monthly plan early in its cycle is enough to hit this. The hook now waits at most 2,147,483,647 ms per timer and re-arms with the remaining time until the reset is close enough. Nearer resets keep the old timing: one second after the reset, at least five seconds out. Tests cover the normal reset refresh and a 30-day reset, which refreshed at once before this change.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
UI proof (browser-use)Result: PASS on build
At the maintainer's direction, this proof drove the app's WebView2 over CDP with the browser-use CLI instead of CUA. It used no keyboard, mouse or focus, and the global shortcut was off in the kit settings. Setup
Results
Validation at
|
| Command | Result |
|---|---|
pnpm install --frozen-lockfile |
pass |
pnpm exec vitest run src/hooks/useProviders.test.tsx without the fix |
The new 30-day test fails: refreshProviders was called after 60 s. |
pnpm exec vitest run src/hooks/useProviders.test.tsx with the fix |
16 tests passed |
pnpm run check-locale |
871 keys match between Rust and TS |
pnpm test |
65 files, 395 tests passed |
pnpm run lint |
0 errors. The 11 warnings are all in files this PR doesn't touch. |
pnpm run build |
pass |
cargo +1.98.0 fmt --all --check |
pass |
cargo +1.98.0 clippy --workspace --all-targets -- -D warnings |
pass |
cargo +1.98.0 test -p codexbar |
2160 passed, 0 failed, 1 ignored |
cargo +1.98.0 test -p codexbar-desktop-tauri |
459 passed, 1 failed: bootstrap_payload_exposes_every_provider_variant, the non-hermetic #684 test that #711 fixes |
Screenshots
All paths are under C:\Users\FSOS\AppData\Local\Win-CodexBar\port-audit\proof\720\shots\.
| File | Run | When | What it shows |
|---|---|---|---|
bu-A-early-traypanel.png |
Control (A) | 24 s after launch | The Codex card shows the auth error instead of the seeded usage. |
bu-B-early-traypanel.png |
This build (B) | 21 s after launch | "30-Day 61% used" and "Weekly 74% used" |
bu-B-late-traypanel.png |
This build (B) | 163 s after launch | Byte-identical to the 21 s screenshot. |
bu-C-early-traypanel.png |
This build (C) | 70 s before the reset | "Session 61% used" and "Weekly 74% used" |
bu-C-late-traypanel.png |
This build (C) | 24 s after the reset | The auth error, byte-identical to bu-A-early-traypanel.png |
Not blocking (found on main, not caused by this PR)
- The card's "Updated just now" label doesn't age while the panel stays open.
- In run B the card still read "Updated just now" at the late check, 163 s after the seed's
updatedAt. MenuCardformats the label withDate.now()during render, and nothing re-renders the card header on a timer. So the label changes only when provider data changes, and between refreshes it can understate the data's age.
- In run B the card still read "Updated just now" at the late check, 163 s after the seed's
- An empty
global_shortcutlogsWARN codexbar_desktop_tauri::shortcut_bridge: Could not parse global shortcut:at every launch.
Summary
Usage resets more than about 24.8 days away no longer force an immediate provider refresh.
useProvidersarms onesetTimeoutfor the soonest reset across all providers, then calls the forcedrefreshProviders(), which skips the stale-cache check. WebView2 stores a timer delay as a signed 32-bit integer, so the longest delay it can hold is 2,147,483,647 ms (about 24.8 days):A monthly plan early in its cycle is enough to hit this. For example, a Cursor- or Copilot-only user in the first days of a billing month.
The #719 proof found this on
main:Change
refresh().Upstream reference
None. This is a Windows-port frontend bug in code from "Port upstream 0.38.0" (
3b39f595). The upstream Swift app doesn't usesetTimeout.Ported / Deferred
Nothing is ported or deferred. No other frontend timer takes a date-derived delay: the rest use fixed delays or the refresh interval setting.
Validation
Run in the worker worktree on Rust 1.98.0 and Node 24.
pnpm install --frozen-lockfilepnpm exec vitest run src/hooks/useProviders.test.tsxbefore the fixrefreshProviderswas called after 60 spnpm exec vitest run src/hooks/useProviders.test.tsxwith the fixpnpm run check-localepnpm testpnpm run lintpnpm run buildcargo +1.98.0 fmt --all --checkcargo +1.98.0 clippy --workspace --all-targets -- -D warningscargo +1.98.0 test -p codexbarcargo +1.98.0 test -p codexbar-desktop-tauribootstrap_payload_exposes_every_provider_variant, the non-hermetic #684 test that #711 fixesNew tests in
useProviders.test.tsx:Affected areas
apps/desktop-tauri/src/hooks/useProviders.ts: the reset refresh timer.apps/desktop-tauri/src/hooks/useProviders.test.tsx: two new tests.UI proof
PASS at
de9b018e(browser-use over WebView2 CDP, no keyboard, mouse or focus): #720 (comment)main7695471): a 30-day Codex seed was replaced by a forced fetch 0.9 s after launch.auto, and the foreground window never changed.The red CircleCI check on this head (started 00:39 UTC) failed in
codex_source_recovery_keeps_appended_duplicate_unpriced_after_cache_reloadand the two paginated fork tests. Those Rust tests fail on any branch between 00:00 and 01:00 UTC, and #721 fixes them. This PR changes no Rust code.