Skip to content

refactor: use NSStatusItem popover shell#296

Merged
EtanHey merged 1 commit into
fix/brainbar-hybrid-parityfrom
refactor/nsstatusitem-popover
May 18, 2026
Merged

refactor: use NSStatusItem popover shell#296
EtanHey merged 1 commit into
fix/brainbar-hybrid-parityfrom
refactor/nsstatusitem-popover

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented May 18, 2026

Summary

  • Replace the active SwiftUI MenuBarExtra shell with a prewarmed AppKit NSStatusItem + transient NSPopover wrapper.
  • Keep the existing SwiftUI BrainBar content tree by hosting BrainBarWindowRootView inside NSHostingController; no dashboard/content rewrite.
  • Route dashboard/search/capture requests through the prewarmed popover and keep StatsCollector wired to BrainBusClient from item feat(engine): Think/Recall/Sessions intelligence layer #5.

Stacking

Stacked on Phase D IPC foundation / Lane B item #5 via fix/brainbar-hybrid-parity. This assumes PR #295's watch-brain-bus push path is present.

Responsiveness Notes

  • Popover and hosting controller are instantiated at app launch, before first click.
  • Status item uses NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength).
  • First-click work is limited to popover.show(...) against already-loaded content.
  • I ran a lightweight simulated-load check with 10 yes workers around the prewarm XCTest. It passed, but this is not a real pointer-click p95 measurement; a human stage-demo click test is still the right final proof.

No UI Polling

  • No MenuBarExtra scene remains in BrainBarApp.
  • This PR does not add timers or polling loops.
  • The app collector factory explicitly injects BrainBusClient() so dashboard state remains push-driven over watch-brain-bus.

Test Plan

  • TDD RED: swift test --package-path brain-bar --filter BrainBarStatusPopoverControllerTests initially failed because BrainBarStatusPopoverController and BrainBarAppSupport.makeStatsCollector did not exist.
  • Focused GREEN: swift test --package-path brain-bar --filter BrainBarStatusPopoverControllerTests -> 2 tests passed.
  • Simulated CPU load: 10 yes >/dev/null workers + swift test --package-path brain-bar --filter BrainBarStatusPopoverControllerTests/testControllerPrewarmsVariableLengthStatusItemPopover -> passed.
  • Full Swift suite: swift test --package-path brain-bar -> 362 tests passed, 0 failures.
  • Pre-push BrainLayer gate: pytest unit suite 2016 passed, 9 skipped, 75 deselected, 1 xfailed; MCP registration 3 passed; isolated eval/hook routing 32 passed; bun stale index 1 passed; FTS5 determinism shell regression PASS.

Review Caveat

Local cr review --plain could not start because CodeRabbit CLI was rate-limited externally.


Note

Medium Risk
Moderate risk because it changes the primary menu bar UI surface and toggle/show routing, which could affect app visibility/interaction and lifecycle cleanup despite largely reusing existing SwiftUI content.

Overview
Replaces the SwiftUI MenuBarExtra-based menu bar shell with an AppKit NSStatusItem + transient NSPopover wrapper that is prewarmed at launch and hosts the existing BrainBarWindowRootView.

Updates AppDelegate to create/stop the new BrainBarStatusPopoverController in .menuBarWindow mode and route toggle/search/capture/dashboard actions through it, and factors StatsCollector construction into BrainBarAppSupport.makeStatsCollector to allow injection/testing while keeping BrainBusClient wired.

Adds focused XCTest coverage to verify popover prewarming/configuration and that the collector factory requests the BrainBus event stream.

Reviewed by Cursor Bugbot for commit 740e90c. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Replace SwiftUI MenuBarExtra with NSStatusItem popover shell in BrainBar

  • Replaces the SwiftUI MenuBarExtra scene with an imperative BrainBarStatusPopoverController that manages an NSStatusItem and a transient NSPopover hosting BrainBarWindowRootView.
  • In .menuBarWindow launch mode, AppDelegate now creates a BrainBarStatusPopoverController on launch; quick actions (search, capture, dashboard) route to its show/toggle APIs instead of focusing a menu bar window.
  • The status item button displays a live-updating sparkline image driven by BrainBarRuntime.$collector stats.
  • Adds a BrainBarAppSupport.makeStatsCollector factory and tests verifying popover prewarming and single-subscription behavior of the event stream.
  • Behavioral Change: the SwiftUI MenuBarExtra scene and BrainBarMenuBarLabel view are removed; menu bar integration is now fully imperative.

Macroscope summarized 740e90c.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@EtanHey has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 37 minutes and 32 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5d0aa655-a50b-4d75-a30c-21e4d63b462b

📥 Commits

Reviewing files that changed from the base of the PR and between 82d02ae and 740e90c.

📒 Files selected for processing (3)
  • brain-bar/Sources/BrainBar/BrainBarApp.swift
  • brain-bar/Sources/BrainBar/BrainBarStatusPopoverController.swift
  • brain-bar/Tests/BrainBarTests/BrainBarStatusPopoverControllerTests.swift
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/nsstatusitem-popover

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 and usage tips.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 18, 2026

@coderabbitai review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 18, 2026

@cursor @BugBot review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 18, 2026

@codex review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 18, 2026

@greptileai review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 18, 2026

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 740e90c1b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


runtime.presentQuickAction(.search)
showMenuBarWindow(nil)
statusPopoverController?.show(nil)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Show popover before delivering quick actions

When Cmd-K/search is invoked while the prewarmed popover is closed and the DB is ready, runtime.presentQuickAction(.search) is published before this show call. Because the hosting view was already loaded, BrainBarWindowRootView can consume and clear the request while its text field still has no window; the async focus attempt then sees nsView.window == nil, and the popover opens without the command bar focused. The capture path has the same ordering, so route the request after the popover is visible or defer focus until the popover window exists.

Useful? React with 👍 / 👎.

@EtanHey EtanHey merged commit d984f06 into fix/brainbar-hybrid-parity May 18, 2026
3 checks passed
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 740e90c. Configure here.

values: stats.recentEnrichmentBuckets,
size: NSSize(width: 22, height: 12),
accentColor: livePresentation.accentColor
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status item brain icon replaced entirely by sparkline

Medium Severity

The renderStatusIcon method overwrites button.image with only the sparkline, completely losing the brain icon set in configureStatusItem. The removed BrainBarMenuBarLabel displayed both a brain icon AND the sparkline side-by-side via an HStack. Once the collector publishes stats, the status item loses its app identifier and shows only a tiny 22×12 sparkline chart, which is a visual regression for the default .menuBarWindow mode.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 740e90c. Configure here.

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