Surface GitHub auto-merge actions (#1001)
* Surface GitHub auto-merge actions * Namespace GitHub auto-merge RPC * Update workspace git refresh test expectation * Avoid redundant GitHub refresh queue
This commit is contained in:
@@ -32,6 +32,7 @@ import type {
|
||||
CheckoutPrCreateResponse,
|
||||
CheckoutPrMergeResponse,
|
||||
CheckoutPrMergeMethod,
|
||||
CheckoutGithubSetAutoMergeResponse,
|
||||
CheckoutPrStatusResponse,
|
||||
PullRequestTimelineResponse,
|
||||
CheckoutSwitchBranchResponse,
|
||||
@@ -274,6 +275,7 @@ type CheckoutPullPayload = CheckoutPullResponse["payload"];
|
||||
type CheckoutPushPayload = CheckoutPushResponse["payload"];
|
||||
type CheckoutPrCreatePayload = CheckoutPrCreateResponse["payload"];
|
||||
type CheckoutPrMergePayload = CheckoutPrMergeResponse["payload"];
|
||||
type CheckoutGithubSetAutoMergePayload = CheckoutGithubSetAutoMergeResponse["payload"];
|
||||
type CheckoutPrStatusPayload = CheckoutPrStatusResponse["payload"];
|
||||
type PullRequestTimelinePayload = PullRequestTimelineResponse["payload"];
|
||||
type CheckoutSwitchBranchPayload = CheckoutSwitchBranchResponse["payload"];
|
||||
@@ -1425,6 +1427,25 @@ export class DaemonClient {
|
||||
});
|
||||
}
|
||||
|
||||
private sendNamespacedCorrelatedSessionRequest<
|
||||
TResponseType extends CorrelatedResponseType,
|
||||
TResult = CorrelatedResponsePayload<TResponseType>,
|
||||
>(params: {
|
||||
requestId?: string;
|
||||
message: { type: Extract<SessionInboundMessage["type"], `${string}.request`> } & Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
timeout: number;
|
||||
selectPayload?: (payload: CorrelatedResponsePayload<TResponseType>) => TResult | null;
|
||||
}): Promise<TResult> {
|
||||
const responseType = params.message.type.replace(/\.request$/, ".response") as TResponseType;
|
||||
return this.sendCorrelatedSessionRequest({
|
||||
...params,
|
||||
responseType,
|
||||
});
|
||||
}
|
||||
|
||||
private sendSessionMessageStrict(message: SessionInboundMessage): void {
|
||||
if (!this.transport || this.connectionState.status !== "connected") {
|
||||
throw new Error("Transport not connected");
|
||||
@@ -2817,6 +2838,23 @@ export class DaemonClient {
|
||||
});
|
||||
}
|
||||
|
||||
async checkoutGithubSetAutoMerge(
|
||||
cwd: string,
|
||||
input: { enabled: true; method: CheckoutPrMergeMethod } | { enabled: false },
|
||||
requestId?: string,
|
||||
): Promise<CheckoutGithubSetAutoMergePayload> {
|
||||
return this.sendNamespacedCorrelatedSessionRequest<"checkout.github.set_auto_merge.response">({
|
||||
requestId,
|
||||
message: {
|
||||
type: "checkout.github.set_auto_merge.request",
|
||||
cwd,
|
||||
enabled: input.enabled,
|
||||
...(input.enabled ? { mergeMethod: input.method } : {}),
|
||||
},
|
||||
timeout: 60000,
|
||||
});
|
||||
}
|
||||
|
||||
async checkoutPrStatus(cwd: string, requestId?: string): Promise<CheckoutPrStatusPayload> {
|
||||
return this.sendCorrelatedSessionRequest({
|
||||
requestId,
|
||||
|
||||
Reference in New Issue
Block a user