diff --git a/README.md b/README.md
index b2bf34c..4ce5ed0 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,8 @@ The MVP is Codex-first:
- reads Codex hook JSON from stdin;
- captures only explicit plan blocks such as `...`, `...`, or `## Accepted Plan`;
- stores captured plans and planning Q/A decisions in `.agent-plan.json`;
-- posts a new PR comment with newly captured current-branch items when an open PR exists;
-- leaves the local stack queued when no open PR exists yet.
+- posts a new PR comment with newly captured current-branch items when a valid (open, non-draft) PR exists;
+- leaves the local stack queued when no valid PR exists yet.
## CLI
@@ -46,7 +46,7 @@ If an agent emits known XML-style plan sections (`summary`, `flow`, `test_plan`,
## Pull Request Comments
-When `gh pr view` finds an open PR for the current branch, `plan-to-git` creates a new issue comment on that PR containing items that have not been posted before:
+When `gh pr view` finds an open, non-draft PR for the current branch, `plan-to-git` creates a new issue comment on that PR containing items that have not been posted before:
```markdown
## Agent Plan Update
@@ -54,7 +54,7 @@ When `gh pr view` finds an open PR for the current branch, `plan-to-git` creates
...
```
-The PR description is not edited. Closed or merged pull requests are not commented on; new items stay queued until an open PR exists. After a comment is created, `.agent-plan.json` records the posted item hashes and GitHub comment id so repeated `sync`, `hook`, or `import-codex` runs do not post the same plan again, including on a later PR.
+The PR description is not edited. Closed, merged, or still-draft pull requests are not commented on; new items stay queued until the PR is valid (open and marked ready for review). After a comment is created, `.agent-plan.json` records the posted item hashes and GitHub comment id so repeated `sync`, `hook`, or `import-codex` runs do not post the same plan again, including on a later PR.
## Safety
diff --git a/changelog.d/20260610_000000_guard_plan_sync_draft_prs.md b/changelog.d/20260610_000000_guard_plan_sync_draft_prs.md
new file mode 100644
index 0000000..9bd1241
--- /dev/null
+++ b/changelog.d/20260610_000000_guard_plan_sync_draft_prs.md
@@ -0,0 +1,6 @@
+---
+bump: patch
+---
+
+### Fixed
+- Kept captured plan updates queued instead of posting comments to draft pull requests, so plans stay on the upload stack until the PR is valid (open and ready for review).
diff --git a/src/github.rs b/src/github.rs
index bcda595..8e2fe9f 100644
--- a/src/github.rs
+++ b/src/github.rs
@@ -18,6 +18,9 @@ pub enum SyncStatus {
number: u64,
state: String,
},
+ DraftPullRequest {
+ number: u64,
+ },
Unchanged {
number: u64,
},
@@ -32,6 +35,8 @@ pub enum SyncStatus {
struct PullRequest {
number: u64,
state: String,
+ #[serde(default, rename = "isDraft")]
+ is_draft: bool,
}
#[derive(Debug, Deserialize)]
@@ -53,6 +58,11 @@ pub fn sync_state(context: &GitContext, state: &mut AgentPlanState) -> AppResult
state: pull_request.state,
});
}
+ if pull_request.is_draft {
+ return Ok(SyncStatus::DraftPullRequest {
+ number: pull_request.number,
+ });
+ }
let (comment_body, item_ids, item_count) = {
let items = state.unposted_items_for_pr(pull_request.number);
@@ -78,7 +88,7 @@ pub fn sync_state(context: &GitContext, state: &mut AgentPlanState) -> AppResult
fn view_current_pr(repo_root: &Path) -> AppResult