Skip to content

perf: open data-stale dropdowns in two phases (first-populateMenu off the click path)#1

Draft
hhh2210 wants to merge 753 commits into
mainfrom
claude/codex-bar-menu-lag-kd181h
Draft

perf: open data-stale dropdowns in two phases (first-populateMenu off the click path)#1
hhh2210 wants to merge 753 commits into
mainfrom
claude/codex-bar-menu-lag-kd181h

Conversation

@hhh2210

@hhh2210 hhh2210 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

Targets the acknowledged leftover of upstream steipete#1274: PR steipete#1314's scope note said "This still does not remove the first populateMenu or reuse hosting views; it eliminates the redundant closed rebuild only."

Since the merged menu is deferred-until-next-open (StatusItemController+MenuTracking.swift, steipete#1274 fix), every data-refresh tick while the menu is closed leaves it stale — so the next click pays the full populateMenu (MenuDescriptor build + NSHostingView creation + SwiftUI layout) synchronously inside menuWillOpen, before the dropdown can appear. This is the residual click latency reported after 0.32.4/0.32.5 (upstream steipete#1325 sampled populateMenu/addMenuCards as the hot frames while the menu was stuck).

Approach: two-phase open

  • menuWillOpen on a data-stale menu now attaches the existing (stale) content as-is, so the dropdown appears immediately, and schedules the rebuild via the existing scheduleOpenMenuRebuildIfStillVisible machinery — it runs right after the menu is on screen and goes through the smart-update path that preserves the provider switcher.
  • Structural / privacy / localization invalidations (anything that bumps latestRequiredMenuRebuildVersion) still rebuild synchronously before display — no stale structure is ever shown.
  • The in-flight-refresh stale-preserve path (perf: cut menu readiness signature cost on store changes steipete/CodexBar#1351 semantics) keeps precedence; refresh completion still drives the rebuild in that case.
  • Closing before the deferred rebuild runs cancels it (existing forgetClosedMenu cleanup) and re-defers the merged menu until next open.
  • Tests-only mode (isMenuRefreshEnabled == false) keeps the synchronous rebuild, since the post-display rebuild would never run without open-menu tracking.

Testing

  • Three new regression tests in StatusMenuTwoPhaseOpenTests.swift: data-stale open keeps stale content then rebuilds after display; required invalidation still rebuilds synchronously; close-before-rebuild cancels and re-defers.
  • ⚠️ Authored in a Linux container without a macOS toolchain — relying on CI for swift test. Behavior proof (peekaboo open-click timing + sample before/after, as in Cache menu card heights and skip closed merged-menu rebuild steipete/CodexBar#1314) still needs to be captured on a Mac before this is upstreamed.

Refs steipete#1274, steipete#1325, steipete#1314

https://claude.ai/code/session_01ATo2T7154YGB9ey1TuPt6B


Generated by Claude Code

Yuxin-Qiao and others added 30 commits May 24, 2026 00:26
Fix Claude CLI subscription-only /usage handling.

Claude CLI 2.1 can return only the subscription notice without quota data. Classify that as a precise no-quota parse failure, stop PTY collection on the notice, and fall back to direct CLI usage when the PTY panel times out or fails to load.

Proof:
- claude --version => 2.1.148 (Claude Code)
- direct claude /usage returns the subscription-only notice
- CodexBarCLI usage --provider claude --source cli reports the subscription-specific error
- swift test --filter 'StatusProbeTests.*subscription|TTYIntegrationTests.*subscription|ClaudeDirectUsageFallbackTests|SubprocessRunnerTests'
- make check
- autoreview --mode local clean

Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
Add zh-Hant localization resources, wire Traditional Chinese into the language picker, and credit the contributor in the changelog.

Co-authored-by: IlyaL <ilyaliao324@gmail.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Allow the valid Codex CLI Gatekeeper diagnostic where spctl reports a signed command-line binary as "rejected (the code is valid but does not seem to be an app)" while keeping higher-risk blocked signals denied.

Validated with focused PathBuilderTests, make check, local spctl reproduction against Codex CLI, and green GitHub checks.

Co-authored-by: hhh2210 <hzy2210@gmail.com>
Co-authored-by: ngutman <1540134+ngutman@users.noreply.github.com>
Avoid overcounting forked Codex sessions when parent logs are unavailable. Includes maintainer changelog credit for @jskoiz.
Preserve legacy credentials when migrated config changes fail to persist, so a later retry can recover and clean up safely. Includes maintainer changelog credit for @RajvardhanPatil07.
Label Grok usage bars from the actual billing/reset window, including the maintainer fix for late-cycle windows. Includes maintainer changelog credit for @kiankyars.
…ipete#1145)

* Improve Simplified Chinese localization for visible UI

* Fix cost labels and localization lookup

* Fix dynamic cost window labels and missing localization keys

* Fix UsageFormatter localization resources and locale

* Fix formatter locale fallback and pace resource keys

* Polish remaining zh-Hans visible labels

* Fix one-day and token KPI labels

* docs: update changelog for zh-Hans localization

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
* fix(localization): improve Traditional Chinese wording

- Refine zh-Hant strings for more natural Taiwan usage and terminology.

- Replace provider terminology with 提供者 across Traditional Chinese copy.

- Validate localized resources, placeholder parity, diff cleanliness, and high-risk term usage.

* fix(localization): localize notification copy

- Route quota warning, session depleted/restored, and login success notifications through localized strings.

- Add English and Traditional Chinese notification keys with focused notification copy tests.

- Validate with make check and focused notification/localization tests.

* test(localization): stabilize English text assertions

- Pin English-only assertions to the English localization override so local app language settings do not affect tests.

- Adjust the OpenAI web refresh test wait order to avoid a full-suite scheduling timeout.

- Verification: make check, swift test.

* docs: update changelog for zh-Hant localization

---------

Co-authored-by: Alan.Chang <alan.chang@everbot.com.tw>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
* Harden Release CLI manual dispatch [skip ci]

* Harden release tag handling [skip ci]

* Preserve manual artifact dispatches [skip ci]

* docs: update changelog for release CLI hardening

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
Deduplicate OpenAI and Mistral API spend rendering through the shared cost-history dashboard and menu path.

Co-authored-by: Zhongyue Lin <101193087+LeoLin990405@users.noreply.github.com>
Fix provider switcher keyboard shortcuts while the merged status menu is open.

- handle Cmd-number and left/right provider switcher shortcuts without closing the menu
- clean up the shortcut monitor through the shared menu close path
- keep the monitor polling nonblocking in event-tracking mode

Local proof:
- swift test --filter 'StatusMenuSwitcherClickTests|StatusMenuSwitcherRefreshTests|StatusMenuPersistentRefreshTests|SubprocessRunnerTests'
- swift test --filter StatusMenuSwitcherClickTests
- make check
- autoreview --mode branch --base origin/main

Fixes steipete#1156.
Fixes steipete#1144.

Co-authored-by: Anirudh Venkatachalam <50367124+anirudhvee@users.noreply.github.com>
Add characterization coverage for provider metadata label invariants without changing runtime behavior.

Local proof:
- swift test --filter 'ProviderLabelMetadataCharacterizationTests|ProviderRegistryTests'
- make check
- autoreview --mode branch --base origin/main

Refs steipete#804.

Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
Switch Alibaba Token Plan usage refreshes to the Bailian subscription-summary endpoint and parse its quota fields, remaining credits, expiry date, and empty-subscription state.

Proof:
- swift test --filter AlibabaTokenPlan
- make check
- autoreview --mode branch --base origin/main

Co-authored-by: YanxinXue <YanxinXue@gmail.com>
Propagate Ollama's documented 5-hour session and 7-day weekly usage windows into menu and CLI pace rendering.

Proof:
- swift test --filter 'OllamaUsageParserTests|UsagePaceTextTests|CLISnapshotTests'
- make check
- autoreview --mode branch --base origin/main --engine codex --no-web-search

Co-authored-by: bdamokos <163609735+bdamokos@users.noreply.github.com>
Polish Simplified Chinese wording and add missing notification localization keys with matching placeholders.

Proof:
- plutil -lint Sources/CodexBar/Resources/zh-Hans.lproj/Localizable.strings
- zh-Hans/en key coverage: 785/785, no duplicate keys
- make check
- autoreview --mode branch --base origin/main --engine codex --no-web-search

Co-authored-by: zhuyifan <127591871+18997392316@users.noreply.github.com>
Refresh expired StepFun Oasis tokens, persist recovered manual sessions in app and CLI paths, and recover stale cached tokens through non-cached credentials before falling back to login.

Co-authored-by: Zhongyue Lin <101193087+LeoLin990405@users.noreply.github.com>
Route resolved fork children through corrected cumulative totals, treat unresolved fork totals as untrusted replay watermarks, and force a full rescan when fork metadata appears after an incremental cache boundary.

Co-authored-by: Xu Xiang <xx205@outlook.com>
Add OpenAI Admin API project scoping via OPENAI_PROJECT_ID/providers[].workspaceID, pass project_ids to costs and completions usage requests, scrub project scope from selected token accounts, and preserve legacy billing fallback for ambient OPENAI_API_KEY setups.

Co-authored-by: Matt Stallone <mstallone@users.noreply.github.com>
Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
Fixes steipete#1170.

Shows explicit Codex CLI sign-in guidance when app-server rate-limit reads fail because the CLI is logged out, instead of collapsing that state to a temporary usage outage.

Co-authored-by: jskoiz <20649937+jskoiz@users.noreply.github.com>
Shows tertiary usage rows in widget snapshots and the legacy widget fallback for providers that expose a third usage lane.

Co-authored-by: Zhongyue Lin <101193087+LeoLin990405@users.noreply.github.com>
Yuxin-Qiao and others added 28 commits June 8, 2026 11:22
…eipete#1347)

localizedBundle()/codexBarLocalizationResourceBundle()/lprojBundle() did
Bundle(url:)/Bundle(path:) filesystem lookups on every call. Menu row bodies
re-evaluate them on every closed-menu rebuild tick on the main thread, so idle
CPU climbs. Cache the (constant) resource bundle and the resolved localized
bundle keyed on the current language; a language switch transparently
re-resolves. Single lock with compute-outside-lock keeps disk work off the
critical section and avoids re-entrant deadlock.

Co-authored-by: Cursor <cursoragent@cursor.com>
CI failed because the language-switch assertion used "ja", which has no
ja.lproj in the repo and correctly falls back to en.lproj. Use "es"
instead, which matches an actual catalog.

Co-authored-by: Cursor <cursoragent@cursor.com>
…e#1351)

Only re-anchor the readiness baseline on root menu open when the menu was
actually rebuilt or is already fresh for the current menuContentVersion.
When refreshMenuForOpenIfNeeded preserves stale content during an in-flight
provider refresh, resyncing to live store data would mask the
refresh-completion update. Add a focused regression test (negative-validated).

Co-authored-by: Cursor <cursoragent@cursor.com>
…-bundle

Cache localized bundle resolution to cut main-thread disk lookups (steipete#1347)
…asure

perf: size hosted menu charts without a throwaway hosting controller
…signature

perf: cut menu readiness signature cost on store changes
- Link T3 Chat in the provider list
- Describe the Base and Overage usage buckets
* fix: default remainingPercent to 100 for untracked Antigravity models to prevent them from dominating summary bar max quota

* fix: ignore untracked Antigravity summary quotas

---------

Co-authored-by: vibecode-vm <vcvm@servas.ai>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
When the merged menu is invalidated by data-refresh ticks while closed
(the deferred-until-next-open path from steipete#1274/steipete#1314), menuWillOpen ran
the full populateMenu - including SwiftUI hosting-view creation and
layout - synchronously on the click path before the dropdown could
appear. PR steipete#1314 deliberately scoped this out: "This still does not
remove the first populateMenu."

Attach the existing stale content immediately instead, and schedule the
rebuild from current store data through the open-menu rebuild scheduler
so it runs right after the menu is on screen. Structural, privacy, and
localization invalidations bump latestRequiredMenuRebuildVersion and
still rebuild synchronously before display, and the in-flight-refresh
stale-preserve path keeps precedence. Closing the menu before the
deferred rebuild runs cancels it and re-defers the merged menu until
its next open.

Refs steipete#1274, steipete#1325

https://claude.ai/code/session_01ATo2T7154YGB9ey1TuPt6B
SwiftFormat's redundantAsync rule flags the required-invalidation test
because it never awaits.

https://claude.ai/code/session_01ATo2T7154YGB9ey1TuPt6B
The non-merged attached menu now also keeps stale content on open and
rebuilds right after display, so assert the deferred rebuild instead of
a synchronous one.

https://claude.ai/code/session_01ATo2T7154YGB9ey1TuPt6B
@hhh2210 hhh2210 force-pushed the claude/codex-bar-menu-lag-kd181h branch from abe46ca to c39c031 Compare June 10, 2026 04:30
The two-phase open returns from refreshMenuForOpenIfNeeded while the menu
is still marked stale, so menuWillOpen skips the root-open baseline resync.
Anchor the baseline in rebuildOpenMenuIfStillVisible once the deferred
rebuild renders current store data; otherwise an open-menu store change
reverting to the pre-rebuild signature compares equal against the stale
baseline and the visible menu keeps the deferred-rebuild data.

Addresses the ClawSweeper P2 on steipete#1375.
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.