Skip to content

Upstreams: one account label everywhere, read from the token; no live call for a broken sign-in - #205

Merged
fylorn merged 1 commit into
devfrom
ui/upstreams-core-data
Sep 25, 2026
Merged

fylorn merged 1 commit into
devfrom
ui/upstreams-core-data

Conversation

@fylorn

@fylorn fylorn commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

What this changes

Account upstreams now carry the same label everywhere, all read from ProviderView.oauth.account (core v0.48.0 reads the email and plan from the credential's own token, with no network call):

  • Edit dialog, Account section. The sign-in box still names the account when the sign-in has expired: dev@example.com · Plus ● 登录已失效, with the reason below and the re-login button. Before, it replaced the email and plan with "登录已失效", while the table row next to it still showed both. The dialog header names the account where other upstreams show their address (chatgpt · ChatGPT 账号 · dev@example.com), the same way the row does, so the account is still visible on the Models and Billing tabs.
  • ChatGPT sign-in dialog, done state. It now says which account was signed in, with email and plan: 账号 work@example.com,订阅类型 Pro (More)。 The line reads the upstream view once after core reports the sign-in done. Core writes the config before it reports, so this is the new account, also after a re-login into a different account. It is on its own line, so the plan name no longer wraps mid-word.
  • Z.ai sign-in dialog, done state. The account name now always appears (see Why).
  • No live call for a broken sign-in. When oauth.needs_login is set, the page no longer calls ChatgptUsage for that account on open (quotaAccounts). The Account section no longer calls ChatgptUsage/ChatgptResets either, and shows only the sign-in box. Both calls fail without a token anyway, and the error used to repeat the sign-in box's reason. Accounts that work still get one ChatgptUsage on page open, for the cold-start quota bar in the row. That is the only remaining page-level call, and nothing uses it for the label.
  • Command palette. Account upstreams show their email instead of chatgpt.com and can be found by it. A broken sign-in shows "需要重新登录", the same label as the row.

Why

The v0.48.0 bump (#202) moved the row and the sign-in box to oauth.account, but a few places still disagreed. The sign-in dialog's done state took its plan from ChatgptLoginStatus.plan, and that field only arrives through the 2-second poll. The login_finished event, which normally lands first, has no plan, so the plan was usually missing, and the email was never shown. The Z.ai dialog had the same race for ZaiLoginStatus.account. The event now triggers one status read there, and both dialogs settle a sign-in only once, even when the event and a poll both report it.

How it was verified

  • pnpm typecheck, pnpm test and pnpm build, on the latest dev. New tests: quotaAccounts skips disabled accounts, accounts with a broken sign-in and other upstreams, and the palette finds an account upstream by its email and labels a broken sign-in. Rust is untouched.
  • Full-app preview harness (core 0.48 mocks), headless Chromium with real clicks, zh and en. Two changes were made to the harness copy used here. Sign-ins now finish through login_finished, after config_reloaded, like core. A re-login switches the account to work@example.com on Pro.
    • ?issues (chatgpt needs sign-in): no ChatgptUsage call on page open, and none when the Account section opens. The sign-in box reads dev@example.com · Plus ● 登录已失效 with the translated gw.oauth.expired reason, and there are no quota or credits sections. Re-login → done shows 账号 work@example.com,订阅类型 Pro (More)。 → the row becomes chatgpt [Pro (More)] ChatGPT 账号 · work@example.com, and the page then asks ChatgptUsage once for its quota.
    • Normal data: one ChatgptUsage on page open. The dialog header shows … · dev@example.com on all three tabs. A new ChatGPT sign-in completes in about 3.3 s, driven by the event and not by the next poll, with 账号 dev2@example.com,订阅类型 Plus。, and the new row shows the same account. A Z.ai sign-in completes through the event with 账号 dev@example.com。
    • Palette: dev@ finds chatgpt dev@example.com ● 需要重新登录, and other upstreams still show their host.
    • Dark, English, 820×560: the broken sign-in box fits, and the long reason wraps under it.

🤖 Generated with Claude Code

… call for a broken sign-in

- The edit dialog's sign-in box keeps saying which account it is (email and
  plan, from ProviderView.oauth.account) when the sign-in has expired, with
  the invalid state as a status label next to it, like the table row. The
  dialog header names the account where other upstreams show their address.
- The ChatGPT sign-in dialog's "done" state names the account (email and
  plan) from the same place the row and the edit dialog read. It reads the
  upstream view once after core reports the sign-in done (core writes the
  config first), instead of ChatgptLoginStatus.plan, which only arrived
  when the 2 s poll beat the login_finished event, so the plan was usually
  missing.
- The Z.ai sign-in dialog had the same race for its account name: the
  event now triggers one status read. Both dialogs settle a sign-in once.
- No live ChatgptUsage / ChatgptResets call for an account whose sign-in
  has expired: not on page open (quotaAccounts) and not in the account
  section, which then shows only the sign-in box.
- Command palette: account upstreams show and match their email, and say
  "Sign in again" like the row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit e493835 into dev Sep 25, 2026
4 checks passed
@fylorn
fylorn deleted the ui/upstreams-core-data branch September 25, 2026 06:09
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