Skip to content

feat(windows): support Cursor Agent sessions in the island - #231

Closed
BeyondBirthday07 wants to merge 28 commits into
Louis-CFM:mainfrom
BeyondBirthday07:feat/cursor-agent-windows
Closed

BeyondBirthday07 wants to merge 28 commits into
Louis-CFM:mainfrom
BeyondBirthday07:feat/cursor-agent-windows

Conversation

@BeyondBirthday07

Copy link
Copy Markdown
Contributor

Closes #72

Summary

Adds Windows support for Cursor Agent sessions in Coucou and surfaces them as first class sessions in the island.

This implementation uses Cursor's native hooks and the existing coucou_agent relay protocol. Cursor sessions remain display only in Coucou for this first version: permission decisions continue to be handled by Cursor itself.

What Changed

Cursor Hook Relay

Added Cursor event normalization in coucou_hook:

  • sessionStart → SessionStart
  • sessionEnd → SessionEnd
  • beforeSubmitPrompt → UserPromptSubmit
  • preToolUse → PreToolUse
  • postToolUse → PostToolUse
  • postToolUseFailure → PostToolUseFailure
  • stop → Stop / StopFailure

Cursor's conversation_id is maped to Coucou's session_id.

The workspace cwd is taken from workspace_roots[0] when available, with the normal cwd fallback preserved.

For stop events, Cursor statuses are mapped so that error stops become StopFailure, while completed/aborted stops remain normal Stop events.

Cursor tool output payloads are intentionally not forwarded to the island.

Display only / Faile open Behavior

Cursor hooks never wait for a Coucou permission decision.

The relay immediately emits Cursor-compatible responses:

  • preToolUse → {"permission":"allow"}
  • beforeSubmitPrompt → {"continue":true}

This keeps Cursor usable even when Coucou is unavailable.

I also manually verified that Cursor agent continues normally when the Coucou application is completely stopped.

Cursor hook Config.

Added windows support for managing:
~/.cursor/hooks.json

Coucou installs hooks for:

  • sessionStart
  • sessionEnd
  • beforeSubmitPrompt
  • preToolUse
  • postToolUse
  • postToolUseFailure
  • stop

The hook config. logic:

  • preserves existing user hooks and unrelated config.
  • avoids duplicating Coucou entries
  • removes only Coucou owned Cursor entries on uninstall
  • rejects invalid/unreadable JSON instead of overwriting it
  • accepts UTF-8 BOM files
  • fingerprints the source config. to detect stale writes
  • creates a backup when modifying an existing hooks file
  • safely handles first time installation when hooks.json does not exist

Settings UI

Added a Cursor agent section to windows settings with:

  • installation status
  • hook path/status
  • Install hooks
  • Reinstall hooks
  • Uninstall hooks
  • configuration diff preview before applying changes
  • backup path display when a backup will be created

The install, reinstall, backup, uninstall, and reinstall flows were manually tested against a real Cursor installation.

Island Session Support

Cursor conversations now get independent Coucou session IDs:
agent_cursor_<session_id>

Cursor sessions appear as their own pills, for example:
Cursor · coucou

The island now displays Cursor session activity for:

  • prompt submission
  • tool execution
  • tool failures
  • finished sessions
  • error sessions
  • session end

External agent sessions now use the normal session/activity view instead of falling through to the Integration / Key config. card.

Cursor specific finished/error labels are also shown instead of the previous Clause Code fallback text.

Validation

Automated:

  • cargo test -p coucou-hook
    • 9 passed
  • cargo test -p coucou
    • 20 passed
  • npm run build
    • passed
  • git diff --check
    • clean
  • working tree clean after final validation

Manual:

  • installed Cursor hooks from Coucou Settings
  • verified all seven hooks appear in Cursor's Hooks UI
  • verified Cursor execution logs receive real hook events
  • verified a live Cursor Agent session appears as Cursor · coucou
  • verified prompt/tool activity reaches the island
  • verified finished state displays Cursor finished
  • verified Coucou hook reinstall creates a backup
  • verified uninstall preserves non-Coucou configuration
  • verified reinstall works after uninstall
  • verified Cursor Agent continues normally with Coucou completely stopped

Scope

This PR intentionally implements the Windows side first.

Cursor sessions are display only in the version. Coucou does not provide Allow/Deny controls for Cursor permission requests, Cursor remains responsible for permission handling.

macOS Cursor hook installation/support can follow separately.

JhoanG956 pushed a commit to JhoanG956/coucou that referenced this pull request Oct 7, 2026
Takes Louis-CFM#231's Cursor support onto the shared pieces: its native
~/.cursor/hooks.json format and event list (installed and removed by the
hardened writer, which refuses a "hooks" of an unexpected type instead
of replacing it), and its event mapping and stop status → StopFailure,
which now live in the relay's single normaliser.

Left out of Louis-CFM#231: the relay answered every preToolUse with an allow and
every prompt with continue — it now prints nothing, so Cursor's own
permission rules decide; the hook command was Windows-only in a module
every platform builds (the shared relay command works on both, and is
quoted for cmd); and each session got its own agent_cursor_<session>
pill — every Cursor session is on agent_cursor, the Mac's pill id.

Co-authored-by: BeyondBirthday07 <sruhilmodi78@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner

Thank you! Cursor Agent sessions are in Coucou for Windows 0.2.0 (https://github.com/Louis-CFM/coucou/releases/tag/windows-v0.2.0): your event mapping and stop-status handling were folded into the shared normaliser, with you credited as co-author (#307). Changes: no {"permission":"allow"} reply (it would skip Cursor's own approvals), one agent_cursor pill instead of one per session, and it now builds on Linux. Details in #307.


Generated by Claude Code

@Louis-CFM Louis-CFM closed this Oct 7, 2026
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.

Support Cursor Agent sessions in the island

2 participants