Skip to content

Mark upstreams whose key came from a Z.ai sign-in - #324

Merged
fylorn merged 1 commit into
mainfrom
feat/zai-signed-in
Oct 10, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/zai-signed-in

Conversation

@fylorn

@fylorn fylorn commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Why

Signing in with a Z.ai or BigModel account ends in an ordinary API key, written to key: exactly like one typed by hand. The desktop app could not tell such an upstream from a hand-made one, so its edit dialog could not show "account sign-in" as the method.

What

  • Config: providers[].signed_in: zai | bigmodel (optional, tw_config::SignedIn). Only the Z.ai / BigModel sign-in writes it; it is never serialized when absent, so other upstreams never carry it. It records where the key came from and changes nothing about forwarding, quota or balance.
  • Protocol (stays 46, unreleased): ProviderView.signed_in: ZaiFamily | null. Version notes above CONTROL_API_VERSION updated.
  • Sign-in (tw-control/src/zai.rs): writes the mark with the site it signed in to; signing in again writes it too, including on an upstream signed in before this change.
  • Edit (to_provider in resources.rs): the mark is kept only when the submitted key equals the saved one; a different key (or none) drops it, because the key no longer came from signing in. ProviderInput has no way to set it.
  • ChatGPT sign-in clears a hand-written mark on its upstream, since its credential is not a key.
  • Manual: signed_in row in docs/config.md / docs/config.zh-CN.md, regenerated from tests/manual/schema.rs. An unknown value is refused as config.unknown_variant and the safe-mode repair removes the line.

A config written before this change simply has no mark.

Tests

  • tw-control/tests/zai.rs: sign-in writes signed_in: zai / bigmodel; re-sign-in adds it to an unmarked upstream; /overview carries "signed_in": "zai" and null for a hand-made upstream; an edit that keeps the key keeps the mark; an edit with another key drops it (checked to fail when the comparison is removed).
  • tw-config reload.rs: both values load and round-trip, absent stays absent and is not written; an unknown value is refused and repaired away.

Local: cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (proxy vars unset; 3379 passed, 0 failed), cargo test -p tw-config --test manual, the ts feature (clippy, tests, export_ts + tsc --strict), ./scripts/smoke.sh (82 passed, 0 failed).

New messages

None.

🤖 Generated with Claude Code

Signing in with a Z.ai or BigModel account ends in an ordinary API key,
written to `key:` exactly like one typed by hand. The desktop app could
not tell such an upstream from a hand-made one, so editing it could not
show "account sign-in" as its method.

The sign-in now also writes `signed_in: zai | bigmodel` on the upstream
it creates or refreshes, and `ProviderView.signed_in` (`ZaiFamily | null`)
carries it. It records where the key came from and changes nothing about
how requests are sent.

The mark follows the key, decided by comparing it with the saved one:
an edit from the control plane that sends the same key back keeps it,
and one that replaces the key drops it, because the key no longer came
from signing in. Signing in again writes it, including on an upstream
signed in before this change, which simply has no mark until then. A
ChatGPT sign-in, whose credential is not a `key`, clears it if one was
written by hand on that upstream.

The config manual documents the field; an unknown value is refused as
`config.unknown_variant` and the safe-mode repair removes it. Protocol
stays 46 (unreleased); no new messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 9a7fc28 into main Oct 10, 2026
5 checks passed
@fylorn
fylorn deleted the feat/zai-signed-in branch October 10, 2026 16:18
@fylorn fylorn mentioned this pull request Oct 10, 2026
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