# fix\(source-control\): resolve SSH aliases and repository GitHub accounts · PR \#23909 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/23909)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: Unavailable fork

Source branch: fix/ssh-remote-github-account

Target branch: main

Head commit: 4fa05b4036ae33171da495e4fa04816e4e7ea814

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/23909)

[Commits](https://git.cafe/pingdotgg/t3code/pull/23909/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/23909/diffs?format=markdown)

## Description

---

## Problem

I use two GitHub accounts with SSH aliases. These are names that point to another host in SSH configuration. Git can fetch and push, but T3 Code can miss the repo's PRs or use the wrong account.

For example, `git@github-work:owner/repo.git` can point to `github.com`. T3 Code needs to use `github.com` for that repo. A repo set to use `example-user` keeps that account without a global account switch.

## Inbox symptoms

With two accounts on the same host, Authored, Reviewing, and `author:me` can use the wrong login. The inbox can also show a GitHub credential error. For an alias like `github.com-work`, T3 Code runs `gh auth token --hostname github.com-work`. That fails with `GitHubNotSignedInError`, even though the account is signed in to `github.com`.

Before: the inbox shows a credential error.

![Before: the PR inbox shows a GitHub credential error](https://github.com/user-attachments/assets/1f6822fd-5b4b-4c83-895f-0d5c33b11f81)

After: the same search finds the existing PR.

![After: the inbox finds the existing PR](https://github.com/user-attachments/assets/a56745d8-bb94-40be-b4f0-97966da85ab9)

These screenshots use public test data.

## Root cause

The remote URL does not tell us where an SSH alias points. T3 Code also assumed one account per GitHub host. T3 Code did not always keep the repo's selected account when loading PRs or more inbox results.

## Approach

I read the alias's `HostName` with `ssh -G` before looking up the repo on GitHub. Git keeps the original remote URL for fetches and pushes.

I also read `github.user` from Git configuration, including global and conditional values. When GitHub CLI supplies the token, T3 Code selects that account with `gh auth token --user`. Saved tokens and environment tokens keep their existing priority. If the selected account is signed out, T3 Code reports an error instead of switching accounts.

The inbox, PR details, and code views now use the repo's account. Requests and cached results stay separate for different accounts. Loading more inbox results also checks that the account has not changed.

The bot review caught two more places where I needed to look up the alias. PR checkout now looks up the host and keeps the remote name. This makes it fetch from the right remote. The inbox looks up the alias before filtering by host, so it keeps repos that use GitHub aliases. I also cache successful `ssh -G` results for 30 seconds to avoid repeated processes. Failed lookups are retried without waiting for the cache to expire.

The alias work overlaps with #22246. I kept its remote-selection checks and added SSH configuration lookup and account selection per repo.

This covers existing `github.com` checkouts. It does not change the clone flow or add Enterprise alias support.

## Test evidence

Before these review fixes, all 689 focused tests passed on macOS, Linux, and Windows. I also tested two real accounts in the macOS app: Authored, `author:me`, PR details, and code.

For these review fixes, lint and typecheck pass on macOS. All 327 tests in the two source-control packages and all 101 server inbox tests pass too.

The new tests cover both alias bugs. They also cover the 30-second cache limit, separate cache entries, and retries after failed lookups.

Some broader tests had macOS-specific failures in unchanged files. CI still checks the full change.

Fixes #17805

