Waiting for a person to merge
Add a stage where a task waits for a person to merge its pull request. See how it starts and ends, what its states mean, and how to find it.
The built-in merge stage holds the task until every pull request it waits on is merged. The merge agent lands the request. CodeHerder then moves the task on. The agent does not.
Some teams want a person to press the merge button instead. A merge-hold stage supports that. A task that reaches it stops and waits, and no agent runs. When every pull request the task waits on is merged, CodeHerder moves the task on. If you want an agent to prepare the request and a person to merge it, see Let a person merge after the agent prepares the request.
A task can also wait for a person’s merge without a custom stage. An agent files a blocker that waits on a merge request, and the task resumes when the request merges, closes, fails its pipeline, has a conflict, gets approved or passes its pipeline. See the blockers guide for the full list.
This page covers setting up the stage, how a task enters and leaves it, what the task page shows while it waits, and how to find waiting tasks. For the built-in merge path, see The merge stage.
Before you start
- You must be an admin or owner of the workspace.
- Your plan must include Custom workflows, because you create a stage in your stage library. See What your plan unlocks.
- CodeHerder must be able to read your pull requests. In a cloud workspace, install the GitHub App on the repository, or connect GitHub or GitLab under Integrations. A task cannot enter the stage without one of these. A task that runs locally reads your pull request through your own sign-in instead.
No built-in workflow has a merge-hold stage with no agent. You add one to a workflow of your own. You set it up from the CLI today. The web app has no control for it. Settings → Stages keeps the setting on a stage that already has it, but it shows no toggle to turn it on.
Set up a merge-hold stage
Create a stage in your library and mark it as a merge-hold stage:
ch stage create await_merge --stage '{"label":"Waiting for merge","spec":{"awaits_external_merge":true}}'
A merge-hold stage does no work itself. It has no prompt, and no agent runs there. Check it with ch stage show await_merge. The output has a row awaits external merge with the value yes.
Then add the stage to a workflow. This example puts it between code and done:
{
"key": "hand_merge",
"label": "Hand merge",
"instances": [
{ "name": "todo", "stage": "todo", "class": "todo" },
{ "name": "code", "stage": "code", "class": "doing", "to": ["await_merge"] },
{ "name": "await_merge", "stage": "await_merge", "class": "doing", "to": ["done", "code"] },
{ "name": "done", "stage": "done", "class": "done", "terminal": "success" }
]
}
ch workspace workflow edit hand_merge --from-file composition.json
The stage must have class doing. CodeHerder rejects a merge-hold stage that has class done. It reports that when you save a workflow that uses the stage. See Composing a workflow from the library for the rest of the file format.
Let a person merge after the agent prepares the request
The built-in merge stage has a setting named externally_merged. With it on, the agent never merges. A person, or an outside process such as a merge queue, merges the request. The agent keeps the request ready until that happens. Use it when you want an agent to fix conflicts and review comments, but want a person to press the button.
Who can set it. An admin or owner can set it, on a workflow of their own, as any workflow edit. It needs the Custom workflows plan. An agent cannot set it. The web app has no toggle. Settings → Workflows keeps the setting when it is on, but you cannot turn it on there.
Set it up. Set "externally_merged": true on the merge stage in the workflow’s file. This example is a copy of the lightweight task pipeline:
{
"key": "person_merges",
"label": "Person merges",
"instances": [
{ "name": "todo", "stage": "todo", "class": "todo" },
{ "name": "code", "stage": "code", "class": "doing", "to": ["merge"] },
{ "name": "merge", "stage": "merge", "class": "doing", "externally_merged": true, "to": ["done", "code"] },
{ "name": "done", "stage": "done", "class": "done", "terminal": "success" }
]
}
ch workspace workflow edit person_merges --from-file composition.json
CodeHerder refuses the setting on a stage that does not wait for a merge, and on a stage with no agent. Use the built-in merge stage, or a copy of it. Check the result:
ch workspace workflow show person_merges
The merge stage line then reads externally_merged: yes.
What the agent does. It does not merge the request and does not move the task forward. It makes the request ready: it resolves conflicts and makes small fixes that a review asks for. It hands larger work back to code. Then it blocks the task on the request. If the session ends with no blocker, CodeHerder parks the task on the open requests for you. If no request is open, CodeHerder files a note that asks a person.
What wakes the task. The task wakes when the request:
- merges. CodeHerder then moves the task on, and no agent runs.
- closes without a merge. The agent does not reopen it. It asks a person.
- fails its pipeline, or a required job fails.
- has a conflict.
- is removed from the merge queue. The agent does not queue it again. It asks a person to queue it, or it fixes a real defect.
- gets a new reviewer comment or review.
A green pipeline or an approval does not wake the task. See Blockers that wait on a merge request for the rules on comments.
How a task enters and leaves the stage
Entering. Nothing moves a task into the stage by itself. The agent in the stage before it, or a person, moves the task there. For the workflow above, that is ch task status <taskId> await_merge. CodeHerder refuses the move in two cases:
- The task has no pull request recorded. The error says to run
ch task merge-requests create <taskId> <pr-or-mr-url>first. When an agent writes a pull request link into the task’sartifactfield, CodeHerder records it for you. You can record one yourself with the same command. - In a cloud workspace, no GitHub App installation or enabled integration covers the pull request’s repository.
Leaving. The task leaves when every pull request it waits on is merged. CodeHerder learns about a merge from a webhook from your git host. It also checks again about every two minutes. If only some pull requests are merged, the task keeps waiting. The task then moves to the next stage in the workflow. If that move needs approval, the task waits there for it.
Merged, but held. Sometimes every pull request is merged and the task still stays in the stage. This happens when an acceptance item is due before the next stage and is not ticked yet. The task page shows an info callout titled Merged — held for acceptance. It lists the due items. Up to three appear by name, then (and N more). ch task show prints a merge held row for each one, in the form <field>: <reason>. Tick the last due item, or move it to a later stage. The task then moves on at once. It does not wait for the next check.
Moving it by hand. A person cannot move a waiting task forward. This holds for the built-in merge stage too. CodeHerder answers that the task advances on its own once the merge is confirmed. Once every pull request is merged, the answer names the due acceptance items instead. You can still send the task back, block it, or cancel it, as far as the workflow allows each move.
Reacting to CI, reviewers and conflicts while it waits
By default the stage only watches for the merge. A merge-hold stage can also send the task back to an earlier stage when the pull request’s CI fails, a new reviewer thread arrives, or a conflict appears. A round cap blocks the task when it is reached. See Converge a merge request before merge.
Reading the wait
The task page shows a banner only when the pull request needs your attention: a draft, a conflict, or a closed pull request. It lists each pull request the task waits on, with a link and how long it has waited.
The state of the pull request has one of these labels. With several pull requests, the task shows the most urgent one, in this order: closed, conflicted, draft, open and mergeable, open and still checking. When your git host gives its full verdict for an open pull request, the verdict replaces the last two labels: Ready to merge or Open, not ready.
| Label | Meaning |
|---|---|
| Ready to merge | Your git host says the pull request can merge now: the pipeline passed, threads are resolved and the required approvals are in. GitLab reports mergeable. GitHub reports clean. |
Open, not ready: <reason> |
Your git host holds the pull request back. The reason is the host’s own word, for example not_approved, ci_must_pass, discussions_not_resolved, need_rebase or draft_status on GitLab, and blocked, behind or unstable on GitHub. With several pull requests, the task is ready only when every one is ready. Otherwise it shows the reason of the first one that is not. |
| Open and mergeable | The pull request has no merge conflict. Your git host has not given its full verdict yet. |
| Open, checking mergeability | Your git host has not finished checking it. |
| Draft | The pull request is a draft. Mark it ready for review. |
| Conflicted, needs a decision | The pull request has a merge conflict. |
| PR closed, needs a decision | Someone closed the pull request without merging it. |
When a decision is needed, the banner offers buttons. Each button appears only if the workflow allows that move:
- Send back to
<stage>moves the task to the nearest earlier stage where an agent can write code, usuallycode. - Cancel task cancels the task.
CLI output shows the same facts:
ch task show <taskId>
While a task waits, the output has a row like awaited PR: conflicted, needs a decision (move it to code or cancelled), since 13:04. The state is ready to merge, open, not ready: <reason>, mergeable, checking, draft, conflicted or closed. The time reads just now or N min ago within the last hour. Later the same day it shows a clock time. Within the past week it adds the weekday, for example Mon 13:04. Older times show the date, for example Jan 2, 13:04. The PR column of ch task list shows the link, then (merged) for a merged pull request. While the task waits, it shows (ready), (not ready: <reason>), (draft), (conflicted), (closed), (mergeable) or (checking) instead.
The host state of a waiting task’s pull request refreshes on a webhook or on the two-minute check. A new approval or pipeline result does not always send a webhook. So CodeHerder reads a pull request that is not ready from your git host on every two-minute check. A change on your git host can take that long to show.
On the Tasks page, a row with a recorded pull request shows a pull request icon beside its title. Hover the icon to see which pull request it is and its state. A task with several shows how many there are and how many have merged.
When something goes wrong
The pull request closes without a merge. The task stays in the stage. CodeHerder files a blocker that starts with “PR/MR closed without merging”. Reopen the pull request, or use the banner buttons to send the task back or cancel it. If you reopen it, CodeHerder clears the note on a later check. See Blockers and blocked tasks.
CodeHerder cannot read the pull request. After three failed reads in a row, it files a blocker that starts with “Can’t verify merge status” and gives the reason. The reason says what failed. Fix the connection to your git host. The next successful check clears the blocker.
The task is stuck although the pull request merged. An admin or owner can confirm the merge by hand and give a reason:
ch task status <taskId> done --force-merge-confirm --reason "Merged on the host; webhook missed"
Use the stage the workflow moves to next in place of done. CodeHerder posts a task comment that records the override and your reason. There is no web control for this.
Finding tasks that wait
In the web app, open Tasks and use the PR state filter:
- Awaiting merge shows tasks whose pull request is open and asking for a merge. A draft, conflicted or closed pull request does not count.
- Ready to merge shows tasks whose pull requests all have your git host’s full verdict to merge. It is stricter than Awaiting merge.
- Draft shows tasks whose pull request is a draft.
- Needs a decision shows tasks whose pull request is conflicted or closed.
From the CLI:
ch task list --merge-state awaiting --status await_merge
ch task list --merge-state ready --status await_merge
ch task list --merge-state needs_decision --status await_merge
The filter matches any task that has a recorded pull request that is not merged, at any stage, not only tasks in a merge-hold stage. A task in review with an open pull request also matches Awaiting merge. Combine the filter with the Stage filter, or with --status, to list only the tasks that wait in your merge-hold stage. See Tracking work.
Tasks that run locally
A task you run on your own machine has no webhook from your git host. A local task that has a recorded pull request still detects the merge. ch reads the pull request through your own signed-in gh or glab command. It reads at once, then about every 30 seconds while the task waits.
- Merged. The task moves on, as in a cloud workspace.
- Closed without a merge.
chfiles a note that starts with “PR/MR closed without merging”. It clears the note if the pull request reopens. - Can’t read it. After three failed reads in a row,
chfiles a note that starts with “Can’t verify merge status”. The next good read clears it. A read that your host rate-limits is paused and does not count.
Sign in to gh or glab on the machine that runs ch. --force-merge-confirm works for a local task too.
Related guides
- How work flows for the built-in stages, including the merge stage.
- The stage library for creating and composing stages.
- Task status on pull requests for the status badge on a pull request, and how to remove the retired
CodeHerdercheck. - Blockers and blocked tasks for what a blocker does.
Last updated