feat(mobile): wire every pull request card action

Merged
SA
3mo ago
+520-16

What & why

Every button on the mobile PR card except Merge hit a "Not available yet" alert. This wires them all.

Host (github router): markPullRequestReady, updatePullRequestBranch, reopenPullRequest, dequeuePullRequest — the GraphQL-based ones resolve the PR node id internally. mergeRejectionError generalizes into the exported actionRejectionError(error, fallback): same non-500 mapping (500s page Sentry), GitHub's own wording, plus GraphQL rejections (errors in a 200, no HTTP status) mapping to BAD_REQUEST. The project-scoped pullRequests.mergePR consumer is updated.

Mobile: usePullRequestActions runs the plain actions with a per-action busy spinner and refetch-on-success; useAskAgent makes the "… with Agent" buttons start a fresh agent session via agents.run with the instruction already sent (no edit step — the reference-mock decision), using the composer's last-used agent, then lands on the session tab via dismissTo. agentPrompt names the PR, the base branch for conflicts, and the failing checks by name.

Note: the host github.reopenPullRequest (octokit, non-500 refusal wording) deliberately coexists with pullRequests.setState (gh CLI, project-scoped) — the card wants GitHub's refusal text surfaced to the user.

How I tested it

  • bun test apps/mobile (34 pass, includes new agentPrompt tests)
  • host-service typecheck + full suite green on the combined branch; mobile typecheck has zero app-code errors
  • Merge-path behavior unchanged (existing merge flow untouched)

Summary by cubic

Wires all non-merge actions on the mobile PR card, replacing the “Not available yet” alert. Plain actions call GitHub with safe error mapping; “… with Agent” actions start a new agent session with a prefilled, sanitized instruction.

  • Host (packages/host-service): adds github.markPullRequestReady, github.updatePullRequestBranch, github.reopenPullRequest, and github.dequeuePullRequest (GraphQL ones resolve the PR node id). Replaces mergeRejectionError with exported actionRejectionError(error, fallback) and uses it in pullRequests.mergePR; maps GitHub refusals to non-500s, including GraphQL 200-error responses as BAD_REQUEST.
  • Mobile (apps/mobile): usePullRequestActions runs one plain action at a time, now latching submission synchronously to block double-taps within a frame; shows a busy spinner, refetches on success, and alerts with GitHub’s wording on refusal. useAskAgent starts a fresh agent session via agents.run using the last-used agent and navigates to its tab. Agent prompts name the PR and failing checks; check names are fenced (control characters stripped, double quotes swapped, max 10 names, max 80 chars). Merge flow is unchanged.

Summary by CodeRabbit

  • New Features

    • Added pull-request actions for marking ready, updating branches, reopening, and removing from the queue.
    • Added agent-assisted workflows for resolving conflicts, fixing failed checks, and addressing review comments.
    • Pull-request screens now show progress while actions are running and open a terminal session when agent work begins.
  • Bug Fixes

    • Improved error messages when GitHub rejects pull-request actions, including merges.
    • Improved generated instructions by safely formatting failed check details.
  • Tests

    • Added coverage for generated agent instructions and failed-check scenarios.