Add optional context to PR description generation (#270)
* types: add optional context parameter to generatePullRequestDescription signature * api: update gitApi to pass optional context to PR description generation * http: include trimmed context in PR description API request body * ui: add additional context input for PR generation with desktop disclosure and mobile sheet * desktop: pass optional context to Tauri generate_pr_description command * tauri: add optional context parameter and inject into PR description prompt * server: read optional context from request and inject into PR description prompt * vscode: update type signature for context parameter (compatibility only) * fix(vscode): drop context from pr-description payload Remove context field from PR description payload Send only base and head to the bridge API for PR descriptions Clarify payload compatibility across web/desktop environments
This commit is contained in:
@@ -2343,6 +2343,7 @@ pub async fn generate_pr_description(
|
||||
directory: String,
|
||||
base: String,
|
||||
head: String,
|
||||
context: Option<String>,
|
||||
state: State<'_, DesktopRuntime>,
|
||||
) -> Result<serde_json::Value, String> {
|
||||
let root = validate_git_path(&directory, state.settings())
|
||||
@@ -2398,8 +2399,8 @@ pub async fn generate_pr_description(
|
||||
}
|
||||
|
||||
// 2. Construct PR-specific prompt
|
||||
let prompt = format!(
|
||||
r#"You are drafting a GitHub Pull Request title + description. Respond in JSON of the shape {{\"title\": string, \"body\": string}} (ONLY JSON in response, no markdown fences) with these rules:
|
||||
let mut prompt = format!(
|
||||
r#"You are drafting a GitHub Pull Request title + description. Respond in JSON of the shape {{"title": string, "body": string}} (ONLY JSON in response, no markdown fences) with these rules:
|
||||
- title: concise, sentence case, <= 80 chars, no trailing punctuation, no commit-style prefixes (no \"feat:\", \"fix:\")
|
||||
- body: GitHub-flavored markdown with these sections in this order: Summary, Testing, Notes
|
||||
- Summary: 3-6 bullet points describing user-visible changes; avoid internal helper function names
|
||||
@@ -2407,15 +2408,21 @@ pub async fn generate_pr_description(
|
||||
- Notes: bullet list; include breaking/rollout notes only when relevant
|
||||
Context:
|
||||
- base branch: {base}
|
||||
- head branch: {head}
|
||||
|
||||
Diff summary:
|
||||
{diffs}"#,
|
||||
- head branch: {head}"#,
|
||||
base = base.trim(),
|
||||
head = head.trim(),
|
||||
diffs = diff_summaries
|
||||
head = head.trim()
|
||||
);
|
||||
|
||||
// Include additional context if provided
|
||||
if let Some(ctx) = context {
|
||||
let trimmed = ctx.trim();
|
||||
if !trimmed.is_empty() {
|
||||
prompt.push_str(&format!("\n\nAdditional context provided by user:\n{}", trimmed));
|
||||
}
|
||||
}
|
||||
|
||||
prompt.push_str(&format!("\n\nDiff summary:\n{}", diff_summaries));
|
||||
|
||||
let model = "gpt-5-nano";
|
||||
|
||||
// 3. Call API
|
||||
|
||||
Reference in New Issue
Block a user