Skip to content

GitHub account per host + saved token in Settings › Source control (#1528 follow-up) #1533

Closed

Description

@currentbits

Part 2 of #1528. electron/github.js now exists: it gets a token from gh auth token --hostname <host>, caches it per host, and sourceControl.invalidateDiscoveryCache() clears that cache.

Remaining:

  1. Settings › Source control: let the user pick the account for each host. Pass it as gh auth token --hostname <host> --user <login> (gh ≥ 2.40). The account list comes from gh auth status --json hosts, which sourceControl.probeGithub already parses.
  2. A saved token for users without gh. Design constraint: electron/secrets.js has safeStorage DISABLED by default. On macOS the keychain item's ACL pins the creating binary's code signature, so every rebuild prompted for the login-keychain password. A saved token needs a different store, for example security add-generic-password with -T /usr/bin/security, or the plaintext settings file with a warning. Decide that before building the UI.
  3. githubToken() should check the saved token or the chosen account before the default gh account.

Activity

  1. added
    plan:todo
    on Oct 9, 2026
  2. currentbits commented on Oct 9, 2026

    @currentbits
    OwnerAuthor

    Implemented in bcab6b1c on coder/talk-to-github-through-its-api-instead-o-04dd2a.

    • New setting settings.githubHosts holds [{host, account, token}] rows. Token lookup order: saved token, then gh auth token --hostname <host> --user <account>, then gh's active account.
    • Storage decision: tokens go through secrets.js, the same as linearApiKey: plaintext while safeStorage stays disabled, sealed if it's re-enabled. So there are no keychain prompts after rebuilds. Unlike linearApiKey, the token never reaches the renderer: settings come back as {host, account, hasToken}, and a row saved without a token key keeps the stored token.
    • Settings › Source control › GitHub now has a per-host account picker (logins come from gh auth status --json hosts), a token field with Save/Clear, and "Add host" for GHE with a token only.
    • Tests: typecheck clean; renderer 2693/0; electron 4113/0 with a CI-style env.

    Known limit: the remaining gh CLI fallback paths still use gh's active account. #1534 moves those calls onto the API.

  3. added
    plan:doing
    and removed
    plan:todo
    on Oct 9, 2026
  4. added
    plan:done
    and removed
    plan:doing
    on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions