Files
orca/src/main/runtime/rpc/methods/github-pull-request-update-methods.ts
T
Brennan Benson df95f03101 Show ready and close actions for draft reviews (#16889)
* Fix draft review sidebar actions

* Drop unused React import in draft actions test

The automatic JSX runtime makes the default React import dead, and
tsconfig.tc.web.json failed the branch on TS6133.

* Add localization keys for draft review actions

The new Ready for review controls introduced five untranslated keys and
the static analysis job requires them present in en.json.

* Name the draft action for what it does

The button read 'Ready for review', which states a status rather than an
action, directly under a header already showing the PR state. The i18n
key (markReady), the in-flight label ('Marking ready...') and the success
toast ('marked ready for review') all already used the verb.
2026-08-28 12:31:55 -07:00

178 lines
5.2 KiB
TypeScript

import { z } from 'zod'
import { defineMethod, type RpcMethod } from '../core'
import { OptionalString, requiredString } from '../schemas'
import { RepoSelector, SlugRepo } from './github-repo-target-schemas'
const UpdatePrTitle = RepoSelector.extend({
prNumber: z.number().int().positive(),
title: requiredString('Missing title'),
prRepo: SlugRepo.nullable().optional()
})
const UpdatePr = RepoSelector.extend({
prNumber: z.number().int().positive(),
updates: z.object({
title: OptionalString,
body: z.string().optional()
}),
prRepo: SlugRepo.nullable().optional()
})
const MergePr = RepoSelector.extend({
prNumber: z.number().int().positive(),
method: z.enum(['merge', 'squash', 'rebase']).optional(),
prRepo: SlugRepo.nullable().optional()
})
const SetPrAutoMerge = RepoSelector.extend({
prNumber: z.number().int().positive(),
enabled: z.boolean(),
method: z.enum(['merge', 'squash', 'rebase']).optional(),
prRepo: SlugRepo.nullable().optional()
})
const UpdatePrState = RepoSelector.extend({
prNumber: z.number().int().positive(),
prRepo: SlugRepo.nullable().optional(),
updates: z.object({
state: z.enum(['open', 'closed'])
})
})
const MarkPrReadyForReview = RepoSelector.extend({
prNumber: z.number().int().positive(),
prRepo: SlugRepo.nullable().optional()
})
const RequestPrReviewers = RepoSelector.extend({
prNumber: z.number().int().positive(),
prRepo: SlugRepo.nullable().optional(),
reviewers: z.array(z.string()).min(1)
})
const RemovePrReviewers = RepoSelector.extend({
prNumber: z.number().int().positive(),
prRepo: SlugRepo.nullable().optional(),
reviewers: z.array(z.string()).min(1)
})
const PRReviewComment = RepoSelector.extend({
prNumber: z.number().int().positive(),
prRepo: SlugRepo.nullable().optional(),
commitId: requiredString('Missing PR head SHA'),
path: requiredString('File path required'),
line: z.number().int().positive(),
startLine: z.number().int().positive().optional(),
body: requiredString('Comment body required')
})
const PRReviewCommentReply = RepoSelector.extend({
prNumber: z.number().int().positive(),
commentId: z.number().int().positive(),
body: requiredString('Comment body required'),
threadId: OptionalString,
path: OptionalString,
line: z.number().int().positive().optional(),
prRepo: SlugRepo.nullable().optional()
})
export const GITHUB_PULL_REQUEST_UPDATE_METHODS: RpcMethod[] = [
defineMethod({
name: 'github.updatePRTitle',
params: UpdatePrTitle,
handler: async (params, { runtime }) =>
runtime.updateRepoPRTitle(params.repo, params.prNumber, params.title, params.prRepo ?? null)
}),
defineMethod({
name: 'github.updatePR',
params: UpdatePr,
handler: async (params, { runtime }) =>
runtime.updateRepoPRDetails(
params.repo,
params.prNumber,
params.updates,
params.prRepo ?? null
)
}),
defineMethod({
name: 'github.mergePR',
params: MergePr,
handler: async (params, { runtime }) =>
runtime.mergeRepoPR(params.repo, params.prNumber, params.method, params.prRepo ?? null)
}),
defineMethod({
name: 'github.setPRAutoMerge',
params: SetPrAutoMerge,
handler: async (params, { runtime }) =>
runtime.setRepoPRAutoMerge(
params.repo,
params.prNumber,
params.enabled,
params.method,
params.prRepo ?? null
)
}),
defineMethod({
name: 'github.updatePRState',
params: UpdatePrState,
handler: async (params, { runtime }) =>
runtime.updateRepoPRState(params.repo, params.prNumber, params.updates, params.prRepo ?? null)
}),
defineMethod({
name: 'github.markPRReadyForReview',
params: MarkPrReadyForReview,
handler: async (params, { runtime }) =>
runtime.markRepoPRReadyForReview(params.repo, params.prNumber, params.prRepo ?? null)
}),
defineMethod({
name: 'github.requestPRReviewers',
params: RequestPrReviewers,
handler: async (params, { runtime }) =>
runtime.requestRepoPRReviewers(
params.repo,
params.prNumber,
params.reviewers,
params.prRepo ?? null
)
}),
defineMethod({
name: 'github.removePRReviewers',
params: RemovePrReviewers,
handler: async (params, { runtime }) =>
runtime.removeRepoPRReviewers(
params.repo,
params.prNumber,
params.reviewers,
params.prRepo ?? null
)
}),
defineMethod({
name: 'github.addPRReviewComment',
params: PRReviewComment,
handler: async (params, { runtime }) =>
runtime.addRepoPRReviewComment(params.repo, {
prNumber: params.prNumber,
prRepo: params.prRepo ?? null,
commitId: params.commitId,
path: params.path,
line: params.line,
startLine: params.startLine,
body: params.body
})
}),
defineMethod({
name: 'github.addPRReviewCommentReply',
params: PRReviewCommentReply,
handler: async (params, { runtime }) =>
runtime.addRepoPRReviewCommentReply(params.repo, {
prNumber: params.prNumber,
commentId: params.commentId,
body: params.body,
threadId: params.threadId,
path: params.path,
line: params.line,
prRepo: params.prRepo ?? null
})
})
]