Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions webhook_server/libs/handlers/runner_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,17 +690,6 @@ async def _get_ai_title_suggestion(
else:
types_info = f"Allowed types: {', '.join(allowed_names)}"

prompt = (
"You are in a git repository checked out to a PR branch.\n"
"Look at the recent commits and changes to understand what this PR does.\n"
f"Current PR title: {title}\n"
f"{types_info}\n"
f"Required format: <type>[optional scope]: <description>\n"
f"Output ONLY the corrected title on a single line.\n"
f"Do NOT include any explanation, reasoning, markdown, or quotes.\n"
f"Example output: feat: add user authentication"
)

cli_flags: list[str] = []
if ai_provider == "claude":
cli_flags = ["--dangerously-skip-permissions"]
Expand All @@ -710,11 +699,28 @@ async def _get_ai_title_suggestion(
cli_flags = ["--force"]

try:
base_ref = await github_api_call(
lambda: pull_request.base.ref, logger=self.logger, log_prefix=self.log_prefix
)

async with self._checkout_worktree(pull_request=pull_request) as (wt_success, worktree_path, _, _):
if not wt_success:
self.logger.warning(f"{self.log_prefix} Failed to create worktree for AI title suggestion")
return None

prompt = (
"You are in a git repository checked out to a PR branch.\n"
f"Run `git diff origin/{base_ref}` to see the changes in this PR.\n"
f"Run `git log origin/{base_ref}..HEAD --oneline` to see the commit messages.\n"
f"Based on the diff and commit messages, suggest a conventional commit title.\n\n"
f"Current PR title: {title}\n"
f"{types_info}\n"
f"Required format: <type>[optional scope]: <description>\n"
f"Output ONLY the corrected title on a single line.\n"
f"Do NOT include any explanation, reasoning, markdown, or quotes.\n"
f"Example output: feat: add user authentication"
)

success, result = await call_ai_cli(
prompt=prompt,
ai_provider=ai_provider,
Expand Down