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

* feat: add copy remote URL to line number context menu

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

* refactor: use @types/hosted-git-info instead of custom type declarations

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

* refactor: revert to local type declarations for hosted-git-info

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.
This commit is contained in:
Matheus Nogueira
2026-04-01 20:02:05 -03:00
committed by GitHub
parent e8e7d2ea8f
commit 2ec433f6df
8 changed files with 143 additions and 2 deletions
+5
View File
@@ -172,6 +172,11 @@ type GitApi = {
stage: (args: { worktreePath: string; filePath: string }) => Promise<void>
unstage: (args: { worktreePath: string; filePath: string }) => Promise<void>
discard: (args: { worktreePath: string; filePath: string }) => Promise<void>
remoteFileUrl: (args: {
worktreePath: string
relativePath: string
line: number
}) => Promise<string | null>
}
type Api = {
+6 -1
View File
@@ -283,7 +283,12 @@ const api = {
unstage: (args: { worktreePath: string; filePath: string }): Promise<void> =>
ipcRenderer.invoke('git:unstage', args),
discard: (args: { worktreePath: string; filePath: string }): Promise<void> =>
ipcRenderer.invoke('git:discard', args)
ipcRenderer.invoke('git:discard', args),
remoteFileUrl: (args: {
worktreePath: string
relativePath: string
line: number
}): Promise<string | null> => ipcRenderer.invoke('git:remoteFileUrl', args)
},
ui: {