Skip to content

fix(cursor): make tracing independent of plugin imports - #167

Merged
Abhijeet Prasad (AbhiPrasad) merged 3 commits into
mainfrom
fix/cursor-user-capture-hooks
Oct 9, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 3 commits into
mainfrom
fix/cursor-user-capture-hooks

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

bt trace enable cursor could report tracing as enabled without capturing any Cursor sessions. It configured the destination and installed a local plugin, but the user hooks only returned no-op responses. Capture therefore depended on Cursor loading the plugin.

That dependency breaks when third-party imports are disabled or an older marketplace installation takes precedence over the local plugin. Re-enabling imports can also bring in the Claude tracing plugin: Cursor drops its separate command arguments, runs bare bt, and treats its exit code 2 as a blocked prompt. Users should be able to trace Cursor without enabling Claude hooks.

This change makes bt trace enable cursor register capture hooks directly in Cursor's user configuration. User hooks work independently of plugin imports and marketplace versions, so enabling tracing establishes a working capture path. When both user and plugin hooks are active, the user hooks own capture to avoid recording the same event twice. Existing unrelated hooks are preserved.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T20:23:02.649292Z 2c80a04 New commits
ℹ️ About Codex in GitHub

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

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 4aa872749e

ℹ️ 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 (@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 (@codex) address that feedback".

Comment thread bt-daemon/src/setup/cursor/hooks.rs Outdated
Comment on lines +182 to +188
let persistent = specs == persistent_specs();
if persistent {
for (event, command) in self::specs(PERSISTENT_MARKER, cfg!(windows)) {
if let Some(entries) = hooks.get_mut(&event).and_then(Value::as_array_mut) {
entries.retain(|entry| {
entry.get("command").and_then(Value::as_str) != Some(command.as_str())
});

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 Reconcile capture hooks by marker across upgrades

When a later release changes any generated capture command—for example, by adding an argument or changing the timeout—this migration removes only the old discovery command and the exact current command. The previous braintrust-cursor-capture entry therefore remains while the new one is appended, causing every Cursor event to be captured twice; disabling also leaves the stale entry behind, so a later re-enable restores the duplication. Match and replace/remove persistent entries by their capture marker (including decoding the PowerShell form), rather than enumerating only this one legacy command.

AGENTS.md reference: AGENTS.md:L27-L31

Useful? React with 👍 / 👎.

Remove older capture and discovery commands during enable, update, and disable, including PowerShell entries and retired events. Consolidate setup tests while preserving upgrade and lifecycle coverage.

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

Copy link
Copy Markdown

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: 7beb0bd0c8

ℹ️ 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 (@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 (@codex) address that feedback".

Comment thread bt-daemon/src/hook.rs Outdated
(args.source == "cursor").then(|| cursor_hook_response_for_event(args.event.as_deref()));
let result = async move {
if suppress_inherited_hook(&args) {
if suppress_inherited_hook(&args) || suppress_cursor_plugin_hook(&args) {

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 Apply Cursor suppression in the mounted hook path

When the embedded bt CLI dispatches bt trace hook through run_trace, trace_runtime.rs::run_hook_command calls run_hook_with_route directly, so this new suppression check in run_hook is never reached. Consequently, when both the newly installed user hooks and a Cursor plugin hook are active, both forward the same event; the translator absorbs many identical payloads, but the daemon still journals and processes every duplicate and events outside that deduplication scope can produce repeated operations. Move or repeat the ownership check in the shared path used by run_trace so the production bt command actually suppresses plugin capture.

Useful? React with 👍 / 👎.

Share capture ownership checks across standalone and mounted hook entry points before settings and route resolution. Verify that plugin hooks are suppressed while user hooks still reach the host.
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 0e4f63e into main Oct 9, 2026
22 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the fix/cursor-user-capture-hooks branch October 9, 2026 20:27
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