Files
orca/mobile/src/session/github-pr-mutation-operations.ts
T
Kelvin Amoaba 89e272abc5 fix(mobile): use desktop's merge gating and PR link rules in the PR panel (#33982)
* fix(mobile): gate PR merge and linking on desktop's shared rules

Merge state moves to src/shared so the phone stops offering Merge on drafts,
conflicts and blocked PRs, and stops letting branch PRs override explicit links.

* fix(mobile): keep stack merges and stale-link recovery in the PR panel

Mobile now applies desktop's stack override and drops a linked PR the branch has moved
past, and only offers Ready for review when a relaying desktop also forwards it.

* fix(mobile): persist stale PR link clears and add a merge recheck

The phone now writes desktop's link clear instead of rereading the stale link, and a
blocked Merge can be rechecked since nothing on mobile polls PR state.

* fix(mobile): guard stale PR link clears like desktop

Re-reads the worktree before clearing so a link chosen after the lookup survives, and
localizes the merge-state strings the lift exposed to the coverage gate.

* test(mobile): drop identity test for worktree link params

* refactor(mobile): share one stack-merge decision and trim PR panel wiring

* fix(mobile): default worktree bare/archived flags for the stale-link guard

* fix(mobile): label the PR merge button from its default merge method
2026-10-27 02:12:00 +00:00

107 lines
3.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { bindDeferredRpcOperation, defineRpcOperation } from '../transport/rpc-operation'
import type { RpcMethodName } from '../transport/rpc-params-contract'
import { rpcResultVariant, rpcResultVariants } from '../transport/rpc-operation-result-reader'
import {
githubPrMutationConfirmationSchema,
githubPrMutationStatusSchemas,
type GitHubPrMutationStatus
} from './github-pr-mutation-reply-schema'
// Transport rejection preserves its delivery-unknown identity; never retry or infer that a dropped reply means no mutation occurred.
export type { GitHubPrMutationStatus } from './github-pr-mutation-reply-schema'
// Share the host’s status/void convention across methods; callers own fallback failure text.
const mutationStatusReader = rpcResultVariants<
'pr-mutation-status' | 'pr-mutation-void',
GitHubPrMutationStatus
>([
rpcResultVariant('pr-mutation-status', githubPrMutationStatusSchemas[0]),
rpcResultVariant('pr-mutation-void', githubPrMutationStatusSchemas[1])
])
function mutationStatusOperation<Method extends RpcMethodName>(name: string, method: Method) {
return bindDeferredRpcOperation(
defineRpcOperation({
name,
method,
acceptance: 'require-result-or-throw-message',
barrier: 'after-caller-barrier',
read: mutationStatusReader
})
)
}
export const githubPrMergeRun = mutationStatusOperation('github.merge-pr', 'github.mergePR')
export const githubPrAutoMergeSet = mutationStatusOperation(
'github.set-pr-auto-merge',
'github.setPRAutoMerge'
)
export const githubPrStateSet = mutationStatusOperation(
'github.update-pr-state',
'github.updatePRState'
)
export const githubPrReadyForReviewMark = mutationStatusOperation(
'github.mark-pr-ready-for-review',
'github.markPRReadyForReview'
)
export const githubPrReviewersRequest = mutationStatusOperation(
'github.request-pr-reviewers',
'github.requestPRReviewers'
)
export const githubPrReviewersRemove = mutationStatusOperation(
'github.remove-pr-reviewers',
'github.removePRReviewers'
)
export const githubPrChecksRerun = mutationStatusOperation(
'github.rerun-pr-checks',
'github.rerunPRChecks'
)
export const githubPrReviewCommentReplyAdd = mutationStatusOperation(
'github.add-pr-review-comment-reply',
'github.addPRReviewCommentReply'
)
export const githubPrIssueCommentAdd = mutationStatusOperation(
'github.add-issue-comment',
'github.addIssueComment'
)
export const githubPrIssueCommentEdit = mutationStatusOperation(
'github.update-issue-comment-by-slug',
'github.project.updateIssueCommentBySlug'
)
export const githubPrIssueCommentDelete = mutationStatusOperation(
'github.delete-issue-comment-by-slug',
'github.project.deleteIssueCommentBySlug'
)
// These two methods require explicit boolean confirmation; status-envelope void-success semantics would accept false.
export const githubPrTitleSet = bindDeferredRpcOperation(
defineRpcOperation({
name: 'github.update-pr-title',
method: 'github.updatePRTitle',
acceptance: 'require-result-or-throw-message',
barrier: 'after-caller-barrier',
read: rpcResultVariant('pr-mutation-confirmation', githubPrMutationConfirmationSchema)
})
)
export const githubPrReviewThreadResolve = bindDeferredRpcOperation(
defineRpcOperation({
name: 'github.resolve-review-thread',
method: 'github.resolveReviewThread',
acceptance: 'require-result-or-throw-message',
barrier: 'after-caller-barrier',
read: rpcResultVariant('pr-mutation-confirmation', githubPrMutationConfirmationSchema)
})
)