ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ffe493773c |
usage: magpie's own Test, Detect APIs and model list requests are rows of the request log, counted nowhere
neiko and gys619 on Discord: a provider's Test or Detect APIs left no
trace in Usage > Requests, so a failing test couldn't be read back.
The provider package marks the context of the editor's Test, Detect APIs
(and per-model detection) and a model list's refresh with a kind
(internal/probelog). Each request sent under the mark is written once:
by the provider's Do, or by probelog.Transport under http.DefaultClient
(netproxy.Install), whichever sends it first; the Claude Code run and
the gateway's translated test write theirs from their result. A row
keeps time, provider, account, model, host, path (no query, no
user:password), method, status, ms and the first 500 bytes of the error.
The row is usage.SourceProbe, agent "magpie", Kind provider_test /
api_detect / model_list ("Test", "Detect APIs", "Model list" in Called
for; purposes.js regenerated). The log index keeps probes apart
(logSnapshot.probes), so Visit, Load, Summarize, budgets, Vias, heatmap,
shared days, LastSeen and observers never meet one. The request page
lists them (probeChunk) and counts none: Row.IsProbe, since a packed row
keeps the row's Source and not its record's. The page shows a muted
badge "magpie's own · not counted in any total" (en, zh, zh-TW, ja, de);
no new control, no layout change.
Tests, each red on the old code:
- usage TestProbeRowsListedNotCounted: listed, clipped, and absent from
Sum, Through, every By group, Summarize, Load, LastSeen, OwnDays and
the observer; a provider filter lists it and sums 0.
- provider TestTestWritesItsRequestsDown / TestDetectWritesItsRequestsDown:
every request the fake server saw is exactly one row, with the right
kind, model and 401 text; an unmarked Do writes nothing.
- probelog TestNoteKeepsNoSecret, TestTransportOnce.
- GUI usage-ledger-probe: badge per language, both engines, 1180/420,
light and dark, no left border, no sideways scroll.
- gui TestProviderDetectDraft now expects the log line (source probe,
kind api_detect, no key) and leaves usage.jsonl out of the unchanged
config comparison.
Broken by hand, each went red: request_page's uncounted check,
log_index's probe skip, Append's observer skip, Do's Taken (6 rows for
4 requests), Test's and Detect's marks, probelog's query strip,
page.js's badge (11 GUI fails).
Run at this head (on origin/main
|
||
|
|
7a9cf4dd4d |
gui, provider: Detect APIs and Each picked model ask with the form as it stands before any Save, and say what is missing in place (#1545, thedavidweng)
What the user saw: on a custom provider being added (or a Duplicate not
added yet), "Each picked model" said "Pick models first" although models
were typed in the Models field, and on a relay with no model list "Detect
APIs" said "no model to try" on every API. Both worked only after a Save,
when the models became the provider's own. A Duplicate not added sent no
key at all. Hints for a missing URL or models went to the toast at the top.
Why: chosenIds() reads a saved provider's chips only, not a new one's
draft.extra; Detect picked its model from the saved provider's list or the
vendor's, never from the form; an unsaved copy posted no id, so the server
had no key to fill in.
What changed:
- provider.Detect takes the form's picks (picked ...string) and tries one
of them per API before the saved list or the vendor's.
- /api/provider/detect takes `picked`, and for `new` + `copyOf` fills
what the draft left empty from the copied provider, as a saved edit
fills from its id. It still only reads: nothing is written, no provider
is added, no route or health check changes. No new route; magpie web's
key guard is the same.
- detectAPIs sends the add form's models (draft.extra) for a new
provider, copyOf for an unsaved copy, and says a missing URL, missing
models, a refusal, and "none answered, and no API key is typed" inline
under the buttons (amber/red text, no border). One new string in zh,
zh-TW, ja, de.
- docs/subsystems/providers-accounts.md: the detection row says so.
What was run:
- TestProviderDetectDraft (new): new draft with picked models on a relay
with no list, Each picked model, saved provider with a masked key and an
unsaved pick, an unsaved copy with no key typed and with a key typed,
config folder bytes unchanged, provider.All unchanged, magpie web without
its key -> 401 and the vendor never asked. Fails on the old detect.go /
providers.go ("no model to try").
- provider-detect-draft.test.cjs (new): chromium + webkit, en/zh/zh-TW/ja/
de, 900 and 360px, 20/20 pass; no scroll on click, no <select>, no
left-border, no sideways scroll, nothing but detect posted. Fails on the
old app.js (no inline hint).
- provider-detect, provider-detect-models, provider-add-models,
duplicate-pause, i18n-keys: 29/29, both engines.
- go test -tags nogui ./internal/gui/ ./internal/provider/ ok; gofmt -l
clean; GOOS=linux and GOOS=windows go vet -tags nogui ok.
- Real use: sandbox `magpie web` (nogui build) with a fake upstream. New
provider, relay with no model list: Detect APIs and Each picked model
answered with the typed key and models, no providers.json written. Saved
provider with its key masked plus a model typed in its add box: both
asked with the saved key. Duplicate not added: asked with the copied
key. providers.json bytes unchanged. Without the web key: 401, the
upstream got nothing.
|