Skip to content

fix: eliminate quota bar constraint churn causing menu unresponsiveness (closes steipete/CodexBar#1303)#1315

Closed
juanjoseluisgarcia wants to merge 0 commit into
steipete:mainfrom
juanjoseluisgarcia:main
Closed

fix: eliminate quota bar constraint churn causing menu unresponsiveness (closes steipete/CodexBar#1303)#1315
juanjoseluisgarcia wants to merge 0 commit into
steipete:mainfrom
juanjoseluisgarcia:main

Conversation

@juanjoseluisgarcia
Copy link
Copy Markdown

@juanjoseluisgarcia juanjoseluisgarcia commented Jun 5, 2026

Summary

  • Identified regression in commit `53a7f228` (May 21, "Restore full-width
    provider switcher quota bars") that caused menu tab switches to
    unconditionally replace `NSLayoutConstraint` objects for every provider's
    quota bar on each call to `updateMenuContentPreservingSwitcher` — even when
    usage data had not changed
  • Fixed by guarding constraint replacement with a ratio equality check
    (`newRatio != indicator.fillRatio`); tab switches with unchanged quota data
    now skip all AutoLayout work entirely
  • Added two regression tests to `StatusMenuSwitcherRefreshTests` verifying
    that constraints are preserved when the ratio is unchanged and replaced only
    when it actually changes

Root cause

`updateQuotaIndicators()` was called on every tab switch via
`updateMenuContentPreservingSwitcher`. With 10+ enabled providers this
performed O(N) `NSLayoutConstraint` deactivation + creation on the main thread
per click, blocking the menu from responding.

Branch note

This branch also carries the icon-observation refactor that overlaps with open PR #1297. The unique quota-constraint work is isolated to `StatusItemController+SwitcherViews.swift` and `StatusMenuSwitcherRefreshTests.swift`. Happy to rebase to a narrow PR targeting only those two files once #1297 is resolved — deferring to maintainer on consolidation approach.

Test plan

  • Run test suite: `swift test --filter StatusMenuSwitcherRefreshTests`
  • Run icon observation tests: `swift test --filter StatusItemIconObservationSignatureTests`
  • Switch between provider tabs (Overview / Codex / Claude / Gemini) — menu should feel instant
  • Trigger a usage data refresh — quota bar fill levels should still update correctly
  • Run lint: `./Scripts/lint.sh lint`

Test output (macOS arm64, June 5 2026)

swift test --filter StatusMenuSwitcherRefreshTests

Suite StatusMenuSwitcherRefreshTests started.
  Test "merged provider switch rebuilds stale width switcher rows" passed after 0.176 seconds.
  Test "tab switch does not replace quota indicator constraints" passed after 0.012 seconds.
  Test "quota indicator constraints are replaced when ratio changes" passed after 0.002 seconds.
Suite StatusMenuSwitcherRefreshTests passed after 0.191 seconds.
Test run with 3 tests in 1 suite passed after 0.192 seconds.
swift test --filter StatusItemIconObservationSignatureTests

Suite StatusItemIconObservationSignatureTests passed after 0.282 seconds.
Test run with 8 tests in 1 suite passed after 0.283 seconds.

All 11 tests pass, 0 failures.

Closes #1303

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open: the quota guard is source-plausible and covered by focused tests, but the PR still has no posted after-fix runtime proof and still carries icon-observation work that overlaps #1297.

Canonical path: Close this PR as superseded by #1297.

So I’m closing this here and keeping the remaining discussion on #1297.

Review details

Best possible solution:

Close this PR as superseded by #1297.

Do we have a high-confidence way to reproduce the issue?

No high-confidence runtime reproduction was established in this review. Source inspection confirms current main recreates quota fill constraints on each quota update, and the linked bug report supplies current-release macOS 26.5 lag evidence.

Is this the best way to solve the issue?

Unclear as submitted. The quota ratio guard is a narrow maintainable fix, but the branch should either be rebased to the quota files with runtime proof or explicitly consolidated with the open icon-observation PR.

Security review:

Security review cleared: No concrete security or supply-chain concern found; the diff is Swift app/test code with no dependency, workflow, secret, or release-script changes.

AGENTS.md: found and applied where relevant.

What I checked:

  • linked superseding PR: Reduce merged icon observation churn #1297 (Reduce merged icon observation churn) is still open as the canonical replacement.
  • cluster evidence: the durable review links that PR in the work cluster or recommended risk path.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • bcharleson: Authored the merged full-width provider switcher quota bar work that introduced the quota-indicator path now being optimized. (role: introduced related behavior; confidence: high; commits: 53a7f22885dc; files: Sources/CodexBar/StatusItemController+SwitcherViews.swift, Sources/CodexBar/ProviderSwitcherButtons.swift)
  • steipete: Released v0.32.4 and has recent ownership signals around the menu responsiveness/release surface touched by this PR. (role: release owner and recent area contributor; confidence: high; commits: 723734ef3422; files: CHANGELOG.md, appcast.xml, Sources/CodexBar/StatusItemController+SwitcherViews.swift)
  • hhh2210: Authored the current-main merged menu dismiss latency work and the open icon-observation PR that overlaps this branch. (role: recent adjacent area contributor; confidence: high; commits: 65e39f4dcb3a, 069d518fe5f5; files: Sources/CodexBar/StatusItemController.swift, Sources/CodexBar/StatusItemController+IconObservation.swift, Sources/CodexBar/StatusItemController+MenuRefreshScheduling.swift)
  • Perry Story: Authored the merged icon observer signature work that created the current storeIconObservationSignature surface touched by the overlapping refactor. (role: icon-observation feature history; confidence: medium; commits: d5bf26974b85; files: Sources/CodexBar/StatusItemController.swift, Sources/CodexBar/StatusItemController+Animation.swift, Tests/CodexBarTests/StatusItemIconObservationSignatureTests.swift)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 65e39f4dcb3a.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 5, 2026
@juanjoseluisgarcia
Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@steipete
Copy link
Copy Markdown
Owner

steipete commented Jun 5, 2026

Thanks @juanjoseluisgarcia. The merged icon-observation part overlapped the already-landed #1297, and I landed the remaining quota bar constraint fix in #1319: #1319, merge commit af2c754.

Because this branch could not be updated by maintainers, I carried the narrow fix in a maintainer PR. Enabling Allow edits by maintainers helps for future PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Menu bar dropdown remains unresponsive on macOS despite changelog fixes

2 participants