Repository navigation
feat(pr): move task to new PR/MR created on the same branch - #471
Conversation
Once a tracked PR or MR is merged or closed, keep tracking that settled identity across detached checkouts or branch switches, but roll the task over to a newer PR or MR created on the same branch. - Track each task's and composition member's PR source branch (`pr_head`) and reject replacements from other branches, detached HEADs, fork review aliases (`pr-<n>-<head>`), unrelated forks, or older open PRs. - Resolve legacy records lacking `pr_head` by stored number first before evaluating rollover, and handle `merged -> merged` transitions cleanly. - Scan same-branch replacements on GitHub in lightweight paginated GraphQL batches and hydrate only selected winners, preserving cached entries on rate refusals or transient errors. - Serialize task PR persistence so stale polls cannot overwrite a newly created PR, and hydrate `task_pr_create` by the returned PR number. - Support `--hostname` + percent-encoded project paths on GitLab API fallbacks, `source_project_id` / `forkSource` filtering on GitLab and Azure, URL-based fallback for checkouts without `.git`, turn-end discovery, and a "+" action on settled PR cards to open a new PR.
|
Could you add a direct test for — Simion's agent here, he'll take a look at this shortly. |
|
Added Verified with |
simion
left a comment
There was a problem hiding this comment.
Good fix, and the added test covers exactly the branch-switch/detached HEAD case called out. Merging.
Summary
Once a task's PR or MR was merged or closed, Termic previously kept polling that settled identity forever even when Phase 2 work continued on the same branch and a new PR or MR was opened.
This change keeps the task pinned to the settled PR or MR until a newer PR or MR exists on the same branch,
while continuing to stay pinned on the settled PR if the checkout switched branches or detached HEAD.
What changed
src-tauri/src/lib.rs,src-tauri/src/forge.rs):pr_head(headRefName/source_branch) onTaskandTaskMemberso rollover checks know which branch the tracked PR or MR came from.pr_headby stored PR number first so their real head branch is backfilled before evaluating any branch lookup.candidate.number > known_number) on the same branch (branch == pr_head), keeping detached HEADs, moved branches, fork review aliases (pr-<n>-<head>), unrelated forks, and older open PRs targeting other bases out of rollover.CheckoutBranchdistinction (OnBranchvsDetachedvsNoGit) and GitHub URL fallback (pr_lookup_github_url_fallback) so tasks whose.gitcheckout is absent on disk still roll over using their cached GitHub URL and branch while real detached checkouts stay pinned.src-tauri/src/forge.rs,src-tauri/src/lib.rs):batch_routeto emitBatchRoute::SettledSameBranchand addedgithub_branch_pr_replacements_batchusing lightweight paginated GraphQL candidate scans (first: 20, up to 5 pages) followed bygithub_pr_status_batch_metahydration for selected winners only.ReplacementOutcome(KeepOld,Replace,Retry) and failure streak fallback so rate refusals, partial alias nulls, or transient GraphQL errors leave the cached UI entry intact without locking into long backoff.pr_persist_lockandapply_pr_identityso slow background polls cannot overwrite a newer PR just saved bytask_pr_create, and updatedtask_pr_createto hydrate by the returned PR number.gitlab_newest_open_mr_iid,gitlab_mr_status) to pass--hostnameplus a percent-encoded project path on server-backed tasks (instead of unsupported-Ronglab api) and matchsource_project_id, and updated Azurepick_azure_branch_prto matchforkSourceand ignore older IDs once settled.src/store/pr.ts,src/components/task/PrCard.tsx,src/locales/,docs/ipc.md):setLookup, checked settled PRs on turn-end (bypassing the 30s floor, including settled multi-repo members), reduced background polling forbatchablesettled GitHub PRs to 3 minutes (SETTLED_BATCH_STALE_MS) alongside Rust'sRECHECK_SECS, enabledunseenhighlights and opened toasts when replacing a settled PR, and keyedwasMergedchecks on(provider, number)so a directmerged -> mergedrollover still runs the merge lifecycle.+button (pr-create-new) on merged and closed PR cards with matching English and Simplified Chinesepr.createNewstrings, updatede2e/specs/git.e2e.ts, and documented the updated batch flow indocs/ipc.md.Testing
npm test:256test files,3956tests passed (including rollover unit tests insrc/store/pr.test.ts).cargo test --workspace --lib --manifest-path src-tauri/Cargo.toml: passed (termic_lib:1770 passed; 0 failed; 8 ignored;termic_cli:98 passed;termic_proto:29 passed;termic_remote:73 passed).cargo check --lib,npm run build(tsc -b && vite build),npm run typecheck:e2e, andgit diff --check HEAD: all passed after the final edit.make e2eWebDriver runs were not executed locally.