Skip to content

fix: restore quick capture panel actions#149

Merged
EtanHey merged 2 commits intomainfrom
feat/fix-capture-actions
Mar 30, 2026
Merged

fix: restore quick capture panel actions#149
EtanHey merged 2 commits intomainfrom
feat/fix-capture-actions

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented Mar 30, 2026

Summary

  • route quick capture key handling through an AppKit text view so Enter, Cmd+Enter, Tab, and arrow navigation work from the live input surface
  • wire the quick capture panel to the real BrainBarServer BrainDatabase instance instead of opening a separate database connection
  • support wrapped multi-line search input, copy search result content on double-click, and add regression coverage for command routing and shared-db wiring

Test plan

  • cd brain-bar && swift test
  • cd brain-bar && swift test --filter 'QuickCapturePanelTests/(testHandleInputReturnInCaptureModeStoresAndTriggersConfirmationFlash|testSubmitSearchPublishesResults|testBrainBarServerUsesProvidedDatabaseInstance)'

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Summary by CodeRabbit

  • New Features

    • Added ability to copy search results directly to clipboard from Quick Capture.
    • Added placeholder text display in the input field for improved UX.
  • Improvements

    • Enhanced keyboard handling for better input field responsiveness.
    • Adjusted input field sizing based on search vs. capture mode.
    • Improved Quick Capture panel initialization timing for better reliability.

Note

Restore quick capture panel actions with shared database and multi-line input

  • Introduces a shared BrainDatabase instance passed from AppDelegate into BrainBarServer, with panel creation deferred until the server fires an onDatabaseReady callback.
  • Replaces the NSTextField-based input with an NSTextView subclass (KeyHandlingTextView) to enable reliable Tab/Return/Arrow keyboard routing and multi-line input.
  • Adds copyResultToClipboard to QuickCaptureViewModel so activating a search result copies its content to the clipboard with confirmation feedback, replacing the previous capture-mode switch.
  • QuickCapturePanelController now supports both owned and shared database connections, only closing the database on teardown if it opened it.
  • Risk: the hotkey is registered immediately on launch but the quick capture panel is nil until the server signals database readiness, so hotkey presses during startup are silently ignored.

Macroscope summarized c9f6fca.

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 Mar 30, 2026

@coderabbitai review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Mar 30, 2026

@codex review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Mar 30, 2026

@cursor @BugBot review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Mar 30, 2026

@greptileai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 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.

@cursor
Copy link
Copy Markdown

cursor Bot commented Mar 30, 2026

Perfect! Now let me create a final summary comment for the user:

BugBot Review Complete ✅

I've completed a comprehensive bug-focused review of PR #149 ("fix: restore quick capture panel actions"). Here's what I found:

🔴 Critical Issue - Must Fix Before Merge

Async Initialization Race Condition: The F4 hotkey is registered immediately on app launch, but the Quick Capture panel is only created after the database finishes opening (async). On slow machines or with large databases, pressing F4 within the first 1-2 seconds will silently fail.

Recommended Fix (simplest):

private func configureQuickCapture(database: BrainDatabase) {
    guard quickCapturePanel == nil else { return }
    quickCapturePanel = QuickCapturePanelController(db: database)
    
    // Start hotkey AFTER panel is ready
    if let hotkey = quickCaptureHotkey {
        _ = hotkey.start()
    }
}

What's Excellent About This PR

  1. Shared Database Architecture - Eliminates duplicate SQLite connections, prevents concurrency bugs
  2. Proper Keyboard Routing - NSTextView + doCommand is the correct AppKit pattern
  3. Multi-line Text Support - Users can now paste code snippets and long queries
  4. Comprehensive Test Coverage - 5 new tests validate all new behaviors
  5. Better UX - Double-click now copies search results to clipboard

🟡 Minor Issues (Non-Blocking)

  1. Placeholder is 4px misaligned (visual polish)
  2. Dual-init pattern could be clearer for future maintainers

📄 Review Documents

I've created two documents and pushed them to the branch:

  1. BUGBOT_REVIEW_RESTORE_CAPTURE_ACTIONS.md - Full detailed review (797 lines)

    • Detailed code analysis
    • Architecture diagrams
    • Test recommendations
    • Follow-up work suggestions
  2. BUGBOT_REVIEW_SUMMARY_RESTORE_CAPTURE.md - Executive summary (236 lines)

    • TL;DR of critical issues
    • Quick fix recommendations
    • Risk assessment table

Final Verdict

CONDITIONALLY APPROVED - Fix the race condition, then merge immediately. The core changes are solid and well-tested. Minor issues can be addressed in follow-up PRs.

Open in Web Open in Cursor 

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 15 minutes and 0 seconds.

⌛ 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: 4ff85d77-2dff-4cb5-8b6a-f9bf07d82cca

📥 Commits

Reviewing files that changed from the base of the PR and between 315a67f and c9f6fca.

📒 Files selected for processing (1)
  • BUGBOT_REVIEW_RESTORE_CAPTURE_ACTIONS.md
📝 Walkthrough

Walkthrough

The PR refactors the app's database initialization to use dependency injection: AppDelegate creates a shared BrainDatabase and passes it to BrainBarServer, which now accepts an optional database parameter instead of always creating its own. QuickCapturePanel initialization is deferred until the server signals database readiness via a new onDatabaseReady callback. Additionally, QuickCapturePanel gains clipboard integration for copying search results and upgrades the input field from NSTextField to NSTextView with improved keyboard routing.

Changes

Cohort / File(s) Summary
Database Initialization & Dependency Injection
BrainBarApp.swift, BrainBarServer.swift
AppDelegate creates shared BrainDatabase and passes it to BrainBarServer via new database parameter. Server uses injected instance when present, avoids closing injected databases, and exposes onDatabaseReady callback. QuickCapturePanel creation deferred until server signals readiness.
Quick Capture UI & Clipboard Integration
QuickCapturePanel.swift
Introduces QuickCaptureClipboard abstraction and SystemQuickCaptureClipboard implementation. Adds copyResultToClipboard method to ViewModel. Replaces NSTextField with NSTextView using doCommand(by:) for improved keyboard routing. Adds ownsDatabase flag to controller for external database lifetime management. Implements SwiftUI placeholder rendering.
Tests
QuickCapturePanelTests.swift
Adds test helpers (TestClipboard, DatabaseBox) and test coverage for keyboard command routing in KeyHandlingTextView, clipboard behavior, input handling (tab/return keystroke processing), and server database injection.

Sequence Diagram

sequenceDiagram
    participant AppDelegate
    participant BrainBarServer
    participant QuickCapturePanel
    participant ViewModel
    participant Clipboard

    rect rgba(100, 150, 200, 0.5)
    Note over AppDelegate,QuickCapturePanel: New Flow: Database Injection & Deferred Panel Init
    AppDelegate->>AppDelegate: Create shared BrainDatabase
    AppDelegate->>BrainBarServer: init(database: shared db)
    BrainBarServer->>BrainBarServer: Use injected database
    BrainBarServer->>AppDelegate: onDatabaseReady callback
    AppDelegate->>QuickCapturePanel: Create with db (when ready)
    QuickCapturePanel->>ViewModel: init(db, clipboard)
    end

    rect rgba(200, 150, 100, 0.5)
    Note over ViewModel,Clipboard: Clipboard Integration Flow
    ViewModel->>ViewModel: copyResultToClipboard(id)
    ViewModel->>Clipboard: copy(text)
    Clipboard->>Clipboard: Write to NSPasteboard
    ViewModel->>ViewModel: Set .success feedback
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 A database hops, now shared with care,
From panel to server, everywhere!
The clipboard catches what rabbits find,
Text views route commands, so swift and refined.
Dependencies injected—ready, set, go!
Chef's kiss 🍂✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 PR title 'fix: restore quick capture panel actions' directly aligns with the primary changes—restoring keyboard handling and command routing for the quick capture panel through a new text view implementation and database wiring improvements.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fix-capture-actions

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


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.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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.

Co-authored-by: Etan Heyman <EtanHey@users.noreply.github.com>
@EtanHey EtanHey merged commit b91dbf3 into main Mar 30, 2026
2 of 5 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.

2 participants