Skip to content

feat(status): show logged-in GitHub user + Copilot plan on the status card - #56

Merged
wangcansunking merged 2 commits into
masterfrom
worktree-status-card-identity
Jul 8, 2026
Merged

wangcansunking merged 2 commits into
masterfrom
worktree-status-card-identity

Conversation

@wangcansunking

Copy link
Copy Markdown
Owner

What

The status card's GitHub line now shows who's logged in and their Copilot subscription tier:

GitHub login   ✓ connected · Can Wang (canwa_microsoft) · Copilot Enterprise

Answers both parts of the request: the username on the login status, and Copilot subscription status.

How

  • Username — GET https://api.github.com/user → login + name, formatted as Name (login). Best-effort and timed out; a failure just omits it.
  • Subscription — the Copilot token exchange (/copilot_internal/v2/token) already returns a sku field (e.g. copilot_enterprise_seat_quota) plus chat_enabled. CopilotTokenStore now parses that entitlement and exposes it via getEntitlement() — no extra network call; the plan rides along on a request we already make. skuLabel() maps the sku to a friendly name (Enterprise / Business / Pro / Free), with a legible fallback for unknown skus.

Both are best-effort and connection-gated: summarizeStatus only surfaces identity/plan when the token is actually valid, so an expired or signed-out login never shows a stale name.

Files

File Role
src/providers/copilot/account.ts fetchGithubUser, skuLabel, formatIdentity (new)
src/providers/copilot/token.ts parse + expose entitlement from the existing exchange
src/tui/status-summary.ts optional identity/plan on inputs+summary, gated on connected
src/tui/app.tsx statusCard() folds them into the GitHub line; new accountInfo prop for live /status
src/cli/index.ts resolve account for startup + /status (username cached per-login, cleared on /login re-auth)

Tests

  • account.test.ts — user fetch (success / no-name / non-ok / reject / timeout / headers), skuLabel families + fallback, formatIdentity variants.
  • token.test.ts — entitlement parsed from the exchange with no extra call; undefined when sku absent.
  • status-summary.test.ts — identity/plan pass through when connected, omitted when expired/signed-out.
  • app-interaction.test.tsx — startup card folds username+plan into the GitHub line; /status pulls fresh values via accountInfo.

Full suite green: 675 tests / 75 files. tsc clean.

Verified live against real Copilot creds — renders ✓ connected · Can Wang (canwa_microsoft) · Copilot Enterprise (sku copilot_enterprise_seat_quota → "Copilot Enterprise").

e2e scope

No proxy request/response surface — this reads two account endpoints and renders a TUI card. The http-e2e / cli-e2e matrices don't apply; unit + real-<App> interaction coverage is the gate.

Changeset: minor.

wangcansunking and others added 2 commits July 8, 2026 09:24
… card

The GitHub line on the status card now folds in who's logged in and their
Copilot subscription tier, e.g.:

  GitHub login   ✓ connected · Can Wang (canwa_microsoft) · Copilot Enterprise

- src/providers/copilot/account.ts: fetchGithubUser() (GitHub /user →
  login+name, best-effort/timed-out), skuLabel() (sku → friendly plan name),
  formatIdentity() ("Name (login)").
- token.ts: CopilotTokenStore now parses the entitlement (sku/chat_enabled/
  individual) that already rides along on the token exchange and exposes it
  via getEntitlement() — no extra network call for the plan.
- status-summary.ts: StatusInputs/StatusSummary carry optional identity+plan;
  summarizeStatus only surfaces them when actually connected (no stale name on
  an expired/signed-out token).
- app.tsx: statusCard() appends identity + plan to the GitHub line when
  present; new accountInfo() prop feeds the live /status card.
- cli/index.ts: resolves account (username cached per-login, cleared on
  /login re-auth; plan from the cached entitlement) for startup + /status.

All best-effort — a failed/pending lookup omits the segments cleanly.

Verified live against real Copilot creds: renders
"✓ connected · Can Wang (canwa_microsoft) · Copilot Enterprise".
Full suite green (675); tsc clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wangcansunking
wangcansunking merged commit 402d3f1 into master Jul 8, 2026
6 checks passed
@wangcansunking
wangcansunking deleted the worktree-status-card-identity branch July 8, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant