Repository navigation
fix(editor): copy gutter URLs from the owning file - #34922
Conversation
27f0dd1 to
f486da6
Compare
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[Low impact] The change is limited to remote URL copying from an editor gutter menu. The PR should not merge until the ID lookup also checks the supplied Findings
SummaryThe PR makes gutter URL copying use the mounted editor's file ID instead of the first matching path.
Reviews (2) · Last reviewed commit: "fix(editor): scope gutter remote URL fal..." · Reviewed by Greptile |
| const activeFile = state.openFiles.find((f) => f.filePath === filePath) | ||
| // Conflict overview editors may carry a synthetic id; fall back only within this owner. | ||
| const activeFile = | ||
| state.openFiles.find((file) => file.id === fileId) ?? |
There was a problem hiding this comment.
Overview copies another owner's URL
A conflict overview uses the absolute path as its synthetic fileId when no matching view exists. Local or SSH tabs can also use that path as their real ID. If another host has that path open, this lookup selects its tab and skips the worktreeId check, so Copy Remote URL still copies the other owner's URL.
Check the supplied worktreeId on the ID match too. Borrowed views already pass their owning worktree.
Look up the gutter menu's owning file by fileId, falling back to a same-path match only within the editor's worktree so conflict-overview editors with synthetic ids still copy a URL. Drop the e2e proof spec and trim the unit test to the same-path/different-owner regression.
f486da6 to
b840387
Compare
Problem
The editor gutter menu's Copy Remote URL found the owning tab with
openFiles.find(f => f.filePath === filePath).openFilescan hold several tabs with the same absolute path under different owners (e.g. two SSH/runtime hosts with a repo at the same path, or a folder workspace overlapping a git worktree). The first match could belong to another owner, so its worktree path and runtime target were paired with this editor's relative path, copying a URL for the wrong repo/host or nothing at all.Fix
MonacoEditorpasses itsfileIdandworktreeIdtoMonacoGutterContextMenu.fileId. If that misses (conflict-review overview editors can carry a synthetic id), it falls back to a same-path match restricted to the editor's ownworktreeId; with noworktreeIdit does not fall back.Tests
MonacoGutterContextMenu.owner.test.tsx: two open files with the same path under different hosts; the mounted owner's worktree and runtime target are used. Fails on the old path lookup.use-monaco-editor-mount.cursor-owner.test.tsx: passes the newfileIdprop.pnpm check:changed --maxWorkers=2passes.