Repository navigation
fix(devtools): resolve open-in-editor paths against the workspace root - #1165
Conversation
The component inspector sends paths relative to the workspace root, but openInEditor only joined them with the package cwd. Files outside that package were reported missing. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "5c46857c497fb5d8d6f28dd248abb821df02e2d7",
"result": {
"overallSummary": "Fixes \"open in editor\" for monorepo/workspace setups: inspector paths are workspace-relative, but `openInEditor` only ever joined them with `process.cwd()` (the package dir), so paths belonging to the workspace root were reported missing. The fix resolves against `cwd`, `rootDir` and `workspaceDir` in that order and opens the first existing candidate, and adds focused unit tests for each base.",
"groups": [
{
"key": "open-in-editor-resolution",
"label": "Workspace path resolution",
"summary": "`openInEditor` builds a candidate list per base directory (`process.cwd()`, `nuxt.options.rootDir`, `nuxt.options.workspaceDir`, deduplicated) for relative input instead of resolving against `cwd` only, then applies the existing `.js`/`.mjs`/`.ts` fallbacks to every candidate. The `:line:col` suffix is now split off before resolution so it can never end up inside a filename. Auth (`ensureDevAuthToken`) and the `launch-editor` call are untouched.",
"category": "core",
"filePaths": [
"packages/devtools/src/server-rpc/general.ts"
],
"fileNotes": [
{
"path": "packages/devtools/src/server-rpc/general.ts",
"text": "Candidate order is the priority order: `cwd` still wins, so behaviour inside a package is unchanged, while `rootDir`/`workspaceDir` only kick in when no file is found earlier. A file with the same relative path in both `cwd` and the workspace root still resolves to the cwd one."
},
{
"path": "packages/devtools/src/server-rpc/general.ts",
"text": "The failure log now prints `candidates[0]` (the cwd-resolved path) rather than the raw input, so the reported path is only one of the locations actually searched."
}
],
"lineNotes": [
{
"path": "packages/devtools/src/server-rpc/general.ts",
"side": "additions",
"line": 204,
"text": "`isRelative` is decided on the un-stripped input, so an absolute path carrying `:line:col` still takes the single-candidate branch — correct, but only because the regex is prefix-anchored."
}
]
},
{
"key": "open-in-editor-tests",
"label": "openInEditor tests",
"summary": "New unit tests drive `setupGeneralRPC().openInEditor` against a temp workspace (`docs/` package inside a workspace root), covering cwd-relative, rootDir-relative, workspace-relative with `:line:col`, absolute paths, and the not-found error message. `process.cwd` is mocked per test and `launch-editor` + `getOptions` are stubbed.",
"category": "tests",
"filePaths": [
"packages/devtools/test/open-in-editor.test.ts"
],
"fileNotes": [
{
"path": "packages/devtools/test/open-in-editor.test.ts",
"text": "The `openInEditorHooks` stub always returns `handledByHook`, so the tests assert only which path is resolved and passed on — they never exercise a real `launch-editor` invocation or the dev-auth token check."
}
],
"lineNotes": [
{
"path": "packages/devtools/test/open-in-editor.test.ts",
"side": "additions",
"line": 52,
"text": "`vi.spyOn(process, 'cwd')` is re-mocked per test and restored in `afterEach`; the second mock in the rootDir test replaces the one set in `beforeEach`, so cwd points at a non-existent `tools/` dir there."
}
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-11-18T13:48:08.375Z",
"model": "openai-compatible/opencode-go/deepseek-v4.1-flash",
"locale": "en"
}
} |
🔗 Linked issue
resolves #1097
📚 Description
Relative inspector paths were only joined with
process.cwd(). In a workspace package that directory is the package itself, sosrc/components/button/Button.demo.vuebecomes<repo>/docs/src/components/button/Button.demo.vueand the file is reported missing.openInEditornow triesprocess.cwd(),rootDir, andworkspaceDir, and opens the first path that exists. The:line:colsuffix is stripped before the join. Auth andlaunch-editorare unchanged.#1098 already did this on main. Nuxt 4.6 still depends on 3.4.4, so this brings the same lookup to v3.
In
packages/devtools,pnpm exec vitest run test/open-in-editor.test.ts test/server-rpc-auth.test.ts. The caseopens a file that lives at the workspace root, outside the Nuxt packagesendssrc/components/button/Button.demo.vue:27:2with cwd atdocs/and expects the file under the workspace root. That case passes on this branch. I did not run the repo lint or typecheck, and I did not boot this build in a running Nuxt app.