Commit Graph
4 Commits
Author SHA1 Message Date
yetone 3587bf70e2 providers: a plugin account's Select all available ticks its own list; zcode min 0.1.51 (young02036)
young02036 on Discord: their two ZCode accounts in magpie, one with no
GLM Coding Plan whose Start Plan holds glm-5.3-flash and one subscribed
whose gift shows as glm-5.3-flash-trial, failed while the ZCode app
worked; picking each account's usable models by hand worked. They also
said ticking the available models by default didn't work.

- zcode mover min 0.1.51: the plugin now lists for a gift-only account
  only the models its Start Plan balance names, as ZCode 3.17.2 offers
  it, not every model of the Start Plan config, so routing stops sending
  GLM-5.2 or GLM-5-Turbo to an account that holds only GLM-5.3-Flash
  (plugins c96d04bb, npm 0.1.51 checked with --prefer-online).
- Select all available in an account's model picker ticked every model
  shown for a signed-in account. provider/keylisted now answers for a
  plugin's account with the models its plugin lists for that account
  (plugin.Account.Models, by the provider's listed ids), and the picker
  asks it for accounts as for keys. An account the plugin keeps no list
  for (one account has them all) or doesn't have is unknown, which still
  ticks every model shown; a non-plugin account is unchanged in effect.
  The account title says so, translated in zh, zh-TW, ja and de.

Run on mote:
- go test ./internal/provider -run 'TestKeyListed|TestPluginAccountModels':
  TestKeyListedIsAPluginAccountsOwnList red on the old code (the key
  account's list: [], want [fake-1]), green after.
- node --test account-models-available.test.cjs (chromium + webkit,
  en zh zh-TW ja de, 900 and 420px): with the old app.js the new plugin
  account case and the Codex case (now asks keylisted) are red; green
  after. i18n-keys green.
- go test ./internal/gui -run Budget, go test ./internal/provider (whole
  package), GOOS=windows go vet of both packages, GOOS=linux go vet of
  internal/provider (internal/gui's wails needs cgo for a Linux vet from
  mac), gofmt.
Not tried: a real ZCode account (none available); whether the 3012s
young02036 saw came from these requests is not proven; the whole GUI
suite (only this picker's file and i18n-keys).
2026-11-05 11:46:26 +08:00
yetone 7661a0aa72 provider: Fetch models ticks each key's own models, the first key's too (young02036)
young02036 on Discord (#feedback, v0.1.2965): "点击供应商的获取模型,给这个
供应商的所有账号默认勾选上可用模型,和新增账号之后默认勾选上可用模型这个功能
好像失效了".

Cause: no later change broke it; the two commits that built it each left
keys out. 0431793db (v0.1.2674) gives a key its own list only when it is
added beside others and its list is short, and says "the keys it had keep
their lists". 1a67ca614 (v0.1.2942) carries on each Fetch only what a key's
list gained and lost, and only for a key that already had a list of its
own ("a key serving every model still does"). So every key on All models
stayed there through every Fetch: the provider's first key, keys added
before per-key lists, and a key whose list wasn't read in the 8s when it
was added. In the reporter's setup that is the key the provider was made
with, so the feature reads as gone.

Fix (refreshKeyModels): a key on All models whose fetched list leaves out
a model the provider's other keys list is given that list. A key whose
list has every model stays on All models, so later additions still reach
it; a lone key stays too. Keys with lists of their own work as before
(un-ticks and ticks kept).

The user's choice is never overridden: a key the user set to All models
(`accountmodels` with none, the picker's All models) is now remembered in
Provider.AccountModelsAll and left alone by Fetch. The editor's save keeps
it, a key replaced in place moves it (moveKeyed), accountSettings and
clone carry it, normalize drops a mark for a key that has a list.
Not covered: a key set back to All models before this release has no mark
and is narrowed once to its own list on the next Fetch; the user can
press All models again and it stays.

Tests:
- TestFetchTicksEachKeysListOnAllModels: keys saved with no lists are
  ticked on Fetch; a key set to All models before and after stays so
  through two fetches; an un-tick survives; a key whose list failed stays
  All models and gets its list once it reads.
- TestFetchLeavesALoneKeyOnAllModels.
- internal/gui TestFetchModelsTicksEveryKeysModels through the real
  routes: provider/save, provider/models, keys/add, accountmodels, the
  editor's save, against an httptest relay with a list per key.
- TestFetchRefreshesEachKeysModels and TestNewKeyTakesItsOwnModels pinned
  the old rule (sk-b / sk-old left on All models); they now expect the
  key's own list.

Broken by hand (mote): the old `was == nil -> continue` put back: the
new provider test, the GUI test (sk-a, the first key: [] want
[m1 m2 m3 m4]) and the two updated tests go red. The AccountModelsAll
check removed: sk-c/sk-d set to All models get narrowed, red. The editor
save not keeping AccountModelsAll: the GUI test's sk-c red.

Run (mote, at this tree): gofmt -l clean; go vet of the touched packages,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
go test -tags nogui -count=1 -timeout 45m ./internal/provider ./internal/gui
./internal/cli ./internal/gateway ./internal/tui: all ok (provider 223s,
gui 138s, cli 106s, gateway 797s, tui 26s).
GUI: account-models, account-models-available, account-refresh,
gateway-key-models, gateway-key-models-redraw (each in Chromium and
WebKit, as the files run): 94 of 94 pass.

Rebased on origin/main 8e97e26d6 (google.go, migrate_zcode.go): ./internal/provider
run again at this head, ok (157s).

Not tried: a real relay with per-group keys; Windows and Linux test runs
(nothing OS-specific changed). No app.js change.
2026-11-05 00:11:02 +08:00
yetone dd50cbba25 provider: a key's or account's model picker has Select all available (young02036)
young02036 on Discord (after 1a67ca614 fetched each key's own models):
"建议再同步给一个给按钮设置所有可用模型的触发按钮". A key or account's
model picker (the pill under the provider editor's accounts) now has
"Select all available" in its foot, beside All models. For a key it
ticks every model that key's own fetched list has, ones the user
un-ticked before included, since the user asked for it; with no per-key
list (one key, or a fetch not asked per key) and for a signed-in
account it ticks every chip shown. Nothing is saved until Save. The
provider level already had Select all; no new layout.

- provider.KeyListed(id, ref): the models the last fetch marks a key as
  seeing, by listed id; nil when unknown, not none.
- gui: provider/keylisted action returns {models, known}.
- app.js: the button, and the account's kept models joined at draw time
  so a re-draw after ticking shows them. Comments shortened so the core
  script stays under TestCoreScriptBudget with no raise.
- i18n: zh, zh-TW, ja, de for the button and its two tooltips.
- account-models.test.cjs clicks All models by name (the foot now has
  two .action buttons).

What was run (mote, via mote-run). At this tree rebased on 7818dc316:
- TestCoreScriptBudget, the two provider tests, go vet, gofmt,
  account-models-available (60/60), account-models and i18n-keys: ok.
At the same change on 083821dc9 (before the rebase):
- go test ./internal/provider -run 'TestKeyListedIsTheKeysOwnList|TestFetchRefreshesEachKeysModels'
  and ./internal/gui -run TestCoreScriptBudget: ok.
- go vet ./internal/provider ./internal/gui, also GOOS=windows and
  GOOS=linux -tags nogui: ok. gofmt -l: nothing.
- account-models-available.test.cjs (new): chromium + webkit, en zh
  zh-TW ja de, 900 and 420px: 60/60 ok. It checks the relay key ticks
  only its own list's models (an un-ticked one included) and Save posts
  them, a key with no list and a Codex account tick every chip without
  asking keylisted, the button fits its line, and every translation.
- account-models*, account-refresh, gateway-key-models*, provider-*,
  i18n-keys, gui-de, gui-ja, gui-zh-tw: 1219 tests, 1189 ok, 30 red.
  The same 7 files at a clean 083821dc9: 29 of 172 red, the same tests
  (provider-fetch-again #5232, provider-picks-stay and gateway-key-models
  #5233/#4616, provider-mask #5109, provider-typed #4673,
  provider-levels-scroll #4395, provider-models-rest #4396). None new.

Broken by hand: the new GUI test on origin/main's app.js: 0/60 (each
waits for the button).

Not tried: a real relay with per-group keys (the relay is a fixture),
and the full go test ./... before the tag (run after, issues filed for
any red).
2026-11-04 21:52:05 +08:00
yetone 1a67ca614e provider: Fetch models refreshes each key's own models, keeping what the user un-ticked (young02036)
young02036 on Discord: a provider holds several keys, each at a group of
a relay's that serves different models. Each key's own list was read
only when the key was added (PrefillNewKeys); Fetch models merged every
key's list into the provider's (fetchPerKey marks each model with the
keys that list it) but never changed a key's own models, so a model a
group took on later was never sent to its key and one it gave up still
was.

Fix: refetch, which every Fetch goes through (the editor's button, the
CLI, the TUI, the automatic re-list), takes each key's marks before and
after the fetch and carries the difference into that key's
AccountModels (key_models_refresh.go): a model the key's list has now
and didn't before is ticked for it, one it had and has no more is taken
out. A model the user un-ticked that the list had before and still has
stays un-ticked; one the user ticked that the list never had stays
ticked. Only keys with a list of their own are touched (a key serving
every model still does), a key with no marks before or now (one key
on, just added, a list that failed) is unknown and left alone, nothing
is ever narrowed to an empty list, and a key whose models the user
changed while the lists were asked keeps the user's. The provider's own
picks (what agents get) are not touched. No GUI change: the editor's
Fetch already redraws the key rows from the saved provider.

Test: TestFetchRefreshesEachKeysModels, against an httptest relay whose
per-key lists change between fetches: add a key (prefill), un-tick by
hand, groups change, fetch; un-tick again and tick a model the list
lacks, fetch twice; a key's list failing; the provider's picks unset.

Red on the old code (the refreshKeyModels call removed): "sk-a after a
fetch: [gpt-5.5 deepseek-v4], want [gpt-5.5 kimi-k3]", "sk-c after a
fetch: [deepseek-v4 qwen3-max], want glm-5 ticked", and the gateway's
AccountServes check. Broken by hand: ticking every listed model instead
of only those new to the key turns the un-tick, hand-tick and failed-list
cases red (4 errors).

Run on mote at this tree (on 78128b510): gofmt clean; go vet
./internal/provider ./internal/gui, GOOS=linux -tags nogui and
GOOS=windows go vet: ok. go test -count=1 -timeout 45m
./internal/provider ./internal/cli ./internal/tui: ok. ./internal/gui:
TestCoreScriptBudget (#5139) and TestMainWindowCorners/macOS_26_SDK
(#3949) red, the same as for 78128b510; no gui file changed here.
GUI files, chromium and webkit, every language they run:
account-models and account-refresh 26/26 ok. provider-fetch-again,
provider-picks-stay and gateway-key-models (en) are red, and red the same
way at a clean 78128b510 checkout with no change of this commit: #5232
and #5233.

Not tried: a real relay with per-group keys, and the full suite before
the push.
2026-11-04 19:30:08 +08:00