resolver: add current-PR resolution from head context #390

Closed
opened 2026-04-25 16:20:51 +00:00 by barrettruth · 0 comments
barrettruth commented 2026-04-25 16:20:51 +00:00

Part of #389.

Problem

Current PR lookup already exists in backend pr_for_branch_cmd(...) implementations, but it is only used ad hoc from the PR creation flow. Ex commands, picker actions, and Lua APIs all express targeting differently, so there is no single semantic resolver for "the PR for this branch context".

Proposed solution

Add a shared resolver layer that can:

  • resolve repository addresses into scopes
  • resolve head addresses into { branch, scope }
  • resolve the current PR from current head context or explicit repo= / head= input

Suggested public/internal shape:

  • public helper: require(forge).current_pr(opts?)
  • internal/shared resolver: forge.resolve.current_pr(opts?)

Scope

  • add the new resolver module and typed return values
  • define the current-PR heuristic and error messages
  • cover push-remote vs collaboration fallback, detached HEAD, and ambiguity paths in specs

Acceptance criteria

  • there is one shared code path for current-PR resolution reused by higher-level Ex and Lua entrypoints
  • no command family performs ad hoc branch->PR lookup outside that resolver
  • ambiguity errors explicitly tell the user to pass repo= or head=

Out of scope

  • new Ex commands
  • renaming or removing existing Lua APIs
Part of #389. ## Problem Current PR lookup already exists in backend `pr_for_branch_cmd(...)` implementations, but it is only used ad hoc from the PR creation flow. Ex commands, picker actions, and Lua APIs all express targeting differently, so there is no single semantic resolver for "the PR for this branch context". ## Proposed solution Add a shared resolver layer that can: - resolve repository addresses into scopes - resolve head addresses into `{ branch, scope }` - resolve the current PR from current head context or explicit `repo=` / `head=` input Suggested public/internal shape: - public helper: `require(forge).current_pr(opts?)` - internal/shared resolver: `forge.resolve.current_pr(opts?)` ## Scope - add the new resolver module and typed return values - define the current-PR heuristic and error messages - cover push-remote vs collaboration fallback, detached HEAD, and ambiguity paths in specs ## Acceptance criteria - there is one shared code path for current-PR resolution reused by higher-level Ex and Lua entrypoints - no command family performs ad hoc branch->PR lookup outside that resolver - ambiguity errors explicitly tell the user to pass `repo=` or `head=` ## Out of scope - new Ex commands - renaming or removing existing Lua APIs
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
barrettruth/forge.nvim#390
No description provided.