GitHub Account Management
Actual behavior of GitHub account management through the `gh` CLI in Piaf.
Prerequisites
Piaf relies on gh (GitHub CLI), not a native OAuth integration.
- Installation check:
gh --version - Auth check:
gh auth status
UI States (Sidebar)
Based on the sidebar implementation, the user can see:
- GitHub not installed -> link to
https://cli.github.com/ - Not authenticated -> link to
https://cli.github.com/manual/gh_auth_login - GitHub data loading
- Available account (avatar, login, name)
- Unavailable/error state
Multiple Accounts
When multiple gh accounts exist for a host:
- Piaf displays an account selector in the sidebar.
- Switching triggers
gh auth switch --hostname <host> --user <login>.
Automatic Account Fallback
For PR/repository operations, Piaf applies fallback by host:
- Runs the
ghcommand with the active account. - If an access/auth error is detected, tries other valid accounts on the same host.
- Retrieves their token via
gh auth token --hostname ... --user .... - Replays the command with
GH_TOKEN/GITHUB_TOKENandGH_HOST.
GitHub Enterprise Compatibility
The host is detected from the origin remote (SSH/HTTPS):
git@github.com:owner/repo.gitssh://git@github.enterprise.local/team/repohttps://github.com/owner/repo.git
Fallback therefore works on github.com and Enterprise hosts.