Skip to content
Source
Sign inSign up
TanStack/devtools

Click-to-code does not work when command run from different directory #281

Closedliteralpie(GitHub profile, opens in a new tab) opened this issue 2 comments

TanStack Devtools version

0.3.11

Framework/Library version

React 19.2.0

Describe the bug and the steps to reproduce it

If the Vite command is run from a different directory than what the Vite root is (we do this because we have a big monorepo), the click-to-code feature does not work. When making a custom editor config, I can see that the filePath includes duplication of some parts of the path (/Users/literalpie/my-repo/config/Users/literalpie/my-repo/src/App.tsx)

I believe the problem is that cwd is used to clean up the path, but cwd might not match what's in the vite id path.

https://stackblitz.com/edit/vitejs-vite-bvszfdfc?file=config%2Fvite.config.ts,README.md&terminal=dev

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

No, because I do not have time to dig into it

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
  1. This is similar to #176 , but that didn't include a minimal repro and I'm seeing the issue in MacOS, not Linux

  2. We're using the following as a workaround:

          editor: {
            name: 'Default Editor',
            open: async (filePath, lineNumber, columnNumber) => {
              const filePathString = filePath.split('repo-name/config')[1];
    
              const launch = (await import('launch-editor')).default;
              launch(
                `${filePathString.replaceAll('$', '\\$')}${lineNumber ? `:${lineNumber}` : ''}${
                  columnNumber ? `:${columnNumber}` : ''
                }`,
                undefined,
                (filename, err) => {
                  console.warn(`Failed to open ${filename} in editor: ${err}`);
                },
              );
            },
          }
  3. AlemTuzlak closed this

Sign in to join this conversation.