feat: batch mobile review suggestions (Closes #1384)
CI / lint (pull_request) Successful in 3m38s
CI / build-release (pull_request) Successful in 7s
CI / browser-journey (pull_request) Successful in 6m20s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy committed 2026-08-25 07:14:54 +00:00
1 parent c8ffde7d96
commit 869543e992
8 files changed
+392 -2

No files matched your search

+18
View File
@@ -2419,6 +2419,24 @@ async def commit_authored_pull_feedback_fix(
}
async def commit_authored_pull_feedback_batch(
repository: str,
number: int,
file: dict,
suggestion_count: int,
message: str,
expected_head_sha: str,
) -> dict:
"""Commit multiple reviewed replacements in one file as one verified commit."""
if not 2 <= suggestion_count <= 8:
raise IssueNotAvailableError("Feedback batch is outside the editable bounds")
result = await commit_authored_pull_feedback_fix(
repository, number, file.get("path", ""), file.get("content", ""), message,
expected_head_sha, file.get("expected_blob_sha", ""),
)
return {**result, "suggestion_count": suggestion_count}
async def update_authored_pull_branch(
repository: str, number: int, expected_head_sha: str
) -> dict:
+43
View File
@@ -1166,6 +1166,21 @@ class PullFeedbackFileUpdate(BaseModel):
expected_blob_sha: str = Field(min_length=1, max_length=128)
class PullFeedbackBatchFile(BaseModel):
path: str = Field(min_length=1, max_length=1024)
content: str = Field(max_length=131_072)
expected_blob_sha: str = Field(min_length=1, max_length=128)
class PullFeedbackBatchUpdate(BaseModel):
file: PullFeedbackBatchFile
suggestion_count: int = Field(ge=2, le=8)
message: str = Field(min_length=1, max_length=120)
expected_head_sha: str = Field(
min_length=7, max_length=64, pattern=r"^[A-Fa-f0-9]+$"
)
class PullContentUpdate(BaseModel):
title: str = Field(min_length=1, max_length=255)
body: str = Field(default="", max_length=10_000)
@@ -7159,6 +7174,34 @@ async def commit_authored_pull_feedback_fix(
return JSONResponse(result)
@app.post("/api/v1/repos/{owner}/{repo}/pulls/{number}/feedback-batch")
async def commit_authored_pull_feedback_batch(
update: PullFeedbackBatchUpdate,
owner: str,
repo: str,
number: int = PathParam(gt=0),
):
try:
result = await asyncio.wait_for(
gitea_proxy.commit_authored_pull_feedback_batch(
f"{owner}/{repo}", number, update.file.model_dump(),
update.suggestion_count, update.message, update.expected_head_sha,
),
timeout=ISSUE_ACTION_TIMEOUT_SECONDS,
)
except gitea_proxy.IssueNotAvailableError:
return JSONResponse(
{"error": "The pull request or a suggested file changed. No fixes were committed."},
status_code=409,
)
except Exception:
return JSONResponse(
{"error": "The suggestion batch could not be confirmed. Keep the batch and retry."},
status_code=503, headers={"Retry-After": "1"},
)
return JSONResponse(result)
@app.get("/api/v1/repos/{owner}/{repo}/pulls/{number}/review-data")
async def assigned_pull_review_data(
owner: str, repo: str, number: int = PathParam(gt=0)