Skip to content

feat: wire Injection Viewer + KG into BrainBar UI#163

Merged
EtanHey merged 2 commits intomainfrom
feat/wire-injection-kg-ui
Mar 31, 2026
Merged

feat: wire Injection Viewer + KG into BrainBar UI#163
EtanHey merged 2 commits intomainfrom
feat/wire-injection-kg-ui

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented Mar 31, 2026

Summary

  • Adds Dashboard / Injections / Graph tabbed segmented control to the BrainBar status popover
  • Wires the existing InjectionFeedView (PR Phase 4: BrainBar injection viewer #158) and KGCanvasView (PR feat: BrainBar Knowledge Graph viewer #159) into navigable tabs — previously these views existed but had zero entry points
  • Popover auto-resizes per tab (360×350 → 360×440 → 620×500)
  • Tabs auto-disable when dependencies (InjectionStore / BrainDatabase) are unavailable
  • 13 new tests in PopoverTabTests

Files Changed

File What
StatusPopoverView.swift Added PopoverTab enum, segmented control, lazy SwiftUI hosting for injection/graph tabs
BrainBarApp.swift Passes injectionStore + sharedDatabase to popover, wires resize callback
PopoverTabTests.swift 13 tests: enum, segmented control, tab switching, backward compat

Test plan

  • swift test --package-path brain-bar — 225/225 pass
  • build-app.sh — builds and installs to /Applications/BrainBar.app
  • Manual: click brain icon → verify 3-tab segmented control appears
  • Manual: switch to Injections tab → verify InjectionFeedView renders with filter
  • Manual: switch to Graph tab → verify KGCanvasView renders with force-directed layout
  • Manual: switch back to Dashboard → verify metrics still update live

@coderabbitai review

🤖 Generated with Claude Code

Note

Add tabbed Injection Viewer and Knowledge Graph to BrainBar popover UI

  • Adds a PopoverTab enum with three cases (dashboard, injections, graph), each defining a label and preferred NSPopover content size.
  • Expands StatusPopoverView with a segmented control for tab navigation; tabs are disabled when their dependencies (InjectionStore, BrainDatabase) are absent.
  • The popover dynamically resizes when the active tab changes via an onPreferredSizeChange callback wired in BrainBarApp.swift.
  • Adds SwiftUI PopoverInjectionTab (wraps InjectionFeedView, calls store.start() on open) and PopoverGraphTab (renders KGCanvasView via KGViewModel).
  • Updates the landing page with a new BrainBar section, raises the listed tool count from 7 to 11, and refreshes footer copy.
📊 Macroscope summarized 100d3e4. 4 files reviewed, 3 issues evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues

Summary by CodeRabbit

  • New Features

    • Added tabbed popover interface with Dashboard, Injections, and Knowledge Graph tabs that resize dynamically
    • Updated landing page to showcase BrainBar features with card layout and expanded tool entries
  • Tests

    • Added test suite validating popover tab functionality and UI interactions

EtanHey and others added 2 commits March 31, 2026 20:00
…inks

- Updated tool count from 7 to 11 (added brain_ack, brain_expand,
  brain_tags, brain_update)
- Added BrainBar section showcasing native macOS companion app:
  Cmd+K search, dashboard, knowledge graph viewer, injection viewer
- Updated footer with Golems ecosystem links (cmuxLayer, VoiceLayer)
- Added responsive breakpoint for BrainBar grid

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…over tabs

Adds a 3-tab segmented control (Dashboard / Injections / Graph) to
StatusPopoverView so users can actually access the InjectionFeedView
and KGCanvasView that were merged in PRs #158 and #159 but had no
navigation entry point.

- PopoverTab enum drives labels, sizes, and tab state
- Tabs without dependencies (injectionStore/database) are auto-disabled
- Popover resizes per tab via onPreferredSizeChange callback
- 13 new tests in PopoverTabTests covering enum, segmented control,
  tab switching, and backward compatibility

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 31, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Introduces a tabbed popover UI to BrainBar with three tabs (dashboard, injections, graph), each with distinct content and sizing. Implements dynamic popover resizing based on selected tab, adds optional InjectionStore and BrainDatabase support, and includes new SwiftUI wrapper views for injections and graph visualization along with comprehensive tests.

Changes

Cohort / File(s) Summary
BrainBar Popover Core
BrainBarApp.swift
Updated popover initialization to use PopoverTab.dashboard.contentSize, pass injectionStore and database to StatusPopoverView, and implement dynamic sizing via onPreferredSizeChange callback.
StatusPopoverView & Tabs
StatusPopoverView.swift
Introduced PopoverTab enum with three cases (dashboard, injections, graph), each with label and contentSize. Expanded StatusPopoverView to accept optional injectionStore and database, replaced hard-coded layout with showTab(_:) method, added lazy content builders for each tab, introduced segmented control with conditional segment enablement, and added PopoverInjectionTab and PopoverGraphTab SwiftUI wrappers.
Popover Tests
PopoverTabTests.swift
New test suite validating PopoverTab API (cases, raw values, labels, sizes), segmented control presence and segment enablement behavior based on dependencies, StatusPopoverView size tracking across tab switches, and current tab state management.
Landing Page
landing/index.html
Added "Native macOS" section with four BrainBar feature cards (Cmd+K search, Dashboard, Knowledge graph, Injection viewer), updated Tools section heading and added four new tool entries (brain_ack, brain_expand, brain_tags, brain_update), and updated footer attribution and links.

Sequence Diagram

sequenceDiagram
    participant User
    participant SegmentedControl as UI: Segmented<br/>Control
    participant StatusPV as StatusPopoverView
    participant ContentBuilder as Content Builders
    participant BrainBarApp

    User->>SegmentedControl: Select tab (e.g., Injections)
    SegmentedControl->>StatusPV: tabChanged(_:)
    activate StatusPV
    
    alt Dependencies available
        StatusPV->>ContentBuilder: makeInjectionContent()
        ContentBuilder->>ContentBuilder: Create NSHostingController<br/>with PopoverInjectionTab
        ContentBuilder-->>StatusPV: Return content view
    else Dependencies missing
        StatusPV->>ContentBuilder: makePlaceholder(_:)
        ContentBuilder-->>StatusPV: Return unavailable message
    end
    
    StatusPV->>StatusPV: Remove old subviews<br/>Add new content to containerView
    StatusPV->>StatusPV: Update preferredContentSize<br/>to PopoverTab.contentSize
    StatusPV->>StatusPV: Call onPreferredSizeChange
    deactivate StatusPV
    
    StatusPV->>BrainBarApp: onPreferredSizeChange callback
    BrainBarApp->>BrainBarApp: Update popover?.contentSize
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 Tabs now flutter like clover in the breeze,
Dashboard, injections, graphs with ease—
Popovers dance to a segmented beat,
Dynamic sizing makes the UI complete! 🌳✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: wiring the Injection Viewer and Knowledge Graph into the BrainBar UI via a segmented control.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wire-injection-kg-ui

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.

Comment on lines +98 to +100
func showTab(_ tab: PopoverTab) {
containerView.subviews.forEach { $0.removeFromSuperview() }
currentTab = tab
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium Dashboard/StatusPopoverView.swift:98

When showTab(_:) is called programmatically, it updates currentTab and swaps the container content, but it never updates segmentedControl.selectedSegment. The segmented control continues to highlight the previous tab while displaying content for the new tab, leaving the UI in an inconsistent state. Consider setting segmentedControl.selectedSegment = tab.rawValue at the start of showTab(_:) to keep the control synchronized with the displayed content.

    func showTab(_ tab: PopoverTab) {
+        segmentedControl.selectedSegment = tab.rawValue
         containerView.subviews.forEach { $0.removeFromSuperview() }
         currentTab = tab
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file brain-bar/Sources/BrainBar/Dashboard/StatusPopoverView.swift around lines 98-100:

When `showTab(_:)` is called programmatically, it updates `currentTab` and swaps the container content, but it never updates `segmentedControl.selectedSegment`. The segmented control continues to highlight the previous tab while displaying content for the new tab, leaving the UI in an inconsistent state. Consider setting `segmentedControl.selectedSegment = tab.rawValue` at the start of `showTab(_:)` to keep the control synchronized with the displayed content.

Evidence trail:
brain-bar/Sources/BrainBar/Dashboard/StatusPopoverView.swift lines 98-123 (showTab method does not update segmentedControl.selectedSegment), lines 127-144 (configureSegmentedControl sets initial segment), lines 145-148 (tabChanged action calls showTab). brain-bar/Tests/BrainBarTests/PopoverTabTests.swift lines 151, 154, 157, 177 (tests call showTab programmatically).

@EtanHey EtanHey merged commit 51755cf into main Mar 31, 2026
2 of 6 checks passed
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