Repository navigation
feat(api): route stats say where their history starts; the ChatGPT login result names the account - #200
Merged
Conversation
…gin result names the account
GET /summary/routes now returns RouteStats { covered_since_ms, routes }
instead of a bare RouteHits array. The counts only see requests that are
still in the store: on a fresh install, after the store is rebuilt on an
upgrade, or when rows are kept for fewer days than the window, the oldest
stored request is later than the window's start, and "no hits" before it
means "not known", not "never matched". covered_since_ms is the later of
the window's start and the oldest stored request (any request, routed or
answered locally); it is null when no moment of the window is covered (no
stored request at all, or the oldest one is at or after the window's
end). When set it lies inside the window: from <= covered_since_ms < to.
The field is always present, so a client has to handle null.
ChatgptLoginStatus drops `plan` and carries `account` (AccountView: email
and plan), the same block as OAuthView.account and read from the same
token: the access token the sign-in just saved to the config. The login
result and the upstream row cannot name different accounts, and the
login completion page no longer needs an Overview read. The id_token is
still read for the account id only. LoginFinished is unchanged.
CONTROL_API_VERSION is 22. No message codes changed; the request store
SCHEMA stays 20.
Tests: store-level coverage for an empty store, history shorter than the
window (including after pruning), history longer than the window, and a
window before the history began; an end-to-end /summary/routes with a
fresh store and with no history yet; the login result's account for
browser, device and repeated sign-ins, equal to the upstream view's, and
taken from the access token when the id_token carries only the account
id. The TypeScript export and the smoke script follow the new shapes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn
force-pushed
the
feat/route-stats-coverage
branch
from
September 25, 2026 07:24
aa58167 to
51cb2df
Compare
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.
Two facts the desktop UI had to fill in on its own. Core now reports them.
Route stats say where their history starts
GET /summary/routesreturned a bareRouteHits[]. The counts only see requests that are still in the store, so after a fresh install, after the store is rebuilt on an upgrade (v0.48.0 did, SCHEMA 19 → 20), or withretention.row_daysshorter than the window, the routing page labelled a few hours of data as "7 days" and flagged rules as never matched in 7 days.The endpoint now returns
RouteStats:covered_since_ms=max(from, oldest stored request's at_ms). The oldest request counts whether it was routed or answered locally: either way the store was recording by then.fromwhen the whole window is covered, and is later thanfromwhen the history starts inside the window. Before it, "no hits" means "not known".nullwhen no moment of the window is covered: no stored request at all, or the oldest one is at or after the window's end (an empty window too).from <= covered_since_ms < to.SELECT MIN(at_ms)on theat_msindex; nothing new is stored, so the request storeSCHEMAstays 20 (no history wipe).The ChatGPT login result names the account
ChatgptLoginStatus(GET/DELETE /chatgpt/login/{id}) dropsplanand carriesaccount?: AccountView({ email?, plan? }), the same block asOAuthView.account, read from the same token: the access token the sign-in just saved to the config. The login result and the upstream row cannot name different accounts, and the login completion page no longer needs an extraOverviewread. It is present fordonewhen the token names at least one of the two. The id_token is still read, for the account id only.LoginFinishedis unchanged (like the Z.ai sign-in, the event reports the outcome and the status carries the account).Compatibility
CONTROL_API_VERSION21 → 22, documented with the previous entries.Tests
null, serialized asnullrather than omitted), history shorter than the window (a local-answer row counts; pruning moves the start), history longer than the window (with and without requests inside it), a window before the history began, the exclusive end, an empty window./summary/routeson a fresh store (start = the first request, notfrom), and a store with no history yet ({"covered_since_ms": null, "routes": []}).accountfor browser, device and repeated sign-ins, equal to the upstream view's; a new test where the id_token carries only the account id shows the account comes from the access token (fails if read from the id_token). Pending and failed statuses carry no account.covered_since_ms: number | null,account?: AccountView, noplanon the login status.scripts/smoke.shreads the new shape and checkscovered_since_ms.cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace, thetsfeature checks (clippy, tests, export +tsc --strict) andscripts/smoke.shpass locally.🤖 Generated with Claude Code