mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
The PR tab now leads with the PR's identity, one row per merge gate (checks, unresolved threads, approvals, conflicts) that opens the screen or sheet that resolves it, a changes card and a collapsed description. Close, Unlink, Auto-merge, Edit title and Copy link move into the ⋯ menu. Checks and Comments become pushed screens: failures open with their annotation and Fix / Rerun / Open / Log on the failure, running checks next, passed folded; comments filter by Unresolved / All / Hide bots with Resolve and Reply on each thread and a comment box at the bottom. Merge opens a sheet that lists only the methods the repo allows, starting on its default. Reviewers move into a sheet with search to add and remove. Every Create PR entry point opens one sheet: title and description seeded from the branch's commits (shared seed rule in src/shared, GitHub's own default), Write with AI, base picker and draft. It pushes first when needed, works for all five providers and lands on the PR tab for GitHub.
297 lines
8.6 KiB
TypeScript
297 lines
8.6 KiB
TypeScript
import type { GitHubPRMergeMethod } from '../../../src/shared/github/pull-request-types'
|
|
import {
|
|
githubPrAutoMergeSet,
|
|
githubPrBodySet,
|
|
githubPrChecksRerun,
|
|
githubPrIssueCommentAdd,
|
|
githubPrIssueCommentDelete,
|
|
githubPrIssueCommentEdit,
|
|
githubPrMergeRun,
|
|
githubPrReviewCommentReplyAdd,
|
|
githubPrReviewersRemove,
|
|
githubPrReviewersRequest,
|
|
githubPrReviewThreadResolve,
|
|
githubPrStateSet,
|
|
githubPrTitleSet
|
|
} from './github-pr-mutation-operations'
|
|
import {
|
|
settleGithubPrConfirmation,
|
|
settleGithubPrMutation,
|
|
type GitHubPrMutationOutcome
|
|
} from './github-pr-mutation-outcome'
|
|
import {
|
|
githubPrRepoSlugParam,
|
|
githubPrRequestParams,
|
|
type GitHubPrRepoSlug
|
|
} from './github-pr-repo-slug'
|
|
import type { RpcOperationSender } from '../transport/rpc-operation-sender'
|
|
import { translate } from '../i18n/mobile-i18n'
|
|
|
|
export type { GitHubPrMutationOutcome } from './github-pr-mutation-outcome'
|
|
|
|
export function fetchMergePR(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: { prNumber: number; method?: GitHubPRMergeMethod; prRepo?: GitHubPrRepoSlug | null }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
const params: Record<string, unknown> = { prNumber: args.prNumber }
|
|
if (args.method) {
|
|
params.method = args.method
|
|
}
|
|
return settleGithubPrMutation(githubPrMergeRun, () =>
|
|
githubPrMergeRun.request(
|
|
client,
|
|
githubPrRequestParams(githubPrMergeRun.operation.method, worktreeId, params, {
|
|
prRepo: args.prRepo
|
|
})
|
|
)
|
|
)
|
|
}
|
|
|
|
export function fetchUpdatePRTitle(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: { prNumber: number; title: string; prRepo?: GitHubPrRepoSlug | null }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
const params: Record<string, unknown> = { prNumber: args.prNumber, title: args.title }
|
|
return settleGithubPrConfirmation(
|
|
githubPrTitleSet,
|
|
() =>
|
|
githubPrTitleSet.request(
|
|
client,
|
|
githubPrRequestParams(githubPrTitleSet.operation.method, worktreeId, params, {
|
|
prRepo: args.prRepo
|
|
})
|
|
),
|
|
translate('session.githubPrMutations.titleUpdateFailed', 'Failed to update title.')
|
|
)
|
|
}
|
|
|
|
export function fetchUpdatePRBody(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: { prNumber: number; body: string; prRepo?: GitHubPrRepoSlug | null }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
const params = { prNumber: args.prNumber, updates: { body: args.body } }
|
|
const method = githubPrBodySet.operation.method
|
|
return settleGithubPrMutation(githubPrBodySet, () =>
|
|
githubPrBodySet.request(
|
|
client,
|
|
githubPrRequestParams(method, worktreeId, params, { prRepo: args.prRepo })
|
|
)
|
|
)
|
|
}
|
|
|
|
export function fetchSetPRAutoMerge(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: {
|
|
prNumber: number
|
|
enabled: boolean
|
|
method?: GitHubPRMergeMethod
|
|
prRepo?: GitHubPrRepoSlug | null
|
|
}
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
const params: Record<string, unknown> = { prNumber: args.prNumber, enabled: args.enabled }
|
|
if (args.method) {
|
|
params.method = args.method
|
|
}
|
|
return settleGithubPrMutation(githubPrAutoMergeSet, () =>
|
|
githubPrAutoMergeSet.request(
|
|
client,
|
|
githubPrRequestParams(githubPrAutoMergeSet.operation.method, worktreeId, params, {
|
|
prRepo: args.prRepo
|
|
})
|
|
)
|
|
)
|
|
}
|
|
|
|
export function fetchUpdatePRState(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: { prNumber: number; state: 'open' | 'closed'; prRepo?: GitHubPrRepoSlug | null }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
return settleGithubPrMutation(githubPrStateSet, () =>
|
|
githubPrStateSet.request(
|
|
client,
|
|
githubPrRequestParams(
|
|
githubPrStateSet.operation.method,
|
|
worktreeId,
|
|
{ prNumber: args.prNumber, updates: { state: args.state } },
|
|
{ prRepo: args.prRepo }
|
|
)
|
|
)
|
|
)
|
|
}
|
|
|
|
export function fetchRequestPRReviewers(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: { prNumber: number; reviewers: string[]; prRepo?: GitHubPrRepoSlug | null }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
return settleGithubPrMutation(githubPrReviewersRequest, () =>
|
|
githubPrReviewersRequest.request(
|
|
client,
|
|
githubPrRequestParams(
|
|
githubPrReviewersRequest.operation.method,
|
|
worktreeId,
|
|
{ prNumber: args.prNumber, reviewers: args.reviewers },
|
|
{ prRepo: args.prRepo }
|
|
)
|
|
)
|
|
)
|
|
}
|
|
|
|
export function fetchRemovePRReviewers(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: { prNumber: number; reviewers: string[]; prRepo?: GitHubPrRepoSlug | null }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
return settleGithubPrMutation(githubPrReviewersRemove, () =>
|
|
githubPrReviewersRemove.request(
|
|
client,
|
|
githubPrRequestParams(
|
|
githubPrReviewersRemove.operation.method,
|
|
worktreeId,
|
|
{ prNumber: args.prNumber, reviewers: args.reviewers },
|
|
{ prRepo: args.prRepo }
|
|
)
|
|
)
|
|
)
|
|
}
|
|
|
|
export function fetchRerunPRChecks(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: {
|
|
prNumber: number
|
|
headSha?: string | null
|
|
failedOnly?: boolean
|
|
prRepo?: GitHubPrRepoSlug | null
|
|
}
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
const params: Record<string, unknown> = { prNumber: args.prNumber }
|
|
if (args.failedOnly !== undefined) {
|
|
params.failedOnly = args.failedOnly
|
|
}
|
|
if (args.headSha) {
|
|
params.headSha = args.headSha
|
|
}
|
|
return settleGithubPrMutation(githubPrChecksRerun, () =>
|
|
githubPrChecksRerun.request(
|
|
client,
|
|
githubPrRequestParams(githubPrChecksRerun.operation.method, worktreeId, params, {
|
|
prRepo: args.prRepo
|
|
})
|
|
)
|
|
)
|
|
}
|
|
|
|
export function fetchAddPRReviewCommentReply(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: {
|
|
prNumber: number
|
|
commentId: number
|
|
body: string
|
|
threadId?: string
|
|
path?: string
|
|
line?: number
|
|
prRepo?: GitHubPrRepoSlug | null
|
|
}
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
const params: Record<string, unknown> = {
|
|
prNumber: args.prNumber,
|
|
commentId: args.commentId,
|
|
body: args.body
|
|
}
|
|
if (args.threadId) {
|
|
params.threadId = args.threadId
|
|
}
|
|
if (args.path) {
|
|
params.path = args.path
|
|
}
|
|
if (typeof args.line === 'number') {
|
|
params.line = args.line
|
|
}
|
|
return settleGithubPrMutation(githubPrReviewCommentReplyAdd, () =>
|
|
githubPrReviewCommentReplyAdd.request(
|
|
client,
|
|
githubPrRequestParams(githubPrReviewCommentReplyAdd.operation.method, worktreeId, params, {
|
|
prRepo: args.prRepo
|
|
})
|
|
)
|
|
)
|
|
}
|
|
|
|
export function fetchAddIssueComment(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: { prNumber: number; body: string; prRepo?: GitHubPrRepoSlug | null }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
const params: Record<string, unknown> = {
|
|
number: args.prNumber,
|
|
body: args.body,
|
|
type: 'pr'
|
|
}
|
|
return settleGithubPrMutation(githubPrIssueCommentAdd, () =>
|
|
githubPrIssueCommentAdd.request(
|
|
client,
|
|
githubPrRequestParams(githubPrIssueCommentAdd.operation.method, worktreeId, params, {
|
|
prRepo: args.prRepo
|
|
})
|
|
)
|
|
)
|
|
}
|
|
|
|
// Thread resolution returns boolean confirmation; do not apply status-envelope void-success semantics.
|
|
export function fetchResolveReviewThread(
|
|
client: RpcOperationSender,
|
|
worktreeId: string,
|
|
args: { threadId: string; resolve: boolean; prRepo?: GitHubPrRepoSlug | null }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
return settleGithubPrConfirmation(
|
|
githubPrReviewThreadResolve,
|
|
() =>
|
|
githubPrReviewThreadResolve.request(
|
|
client,
|
|
githubPrRequestParams(
|
|
githubPrReviewThreadResolve.operation.method,
|
|
worktreeId,
|
|
{ threadId: args.threadId, resolve: args.resolve },
|
|
{ prRepo: args.prRepo }
|
|
)
|
|
),
|
|
translate(
|
|
'session.githubPrMutations.reviewThreadUpdateFailed',
|
|
'Failed to update review thread.'
|
|
)
|
|
)
|
|
}
|
|
|
|
// Issue comment edits use owner/repo/commentId rather than worktree-scoped params.
|
|
export function fetchUpdateIssueComment(
|
|
client: RpcOperationSender,
|
|
args: { owner: string; repo: string; host?: string; commentId: number; body: string }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
return settleGithubPrMutation(githubPrIssueCommentEdit, () =>
|
|
githubPrIssueCommentEdit.request(client, {
|
|
...githubPrRepoSlugParam(args),
|
|
commentId: args.commentId,
|
|
body: args.body
|
|
})
|
|
)
|
|
}
|
|
|
|
export function fetchDeleteIssueComment(
|
|
client: RpcOperationSender,
|
|
args: { owner: string; repo: string; host?: string; commentId: number }
|
|
): Promise<GitHubPrMutationOutcome> {
|
|
return settleGithubPrMutation(githubPrIssueCommentDelete, () =>
|
|
githubPrIssueCommentDelete.request(client, {
|
|
...githubPrRepoSlugParam(args),
|
|
commentId: args.commentId
|
|
})
|
|
)
|
|
}
|