Skip to content

feat: IDE auto-detection and Antigravity support#117

Open
Oct7 wants to merge 10 commits intoaidenybai:mainfrom
Oct7:main
Open

feat: IDE auto-detection and Antigravity support#117
Oct7 wants to merge 10 commits intoaidenybai:mainfrom
Oct7:main

Conversation

@Oct7
Copy link

@Oct7 Oct7 commented Jan 13, 2026

Summary

Added automatic IDE detection by traversing parent processes when Provider CLI starts, enabling direct file opening via IDE-specific URL schemes.

  • Add IDE auto-detection (Antigravity, Cursor, VS Code, Zed, WebStorm)
  • Add Antigravity IDE support
  • Enable direct file opening with detected IDE (bypass open-file page)

Motivation

Previously, opening a file always redirected to the open-file page where users had to manually select their IDE. With this change, the IDE is automatically detected, allowing files to open directly with a single action.

Changes

New Files

File Description
packages/relay/src/detect-ide.ts IDE auto-detection utility (process tree traversal)
packages/website/components/icons/icon-antigravity.tsx Antigravity icon component

Modified Files

Package Changes
@react-grab/relay IDE detection, IDEInfo type in protocol, server→client broadcast
react-grab IDE detection logic in buildOpenFileUrl, global IDE info management
@react-grab/website Antigravity option added, relay client connection

How It Works

IDE Detection Flow

  1. Provider CLI starts → detectParentIDE(): traverse process tree (up to 10 levels)
  2. IDE detected (e.g., Antigravity) → store IDE info in Relay Server
  3. Browser connects → receive IDE info via WebSocket → set globalIDEInfo
  4. Right-click "Open" → call antigravity://file/path/to/file.tsx:42 directly

Open File Flow

  1. User action: Select element → Right-click "Open"
  2. Check IDE info: Look up globalIDEInfo received from Relay server
  3. Generate URL:
    • IDE detected → Use detected IDE's URL scheme (e.g., cursor://file/src/App.tsx:42)
    • IDE not detected → Use Antigravity as default (antigravity://file/src/App.tsx:42)
  4. Open file: Call URL scheme → File opens in IDE at the specified line

Supported IDEs

IDE URL Scheme Process Patterns
Antigravity antigravity://file{path}:{line} antigravity, Antigravity
Cursor cursor://file{path}:{line} cursor, Cursor
VS Code vscode://file{path}:{line} Visual Studio Code, Code.app
Zed zed://file{path}:{line} zed, Zed
WebStorm webstorm://open?file={path}&line={line} webstorm, WebStorm

Note

Enables direct file opening by detecting the parent IDE at relay startup and propagating IDE info to the browser, which react-grab uses to generate editor-specific URLs; falls back to the open-file page when unknown.

  • Relay: add detectParentIDE, extend protocol with IDEInfo, include ideInfo in register-handler and handlers messages, broadcast to browsers, print detected IDE, and export buildEditorUrl
  • Relay client: add onIDEInfoChange, getIDEInfo; track/reset IDE info on connect/close
  • react-grab: add build-open-file-url util with global setGlobalIDEInfo/getGlobalIDEInfo; export from core and package entry; use IDE info to return editor://file{path}:{line} (WebStorm query form) with safe path encoding
  • Website: subscribe to relay IDEInfo in instrumentation-client to set global IDE; add Antigravity option and icon to open-file page; fix URL building and encoding

Written by Cursor Bugbot for commit 98dad39. This will update automatically on new commits. Configure here.


Summary by cubic

Automatically detect the IDE that launched the Provider CLI and open files directly via IDE URL schemes, skipping the open‑file page when IDE info is available. Adds Antigravity support and restores open‑file page fallback when no IDE is detected.

  • New Features

    • Auto-detect IDE by traversing parent processes (Antigravity, Cursor, VS Code, Zed, WebStorm).
    • Relay broadcasts IDE info to the browser; website subscribes and sets global IDE state.
    • buildOpenFileUrl returns editor-specific URLs; falls back to the open‑file page.
    • Antigravity support and icon added; CLI shows detected IDE.
  • Bug Fixes

    • Connect relay client so IDE info reaches the browser.
    • Standardize URL formats: editor://file{path}:{line} (WebStorm: webstorm://open?file={path}&line={line}); remove extra slash.
    • Improve detection order and depth; reduce VS Code false positives.
    • Encode and normalize file paths in URL schemes; reset IDE info on disconnect.

Written for commit bcc59ad. Summary will update on new commits.

Oct7 and others added 6 commits January 12, 2026 03:15
- Add IDE auto-detection that detects parent IDE process (Cursor, VS Code, Antigravity, Zed, WebStorm)
- Add Antigravity IDE support to open-file feature
- When IDE is detected, Cmd+O and right-click Open bypass open-file page and use direct URL scheme
- IDE info is passed from Provider CLI → Relay Server → Browser Client

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The relay client was being created but never connected,
which prevented the browser from receiving IDE detection
information from the relay server.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Prioritize Antigravity in EDITOR_CONFIGS order to detect before VS Code
- Increase maxDepth from 5 to 10 for deeper process chain traversal
- Update VS Code patterns to avoid false positives with "claude-code"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove extra slash in open-file page URL generation
- Standardize URL format: `editor://file/path:line` (single slash after file)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of redirecting to react-grab.com/open-file, use antigravity://file protocol as the default fallback when no editor is detected.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 13, 2026

@Oct7 is attempting to deploy a commit to the Million Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 15 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/relay/src/client.ts">

<violation number="1" location="packages/relay/src/client.ts:171">
P2: Missing IDE info cleanup in WebSocket `onclose` handler. When connection closes unexpectedly, `currentIDEInfo` should be reset to `null` and `ideInfoChangeCallbacks` should be notified, consistent with how `availableHandlers` and `handlersChangeCallbacks` are handled in the same handler.</violation>
</file>

<file name="packages/relay/src/detect-ide.ts">

<violation number="1" location="packages/relay/src/detect-ide.ts:191">
P2: Relative file paths will produce malformed URLs (e.g., `cursor://filesrc/App.tsx` instead of `cursor://file/src/App.tsx`). Consider normalizing the path to ensure it starts with a `/`.</violation>

<violation number="2" location="packages/relay/src/detect-ide.ts:191">
P2: File paths are not URL-encoded for non-webstorm editors, which will cause failures when file paths contain spaces or special characters. Consider encoding the path consistently.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

File paths with special characters (#, ?, &, spaces) are not properly encoded in URI scheme generation, causing file opening to fail for affected paths.

View Details
📝 Patch Details
diff --git a/packages/react-grab/src/utils/build-open-file-url.ts b/packages/react-grab/src/utils/build-open-file-url.ts
index 96d265c..f2b6531 100644
--- a/packages/react-grab/src/utils/build-open-file-url.ts
+++ b/packages/react-grab/src/utils/build-open-file-url.ts
@@ -20,13 +20,15 @@ const buildEditorUrl = (
 ): string | null => {
   if (!editorId) return null;
 
+  const encodedPath = encodeURIComponent(filePath);
+
   if (editorId === "webstorm") {
     const lineParam = lineNumber ? `&line=${lineNumber}` : "";
-    return `webstorm://open?file=${encodeURIComponent(filePath)}${lineParam}`;
+    return `webstorm://open?file=${encodedPath}${lineParam}`;
   }
 
   const lineParam = lineNumber ? `:${lineNumber}` : "";
-  return `${editorId}://file${filePath}${lineParam}`;
+  return `${editorId}://file${encodedPath}${lineParam}`;
 };
 
 // Global IDE info storage - set by relay client or manually
@@ -61,6 +63,7 @@ export const buildOpenFileUrl = (
   }
 
   // Fall back to antigravity (default editor)
+  const encodedPath = encodeURIComponent(filePath);
   const lineParam = lineNumber ? `:${lineNumber}` : "";
-  return `antigravity://file${filePath}${lineParam}`;
+  return `antigravity://file${encodedPath}${lineParam}`;
 };
diff --git a/packages/website/app/open-file/page.tsx b/packages/website/app/open-file/page.tsx
index b81dd62..498a3eb 100644
--- a/packages/website/app/open-file/page.tsx
+++ b/packages/website/app/open-file/page.tsx
@@ -33,13 +33,15 @@ const getEditorUrl = (
   filePath: string,
   lineNumber?: number,
 ): string => {
+  const encodedPath = encodeURIComponent(filePath);
+  
   if (editor === "webstorm") {
     const lineParam = lineNumber ? `&line=${lineNumber}` : "";
-    return `webstorm://open?file=${filePath}${lineParam}`;
+    return `webstorm://open?file=${encodedPath}${lineParam}`;
   }
 
   const lineParam = lineNumber ? `:${lineNumber}` : "";
-  return `${editor}://file${filePath}${lineParam}`;
+  return `${editor}://file${encodedPath}${lineParam}`;
 };
 
 const OpenFileContent = () => {

Analysis

Bug Analysis

Why it happens:
The getEditorUrl function in packages/website/app/open-file/page.tsx and the buildEditorUrl function in packages/react-grab/src/utils/build-open-file-url.ts were passing raw file paths directly into URI schemes without percent-encoding them.

When it manifests:
When file paths contain special characters that have meaning in URIs:

  • # (fragment identifier) - everything after # is treated as a URL fragment
  • ? (query string start) - breaks URI parsing
  • & (query separator) - especially in WebStorm URLs with query parameters
  • spaces and other reserved characters - can cause parsing issues

For example:

  • vscode://file/home/user/file#1.ts:10 → parsed as path /home/user/file + fragment 1.ts:10
  • webstorm://open?file=/path/file?name.ts&line=10 → the ? in filename breaks the query parameter

Impact:
Users cannot open files whose paths contain these special characters, which is not uncommon:

  • Files with hashtags in names or folders
  • Files in folders with spaces
  • Files with special characters in version control branches or generated code

Fix Applied

Modified both files to use encodeURIComponent() when building URI schemes:

  1. packages/website/app/open-file/page.tsx (line 30-45):

    • Added const encodedPath = encodeURIComponent(filePath); at the start of getEditorUrl
    • Use encodedPath instead of raw filePath in both WebStorm and generic editor URL generation
  2. packages/react-grab/src/utils/build-open-file-url.ts:

    • Added encoding in buildEditorUrl function (line 23-37)
    • Added encoding in buildOpenFileUrl fallback for antigravity (line 65-68)
    • Now all editor types (WebStorm, VS Code, Cursor, Zed, Antigravity) properly encode paths

The fix ensures:

  • File paths are consistently encoded across all editors
  • Special characters are properly percent-encoded (e.g., /path#1%2Fpath%231)
  • Editors that support URI scheme handling can decode these paths correctly
  • Normal file paths continue to work (verified with decoding tests)

- Fix WebSocket onclose IDE info cleanup and callback notification
- Fix disconnect() IDE info callback notification
- Improve IDE change detection to compare all properties (editorId, editorName, urlScheme)
- Fix relative path URL format (ensure path starts with /)
- Add URL encoding for file paths with special characters (#, ?, &, spaces)
- Restore open-file page fallback for users without detected IDE

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/relay/src/client.ts">

<violation number="1" location="packages/relay/src/client.ts:144">
P2: Notifying `ideInfoChangeCallbacks` here can cause duplicate callback invocations. When `disconnect()` is called on an open connection, `webSocketConnection.close()` triggers the `onclose` handler which also notifies `ideInfoChangeCallbacks`. This is inconsistent with `handlersChangeCallbacks` and `connectionChangeCallbacks` which are only notified in `onclose`. Consider removing these lines and letting `onclose` handle all callback notifications.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

…ct()

The onclose handler already notifies ideInfoChangeCallbacks when
webSocketConnection.close() is called, so calling it again in
disconnect() causes duplicate callback invocations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Oct7 and others added 2 commits January 14, 2026 12:30
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Oct7
Copy link
Author

Oct7 commented Jan 16, 2026

All issues identified by reviewers have been addressed:

✅ WebSocket onclose IDE info cleanup
✅ Relative path URL format fix
✅ URL encoding for special characters
✅ Restore open-file page fallback
✅ IDE change detection improvement
✅ Remove duplicate callback notification
Ready for review.

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.

1 participant