Make it possible to create draft PRs (vibe-kanban) (#1460)

* All checks pass. Let me summarize what was implemented:

## Summary

I've successfully implemented the draft PR feature. Here's what was changed:

### Backend Changes

1. **`crates/server/src/routes/task_attempts.rs`** (lines 70-76, 724-731):
   - Added `draft: Option<bool>` field to `CreateGitHubPrRequest` struct
   - Pass the draft field to the `CreatePrRequest` when creating PRs

2. **`crates/services/src/services/github.rs`** (lines 146-153):
   - Added `draft: Option<bool>` field to `CreatePrRequest` struct

3. **`crates/services/src/services/github/cli.rs`** (lines 158-160):
   - Added logic to pass `--draft` flag to `gh pr create` when draft is true

### Frontend Changes

4. **`frontend/src/components/dialogs/tasks/CreatePRDialog.tsx`**:
   - Added `Checkbox` import
   - Added `isDraft` state (default: false)
   - Added checkbox UI with label from translations
   - Pass `draft: isDraft` in the API call
   - Reset `isDraft` on success and cancel

### Type Generation

5. **`shared/types.ts`** (auto-generated):
   - `CreateGitHubPrRequest` now includes `draft: boolean | null`

### Translations

6. Added `"draftLabel"` translation key to all locale files:
   - `frontend/src/i18n/locales/en/tasks.json`: "Create as draft"
   - `frontend/src/i18n/locales/es/tasks.json`: "Crear como borrador"
   - `frontend/src/i18n/locales/ja/tasks.json`: "下書きとして作成"
   - `frontend/src/i18n/locales/ko/tasks.json`: "초안으로 만들기"
   - `frontend/src/i18n/locales/zh-Hans/tasks.json`: "创建为草稿"

* Done. I've updated the checkbox to use `h-5 w-5` (20px) and added `text-sm` to the label for consistent sizing.
This commit is contained in:
Louis Knight-Webb
2025-12-08 16:53:37 +00:00
committed by GitHub
parent 047695e554
commit 9c70858b21
10 changed files with 30 additions and 1 deletions

View File

@@ -72,6 +72,7 @@ pub struct CreateGitHubPrRequest {
pub title: String,
pub body: Option<String>,
pub target_branch: Option<String>,
pub draft: Option<bool>,
}
#[derive(Debug, Deserialize)]
@@ -726,6 +727,7 @@ pub async fn create_github_pr(
body: request.body.clone(),
head_branch: task_attempt.branch.clone(),
base_branch: norm_target_branch_name.clone(),
draft: request.draft,
};
// Use GitService to get the remote URL, then create GitHubRepoInfo
let repo_info = deployment

View File

@@ -149,6 +149,7 @@ pub struct CreatePrRequest {
pub body: Option<String>,
pub head_branch: String,
pub base_branch: String,
pub draft: Option<bool>,
}
#[derive(Debug, Clone)]

View File

@@ -155,6 +155,10 @@ impl GhCli {
args.push(OsString::from("--body"));
args.push(OsString::from(body));
if request.draft.unwrap_or(false) {
args.push(OsString::from("--draft"));
}
let raw = self.run(args)?;
Self::parse_pr_create_text(&raw)
}