feat: IDE auto-detection and Antigravity support#117
feat: IDE auto-detection and Antigravity support#117Oct7 wants to merge 10 commits intoaidenybai:mainfrom
Conversation
- 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>
|
@Oct7 is attempting to deploy a commit to the Million Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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+ fragment1.ts:10webstorm://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:
-
packages/website/app/open-file/page.tsx (line 30-45):
- Added
const encodedPath = encodeURIComponent(filePath);at the start ofgetEditorUrl - Use
encodedPathinstead of rawfilePathin both WebStorm and generic editor URL generation
- Added
-
packages/react-grab/src/utils/build-open-file-url.ts:
- Added encoding in
buildEditorUrlfunction (line 23-37) - Added encoding in
buildOpenFileUrlfallback for antigravity (line 65-68) - Now all editor types (WebStorm, VS Code, Cursor, Zed, Antigravity) properly encode paths
- Added encoding in
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>
There was a problem hiding this comment.
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>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
All issues identified by reviewers have been addressed: ✅ WebSocket onclose IDE info cleanup |
Summary
Added automatic IDE detection by traversing parent processes when Provider CLI starts, enabling direct file opening via IDE-specific URL schemes.
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
packages/relay/src/detect-ide.tspackages/website/components/icons/icon-antigravity.tsxModified Files
@react-grab/relayreact-grabbuildOpenFileUrl, global IDE info management@react-grab/websiteHow It Works
IDE Detection Flow
detectParentIDE(): traverse process tree (up to 10 levels)globalIDEInfoantigravity://file/path/to/file.tsx:42directlyOpen File Flow
globalIDEInforeceived from Relay servercursor://file/src/App.tsx:42)antigravity://file/src/App.tsx:42)Supported IDEs
antigravity://file{path}:{line}cursor://file{path}:{line}vscode://file{path}:{line}zed://file{path}:{line}webstorm://open?file={path}&line={line}Note
Enables direct file opening by detecting the parent IDE at relay startup and propagating IDE info to the browser, which
react-grabuses to generate editor-specific URLs; falls back to the open-file page when unknown.detectParentIDE, extend protocol withIDEInfo, includeideInfoinregister-handlerandhandlersmessages, broadcast to browsers, print detected IDE, and exportbuildEditorUrlonIDEInfoChange,getIDEInfo; track/reset IDE info on connect/closebuild-open-file-urlutil with globalsetGlobalIDEInfo/getGlobalIDEInfo; export fromcoreand package entry; use IDE info to returneditor://file{path}:{line}(WebStorm query form) with safe path encodingIDEInfoininstrumentation-clientto set global IDE; add Antigravity option and icon to open-file page; fix URL building and encodingWritten 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
Bug Fixes
Written for commit bcc59ad. Summary will update on new commits.