fix(server): adaptive PR merge method and reliable per-project account use - #13
Merged
Merged
Conversation
…t use Merge: - `gh pr merge` now queries the repo's allowed merge methods and picks a permitted one (merge > squash > rebase) instead of hardcoding `--merge`, which failed on squash-/rebase-only repositories. GitHub account selection: - Resolve a per-project account to a three-way outcome (resolved / ambient / unavailable) instead of silently falling back to the machine's active account. When a project has an account attached but its token can't be minted (not logged in to `gh`), `gh` and raw `git` network operations now refuse with an actionable "account not logged in" error rather than acting as the wrong user. Interactive terminals stay best-effort. - Add `ProjectionSnapshotQuery.listAccountRoutes()` mapping workspace roots and worktree paths (active AND archived threads) to their account, so a worktree belonging to an archived thread still resolves to the right account instead of falling back to ambient. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related fixes to how T3 performs GitHub operations under a per-project selected account.
1. Adaptive PR merge method
gh pr mergehardcoded--merge(merge-commit). On repositories that disallow merge commits (squash- or rebase-only), the merge always failed with the generic "GitHub wouldn't merge this pull request" message. It now queries the repo's allowed methods and picks a permitted one, preferring merge → squash → rebase, falling back to a plain merge if the settings can't be read.2. Never act as the wrong GitHub account
Previously, when a project had an account attached but its token couldn't be applied, operations silently fell back to the machine's active account — running as the wrong user with only a log line.
The resolver now returns a three-way outcome:
gh auth switch, which would race across concurrent projects)git cloneand account-less projects)gh→ refuse with an actionable "account not logged in — rungh auth login" error, for bothghand rawgitpush/fetch/pull. Interactive terminals stay best-effort.3. Archived-thread worktrees resolve correctly
Worktrees live outside the project's workspace root, so they only resolved via active threads in the shell snapshot — an archived thread's worktree fell back to the ambient account. Added
ProjectionSnapshotQuery.listAccountRoutes()mapping workspace roots and all non-deleted worktree paths (active and archived) to their account, and repointed the resolver at it (also cheaper than hydrating the full shell snapshot per command).Tests
ghand rawgitrefuse when the selected account is unavailableProjectionSnapshotQuerytest doubles for the new API🤖 Generated with Claude Code