Clear PR caches after the draft toggle resolves #785

Merged
barrettruth merged 1 commit from fix/pr-edit-draft-toggle-sequence into main 2026-06-08 20:10:14 +00:00
Owner

Checklist

  • I have read CONTRIBUTING.md.
  • No AI was used to generate, edit, or review any part of this contribution.

Problem

Editing a PR's metadata to flip draft on a native-draft backend (GitHub/GitLab) applies the draft change through a separate draft_toggle_cmd after the main update. update_pr dispatched that command but then ran clear_list() and reported the submit done synchronously — before the toggle resolved. A refresh could race the in-flight toggle and re-cache the stale draft state, and a failed toggle was only logged while the edit still reported success. (Forgejo folds draft into the title via the main update, so it was unaffected.)

Solution

Move the post-update finalize (clear_list() + completion) into a finish() step that runs after the draft toggle resolves, mirroring the existing apply_created_pr_reviewers follow-up. When no toggle is needed it runs immediately; on toggle failure the error is logged and the edit still finishes. Adds regression specs covering both: caches clear only after the toggle resolves, and a failed toggle still finishes.

## Checklist - [ ] I have read [CONTRIBUTING.md](https://git.barrettruth.com/barrettruth/forge.nvim/src/branch/main/CONTRIBUTING.md). - [ ] No AI was used to generate, edit, or review any part of this contribution. ## Problem Editing a PR's metadata to flip draft on a native-draft backend (GitHub/GitLab) applies the draft change through a separate `draft_toggle_cmd` after the main update. `update_pr` dispatched that command but then ran `clear_list()` and reported the submit done synchronously — before the toggle resolved. A refresh could race the in-flight toggle and re-cache the stale draft state, and a failed toggle was only logged while the edit still reported success. (Forgejo folds draft into the title via the main update, so it was unaffected.) ## Solution Move the post-update finalize (`clear_list()` + completion) into a `finish()` step that runs after the draft toggle resolves, mirroring the existing `apply_created_pr_reviewers` follow-up. When no toggle is needed it runs immediately; on toggle failure the error is logged and the edit still finishes. Adds regression specs covering both: caches clear only after the toggle resolves, and a failed toggle still finishes.
Clear PR caches after the draft toggle resolves
Some checks failed
quality / Format (pull_request) Has been cancelled
quality / Lint (pull_request) Has been cancelled
quality / Test (pull_request) Has been cancelled
7f9faa95cd
barrettruth deleted branch fix/pr-edit-draft-toggle-sequence 2026-06-08 20:10:14 +00:00
Sign in to join this conversation.
No description provided.