Skip to content

Conversation

@tt-a1i
Copy link
Contributor

@tt-a1i tt-a1i commented Dec 5, 2025

Summary

Adds the ability to click on the floating label to open the selected element's source file directly in your local editor.

Changes

  1. Click to open in editor: When clicking the component tag in the floating label, opens the file at the component's location in your preferred editor

  2. Improved file path detection: Prioritizes data-component-path and data-component-line DOM attributes (added by tools like lovable-tagger) over React Fiber stack traces, providing more accurate source file locations

Supported Editors

  • VS Code (default)
  • Cursor
  • Windsurf
  • Trae
  • WebStorm
  • Zed

Configuration

Users need to configure their Vite project:

// vite.config.ts
export default defineConfig({
  define: {
    __PROJECT_ROOT__: JSON.stringify(process.cwd()),
    __PREFERRED_EDITOR__: JSON.stringify(process.env.REACT_GRAB_EDITOR || 'vscode'),
  },
})

Fallback Behavior

  • If __PROJECT_ROOT__ is not defined, falls back to opening react-grab.com/open-file
  • If no DOM attributes are found, falls back to React Fiber stack trace for file path detection

Closes #50

@vercel
Copy link

vercel bot commented Dec 5, 2025

@tt-a1i is attempting to deploy a commit to the Million Team on Vercel.

A member of the Team first needs to authorize it.

@tt-a1i tt-a1i force-pushed the feat/auto-open-in-editor branch 2 times, most recently from 93ab9dd to bda4687 Compare December 5, 2025 15:22
@tt-a1i tt-a1i changed the title feat: support opening files directly in local editor with multi-editor support feat: open file in local editor when clicking component tag Dec 5, 2025
@tt-a1i tt-a1i force-pushed the feat/auto-open-in-editor branch from bda4687 to 00d7159 Compare December 5, 2025 15:25
- Add direct editor URL scheme support (vscode, cursor, windsurf, trae, webstorm, phpstorm, idea, zed, sublime, atom)
- Use __PROJECT_ROOT__ from Vite config to build absolute file paths
- Use __PREFERRED_EDITOR__ from Vite config to select editor (default: vscode)
- Clean up localhost URL prefixes from file paths
- Fallback to react-grab.com/open-file when __PROJECT_ROOT__ is not configured
@tt-a1i tt-a1i force-pushed the feat/auto-open-in-editor branch from 00d7159 to c7f15ac Compare December 5, 2025 15:58
@tt-a1i
Copy link
Contributor Author

tt-a1i commented Dec 6, 2025

Hi @aidenybai 👋

I've updated this PR to also include JetBrains Rider support, which addresses #48.

I wanted to check if this approach works for you:

  1. DOM attribute priority: The implementation now checks for data-component-path and data-component-line attributes first (commonly added by tools like lovable-tagger), falling back to the React Fiber stack if those aren't present. This provides more accurate source locations in projects using such tools.

  2. Editor URL schemes: Using platform-standard URL schemes for each editor (vscode://, cursor://, rider://, etc.).

Would love to hear your thoughts on whether this direction makes sense for the project! Happy to adjust based on your feedback.

Add Rider to the list of supported editors, using the same URL scheme
as WebStorm (rider://open?file={file}&line={line}&column={column}).

This addresses Issue aidenybai#48 request for JetBrains Rider support.
@tt-a1i tt-a1i force-pushed the feat/auto-open-in-editor branch from 0a04fdc to ca94d3f Compare December 6, 2025 01:10
@tt-a1i
Copy link
Contributor Author

tt-a1i commented Dec 6, 2025

Also curious about your thoughts on the interaction design:

Current approach:

  • Click the component label → opens file in editor
  • Uses data-component-path attribute (from tools like lovable-tagger) when available, falls back to React Fiber stack
image

Editor configuration:
You can configure your preferred editor via environment(.env):

REACT_GRAB_EDITOR=cursor  # or: vscode | windsurf | trae | webstorm | rider | zed

Defaults to vscode if not specified.

What do you think of this way?

@atresnjo
Copy link

atresnjo commented Dec 7, 2025

ayy yeah this is the only missing piece

@kp-perigonai
Copy link

huge! 🎉 makes life so much easier

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.

Clicking component tag doesn't open file in local editor

3 participants