Background sweep, launch modal, PR investigation, and merge queue
Four features from real-data testing feedback: - The sidebar button now opens a launch modal (scope + model + cost summary) instead of navigating. Starting closes the modal and shows a "running in background" toast; completion raises a toast with an actionable-count summary and a "View results" link. The sweep was already navigation-proof; now the UX matches. - Reviews investigate deeper: when a thread's branch has a PR, the server fetches state, review decision, CI rollup, mergeability, and the last five comments via `gh pr view`, feeds them into the review prompt, and returns a prStatus with a computed mergeReady flag (open + clean merge + CI not failing + not blocked on review). Lookups degrade to "no PR context" on any failure. - New "Merge ready" bucket at the top of the results grid with per-card "Merge & settle" and a section-level "Merge all (N)". - Merging runs through a SEQUENTIAL queue: each PR is re-validated against live GitHub state before merging (an earlier queue entry may have just changed the base), merged PRs settle their thread immediately, and a conflict marks the card and hands the rebase to the thread's own agent via a turn message — the queue continues past it. review.mergePullRequest returns conflict/already-closed/not-ready as outcomes rather than errors so the queue can branch on them. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
ade848702d
commit
3e757bd28b
19 files changed
+1000
-15
No files matched your search
@@ -17,5 +17,9 @@ export function createReviewEnvironmentAtoms<R, E>(
|
||||
label: "environment-data:review:summarize-thread",
|
||||
tag: WS_METHODS.reviewSummarizeThread,
|
||||
}),
|
||||
mergePullRequest: createEnvironmentRpcCommand(runtime, {
|
||||
label: "environment-data:review:merge-pull-request",
|
||||
tag: WS_METHODS.reviewMergePullRequest,
|
||||
}),
|
||||
};
|
||||
}
|
||||
@@ -53,6 +53,25 @@ export const ReviewThreadDiffStats = Schema.Struct({
|
||||
});
|
||||
export type ReviewThreadDiffStats = typeof ReviewThreadDiffStats.Type;
|
||||
|
||||
/** Live pull-request context gathered during the review: state, review
|
||||
verdict, CI, and whether the PR is mergeable as-is. */
|
||||
export const ReviewThreadPrStatus = Schema.Struct({
|
||||
number: Schema.Int,
|
||||
url: TrimmedNonEmptyString,
|
||||
state: Schema.Literals(["open", "closed", "merged"]),
|
||||
/** GitHub reviewDecision: APPROVED / CHANGES_REQUESTED / REVIEW_REQUIRED /
|
||||
empty (no required reviews). */
|
||||
reviewDecision: Schema.NullOr(TrimmedNonEmptyString),
|
||||
/** Rolled-up CI outcome for the head commit. */
|
||||
checksPassing: Schema.NullOr(Schema.Boolean),
|
||||
/** GitHub mergeable: whether the branch applies cleanly onto base. */
|
||||
mergeable: Schema.NullOr(Schema.Boolean),
|
||||
/** Open + clean merge + CI green + not blocked by requested changes. */
|
||||
mergeReady: Schema.Boolean,
|
||||
recentCommentCount: Schema.Int,
|
||||
});
|
||||
export type ReviewThreadPrStatus = typeof ReviewThreadPrStatus.Type;
|
||||
|
||||
export const ReviewThreadSummaryResult = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
summary: TrimmedNonEmptyString,
|
||||
@@ -65,6 +84,8 @@ export const ReviewThreadSummaryResult = Schema.Struct({
|
||||
settleReason: Schema.NullOr(TrimmedNonEmptyString),
|
||||
/** Absent when the thread has no ready checkpoint (or pre-diff servers). */
|
||||
diffStats: Schema.optionalKey(ReviewThreadDiffStats),
|
||||
/** Absent when the thread has no PR, the lookup failed, or pre-PR servers. */
|
||||
prStatus: Schema.optionalKey(ReviewThreadPrStatus),
|
||||
});
|
||||
export type ReviewThreadSummaryResult = typeof ReviewThreadSummaryResult.Type;
|
||||
|
||||
@@ -78,3 +99,41 @@ export const ReviewThreadSummaryError = Schema.Union([
|
||||
ReviewThreadNotFoundError,
|
||||
]);
|
||||
export type ReviewThreadSummaryError = typeof ReviewThreadSummaryError.Type;
|
||||
|
||||
export const ReviewMergePullRequestInput = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
/** The PR number the client saw at review time; the server re-validates
|
||||
merge-readiness against live GitHub state before merging. */
|
||||
pullRequestNumber: Schema.Int,
|
||||
});
|
||||
export type ReviewMergePullRequestInput = typeof ReviewMergePullRequestInput.Type;
|
||||
|
||||
export const ReviewMergePullRequestResult = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
outcome: Schema.Literals([
|
||||
"merged",
|
||||
/** Branch no longer applies cleanly (e.g. an earlier queue merge landed
|
||||
first). The client hands the conflict to the thread's agent. */
|
||||
"conflict",
|
||||
/** PR already merged or closed since the review ran. */
|
||||
"already-closed",
|
||||
/** No longer merge-ready (CI regressed, review dismissed, ...). */
|
||||
"not-ready",
|
||||
]),
|
||||
detail: Schema.NullOr(TrimmedNonEmptyString),
|
||||
});
|
||||
export type ReviewMergePullRequestResult = typeof ReviewMergePullRequestResult.Type;
|
||||
|
||||
export class ReviewMergeError extends Schema.TaggedErrorClass<ReviewMergeError>()(
|
||||
"ReviewMergeError",
|
||||
{
|
||||
threadId: ThreadId,
|
||||
detail: TrimmedNonEmptyString,
|
||||
},
|
||||
) {}
|
||||
|
||||
export const ReviewMergePullRequestError = Schema.Union([
|
||||
ReviewThreadNotFoundError,
|
||||
ReviewMergeError,
|
||||
]);
|
||||
export type ReviewMergePullRequestError = typeof ReviewMergePullRequestError.Type;
|
||||
@@ -43,6 +43,9 @@ import {
|
||||
ReviewDiffPreviewError,
|
||||
ReviewDiffPreviewInput,
|
||||
ReviewDiffPreviewResult,
|
||||
ReviewMergePullRequestError,
|
||||
ReviewMergePullRequestInput,
|
||||
ReviewMergePullRequestResult,
|
||||
ReviewThreadSummaryError,
|
||||
ReviewThreadSummaryInput,
|
||||
ReviewThreadSummaryResult,
|
||||
@@ -185,6 +188,7 @@ export const WS_METHODS = {
|
||||
// Review methods
|
||||
reviewGetDiffPreview: "review.getDiffPreview",
|
||||
reviewSummarizeThread: "review.summarizeThread",
|
||||
reviewMergePullRequest: "review.mergePullRequest",
|
||||
|
||||
// Terminal methods
|
||||
terminalOpen: "terminal.open",
|
||||
@@ -507,6 +511,16 @@ export const WsReviewSummarizeThreadRpc = Rpc.make(WS_METHODS.reviewSummarizeThr
|
||||
error: Schema.Union([ReviewThreadSummaryError, EnvironmentAuthorizationError]),
|
||||
});
|
||||
|
||||
/** Merge a review-sweep thread's PR after re-validating merge readiness
|
||||
against live GitHub state. Non-exceptional failures (conflict, already
|
||||
closed, no longer ready) are outcomes, not errors, so the client's merge
|
||||
queue can branch on them. */
|
||||
export const WsReviewMergePullRequestRpc = Rpc.make(WS_METHODS.reviewMergePullRequest, {
|
||||
payload: ReviewMergePullRequestInput,
|
||||
success: ReviewMergePullRequestResult,
|
||||
error: Schema.Union([ReviewMergePullRequestError, EnvironmentAuthorizationError]),
|
||||
});
|
||||
|
||||
export const WsTerminalOpenRpc = Rpc.make(WS_METHODS.terminalOpen, {
|
||||
payload: TerminalOpenInput,
|
||||
success: TerminalSessionSnapshot,
|
||||
@@ -751,6 +765,7 @@ export const WsRpcGroup = RpcGroup.make(
|
||||
WsVcsInitRpc,
|
||||
WsReviewGetDiffPreviewRpc,
|
||||
WsReviewSummarizeThreadRpc,
|
||||
WsReviewMergePullRequestRpc,
|
||||
WsTerminalOpenRpc,
|
||||
WsTerminalAttachRpc,
|
||||
WsTerminalWriteRpc,
|
||||
|
||||
Reference in new issue
Block a user