Repository navigation
feat(api): say who is signed in on a ChatGPT account upstream, read from its own token - #195
Merged
Merged
Conversation
…rom its own token ProviderView.oauth (OAuthView) gains `account`: the signed-in account's email and plan, so the Upstreams page can label a ChatGPT account row without calling ChatgptUsage, which is a live call to the ChatGPT backend. Nothing new is stored and nothing goes online. The access token core already keeps with the credential (written to config.yaml at sign-in and after every refresh) is a JWT that names the account: the plan is in `https://api.openai.com/auth`, the email in `https://api.openai.com/profile` (the id_token has it at the top level; both are read). The view prefers the token in hand (just renewed, possibly not yet written back) and falls back to the configured one. It follows the credential: a re-login or a refresh that brings a new plan changes it, and the change arrives with the config reload the write-back already causes. After the credential expires it still names the last account. The account id and user id in the same token are not exposed. The plan is ChatgptPlan: KnownChatgptPlan (the words the Codex client knows, a closed slug set) or the backend's own word as is, since OpenAI keeps adding plans (go, prolite, ...). `hc` and `education` read as `enterprise` and `edu`. TypeScript: `KnownChatgptPlan | string`. ChatgptLoginStatus.plan uses the same type. ChatgptUsage drops `email` and `plan`: who is signed in now has one source, the credential, so the row and the quota dialog cannot disagree (the backend's rate limiter has been seen to report a different plan than the token). Control-plane protocol 21. Z.ai / BigModel account upstreams get no account block: that sign-in ends in a plain API key with no OAuth section, the key does not say whose it is, and the account name seen during sign-in is not kept with it. Tests use synthetic JWTs only and a fake OpenAI: the claims parser (email in either place, known / alias / unknown plans), the token-in-use choice, the overview after a browser sign-in and a re-login, a refresh that moves the plan along and survives a restart from the written config, and that none of it calls the token endpoint or the backend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 25, 2026
feat(api): session and route at request start, a replayable in-flight snapshot, rule hit counts
#197
Merged
Merged
fylorn
added a commit
that referenced
this pull request
Sep 25, 2026
v0.48.0 was published before the template landed, so its page holds only GitHub's generated list. release-notes/0.48.0.md summarizes it from #191-#198 so the page can be rewritten from the template: - upgrade notes: CONTROL_API_VERSION 21, so ThinkWatch Lite 2026.9.16 (core 0.47.0, protocol 20) does not connect to it and a server used with that app stays on 0.47.0; the request store's schema 20, which empties the request history on the first start (and again on the way back); the /in-flight shape, RequestStarted.session and the removed ChatgptUsage fields; - session and route on the start event, requests a rule decided without an upstream, the replayable /in-flight snapshot and the new /live fields, and /summary/routes (#197); - per-group unpriced and no-usage counts, and security log totals (#193); - the signed-in account on a ChatGPT account upstream (#195); - releases published from one job, the server guide and the crate metadata (#191), and the test port fix (#192). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn
added a commit
that referenced
this pull request
Sep 25, 2026
v0.48.0 was published before the template landed, so its page holds only GitHub's generated list. release-notes/0.48.0.md summarizes it from #191-#198 so the page can be rewritten from the template: - upgrade notes: CONTROL_API_VERSION 21, so ThinkWatch Lite 2026.9.16 (core 0.47.0, protocol 20) does not connect to it and a server used with that app stays on 0.47.0; the request store's schema 20, which empties the request history on the first start (and again on the way back); the /in-flight shape, RequestStarted.session and the removed ChatgptUsage fields; - session and route on the start event, requests a rule decided without an upstream, the replayable /in-flight snapshot and the new /live fields, and /summary/routes (#197); - per-group unpriced and no-usage counts, and security log totals (#193); - the signed-in account on a ChatGPT account upstream (#195); - releases published from one job, the server guide and the crate metadata (#191), and the test port fix (#192). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn
added a commit
that referenced
this pull request
Sep 25, 2026
…summary (#196) * ci(release): write the release page from a template, with an English summary #191 made the publish job write the release once, with GitHub's generated list of pull requests as its only text and the tag as its title. A release is now titled "ThinkWatch Core <version>", and its text has, in order: - an English summary from release-notes/<version>.md, when that file exists; - a table of the files for each platform; - the commands that install this version on a Linux server and switch an existing installation to it (install.sh --version, twcore upgrade --version --restart); - how to verify a download against its .sha256; - GitHub's generated list of pull requests. scripts/release_notes.py builds the text; the publish job fetches the generated list itself (releases/generate-notes) and hands the finished text to action-gh-release, which no longer generates anything. The "only once" rule from #191 stays: a release that already exists keeps its text. A rehearsal (workflow_dispatch) now writes the text into the run summary, using the version in Cargo.toml. scripts/release_notes_test.py checks that the table links exactly the files in release.yml's FILES list, that the install and upgrade options exist, and that every file in release-notes/ renders; the Linux CI job runs it before compiling. release-notes/0.47.0.md summarizes 0.47.0 from #183-#190; the live v0.47.0 release page now carries it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * release-notes: summarize 0.48.0 v0.48.0 was published before the template landed, so its page holds only GitHub's generated list. release-notes/0.48.0.md summarizes it from #191-#198 so the page can be rewritten from the template: - upgrade notes: CONTROL_API_VERSION 21, so ThinkWatch Lite 2026.9.16 (core 0.47.0, protocol 20) does not connect to it and a server used with that app stays on 0.47.0; the request store's schema 20, which empties the request history on the first start (and again on the way back); the /in-flight shape, RequestStarted.session and the removed ChatgptUsage fields; - session and route on the start event, requests a rule decided without an upstream, the replayable /in-flight snapshot and the new /live fields, and /summary/routes (#197); - per-group unpriced and no-usage counts, and security log totals (#193); - the signed-in account on a ChatGPT account upstream (#195); - releases published from one job, the server guide and the crate metadata (#191), and the test port fix (#192). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * release-notes(0.48.0): say where the key is kept without naming the keychain Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
ProviderView.oauth(OAuthView) gainsaccount: the signed-in account's email and plan, so the Upstreams page can label a ChatGPT account row without callingChatgptUsage(a live call to the ChatGPT backend on every page open).Where it comes from (no network, nothing new stored)
The access token core already keeps with the credential (written to
config.yamlat sign-in and after every refresh) is a JWT that names the account: plan inhttps://api.openai.com/auth.chatgpt_plan_type, email inhttps://api.openai.com/profile.email(the id_token hasemailat the top level; both places are read). This is the same place Codex reads an access token handed to it from outside.oauth::Cache::access_in_use: just renewed, possibly not yet written back) and falls back to the configured one. It never refreshes and never records anything.config_reloadedthat the sign-in / write-back already causes, so there is no new event.needs_login), it still names the last account.protocol: chatgpt) get it. Other OAuth upstreams do not, even if their token has an email.The plan type
ChatgptPlanisKnown(KnownChatgptPlan) | Other(String), untagged, so the wire is always the backend's word. The known set is the one the Codex client recognizes. It is open because OpenAI keeps adding plans (go,prolite, ...), and showing a new name as-is beats showing "unknown".hcreads asenterpriseandeducationreads asedu.ChatgptLoginStatus.planuses the same type (the wire is unchanged: still a string).Removed
ChatgptUsage.emailandChatgptUsage.plan. Who is signed in now has one source, the credential, so the upstream row and the quota dialog cannot disagree. The backend's rate limiter has been seen reporting a different plan than the token (openai/codex#29243). An app built for protocol 20 would look for these in the usage answer, soCONTROL_API_VERSIONis 21.Z.ai / BigModel
These upstreams get no account block. That sign-in ends in a plain API key with no
oauthsection. The key does not say whose it is, and the account name seen during sign-in (ZaiLoginStatus.account) is not kept with it. This is documented onOAuthView.account.Tests
All tests use synthetic JWTs and the fake OpenAI. No real token or account is involved.
tw-api: plan words (known, alias, unknown, blank) and their wire round trip;AccountView/OAuthView.accountomit what the token did not say; the TS export isKnownChatgptPlan | stringandaccount?: AccountView.tw-gateway: claims parser (email at top level or in profile, plan known / alias / unknown, nothing → no block, ids not in the view);access_in_use(token in hand, then configured; a changed credential or an empty failed entry does not count; reading does not populate the cache).tw-control(fake OpenAI):promoves the plan along and survives a restart from the written-back config.Local:
cargo fmt --all --check,cargo clippy --workspace --all-targets -D warnings,cargo clippy -p tw-api --features ts,cargo test --workspace(proxy unset),cargo test -p tw-api --features ts, and the exportedtw-api.tsthroughtsc --strict.For the desktop app
p.oauth?.account(email, plus the plan through aRecord<KnownChatgptPlan, string>with the raw word as fallback).ChatgptUsagejust for that.editing.oauth.accountnow.🤖 Generated with Claude Code