refactor!: unify forge:// bufnames to host/slug/resource scheme#288
Merged
barrettruth merged 1 commit intomainfrom Apr 17, 2026
Merged
refactor!: unify forge:// bufnames to host/slug/resource scheme#288barrettruth merged 1 commit intomainfrom
barrettruth merged 1 commit intomainfrom
Conversation
- Replace 6 scattered bufname formats with a single
forge://{host}/{slug}/{resource}/{id-or-action}[/{sub}] scheme,
eliminating silent collision bugs for same-repo and cross-repo edits
as well as the forge://log/{title} / forge://ci/{title} default-title
collisions that the previous pcall was swallowing
- Thread scope+run_id through LogOpts/SummaryOpts and all 6 log.lua
callers (ops.lua, pickers.lua); drop the opts.title field
- compose.lua gains a resolve_bufpath helper with current_scope
fallback; buffers refuse to open loudly when no scope is available
- log.lua reuses an existing buffer when a bufname collides, fixing
the duplicate unnamed-buffer case on repeat CI opens
- Update 8 spec files to match the new surface; doc/forge.nvim.txt
compose-section references updated to the new format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
forge.nvim had six ad-hoc bufname formats:
forge://pr/new,forge://pr/{num}/edit,forge://issue/new,forge://issue/{num}/edit,forge://log/{title},forge://ci/{title}. The first four collide across repos (:Forge pr edit 42in repo A vsrepo=upstreampulls both toforge://pr/42/edit). The last two collide on their default'ci'/'summary'titles when the same CI run is opened twice — thepcallaroundnvim_buf_set_namewas silently swallowing the failure, producing unnamed duplicate buffers. Compose/log/ci buffer naming had zero scoping.Solution
Single scheme:
scope.bufpath(scope)new helper returning"{host}/{slug}"ornilcompose.luagains a localresolve_bufpath(ref, forge_name)that tries the explicit scope first and falls back toforge.current_scope(forge_name)via origin remote. All 4 compose open sites use it;pcalldropped fromnvim_buf_set_name. When no scope can be resolved (not in a repo, no detectable remote) compose refuses to open with a warning instead of creating a nameless buffer.log.luaLogOpts/SummaryOptsdroptitleand gainscope+run_id. New helperslog_bufname()/summary_bufname()produceforge://{host}/{slug}/ci/{run_id}[/log|/job/{job_id}]. BothM.openandM.open_summarynow look up an existing buffer by name before creating a new one, fixing the duplicate-unnamed-buffer bug.ops.lua5 callsites (3×log.open, 2×log.open_summary) threadscope = run_refandrun_id = run.idthrough the opts tables; drop the oldtitle = ...composition.pickers.lua1 callsite in the PR checks picker threadsscope = check_refandrun_id = run_id.Concrete examples:
8 spec files updated: mocks gain
current_scope, opts assertions usescope/run_idinstead oftitle, literal bufnames updated to the new format.doc/forge.nvim.txtcompose-section bufname references updated;PROSPECTIVE_CHANGES.mdline 179's revisit TODO is now addressed.Breaking:
LogOpts.titleandSummaryOpts.titleare gone; both now requirescope+run_id(scopeis optional at the type level to tolerate test stubs with partial context, but production paths all supply it). Existing bufname literals anyone scripted against no longer match.scripts/ci.shgreen: stylua / selene / prettier / nix fmt / lua-language-server / vimdoc-language-server / busted (443/0).