Repository navigation
Mark upstreams whose key came from a Z.ai sign-in - #324
Merged
Merged
Conversation
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>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.ProviderView.signed_in: ZaiFamily | null. Version notes aboveCONTROL_API_VERSIONupdated.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.to_providerinresources.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.ProviderInputhas no way to set it.key.signed_inrow indocs/config.md/docs/config.zh-CN.md, regenerated fromtests/manual/schema.rs. An unknown value is refused asconfig.unknown_variantand 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 writessigned_in: zai/bigmodel; re-sign-in adds it to an unmarked upstream;/overviewcarries"signed_in": "zai"andnullfor 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-configreload.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, thetsfeature (clippy, tests,export_ts+tsc --strict),./scripts/smoke.sh(82 passed, 0 failed).New messages
None.
🤖 Generated with Claude Code