Skip to content

fix(status-bar): guard undefined provider window in usedPercent reduce (crashes d2c1da69, bb74236c) - #10271

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-status-bar-usedpercent
Jul 24, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-status-bar-usedpercent

Conversation

@nwparker

@nwparker nwparker commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes a status-bar overlay crash (overlay.status-bar boundary): TypeError: Cannot read properties of undefined (reading 'usedPercent') at getTightestUsageSection → ProviderSegment/CodexAccountUsageSegment.

usedSections() filtered sections with s.window !== null, but a partial/rehydrated provider can carry a window that is undefined (the type declares session/weekly as RateLimitWindow | null, yet a missing field is undefined at runtime). An undefined window slipped past the null-only filter, so getTightestUsageSection's reduce — and providerMaxUsed — dereferenced undefined.usedPercent and took down the status bar.

Fix: filter out undefined windows too (s.window !== null && s.window !== undefined), matching the codebase's existing style. One point covers every consumer of usedSections.

Crash reports: d2c1da69, bb74236c (macOS, 1.4.152).

ELI5

The status bar shows each AI provider's tightest usage window. It listed the windows and skipped the "empty" ones — but it only checked for one kind of empty (null), not the other (undefined). A provider that came back with a missing window slipped through, and the code tried to read a percentage off nothing, crashing the bar. Now both kinds of empty are skipped.

Proof of fix

Regression tests fail on current code, pass after the one-line filter change:

BEFORE  provider-segment-monthly-window.test.tsx (8 tests | 2 failed)
  × getTightestUsageSection ignores an undefined window instead of crashing
    TypeError: Cannot read properties of undefined (reading 'usedPercent')
  × ProviderSegment renders without crashing when a provider window is undefined
    TypeError: Cannot read properties of undefined (reading 'usedPercent')
AFTER   Test Files 33 passed · Tests 224 passed

The second test reproduces through the real ProviderSegment render path (the crash's component stack). tsc web typecheck exit 0; oxlint clean.

Proof of zero regression

The only behavior change is that a section whose window is undefined is now excluded — such a section was never renderable anyway (every consumer reads window.usedPercent), so excluding it removes a crash and changes nothing for valid windows. null windows were already excluded; undefined now joins them. Entire status-bar suite green (33 files / 224 tests), including all pre-existing provider/window/tooltip tests.

Made with Orca 🐋

…ercent

usedSections filtered only s.window !== null, so a partial/rehydrated provider
whose session/weekly window is undefined (not null) slipped through and
getTightestUsageSection's reduce dereferenced undefined.usedPercent, crashing the
status-bar overlay (TypeError in ProviderSegment/CodexAccountUsageSegment).
Filter out undefined windows too. Fixes crashes d2c1da69 / bb74236c.

Co-authored-by: Orca <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 01f0b489-b276-4b65-beff-25f3f03e9971

📥 Commits

Reviewing files that changed from the base of the PR and between 1b01385 and e9212f7.

📒 Files selected for processing (2)
  • src/renderer/src/components/status-bar/UsageRosterPanel.tsx
  • src/renderer/src/components/status-bar/provider-segment-monthly-window.test.tsx

📝 Walkthrough

Walkthrough

Updated provider usage filtering to exclude both null and undefined windows. Added tests verifying tightest-window calculation and compact ProviderSegment rendering with a partial provider whose session window is undefined.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the fix and tests, but it omits required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections, including Screenshots, Testing, AI Review Report, Security Audit, and Notes, with brief concrete details.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the status-bar crash fix and the undefined provider window guard.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker requested a review from brennanb2025 July 24, 2026 02:25
@nwparker
nwparker merged commit a05a7bb into main Jul 24, 2026
2 checks passed
@nwparker
nwparker deleted the nwparker/fix-status-bar-usedpercent branch July 24, 2026 02:26
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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