fix(brainbar): report live agent and write signals#474
Conversation
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.
|
@greptileai review |
|
@codex review |
|
@coderabbitai review |
📝 WalkthroughWalkthroughAgentActivityMonitor now detects agent family using both process executable and command tokens, adds entrypoint exemptions and cursor-session detection, updates wrapper detection, expands agent-related unit tests, and adds created_at and recent-write assertions to a database chunk test. ChangesAgent Detection and Validation
Possibly related PRs
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 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 |
|
You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor |
✅ Action performedReview finished.
|
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.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fad37ba72
ℹ️ 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".
| if command.hasPrefix("codex ") || command.contains("/codex/codex ") || command.contains(" brainlayercodex") { | ||
| if command.hasPrefix("codex ") | ||
| || command.contains("/codex/codex ") | ||
| || (command.contains("/bin/codex ") && !command.contains("/.bun/bin/codex ")) |
There was a problem hiding this comment.
Exclude Codex shims from actual counts
When Codex is started through a non-Bun package-manager shim such as node /usr/local/bin/codex ..., the native child is already matched by the existing /codex/codex branch, but this added /bin/codex branch also counts the shim as an actual Codex process because only /.bun/bin/codex is excluded. In that scenario the dashboard reports two Codex agents for one session; this path should be treated as a wrapper or broader shim exclusions should be applied before incrementing actualCounts.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in commit 854f89d. Actual-family detection now receives the process executable and only treats /bin/codex as actual Codex when ucomm is codex, so non-Codex launcher rows such as node /opt/homebrew/bin/codex ... are excluded from actual counts. Added testParseSnapshotDoesNotTreatNonCodexLauncherAsActualCodex to cover this.
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.
|
@coderabbitai review |
|
@codex review |
|
You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor |
✅ Action performedReview finished.
|
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ 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". |
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.
|
@coderabbitai review |
|
@codex review |
|
You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor |
✅ Action performedReview finished.
|
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ 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". |
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.
|
@coderabbitai review |
|
@codex review |
|
You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54428013d9
ℹ️ 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".
| for index in tokens.indices where tokens[index] == "--model" && index + 1 < tokens.endIndex { | ||
| let model = tokens[index + 1] | ||
| if model == familyToken || model.hasPrefix("\(familyToken)-") { | ||
| return true |
There was a problem hiding this comment.
Bound model-token scan to actual agy flags
When an agy session is not launched with a Gemini model but its prompt text contains a flag-shaped phrase like --model gemini (for example, asking the agent to edit or run that command), this helper scans the entire flattened ps args string and returns true, so the dashboard reports a live Gemini agent incorrectly. The new regression only covers a Gemini substring inside another flag; it does not prevent prompt text after --prompt-interactive from being interpreted as launcher options.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 005d9d9. commandHasModelToken now stops scanning when it reaches prompt-bearing flags (--prompt, --prompt-interactive, --message) before matching --model, so prompt text cannot classify an agy process as Gemini. Added testParseSnapshotDoesNotClassifyAgyByPromptMentioningModelFlag; it failed before the fix and passes now.
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 |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 005d9d92eb
ℹ️ 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".
| let tokens = command.split { character in | ||
| character.isWhitespace || character == "=" | ||
| } | ||
| let promptFlags = ["--prompt", "--prompt-interactive", "--message"] |
There was a problem hiding this comment.
Stop scanning after short prompt flags
When agy is launched with the Gemini/Gemini-style short prompt aliases, e.g. agy -i "Please explain --model gemini" or agy -p ..., this scanner does not recognize the prompt boundary and will treat --model gemini inside the prompt text as a real model flag. The official Gemini CLI docs list --prompt/-p and --prompt-interactive/-i, so this still produces false live Gemini counts for users who use the short aliases while running another selected agy model; include those aliases in the prompt-boundary set before scanning further.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5b779a5. commandHasModelToken now stops scanning at the short prompt aliases -p and -i as well as the long forms, so prompt text containing --model gemini cannot classify a non-Gemini agy session. Added testParseSnapshotDoesNotClassifyAgyByPromptAliasMentioningModelFlag.
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.
|
Update for live-agent misses on
@codex review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79b566587f
ℹ️ 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".
| if command.contains("/.bun/bin/codex") | ||
| || command.contains("cursor agent") | ||
| || commandHasCursorAgentSession(command) { |
There was a problem hiding this comment.
Avoid treating search text as a Cursor session
When a helper/search process includes the literal phrase cursor agent, this early entrypoint bypass runs before the noise checks for rg, grep, awk, and ps -axo. For example, rg -n "cursor agent" ... now skips the ignore filter and then detectActualFamily counts it as a live Cursor process via the same substring, reintroducing false positives the noise filter is meant to suppress.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5b779a5. The parser no longer treats the literal phrase cursor agent as a live Cursor entrypoint; real Cursor coverage remains through command.hasPrefix("cursor ") for CLI rows and cursor-agent ... index.js agent for the current node launcher shape. Added testParseSnapshotSkipsSearchCommandsThatMentionCursorAgentPhrase, which failed before this fix and passes now.
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 Lean follow-up for latest BrainBar classifier fixes pushed in 5b779a5:
Verification:
|
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ 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". |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5b779a5. Configure here.
| return .codex | ||
| } | ||
| if command.hasPrefix("cursor ") || command.contains("cursor agent") || command.contains(" brainlayercursor") { | ||
| if command.hasPrefix("cursor ") || command.contains(" brainlayercursor") { |
There was a problem hiding this comment.
Path-based Cursor CLI missed
Medium Severity
detectActualFamily no longer treats argv like /Users/.../bin/cursor agent ... as Cursor after removing the cursor agent substring check. Only cursor ... prefixes and brainlayercursor remain, unlike Claude and Gemini which still match install-path argv via /claude and /gemini, so live Cursor sessions launched with a full binary path can disappear from BrainBar counts.
Reviewed by Cursor Bugbot for commit 5b779a5. Configure here.


Summary
gemini ...andagy --model Gemini..., including full-pathagyargv shapes.agy --model Gemini...was counted as Claude when the prompt mentioned Claude launcher names.agyGemini detection narrow: only--model gemini/--model gemini-*before prompt text qualifies, not arbitrarygeminisubstrings or prompt examples.created_atand appear in recent write dashboard stats.Review fixes
854f89de: requireucomm == codexbefore/bin/codexcontributes an actual Codex count.f10c4ecc: detectagy/Gemini fromucomm == agyeven when argv starts with a full path.54428013: classifyagy --model Gemini...before Claude prompt markers, then narrow matching to real model tokens.005d9d92: stopagymodel-token scanning at prompt-bearing flags so prompt text containing--model geminicannot classify the process as Gemini.Test plan
swift test --filter BrainBarTests.AgentActivityMonitorTests/testParseSnapshotClassifiesAgyGeminiByExecutableBeforePromptMentionsClaudefailed before the fix with Claude 1 / Gemini 0.swift test --filter BrainBarTests.AgentActivityMonitorTests/testParseSnapshotDoesNotClassifyAgyByGeminiSubstringInsideArgumentfailed before narrowing with Gemini 1.swift test --filter BrainBarTests.AgentActivityMonitorTests/testParseSnapshotDoesNotClassifyAgyByPromptMentioningModelFlagfailed before the prompt-boundary fix with Gemini 1.swift test --filter BrainBarTests.AgentActivityMonitorTests/testParseSnapshotClassifiesAgyGeminiByExecutableBeforePromptMentionsClaude --filter BrainBarTests.AgentActivityMonitorTests/testParseSnapshotDoesNotClassifyAgyByPromptMentioningModelFlag— 2 tests, 0 failures.swift test --filter BrainBarTests.AgentActivityMonitorTests— 8 tests, 0 failures.swift test --skip BrainBarTests.BrainBarReliabilityTests/testBrainStoreQueuesWithinBudgetWhenDatabaseWriteLockIsHeld— 616 tests, 0 failures.git diff --check— passed.coderabbit review --agentlocal bounded pre-commit review before54428013— 0 findings.scripts/run_tests.shgate after005d9d92— 2610 passed, 10 skipped, 61 deselected, 1 xfailed; MCP registration 3 passed; isolated eval/hook routing 40 passed; bun 1 passed; FTS5 determinism shell test passed.Notes
BrainBarReliabilityTests.testBrainStoreQueuesWithinBudgetWhenDatabaseWriteLockIsHeld; this PR therefore uses SwiftPM--skipfor that known hanging test while running the rest of the suite..gitis a file, not a directory. The hook still completes and pushes successfully.Note
Fix live agent and write signal reporting in BrainBar's
AgentActivityMonitorisAgentEntrypoint(executable:command:), which bypasses noise-token and executable filters for known agent launchers (agy,codex,claude,cursor,gemini).detectActualFamilyto classifyagyprocesses as Gemini by parsing the--modelflag value, and to better distinguish true Codex binaries from unrelated launchers.commandHasCursorAgentSession(_:), which requires a recognized launcher (index.js,cursor-agent) immediately before theagenttoken, avoiding false positives from worker-server or search commands.commandHasModelTokento parse--modelflag values without being confused by prompt argument text (--prompt,-p,-i, etc.).DatabaseTests.swiftto assert ISO8601created_atparsing and a positiverecentWriteFiveMinuteCount.Macroscope summarized 5b779a5.
Note
Low Risk
Changes are confined to BrainBar process parsing heuristics and test assertions; no auth, persistence schema, or network behavior is modified.
Overview
AgentActivityMonitor parsing is tightened so the dashboard’s live agent counts match real CLI sessions instead of search noise or mislabeled processes.
Agent entrypoints (
agy,codex, and known CLI prefixes) are no longer dropped when argv mentions debug strings likegreporps -axo. Gemini viaagyis classified from the executable plus a real--model geminitoken (before prompt flags), so prompts that mention Claude or fake--model geminiin text do not flip the family. Codex vendor binaries count only whenucommiscodexwith the expected path, avoiding double counts from Node launchers. Cursor usescommandHasCursorAgentSessionforcursor-agent+index.js agentand ignores worker-server andrg/pspipelines that mention “cursor agent”.Regression tests cover these cases;
testStoreCreatesChunkalso assertscreated_atanddashboardStats.recentWriteFiveMinuteCountafter a store so write activity shows on the dashboard.Reviewed by Cursor Bugbot for commit 5b779a5. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Release Notes