Skip to content

feat(cmd): argless :Forge {pr,issue,release} browse opens forge list pages#292

Merged
barrettruth merged 2 commits intomainfrom
feat/argless-browse
Apr 17, 2026
Merged

feat(cmd): argless :Forge {pr,issue,release} browse opens forge list pages#292
barrettruth merged 2 commits intomainfrom
feat/argless-browse

Conversation

@barrettruth
Copy link
Copy Markdown
Owner

Problem

The browse verb on pr, issue, and release requires a subject
(number or tag), so invoking :Forge pr browse alone errors out. The
only way to reach a forge's repo-level list page today is the in-editor
picker; there is no command-line path even though every backend can
construct that URL via list_web_url.

Solution

Relax each of the three browse subject specs from min = 1 to
min = 0, max = 1 and branch each dispatcher on whether a subject was
provided. Argful invocations continue to route through
ops.{pr,issue,release}_browse unchanged; argless invocations call
the new ops.list_browse(f, kind, opts) helper, which consumes
f:list_web_url(kind, scope) and opens the result via vim.ui.open.
When a source has no landing page for the kind, list_browse warns
with "<forge> does not support <kind> landing pages" rather than
constructing a bogus URL. Strictly additive for existing callers.

Closes #286.

…pages

Problem: The `browse` verb on `pr`, `issue`, and `release` requires a
subject (number or tag), so invoking `:Forge pr browse` alone errors
out. The only way to reach a forge's repo-level list page today is the
in-editor picker; there is no command-line path even though every
backend can construct that URL via `list_web_url`.

Solution: Relax each of the three `browse` subject specs from
`min = 1` to `min = 0, max = 1` and branch each dispatcher on whether
a subject was provided. Argful invocations continue to route through
`ops.{pr,issue,release}_browse` unchanged; argless invocations call
the new `ops.list_browse(f, kind, opts)` helper, which consumes
`f:list_web_url(kind, scope)` and opens the result via `vim.ui.open`.
When a source has no landing page for the kind, `list_browse` warns
with `"<forge> does not support <kind> landing pages"` rather than
constructing a bogus URL. Strictly additive for existing callers.
Problem: Review feedback flagged that the browse cluster in `ops.lua`
was inconsistently annotated — `browse_repo`, `browse_commit`,
`browse_branch`, `browse_contextual`, `browse_location`, and
`browse_file` had no `@param` / `@return` annotations, and the new
`list_browse` was missing `@param f forge.Forge`. Adding annotations
also exposed that `browse_file` is called from `cmd.lua` with a
possibly-nil `ctx_branch`, so the function's real contract accepts
`string?` but its inner `f:browse` call expects `string`.

Solution: Add `---@param` / `---@return` annotations to every public
browse helper in `ops.lua` and complete the ones on `list_browse`.
Refactor `browse_file` to assign `trim(file_loc)` / `trim(branch)`
into their own names up front, which narrows the types from `string?`
to `string` by the time the inner `f:browse` call runs — preserving
the existing nil-tolerant behavior without a cast. No functional
change; selene, luals, and busted stay green.
@barrettruth barrettruth merged commit 68506e0 into main Apr 17, 2026
8 checks passed
@barrettruth barrettruth deleted the feat/argless-browse branch April 17, 2026 18:23
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.

feat(cmd): argless :Forge {pr,issue,release} browse opens forge list pages

1 participant