fix(open-file): strip Next.js App Router virtual path segments before editor launch#219
Conversation
… editor launch Next.js App Router dev server injects `/(app-pages-browser)/` into stack frame file paths. Passing this corrupted path to `/__nextjs_launch-editor` causes the editor to receive a path that doesn't exist on disk, so "Open in editor" silently fails for all App Router users. Strip the virtual segment before building the URLSearchParams so the endpoint receives the real file path. Fixes aidenybai#215 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This run croaked 😵 The workflow encountered an error before any progress could be reported. Please check the link below for details. |
|
@Logesh-waran2003 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.
No issues found across 1 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
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
|
Good point — fixed. Normalized the path before the dev server call and reused the normalized path in the fallback |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| const params = new URLSearchParams({ file: filePath }); | ||
| const params = new URLSearchParams({ | ||
| file: isNextProject ? stripAppRouterVirtualSegments(filePath) : filePath, | ||
| }); |
There was a problem hiding this comment.
Path stripped twice due to redundant normalization
Low Severity
stripAppRouterVirtualSegments is applied twice for Next.js projects — once in openFile before passing normalizedPath to tryDevServerOpen, and again inside tryDevServerOpen on the already-stripped path. Since tryDevServerOpen is private and only called from openFile, one of these two call sites is redundant. The cleanest fix is to remove the conditional strip inside tryDevServerOpen (line 15), since the caller already normalizes the path.



What
Fixes
Open in editorsilently failing for all Next.js App Router users.Why
Next.js App Router's dev server injects a virtual path segment
/(app-pages-browser)/into stack frame file paths. For example, a real file at:appears in the stack as:
tryDevServerOpen()was passing this corrupted path directly to/__nextjs_launch-editor. The editor receives a path that doesn't exist on disk, so the file never opens — no error, just silence.Fix
Strip the
/(app-pages-browser)/segment before building theURLSearchParams, scoped to Next.js projects only:One function, one call site. No changes to the Vite path.
Fixes #215
🤖 Generated with Claude Code
Note
Low Risk
Small, scoped string normalization change applied only for detected Next.js projects; minimal impact outside the editor-launch path.
Overview
Fixes “Open in editor” failures in Next.js App Router projects by stripping the injected
/(app-pages-browser)/virtual path segment from stack-frame file paths.The normalized path is now used consistently for the dev-server launch endpoint (
/__nextjs_launch-editor) and for the fallbackbuildOpenFileUrl/transformUrlflow, while non-Next (Vite) behavior remains unchanged.Written by Cursor Bugbot for commit 4455b41. This will update automatically on new commits. Configure here.
Summary by cubic
Restore “Open in editor” for Next.js App Router by stripping the injected /(app-pages-browser)/ segment from stack-frame file paths before launching the editor. Normalization now applies to both the Next.js launch-editor request and the fallback open-file URL; only affects Next.js projects, Vite remains unchanged.
Written for commit 4455b41. Summary will update on new commits.