fix(github-issues): base the auth row on the active provider, not the raw gh flag - #156
fix(github-issues): base the auth row on the active provider, not the raw gh flag#156eneskirca wants to merge 1 commit into
Conversation
… raw gh flag Follow-up to #115. The relocation was right, but the new copy keyed off `ghAuthenticated`, which lies in two common states: - **Unapproved project reads as "signed out."** The host masks the auth block to `{ghAuthenticated:false, activeProvider:null}` until the repository is approved (it won't resolve credentials before consent), and approval comes right above this row in setup — so a signed-in user briefly saw "GitHub CLI is not signed in. Run gh auth login" with the token field front and center, the exact noise #115 removed. Unapproved is now its own neutral state. - **gh up + provider pinned to a missing token showed a green "✓ signed in."** What authenticates a request is `activeProvider`, not `ghAuthenticated`; with `provider:'token'` and no token saved, `activeProvider` is null and requests fail, so the ✓ was wrong. The row's decision is now a pure, unit-tested `describeGitHubAuth` (`githubAuthView.ts`) over `{approved, provider, activeProvider, tokenPresent}` → one of `unapproved | gh | token | need-gh | need-token`, and `tokenFieldIsPrimary` decides whether the token field is foregrounded or tucked into Advanced. Also: honest Advanced summary ("provider & token", not "use a token instead" — under `auto`, saving a token does NOT switch auth off gh), a "Check again" link after `gh auth login` (status() bypasses the credential cache, so it's accurate), a saved-token fallback note, and a `:focus-visible` outline on the disclosure. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Heads-up: this collided with a parallel effort on the same two root causes — #165 was built independently against the same review findings and has just been merged, so Coverage check I ran before choosing (not a judgement on the code, which is good):
So #165 was a superset behaviourally, which is why it went in. What this PR still has that main does not, and I think it is the better shape: the pure Apologies for the duplicated work; that is on the coordination, not on you. |
|
Superseded by Commit
The merge conflict here is not mechanical: both sides rewrote the same block, and One thing worth salvaging before closing: this branch extracted the branch logic into Also for the record: the red Your call on the extraction — leaving this open rather than closing someone's branch on their behalf. |
|
Closing as superseded — every fix in this PR is on The three problems you identified:
And the coverage landed too —
The one thing this branch still has that main doesn't is the extraction — (For the record, the CI red on this branch was never yours — it's the known |
Follow-up to #115, addressing a review (Opus + a second reviewer, corroborating).
What was wrong
#115 relocated the token controls correctly, but the new copy keyed off
auth.ghAuthenticated, which lies in two common states:src/core/github/host.tsmasks the auth block to{ghAuthenticated:false, activeProvider:null}until the repository is approved (it won't resolve credentials before consent). Approval happens right above this row in the setup flow, so during setup a signed-in user saw "GitHub CLI is not signed in. Rungh auth login…" with the token field front and center — the exact noise fix(github-issues): hide token controls when the GitHub CLI is signed in #115 set out to remove, plus a wrong instruction.ghAuthenticated≠ what authenticates a request. Requests authenticate viaactiveProvider. Withprovider:'token'and no token saved,activeProvideris null (requests fail), yet the section still rendered the green "✓ Signed in via GitHub CLI."autoprovider it does not (auto keeps preferring the signed-in CLI).Fix
describeGitHubAuth(src/renderer/lib/githubAuthView.ts) over{approved, provider, activeProvider, tokenPresent}→ one ofunapproved | gh | token | need-gh | need-token.tokenFieldIsPrimarydecides whether the token field is foregrounded (it's the only way in) or tucked into Advanced.unapproved→ neutral "Approve this repository above to check GitHub authentication." — never "signed out".gh→ the green check, gated onactiveProvider === 'gh'; "No token needed" dropped when gh-pinned; a "saved token kept as a fallback" note when one exists.token→ "✓ Authenticated with a saved personal access token."need-gh/need-token→ correct, provider-aware guidance (a token hint only when it would actually be consulted).need-ghstate (status() bypasses the 30 s credential cache, so it reflects a just-rungh auth loginimmediately).:focus-visibleoutline on the disclosure summary.Testing
githubAuthView.test.ts— 8 cases pinning every branch, incl. the two regressions above (unapproved-is-not-signed-out; gh-up-but-token-pinned-missing isneed-token, not a green check).styles.theme.test.tsguard passes (--accentis a defined token).npm run typecheck+npm run buildclean.🤖 Generated with Claude Code