Skip to content

feat: edit existing PR via compose buffer#52

Merged
barrettruth merged 1 commit intomainfrom
feat/edit-pr
Apr 4, 2026
Merged

feat: edit existing PR via compose buffer#52
barrettruth merged 1 commit intomainfrom
feat/edit-pr

Conversation

@barrettruth
Copy link
Copy Markdown
Owner

Summary

Adds the ability to edit an existing PR through the same compose buffer UX used for creation. Closes #21.

Entry points

  • :Forge pr edit {num} — direct command to edit a specific PR
  • <c-e> in PR picker — new keybinding opens edit buffer for the selected PR
  • Auto-redirect:Forge pr create on a branch with an existing PR now opens the edit buffer instead of bailing out with a warning

Keybinding changes

  • edit = <c-e> (previously manage)
  • manage = <c-m> (new binding)

Backend methods added (all 3 forges)

Method GitHub GitLab Codeberg
fetch_pr_details_cmd(num) gh pr view --json ... glab mr view --output json tea api /repos/:owner/:repo/pulls/{num}
update_pr_cmd(...) gh pr edit with --add-* flags glab mr update tea pr edit (title/body only)
parse_pr_details(json) labels, assignees, reviewRequests, milestone labels, assignees, reviewers, milestone labels, assignees, milestone

Compose buffer for editing

  • open_pr_edit() opens a compose buffer pre-filled with the PR's current title, body, and all metadata
  • Buffer name: forge://pr/{num}/edit
  • Comment block says "Editing Pull Request #N via github"
  • On :w, calls update_pr_cmd() instead of create_pr_cmd()
  • Draft toggle handled separately via draft_toggle_cmd() when draft state changes

Files changed

  • lua/forge/github.lua — +3 methods
  • lua/forge/gitlab.lua — +3 methods
  • lua/forge/codeberg.lua — +3 methods
  • lua/forge/compose.luaupdate_pr() + open_pr_edit()
  • lua/forge/init.luaedit_pr() + auto-redirect in create_pr()
  • lua/forge/pickers.luaedit action in PR picker
  • lua/forge/config.lua — type annotations + keybinding defaults
  • plugin/forge.lua:Forge pr edit dispatch + tab completion

Test plan

  • All 158 existing tests pass
  • StyLua formatting clean
  • Manual: :Forge pr edit {num} fetches and opens compose buffer
  • Manual: <c-e> in PR picker opens edit buffer
  • Manual: :Forge pr create on branch with existing PR auto-redirects to edit
  • Manual: Editing title/body/metadata and writing updates the PR
  • Manual: Changing draft state toggles draft on save

Add the ability to edit an existing PR through the same compose buffer
UX used for creation. Three entry points:

- :Forge pr edit {num} command
- <c-e> picker action in the PR list (swapped with manage, now <c-m>)
- Auto-redirect: :Forge pr create on a branch with an existing PR
  opens the edit buffer instead of bailing out

Each backend gains fetch_pr_details_cmd(), update_pr_cmd(), and
parse_pr_details() to fetch current PR data and apply updates.
Draft toggle is handled separately after the edit when the draft
state changes.

Closes #21
@barrettruth barrettruth merged commit b3c24f8 into main Apr 4, 2026
7 checks passed
@barrettruth barrettruth deleted the feat/edit-pr branch April 4, 2026 22:59
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.

how to EDIT EXISTING pr?

1 participant