What changed:
- balance.go: the guard that never sends a balance token to new-api's
/api/usage/token (c9e47f043) now covers sub2api's /v1/usage too, and
says to set <site>/api/v1/user/profile (Balance field $data.balance)
or remove the token, as the new-api branch says its /api/user/self.
- gui: the editor's token warning (balanceFix) and the refusal wording
(balanceError) each name sub2api's /v1/usage beside the token; two new
strings in zh, zh-TW, ja and de.
Run:
- TestSub2APIKeyUsageWithLoginToken (new): a JWT beside /v1/usage is
never sent there and the panel's account query is named; the key alone
still asks. On upstream/main 2c18c697 it fails asked=true with the
panel's raw 401 (the token went out as Authorization).
- TestKeyUsageWithAccessToken, TestBalanceKeyAsBearer and the balance
tests unchanged; go test -tags nogui -p 2 -count=1
./internal/provider ok (71.9s). i18n-keys.test.cjs 3/3.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/provider and internal/gui; go build darwin, GOOS=linux
-tags nogui, GOOS=windows.
Generated-by: GLM-5.3-Flash (ZCode)
Review (yetone, #2217): read line by line and kept, with one change in
the GUI. The editor's warning for a token beside /v1/usage offered both
/api/user/self and /api/v1/user/profile, but /v1/usage is sub2api's, so
only the panel's profile is offered now, and a saved "$remaining" (the
key query's field) gives way to $data.balance as the button sets the
URL. balance-fix.test.cjs gets a test for it (chromium and webkit, 440
wide): it is red on the patch's app.js ("only sub2api's account query
is offered") and on main's.
Run at the reviewed head, on origin/main 2a99e7a42, and
again on 91b9065a5 for vet, gui, provider, tui, gateway, agent and
the tests named here:
- TestSub2APIKeyUsageWithLoginToken is red with main's balance.go (ok
true, the panel's 401 "invalid API key", asked true) and green with
the patch.
- node --test balance-fix.test.cjs i18n-keys.test.cjs: 103 pass, 0 fail
(chromium + webkit; the file's matrix is en, zh, ja, de at 900 and
440; zh-TW strings are checked by i18n-keys only).
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ./...;
go build for the three; go test -tags nogui -count=1 -p 4 ./... at a machine load of 100-150:
50 packages ok; internal/agent and internal/gateway ran past the 10m
default under that load and pass with -timeout 40m (674s, 798s);
internal/gui's TestSetAnswersWhileDevinAndProvidersHang failed once
(a state took 10.4s; open as #1375) and the package passes rerun.
Not tried: a real sub2api panel.