Fix BrainBar UI stats DB read-only mode#300
Conversation
📝 WalkthroughWalkthroughThe PR extends ChangesRead-only Database Configuration
Possibly related PRs
Poem
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
@codex review |
|
@coderabbitai review |
|
You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29b74be701
ℹ️ 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".
| targetPID: 0, | ||
| brainBusEvents: brainBusEvents | ||
| brainBusEvents: brainBusEvents, | ||
| databaseOpenConfiguration: BrainDatabase.OpenConfiguration(readOnly: true) |
There was a problem hiding this comment.
Reopen the UI stats DB after read-only startup misses
When the menu UI starts against a fresh install or a new BRAINBAR_DB_PATH before the daemon has created brainlayer.db, this read-only open cannot create the database, so BrainDatabase is left with no handle. StatsCollector.refresh() only catches notOpen and never retries openAndConfigure, so even after the daemon later creates the DB and emits bus events, the dashboard remains permanently degraded until the app is restarted. Either delay this read-only collector until the daemon DB exists or add a reopen path on refresh/events.
Useful? React with 👍 / 👎.
29b74be to
8a05bc0
Compare
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
@codex review |
|
@coderabbitai review |
|
You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor |
✅ Actions performedReview triggered.
|
|
Codex P2 follow-up fixed in 8a05bc0: added |
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
* fix: route BrainBar search through Python hybrid helper * fix: harden BrainBar hybrid helper startup * fix: address BrainBar hybrid review followups * fix: report hybrid helper launch failures * fix: keep source all unfiltered for entity routing * fix: bound hybrid helper socket waits * fix: harden hybrid helper fallback cleanup * fix: sanitize hybrid helper responses * feat: stream BrainBar brain bus events * refactor: use NSStatusItem popover shell * fix: prevent SIGPIPE from hybrid helper socket writes * fix: route BrainBar search through Python hybrid helper * fix: harden BrainBar hybrid helper startup * fix: address BrainBar hybrid review followups * fix: report hybrid helper launch failures * fix: keep source all unfiltered for entity routing * fix: bound hybrid helper socket waits * fix: harden hybrid helper fallback cleanup * fix: sanitize hybrid helper responses * feat: stream BrainBar brain bus events * refactor: use NSStatusItem popover shell * fix: prevent SIGPIPE from hybrid helper socket writes * fix: serialize BrainBus socket writes * refactor: split BrainBar daemon and UI (#298) * fix: refresh BrainBar stats before bus events * test: wait for BrainBar socket readiness * test: relax arbitration drain deadline * fix: open BrainBar UI stats database read-only (#300)
Summary
PRAGMA query_only = ON.Test plan
swift test --package-path brain-bar --filter DatabaseTests/testReadOnlyOpenConfigurationAllowsDashboardReadsButRejectsWritespytest tests/test_brainbar_build_app_guards.py -qinitializehealthyswift test --package-path brain-barNote
Medium Risk
Changes SQLite connection flags/PRAGMAs and schema-migration behavior, which could affect DB availability/locking if misconfigured, but is scoped to the UI stats reader path and covered by new tests.
Overview
Makes the BrainBar UI dashboard stats DB connection read-only so the daemon remains the sole read-write owner.
Adds
readOnlytoBrainDatabase.OpenConfiguration, opening connections withSQLITE_OPEN_READONLY+PRAGMA query_only=ON, and skipping migration/schema checks and write-oriented PRAGMAs when in read-only mode.Threads the configuration through
StatsCollector/makeStatsCollector, setsmakeUIStatsCollectortoreadOnly: true, addsreopenIfNeeded()to self-heal when the DB appears later, and adds regression tests verifying read-only reads succeed, writes fail, and the collector can reopen after the daemon creates the DB.Reviewed by Cursor Bugbot for commit 8a05bc0. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix BrainBar UI stats collector to open the database in read-only mode
readOnlysupport toBrainDatabase.OpenConfiguration, which sets SQLitequery_onlymode, adjusts cache size, and skips schema/migration checks on open.BrainBarAppSupport.makeUIStatsCollectorto passOpenConfiguration(readOnly: true)so the UI process never attempts writes to the stats DB.BrainDatabase.reopenIfNeeded()and calls it inStatsCollector.refreshso stats load once the DB becomes available after the daemon creates it.Macroscope summarized 8a05bc0.
Summary by CodeRabbit
Release Notes
New Features
Improvements
Tests