Skip to content

feat!: let the person who approves a pull request open it as themselves - #110

Draft
electric-gizzard wants to merge 2 commits into
mainfrom
feat/open-pull-requests-as-approver
Draft

electric-gizzard wants to merge 2 commits into
mainfrom
feat/open-pull-requests-as-approver

Conversation

@electric-gizzard

Copy link
Copy Markdown
Contributor

Why

GitHub credits a squash merge to whoever opened the pull request, and adds the commits' authors as Co-authored-by. Shuttle opened every pull request as its GitHub App and (since #36) set the approver as the commits' author. So a squash landed on main authored by the App with the person as co-author, which is the wrong way round. #81 shows the same rule with another bot.

What changes

Step Who GitHub shows Token
Commits in the sandbox Nobody (never pushed) None
Published commits and branch The App, signed by GitHub App installation
Pull request, "Open as you" The approver Their GitHub sign-in token
Pull request, "Open as Shuttle" The App App installation
Squash merge The opener, with Co-authored-by the App when the opener is a person GitHub
  • Commits are the App's again. No author is sent. This undoes the author part of fix(worker): credit published commits to the person who approved them #36 and keeps its approvedBy plumbing, which is now who "you" is.
  • "Open as" on the publish card. Offered only for a pull request that does not exist yet. It starts on the approver when their GitHub account is connected. With no account connected the card says Shuttle will open it and how to change that.
  • No silent swap. Someone who chose themselves and has no GitHub connected, or whom GitHub refuses, gets the reason. The check for a connected account runs before anything is pushed.
  • Policy approvals have no person behind them, so the App opens those.
  • Local dev mirrors production. GITHUB_TOKEN and GitAccess.userToken() are no longer tried when the App is refused opening a pull request. They stay as a fallback for reading pull requests.
  • New host port githubPeople (tokenOf(userId)). Shuttle's Worker fills it from Better Auth's stored GitHub tokens, looked up by user id inside the run. A host without it gets the App for every pull request, as before.
  • New route GET /sessions/{id}/pull-request/opener tells the card who the person asking is on GitHub.

Not included

  • The choice is not remembered; it starts from the default each time.
  • A new layer of a stack does not inherit the opener of earlier layers. Existing pull requests keep whoever opened them.
  • Nothing is added to the pull request body when Shuttle opens it.

Testing

  • bun run verify passes (types, tests, lint, format), and bun run check:package.
  • open-pull-request.test.ts: which token each GitHub call is made with, for the App, the person, a person with no account, a person GitHub refuses, and the dropped host-wide fallback; a commit sends no author or committer.
  • publish-opener.test.ts: every combination of choice, approver and connection, including policy approvals and a host with no githubPeople.
  • user-token.test.ts: the per-user token lookup against a real Better Auth instance with no request.
  • mirror-stack.test.ts, publish-effects.test.ts, pull-request-opener.test.ts: the choice travels from the card to the open call.

🤖 Generated with Claude Code

electric-gizzard and others added 2 commits December 4, 2026 16:57
GitHub credits a squash merge to whoever opened the pull request and adds
the commits' authors as co-authors. Shuttle opened every pull request as
its GitHub App and set the approver as the commits' author, so a squash
landed on main as the App with the person as co-author: the wrong way
round.

Published commits are the App's again (no author is sent, so GitHub
credits and signs them as the App). The publish card has an "Open as"
choice between the approver and Shuttle, starting on the approver when
their GitHub account is connected. The pull request is then opened with
their own token, through the new githubPeople port, which Shuttle's own
Worker fills from the tokens its sign-in keeps. Someone who chose
themselves and cannot be acted as, or whom GitHub refuses, gets the
reason: the App never opens it in their place. An approval the host's
policy decided is always opened by the App.

GITHUB_TOKEN and GitAccess.userToken() are no longer tried when the App
is refused opening a pull request, so local development opens pull
requests the way production does.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant