Skip to content

feat: open in browser — o shortcut to open the focused result's GitHub URL#72

Merged
shouze merged 2 commits intofeat/tui-navigation-result-managementfrom
feat/tui-open-in-browser
Mar 1, 2026
Merged

feat: open in browser — o shortcut to open the focused result's GitHub URL#72
shouze merged 2 commits intofeat/tui-navigation-result-managementfrom
feat/tui-open-in-browser

Conversation

@shouze
Copy link
Contributor

@shouze shouze commented Mar 1, 2026

Context

Part of the 🗂 TUI — Navigation & result management EPIC #66.
Closes #69.

Root cause / motivation

Users frequently want to open a result directly on GitHub without having to copy the URL. This adds a single keystroke to do it.

What changed

File Change
src/tui.ts New openInBrowser(url) helper: uses open (macOS), xdg-open (Linux) or start (Windows), spawned via Bun.spawn with all stdio null so the TUI stays fully responsive. o keypress: repo row → opens https://github.com/<org>/<repo>; extract row → opens CodeMatch.htmlUrl; section header → no-op.
src/render.ts renderHelpOverlay: new o open in browser line. Status bar hint: o open.
src/render.test.ts 2 new tests: overlay contains open in browser; status bar contains o open.
docs/reference/keyboard-shortcuts.md New row o in the Selection table.

How to test manually

bun github-code-search.ts query --org <your-org> <some-query>
# In the TUI:
#   Navigate to a repo row → press o → browser opens the repo page
#   Navigate to an extract row → press o → browser opens the file
#   Press ? → help overlay shows the o entry

Validation

bun test        ✅ 403 pass, 0 fail
bun run lint    ✅ 0 warnings, 0 errors
bun run format:check  ✅
bun run knip    ✅

Copilot AI review requested due to automatic review settings March 1, 2026 23:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a single-keystroke o shortcut to the interactive TUI that opens the focused result's GitHub URL in the system default browser. It is part of the larger TUI Navigation & Result Management EPIC (#66).

Changes:

  • New openInBrowser(url) helper in src/tui.ts that dispatches to the platform-appropriate open command, plus a new o keypress handler in the main input loop.
  • Updated src/render.ts to surface the shortcut in both the help overlay and the status-bar hint line.
  • Two new render tests (src/render.test.ts) verifying the overlay and status-bar text.
  • New row in docs/reference/keyboard-shortcuts.md documenting the o key under the Selection table.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/tui.ts Adds openInBrowser() helper and o keypress handler
src/render.ts Adds o open in browser line to help overlay and status bar
src/render.test.ts Tests that overlay and status bar contain the new shortcut text
docs/reference/keyboard-shortcuts.md Documents the o shortcut in the Selection table

shouze added 2 commits March 2, 2026 00:15
Closes #69

- openInBrowser() helper: open/xdg-open/start depending on platform,
  spawned detached so the TUI stays responsive
- Repo row -> opens https://github.com/<org>/<repo>
- Extract row -> opens the file htmlUrl returned by the GitHub API
- Section header rows are a no-op (type === 'section')
- renderHelpOverlay: adds 'o  open in browser' entry
- Status bar hint line: adds 'o open'
- Tests: overlay contains 'open in browser', status bar contains 'o open'
- docs/reference/keyboard-shortcuts.md: documents the shortcut in
  the Selection table
@shouze shouze force-pushed the feat/tui-open-in-browser branch from 4ebf9d2 to b38cc03 Compare March 1, 2026 23:16
@shouze shouze self-assigned this Mar 1, 2026
@shouze shouze merged commit 68bad64 into feat/tui-navigation-result-management Mar 1, 2026
2 checks passed
@shouze shouze deleted the feat/tui-open-in-browser branch March 1, 2026 23:16
@shouze
Copy link
Contributor Author

shouze commented Mar 1, 2026

Both review points addressed in commit b38cc03:

  1. Windows start as cmd.exe built-in — fixed by replacing ["start", url] with ["cmd", "/c", "start", "", url]. The empty string before the URL is required to prevent start from misinterpreting the URL as a window title.

  2. JSDoc "detached" inaccuracy — replaced with "Fire-and-forget with all stdio set to null" which accurately describes the Bun.spawn call with { stdout: null, stderr: null, stdin: null }.

Also rebased onto the updated feat/tui-navigation-result-management (which now includes the merged PR #70 commits), keeping both the Z fold-all and o open entries in the status bar hint line and in the test suite (now 404 tests, all green).

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.

2 participants