CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Serious lag for the latest release

Open xingpz2008 opened this issue 6 months ago β€’ 30 comments

Hi,

I'm experiencing serious lag after updating to the latest build (0.32.2-77), especially when hovering over one model to another. Thanks.

Hardware details:

  • MacBook Pro 14' 2021
  • M1 Pro
  • macOS 26.5

xingpz2008 avatar Jun 02 '26 06:06 xingpz2008

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 2, 2026, 9:22 AM ET / 13:22 UTC.

Summary Keep open. CodexBar 0.32.3 shipped a partial hover/open mitigation for repeated provider-icon parsing, but current main still has a source-visible redundant menu-open refresh path and the linked canonical regression plus follow-up PR are both still open.

Reproducibility: no. high-confidence live current-main reproduction is available from this review environment. Source inspection does show the remaining redundant deferred-refresh path, and multiple users reproduced the shipped 0.32.2 build 77 lag on macOS 26.x.

Ways to help us reproduce this

  • Add a screenshot or short recording showing the behavior.
  • Add expected vs actual behavior.
  • Include redacted logs or terminal output.

Next step An open related PR already targets the clearest remaining source path, and the repository profile plus no-new-fix-pr label make this a maintainer review lane rather than a new automated fix PR.

Review details

Best possible solution:

Keep this issue open with https://github.com/steipete/CodexBar/issues/1235, review or land https://github.com/steipete/CodexBar/pull/1277, and close only after a shipped build proves the hover/open lag is resolved on macOS 26.x.

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

No high-confidence live current-main reproduction is available from this review environment. Source inspection does show the remaining redundant deferred-refresh path, and multiple users reproduced the shipped 0.32.2 build 77 lag on macOS 26.x.

Is this the best way to solve the issue?

Unclear. The 0.32.3 icon-cache fix was a good partial mitigation, while the open redundant-refresh PR looks like the narrow next fix but still needs maintainer review and macOS runtime proof before this issue can close.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • A local Linux review cannot validate the macOS 26.x AppKit hover/freeze behavior; maintainer-side packaged app proof or profiling is still needed.
  • The lag likely has multiple contributors, so the shipped icon-cache mitigation may not cover slow OpenAI Web refreshes or redundant menu-open refresh scheduling.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 9e6557cc6fa6.

Label changes

Label changes:

  • add P1: Multiple users reproduced a latest-release menu lag/freeze regression, and the canonical linked regression is being handled as urgent active work.
  • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
  • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.
  • remove P2: Current review triage priority is P1, so this older priority label is no longer current.
  • remove clawsweeper:needs-info: Current issue advisory state no longer selects this label.
  • remove issue-rating: πŸ¦ͺ silver shellfish: Current issue advisory state no longer selects this label.

Label justifications:

  • P1: Multiple users reproduced a latest-release menu lag/freeze regression, and the canonical linked regression is being handled as urgent active work.
  • impact:other: The impact is severe menu lag/freeze during hover/open interactions, which is maintainer-visible but outside the specific owned impact categories.
Evidence reviewed

Acceptance criteria:

  • Review the linked PR’s focused StatusMenu tests for fresh-menu and missing-data menu-open behavior.
  • Validate a freshly packaged CodexBar.app on macOS 26.x with menu open/hover timing and redacted provider-refresh diagnostics.

What I checked:

  • Repository policy read: AGENTS.md was read in full; its guidance to prefer stable state/model seams for menu behavior and avoid live prompt-prone validation applies to this macOS menu-performance review. (AGENTS.md:1, 9e6557cc6fa6)
  • Vision fit: VISION.md says CodexBar should preserve fast refreshes and lists bounded performance improvements as merge-by-default. (VISION.md:1, 9e6557cc6fa6)
  • Partial shipped mitigation: The 0.32.3 changelog says provider brand icons are cached so merged-icon status updates no longer repeatedly parse SVG assets on the main thread during hover/open animations, referencing this report and the canonical lag report. (CHANGELOG.md:9, 9e6557cc6fa6)
  • Release provenance for partial mitigation: The Sparkle appcast publishes version 0.32.3 build 78 with the same provider-icon cache note, so the icon-cache mitigation is shipped but only partial. (appcast.xml:6, 9e6557cc6fa6)
  • Remaining redundant refresh source path: Current main still calls deferMenuInteractionRefreshIfNeeded unconditionally when scheduling menu-open refresh work, which can mark deferredMenuInteractionRefreshPending after a menu open. (Sources/CodexBar/StatusItemController+Menu.swift:1111, 9e6557cc6fa6)
  • Deferred refresh effect: When deferredMenuInteractionRefreshPending is set, the post-close task can run performStoreRefresh once menus are closed, so redundant menu-open refreshes remain plausible on current main. (Sources/CodexBar/StatusItemController+MenuInteractionRefresh.swift:67, 9e6557cc6fa6)

Likely related people:

  • Peter Steinberger: Git blame for the current menu refresh, deferred refresh, switcher hover, provider icon cache, and 0.32.3 changelog lines points to the v0.32.3 release commit by Peter Steinberger. (role: recent area contributor; confidence: high; commits: 743c3c447a8e; files: Sources/CodexBar/StatusItemController+Menu.swift, Sources/CodexBar/StatusItemController+MenuInteractionRefresh.swift, Sources/CodexBar/StatusItemController+SwitcherViews.swift)
  • hhh2210: The provided GitHub context shows hhh2210 has the open related PR that targets redundant menu-open refresh scheduling for the same regression cluster. (role: active follow-up contributor; confidence: medium; commits: d06226ec0cf4; files: Sources/CodexBar/StatusItemController+Menu.swift, Tests/CodexBarTests/StatusMenuTests.swift)
  • Yuxin-Qiao: The issue discussion says Yuxin-Qiao reproduced the same hover/model-switch lag on 0.32.2 build 77 and added diagnostics to the canonical issue. (role: diagnostic contributor; confidence: medium)
How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

clawsweeper[bot] avatar Jun 02 '26 06:06 clawsweeper[bot]

The same ;/

arminorlik avatar Jun 02 '26 08:06 arminorlik

same here

Sajjadvv avatar Jun 02 '26 09:06 Sajjadvv

I think, it's the same issue here

the last stable version is 0.29.1

aborovmind avatar Jun 02 '26 11:06 aborovmind

This looks like the same user-facing regression as #1235. I can reproduce the hover/model-switch lag on 0.32.2-77 / macOS 26.5 / M4 Air as well, so I added my extra diagnostics there to keep the evidence in one place.

Yuxin-Qiao avatar Jun 02 '26 12:06 Yuxin-Qiao

I can reproduce a severe lag/freeze path on macOS 26.5.1 with CodexBar 0.32.2 build 77.

Observed locally:

  • CodexBar itself was mostly idle in CPU/memory snapshots, so this did not look like sustained CPU burn.
  • Opening the menu / using Refresh could make the UI feel frozen; in my case keyboard input also became unresponsive briefly while the menu was open.
  • The built-in provider probe showed the main issue was the Codex/OpenAI Web refresh path:
    • CodexBarCLI --provider claude --format json: ~1.8s
    • CodexBarCLI --provider codex --format json: ~67.9s
  • Sampling CodexBar during the repro showed the main thread mostly waiting in AppKit/run loop, not doing visible CPU-heavy work.
  • WindowServer had visible spikes while interacting with the menu.

After updating to 0.32.3 build 78 from steipete/tap/codexbar:

  • CodexBarCLI --provider codex --format json dropped to ~6.6-7.7s.
  • CodexBarCLI --provider claude --format json stayed around ~1.6-2.4s.
  • The app became noticeably less disruptive.

I also enabled OpenAI Web battery saver and changed background refresh from 5 minutes to 30 minutes as a mitigation.

This seems related to the menu/refresh work in #1235 and #1277. The worst local signal was not continuous CPU usage, but a very slow Codex/OpenAI Web refresh path combined with menu interaction.

tavaresgmg avatar Jun 02 '26 12:06 tavaresgmg

As a temporary workaround, and potential trace for locating the issue:

Disable merge icon can fix the issue on my mac studio – https://github.com/steipete/CodexBar/issues/1235#issuecomment-4602369824

FFSchier avatar Jun 02 '26 13:06 FFSchier

0.32.4 still freezes on close β€” profiled it to the menu dismiss path, not the open path

Same symptom as the merged-menu reports in #1235: opening the dropdown is fine, but closing it freezes the UI for a few seconds. I'm on the latest release and it still happens, so I sampled my own process to find out where the time goes.

Setup:

  • CodexBar 0.32.4 (79), clean install of the latest release
  • macOS 26.5, Apple Silicon
  • mergeIcons = 1, refreshFrequency = oneMinute, openAIWebAccessEnabled = 1, openAIWebBatterySaverEnabled = 1

I ran sample <pid> 15 and triggered the freeze inside that window. With the menu idle, the main thread just parks in mach_msg / nextEventMatchingMask, as you'd expect. During the close, it's doing real work:

StatusItemController.rebuildClosedMenu          ~849 samples  (closure #1)
  └─ StatusItemController.populateMenu          ~493
     β”œβ”€ StatusItemController.addPrimaryMenu     ~302
     β”œβ”€ StatusItemController.addMenu            ~237+
     β”œβ”€ MenuCardItemHosting / NSHosting...      ~232   (SwiftUI hosting views)
     └─ StatusItemController.updateMenu         ~328
  └─ NSHostingView.__deallocating_deinit
       └─ GraphHost.invalidate
          └─ AGGraphInvalidate
             └─ AG::Graph::invalidate_subgraphs   (AttributeGraph teardown)

So every dismiss rebuilds the whole closed-state menu on the main thread: it repopulates the items, constructs SwiftUI MenuCardItemHosting views, then tears the AttributeGraph back down. That's the slow closed-menu population hhh2210 already flagged as left over after #1277. #1277 only dropped the redundant refresh on open, so the close rebuild was never touched, which is why it survives on 0.32.4.

It lines up with the existing workaround too: turning off Merge Icons makes the rebuild cheap enough that the freeze goes away.

Two directions that would fix the root cause:

  • Keep rebuildClosedMenu off the dismiss path. Rebuild lazily on the next open, or hand it to a background pass.
  • Cache the closed-menu hosting views instead of reconstructing them every time the menu closes.

Happy to grab the full raw sample stack if that's useful.

giuseppebisemi avatar Jun 02 '26 21:06 giuseppebisemi

0.32.4 still freezes on close β€” profiled it to the menu dismiss path, not the open path

Same symptom as the merged-menu reports in #1235: opening the dropdown is fine, but closing it freezes the UI for a few seconds. I'm on the latest release and it still happens, so I sampled my own process to find out where the time goes.

Setup:

* CodexBar 0.32.4 (79), clean install of the latest release

* macOS 26.5, Apple Silicon

* `mergeIcons = 1`, `refreshFrequency = oneMinute`, `openAIWebAccessEnabled = 1`, `openAIWebBatterySaverEnabled = 1`

I ran sample <pid> 15 and triggered the freeze inside that window. With the menu idle, the main thread just parks in mach_msg / nextEventMatchingMask, as you'd expect. During the close, it's doing real work:

StatusItemController.rebuildClosedMenu          ~849 samples  (closure #1)
  └─ StatusItemController.populateMenu          ~493
     β”œβ”€ StatusItemController.addPrimaryMenu     ~302
     β”œβ”€ StatusItemController.addMenu            ~237+
     β”œβ”€ MenuCardItemHosting / NSHosting...      ~232   (SwiftUI hosting views)
     └─ StatusItemController.updateMenu         ~328
  └─ NSHostingView.__deallocating_deinit
       └─ GraphHost.invalidate
          └─ AGGraphInvalidate
             └─ AG::Graph::invalidate_subgraphs   (AttributeGraph teardown)

So every dismiss rebuilds the whole closed-state menu on the main thread: it repopulates the items, constructs SwiftUI MenuCardItemHosting views, then tears the AttributeGraph back down. That's the slow closed-menu population hhh2210 already flagged as left over after #1277. #1277 only dropped the redundant refresh on open, so the close rebuild was never touched, which is why it survives on 0.32.4.

It lines up with the existing workaround too: turning off Merge Icons makes the rebuild cheap enough that the freeze goes away.

Two directions that would fix the root cause:

* Keep `rebuildClosedMenu` off the dismiss path. Rebuild lazily on the next open, or hand it to a background pass.

* Cache the closed-menu hosting views instead of reconstructing them every time the menu closes.

Happy to grab the full raw sample stack if that's useful.

I thought those hosting views were cached already.

0xa1d0 avatar Jun 02 '26 22:06 0xa1d0

Same here on macOS 26.5 (Tahoe).

Affected machine

  • MacBook Air (Apple M4), 32 GB RAM
  • macOS 26.5 (Tahoe)
  • CodexBar 0.32.2 (stable)
  • Symptoms: menu feels heavy/laggy; clicking Settings (and similar items) often does not open the dialog

Control machine (works fine)

  • Mac mini (Apple M4 Pro), 64 GB RAM
  • macOS 15.7.7 (Sequoia)
  • CodexBar 0.30.0 (stable)
  • No noticeable lag

Looks like a Tahoe + newer CodexBar regression to me. Happy to add a short screen recording if useful.

harunonsystem avatar Jun 03 '26 03:06 harunonsystem

Thanks for the fresh 0.32.4 sample. I think this is real and distinct from what #1277 fixed.

My current read:

  • #1277 only removed one redundant open-menu path: opening a fresh menu no longer queues a provider refresh just because the dropdown was opened.
  • Your sample points at the dismiss / closed-menu rebuild path instead: closedMenuPreparationDelay -> rebuildClosedMenuIfNeeded -> populateMenu.
  • That path can still call populateMenu on the main actor after the menu is closed, when the menu version was invalidated while the menu was open.

On the β€œaren’t hosting views cached already?” question: provider brand icons are cached now, but the menu item SwiftUI hosting views themselves are not reused across this closed rebuild. In the full rebuild branch, rebuildMenuContent removes all menu items, then makeMenuCardItem creates new MenuCardItemHostingView instances and measures them. Removing the old items also explains the NSHostingView / AttributeGraph teardown you saw in the sample.

So I would not treat #1277 as fully resolving this issue. It likely reduced refresh churn, but a remaining root cause is still: merged-menu closed rebuilds can synchronously tear down and reconstruct SwiftUI-backed menu items on the main thread. That lines up with the Merge Icons workaround.

Could you attach the full raw sample output? The most useful details would be:

sample $(pgrep -x CodexBar) 10 -file /tmp/codexbar-close.sample.txt
log show --last 2m --style compact --predicate 'process == "CodexBar" AND (eventMessage CONTAINS "slow menu operation" OR eventMessage CONTAINS "closed menu rebuild completed")'

Also useful: whether the freeze happens on every close, or only after a refresh/data change while the menu was open. That distinction determines whether the fix should be view reuse/diffing, or avoiding this closed rebuild when there is no fresh menu version to prepare.

hhh2210 avatar Jun 03 '26 05:06 hhh2210

@giuseppebisemi tagging you explicitly since your 0.32.4 close-path sample is the clearest current evidence for this remaining path. If you still have it, the full raw sample output would be very useful, especially the frames around rebuildClosedMenuIfNeeded, populateMenu, removeAllItems, MenuCardItemHostingView, and NSHostingView/AttributeGraph teardown.

hhh2210 avatar Jun 03 '26 05:06 hhh2210

For everyone hitting this: a fix for the close/dismiss freeze is in progress in #1286 (it defers the merged-menu rebuild off the dismiss path). It still needs a packaged-build check on macOS 26.x before we can call it resolved, so I'd keep this open until then.

Meanwhile, the workaround is to turn off Merge Icons in settings β€” that makes the closed-menu rebuild cheap enough that the freeze goes away.

Thanks all for the repros, and especially @giuseppebisemi for the close-path sample.

hhh2210 avatar Jun 03 '26 05:06 hhh2210

@hhh2210 thanks, that matches what I'm seeing. Answering your two asks.

Every close, or only after a refresh while open? Every close. I captured a deliberately fast open-then-close (well under a second, no time for a refresh to land while the menu was up) and the heavy path still fires:

665  StatusItemController.rebuildClosedMenuIfNeeded(_:)  (closure #1)
 376  StatusItemController.populateMenu(_:provider:)
  230  StatusItemController.addPrimaryMenuContent(to:context:switcherSelection:)
   194  StatusItemController.addMenuCards(to:context:)
    181  StatusItemController.addMenuCardSections(to:model:provider:width:webItems:)
         MenuCardItemHostingView.measuredHeight(width:)   -> NSHostingView.__allocating_init(rootView:)

So it isn't gated on a menu-version invalidation. Even with no data change while the menu was open, the dismiss tears down the old items and makeMenuCardItem rebuilds + remeasures fresh MenuCardItemHostingView instances. That points away from "skip the closed rebuild when there's no fresh version" as a complete fix, and toward view reuse/diffing or moving the rebuild off the dismiss path. #1286 deferring it sounds right.

Log predicate: your log show came back empty for me. CodexBar 0.32.4 (79) emits no unified-log entries at all in my capture, even with --info --debug, so "slow menu operation" / "closed menu rebuild completed" aren't surfacing here. If those are behind a build flag or a private logger, I can re-run with whatever you need.

Full sample attached. Captured the way you suggested, with a slightly longer window:

sample $(pgrep -x CodexBar) 12 -file ...

0.32.4 (79), macOS 26.5, Apple Silicon, Merge Icons on. It includes the frames you asked about: rebuildClosedMenuIfNeeded, populateMenu, the addMenuCards / addMenuCardSections build, MenuCardItemHostingView.measuredHeight, and the NSHostingView.__deallocating_deinit -> GraphHost.invalidate -> AGGraphInvalidate teardown of the previous tree. Sample counts are occupancy within the window, so read them as relative weight.

Happy to test a packaged #1286 build on this machine (26.5, Merge Icons on) once it's available.

sample-0.32.4-close-FULL.txt

giuseppebisemi avatar Jun 03 '26 07:06 giuseppebisemi

same here,

Hardware details:

  • 16-inch, M5 Pro
  • Apple M5 Pro
  • macOS 26.4

Build details:

  • Version 0.32.4 (79)
  • Built 2 Jun 2026 at 16:38

darkbringer1 avatar Jun 03 '26 08:06 darkbringer1

Same issue. Ran an xctrace (Time Profiler + Hangs) reproducing the lag.

Build: 0.32.4 (build 79) β€” commit edf3d8da

Hardware / Software:

  • MacBook Pro 2021 (MacBookPro18,2)
  • Apple M1 Max (10 cores: 8P + 2E)
  • 64 GB memory
  • macOS 26.3.1 (25D2128)

CodexBar.trace.zip

nandorocker avatar Jun 03 '26 09:06 nandorocker

I symbolicated @nandorocker's CodexBar.trace against the 0.32.4 (79) binary and it lines up with my close-path sample. Same build (the trace carries the same Mach-O UUID 6A19B1DB-… as the shipped binary), two different machines, and the cost lands in the same place.

What's interesting is that we each hit the bottleneck from a different direction:

  • My sample caught the dismiss path: rebuildClosedMenuIfNeeded β†’ populateMenu.
  • Nando's trace caught the open / while-visible path: rebuildOpenMenuIfStillVisible β†’ scheduleOpenMenuRebuildIfStillVisible β†’ populateMenu. rebuildClosedMenuIfNeeded never shows up in his run.

Both funnel into the same core. From his symbolicated Time Profiler (inclusive samples, 1229 main-thread samples in a 39s window):

217  StatusItemController.populateMenu(_:provider:)
171  rebuildOpenMenuIfStillVisible / scheduleOpenMenuRebuildIfStillVisible
112  updateMenuContentPreservingSwitcher  +  NSHostingView.layout()
 98  GraphHost.runTransaction
 85  addPrimaryMenuContent
 60  addMenuCards
 38  MenuCardItemHostingView.measuredHeight(width:)
 31  addMenuCardSections
 29  makePersistentMenuActionItem
  6  NSHostingView.__deallocating_deinit  /  4 AGGraphInvalidate

So the expensive thing isn't specific to close. It's the menu rebuild itself: populateMenu reconstructs the items, addMenuCardSections builds the cards, and MenuCardItemHostingView.measuredHeight allocates a fresh NSHostingView per card just to read a height, with GraphHost/AttributeGraph churn around it. That core runs on every open-while-visible rebuild and again on every dismiss.

One more thing from his trace: the Hangs instrument (250ms threshold) recorded zero hangs, and hang-risks is empty too. That fits what we're seeing rather than contradicting it. There's no single long block. It's many short populateMenu rebuilds, each under 250ms on his machine, which is why it reads as general sluggishness instead of one frozen beachball, and why it gets much worse with more providers in the merged menu.

Net: #1286 deferring the closed rebuild off the dismiss path will help the close case, but the same populateMenu + per-card measuredHeight hosting-view work is also the open-menu cost. Reusing/diffing the hosting views or caching measured heights (keyed on width + content) would cut both at once.

One practical note: I'd keep #1274 open even after #1286 merges. It takes the rebuild off the dismiss path, but the open-path populateMenu / measuredHeight cost above is untouched, so the hover / while-open lag others are reporting here would still be live.

giuseppebisemi avatar Jun 03 '26 10:06 giuseppebisemi

Update from the PR side after reading the newer samples/traces here: I do not think this should be considered fully resolved by the earlier #1277 fix, and #1286 is now scoped to cover more of the remaining shared rebuild cost.

Current read of the evidence:

  • @giuseppebisemi's sample caught the dismiss path: rebuildClosedMenuIfNeeded -> populateMenu -> MenuCardItemHostingView plus NSHostingView / AttributeGraph teardown.
  • @nandorocker's trace caught the open/while-visible path, but it funnels into the same populateMenu / SwiftUI-hosted menu-card construction and measurement work.
  • The Hangs instrument showing no >250ms hangs fits this: users can still feel sluggishness from many short main-thread rebuilds, especially with Merge Icons and multiple providers.

What changed in #1286 now:

  • The close/dismiss rebuild is still deferred off the user dismiss path.
  • The smart-update path reuses the already-built MenuDescriptor instead of building it twice.
  • Menu-card height measurements are cached, but now provider/content scoped so same-version provider switches cannot reuse the wrong height.
  • Switcher-triggered open-menu rebuilds now get a short debounce, so rapid provider/account switching coalesces before calling populateMenu again.

Current-head local proof on my macOS 26.5 machine, using an ad-hoc signed build from #1286 head 15ea6579:

cycle 1: open=114ms dismiss=156ms close-path main-thread: idle/no close rebuild frames
cycle 2: open=130ms dismiss=152ms close-path main-thread: idle/no close rebuild frames
cycle 3: open=172ms dismiss=144ms close-path main-thread: idle/no close rebuild frames
swift test --filter StatusMenuHeightCacheTests      # 2 passed
swift test --filter StatusMenuOpenRefreshTests      # 29 passed
make check                                          # 0 lint violations

I would still keep this issue open after #1286 unless affected machines confirm the shipped build feels good. The deeper remaining target is making first-time populateMenu / SwiftUI hosting construction cheaper, but #1286 should remove the close freeze and reduce repeated open/while-visible rebuild churn.

@giuseppebisemi you offered to test a packaged build on 26.5 with Merge Icons on; current PR head is the useful one to test now. @nandorocker your trace was the clearest open/while-visible evidence, so a retest against #1286 head would be especially helpful too.

hhh2210 avatar Jun 03 '26 14:06 hhh2210

@hhh2210 I built #1286 head (15ea657, 0.32.5) and tested it on macOS 26.5. Two findings.

The close fix works. Dismissing the merged menu went from a multi-second freeze to near-instant, and the close-path rebuild no longer runs on the synchronous dismiss β€” it's a deferred MainActor task now, so the menu closes cleanly.

But with Merge Icons on I still hit the general menubar lag others are reporting, and it's a different path from the menu rebuild. Sampling points at the status-item icon observation, not the menu:

observeStoreIconChanges
  └─ storeIconObservationSignature
       └─ providerStoreIconObservationSignature   (StatusItemController.swift:460–512)

On every store change it builds a full string "signature" across all providers β€” including String(describing: snapshot) for each provider plus the Codex credit projection β€” on the main thread, only to decide whether the icon actually changed. With Merge Icons and a few providers plus minute-interval refreshes, that recompute runs more or less constantly.

The Merge Icons toggle confirms it. With Merge Icons off the icon path drops out of the sample entirely and the lag is gone for me, even though the deferred per-provider menu rebuilds get heavier (closing separate provider menus routes through rebuildClosedMenuIfNeeded instead of the merged-menu deferral). So the residual lag isn't the menu rebuild #1286 defers β€” it's the icon-signature recompute.

Net: #1286 is the right fix for the close freeze, but I'd keep #1274 open. The Merge-Icons lag has a second source in the icon observation path. Caching or short-circuiting that signature, or not stringifying the whole snapshot to compute it, looks like the next target.

giuseppebisemi avatar Jun 03 '26 15:06 giuseppebisemi

Merge Icons off the icon path drops out of the sample entirely and the lag is gone for me, even though the deferred per-provider menu rebuilds get heavier (closing separate provider menus routes through rebuildClosedMenuIfNeeded instead of the merged-menu deferral). So the residual lag isn't the menu rebuild #1286 defers β€” it's the icon-signature recompute.

Net: #1286 is the right fix for the close freeze, but I'd keep #1274 open. The Merge-Icons lag has a second source in the icon observation path. Caching or short-circuiting that signature,

Thank you for the additional information.

It is time for me to go to bed🀣, but I will look into that issue again tomorrow. Thank you for discussing this with me.

hhh2210 avatar Jun 03 '26 16:06 hhh2210