Skip to content

feat: add copy remote URL to line number context menu#253

Merged
mathnogueira merged 3 commits intomainfrom
mathnogueira/github-link
Apr 1, 2026
Merged

feat: add copy remote URL to line number context menu#253
mathnogueira merged 3 commits intomainfrom
mathnogueira/github-link

Conversation

@mathnogueira
Copy link
Copy Markdown
Collaborator

Problem

When viewing code in Orca, users had no easy way to share a direct link to a specific line of code hosted on GitHub, GitLab, Bitbucket, or other git providers. The existing line number context menu only offered copying local file paths, not shareable remote URLs.

Solution

Added a "Copy Remote URL" option to the line number gutter right-click menu that:

  • Parses the git remote origin URL using hosted-git-info library
  • Generates a browsable file URL pointing to the default branch
  • Supports multiple hosted providers (GitHub, GitLab, Bitbucket, Gitea, etc.)
  • Appends the line number fragment for precise linking
  • Uses an ExternalLink icon to distinguish it from local path copy options

Changes

  • src/main/git/repo.ts: Added getRemoteFileUrl() function to resolve file URLs
  • src/main/types/hosted-git-info.d.ts: Type declarations for the library
  • src/main/ipc/filesystem.ts: Added git:remoteFileUrl IPC handler
  • src/preload/index.ts: Exposed git.remoteFileUrl() to renderer
  • src/renderer/src/components/editor/MonacoEditor.tsx: Added menu item with ExternalLink icon

Testing

  • All existing tests pass
  • Linting and type checking pass

Add 'Copy Remote URL' option to the line number gutter right-click menu,
allowing users to quickly copy a shareable link to a file and line on
GitHub, GitLab, Bitbucket, or other hosted git providers.

- Install hosted-git-info to parse remote URLs and generate browse URLs
- Add getRemoteFileUrl() to resolve file URLs using default branch
- Wire up IPC handler, preload bridge, and renderer UI
- Use ExternalLink icon to distinguish from path copy options
Replace the custom hosted-git-info.d.ts with the @types package from
DefinitelyTyped. Use a targeted cast for browseFile() which the @types
package doesn't include yet (stuck on v3 API).
The @types/hosted-git-info package is stuck on the v3 API and lacks
browseFile(). A local .d.ts is cleaner than casting around stale types.
@mathnogueira mathnogueira merged commit 2ec433f into main Apr 1, 2026
1 check 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