Skip to content
Source
Sign inSign up
TanStack/devtools

Click to code doesn't work when file has `(` inside the path #330

Openarchiekd(GitHub profile, opens in a new tab) opened this issue 1 comment

TanStack Devtools version

0.4.1

Framework/Library version

React v18.2.0

Describe the bug and the steps to reproduce it

When I try to use the click to code function it doesn't work if there is a ( inside the file name, is it possible to add strings around the file name so that this works?

/usr/local/bin/cursor: eval: line 20: syntax error near unexpected token `('
/usr/local/bin/cursor: eval: line 20: `ELECTRON_RUN_AS_NODE=1 "/Applications/Cursor.app/Contents/MacOS/Cursor" "/Applications/Cursor.app/Contents/Resources/app/out/cli.js" -r -g /Users/archiekd/Developer/searchland/nx-monorepo/apps/web/src/pages/(dashboard)/alerts/_components/AlertFilters.tsx:27:9'

Could not open AlertFilters.tsx in the editor.
The editor process exited with an error: (code 1).

Path with ( inside it when using click to code

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. Same issue with "$" in file paths. Got 5.3 codex to work around it in the devtools vite plugin options. Here is the workaround for cursor + macOS

      devtools({
          logging: true,
          // Fixes issues with file paths containing "(" or ")" or "$"
          editor: {
            name: "cursor",
            async open(path, lineNumber, columnNumber) {
              const line = lineNumber ?? "1";
              const column = columnNumber ?? "1";
              const target = `${path}:${line}:${column}`;
              // macos specific
              const cursorApp = "/Applications/Cursor.app/Contents/MacOS/Cursor";
              // macos specific
              const cursorCli =
                "/Applications/Cursor.app/Contents/Resources/app/out/cli.js";
    
              const run = (
                command: string,
                args: Array<string>,
                extraEnv?: Record<string, string>,
              ) =>
                new Promise<{ ok: boolean; error: string }>((resolve) => {
                  const child = spawn(command, args, {
                    stdio: ["ignore", "pipe", "pipe"],
                    env: extraEnv ? { ...process.env, ...extraEnv } : process.env,
                  });
                  let stderr = "";
    
                  child.stderr.on("data", (chunk) => {
                    stderr += String(chunk);
                  });
                  child.on("error", (error) => {
                    resolve({ ok: false, error: String(error) });
                  });
                  child.on("exit", (code) => {
                    resolve({
                      ok: code === 0,
                      error: stderr.trim() || `exit_code=${String(code)}`,
                    });
                  });
                });
    
              const withCursorCli = await run(
                cursorApp,
                [cursorCli, "-r", "-g", target],
                { ELECTRON_RUN_AS_NODE: "1" },
              );
              if (withCursorCli.ok) {
                console.info(`[tanstack-devtools] opened in Cursor: ${target}`);
                return;
              }
    
              console.error(
                `[tanstack-devtools] failed to open in Cursor: ${target}\n${withCursorCli.error}`,
              );
            },
          },
        }),

Sign in to join this conversation.