Skip to content

feat(filetree): open the selected file or directory on GitHub#331

Open
jongio wants to merge 1 commit into
mainfrom
idea/filetree-open-on-github
Open

feat(filetree): open the selected file or directory on GitHub#331
jongio wants to merge 1 commit into
mainfrom
idea/filetree-open-on-github

Conversation

@jongio

@jongio jongio commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Adds a B keybinding to the file tree that opens the entry under the cursor on GitHub in the default browser, pinned to the current HEAD commit.

Files open at their blob URL and directories at their tree URL. The tree could open files locally (editor, default app) but had no way to jump to the same file on GitHub.

Changes

  • New openOnGitHub() handler plus a pure blobTreeURL builder in internal/panels/filetree/github.go
  • Wired the B key into the dispatch switch and KeyBindings() (o and O were already taken by the local open actions)
  • Updated keybindings.json and regenerated docs/keybindings.md
  • Unit tests for the URL builder (blob, tree, root, path escaping, non-github) and the handler guard paths

Behavior

  • File under cursor: opens https://github.com/<owner>/<repo>/blob/<sha>/<path>
  • Directory under cursor: opens .../tree/<sha>/<path>
  • Repository root: opens .../tree/<sha>
  • No-op when nothing is selected; clear toast when there is no github remote

Verification

  • go build ./... clean
  • go test ./internal/panels/filetree/ ./internal/keybindings/ pass
  • gofumpt and go vet clean

Closes #325

Add a `B` keybinding to the file tree that opens the entry under the
cursor on github.com in the default browser, pinned to the current HEAD
commit. Files open at their blob URL and directories at their tree URL.
The tree could open files locally (editor, default app) but had no way
to jump to the same file on GitHub.

The handler resolves the git root and origin remote, converts the
remote to an https github.com base with the existing RemoteToHTTPS
helper, computes the repo-relative path, and builds
`/blob/<sha>/<path>` for files or `/tree/<sha>/<path>` for directories.
Path segments are percent-escaped. It is a no-op when nothing is
selected and shows a clear toast when the repo has no github remote or
the entry sits outside the repository.

`o` (open in editor) and `O` (open in default app) were already taken,
so this uses `B` for browse. keybindings.json and docs/keybindings.md
are updated.

Closes #325

Co-authored-by: Copilot App <[email protected]>
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 13, 2026
@jongio jongio self-assigned this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a secret GitHub gist from the previewed file

1 participant