Skip to content

feat(cursor): implement permission approval for interaction_query#848

Open
chenhg5 wants to merge 1 commit into
mainfrom
fix/issue-785-cursor-permission-approval
Open

feat(cursor): implement permission approval for interaction_query#848
chenhg5 wants to merge 1 commit into
mainfrom
fix/issue-785-cursor-permission-approval

Conversation

@chenhg5
Copy link
Copy Markdown
Owner

@chenhg5 chenhg5 commented May 4, 2026

Summary

  • Implemented permission approval flow for Cursor Agent's interaction_query events
  • Added stdin pipe to cursorSession for writing responses back to Cursor process
  • Modified handleInteractionQuery to emit EventPermissionRequest for user approval
  • Implemented RespondPermission to write interaction_query/response via stdin
  • Auto-approve for yolo/force mode, request user approval for default mode

Root Cause

Cursor Agent in default mode was auto-rejecting all tool calls because:

  • RespondPermission was a no-op (empty implementation)
  • handleInteractionQuery only emitted EventToolUse, not EventPermissionRequest
  • Cursor waited for response, timed out, and auto-rejected

Test plan

  • go build ./... passes
  • go vet ./... passes
  • go test ./... passes
  • Manual: Cursor Agent in default mode prompts user for tool approval
  • Manual: yolo/force mode continues to auto-approve

Closes #785

🤖 Generated with Claude Code

Cursor Agent in default mode was auto-rejecting all tool calls because
cc-connect wasn't responding to interaction_query requests. The
RespondPermission method was a no-op.

Changes:
- Added stdin pipe to cursorSession for writing responses
- Modified handleInteractionQuery to emit EventPermissionRequest
- Implemented RespondPermission to write interaction_query/response
- Auto-approve for yolo/force mode, request user approval for default

Now users can approve/deny tool calls through the messaging platform
when using Cursor Agent in default mode.

Closes #785

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Owner Author

@chenhg5 chenhg5 left a comment

Choose a reason for hiding this comment

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

Review Summary

Solid implementation of the two-way permission flow for Cursor Agent. This fixes a real and reproducible bug: Cursor's default mode was auto-rejecting all tool calls because RespondPermission was a no-op. CI is green across all 5 checks.

As an owner PR, I can't formally approve — but sharing detailed notes for the record.


🟡 Protocol: query_type in response may not match Cursor's expected value
File: agent/cursor/session.go, writeJSON call in RespondPermission
Why: The outgoing response hardcodes "query_type": "permission" regardless of the actual incoming query type (shellRequestQuery, webFetchRequestQuery, etc.). If Cursor Agent key-dispatches responses on query_type, it may not route the response back to the correct handler.
Fix: Consider passing queryType through to RespondPermission via core.PermissionResult or a separate field, then echoing the original value in the response.

🟡 response.response.id type mismatch
File: agent/cursor/session.go line ~545
Why: requestID is parsed as float64 from JSON and converted to string via fmt.Sprintf("%d", int(requestID)). If Cursor expects a numeric id in the response payload, sending it as a string may cause a routing failure.
Fix: Confirm Cursor's expected type for id in the response; send as int if needed.


Good: stdin mutex (stdinMu) prevents concurrent write races correctly.
Good: Auto-approve path in yolo/force mode still emits EventToolUse for visibility — clean separation of concerns.
Good: Failure path in RespondPermission checks cs.alive before writing — avoids write-on-closed-pipe panics.

If the query_type echo and id type are confirmed correct by manual testing (or by inspecting Cursor's source), this is ready to merge.

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.

[Bug] Cursor Agent in default mode auto-rejects shell commands on Windows without prompting for approval

2 participants