Skip to content

fix(editor): copy gutter URLs from the owning file - #34922

Merged
OrcaWin merged 2 commits into
mainfrom
OrcaWin/editor-gutter-url-owner
Oct 29, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
OrcaWin/editor-gutter-url-owner

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13

Problem

The editor gutter menu's Copy Remote URL found the owning tab with openFiles.find(f => f.filePath === filePath). openFiles can 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

  • MonacoEditor passes its fileId and worktreeId to MonacoGutterContextMenu.
  • The menu looks up the owning file by 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 own worktreeId; with no worktreeId it 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 new fileId prop.
  • pnpm check:changed --maxWorkers=2 passes.

@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-gutter-url-owner branch from 27f0dd1 to f486da6 Compare October 28, 2026 23:58
@OrcaWin
OrcaWin marked this pull request as ready for review October 29, 2026 00:08
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 40758c12-904d-4658-a49d-98d0f59a47c9
Commits

Reviewing files that changed from the base of the PR and between b2feed0 and b840387.

Files selected for processing: 4
  • src/renderer/src/components/editor/MonacoEditor.tsx
  • src/renderer/src/components/editor/MonacoGutterContextMenu.owner.test.tsx
  • src/renderer/src/components/editor/MonacoGutterContextMenu.tsx
  • src/renderer/src/components/editor/use-monaco-editor-mount.cursor-owner.test.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[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 worktreeId.

Findings

  1. P1 Overview copies another owner's URL ▶

Summary

The PR makes gutter URL copying use the mounted editor's file ID instead of the first matching path.

  • Copy Remote URL follows the file open in the editor.

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) ??

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.
@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-gutter-url-owner branch from f486da6 to b840387 Compare October 29, 2026 00:28
@OrcaWin
OrcaWin merged commit f0c8645 into main Oct 29, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant