Commit Graph
4 Commits
Author SHA1 Message Date
如是 52ad2d9845 gui: a ZCode account with nothing left to spend says so, and says what to do (#1245)
A ZCode account whose free Start Plan (体验套餐) has run out and which has
no GLM Coding Plan of its own reads as "Allowance unavailable" on the
Usage page's card, which is the words for a reading that failed — the
account's real state is that it has nothing to spend. The built-in already
names it (zcodeStartQuota, internal/provider/zcode_start.go: "this account
has no GLM Coding Plan, and ZCode's Start Plan has ended or was never
started") and the plugin's usage error is that same string byte for byte
(NO_START, magpie-community/plugins packages/zcode); quotaError matched
neither, so both fell through to the fallback.

The card now says it, and says the action on the card itself: the
"subscribe at …" wording is in the sign-in errors (zcodeSignedIn /
signedIn), which never reach this card, so there was nothing to hover for
(yetone on #1001). "has ended" would also be wrong for an account that
never started one, hence "no free Start Plan".

The match is anchored on the whole card sentence, so the sign-in errors —
which name the address themselves — and the sibling "…Start Plan could not
be read: <err>" (a reading that failed) are both left alone.

zh, zh-TW, ja and de get the new string. balance-fix.test.cjs gains both
card errors, the sign-in error and the could-not-be-read one, asserting
the first two get the card's words and the last two do not; the new string
joins its list of those needing a Chinese. Red/green: the two card
assertions fail with the mapping taken out of app.js, and the
could-not-be-read and sign-in ones fail if the match is loosened to
"Start Plan has ended" anywhere in the string. 108 tests pass across
balance-fix, gui-de, gui-ja, gui-zh-tw and i18n-keys.
2026-10-08 15:39:50 +08:00
mslxl cd8d64a9fc feat(gui): add Sub2API balance autofill on account balance hint (#1059)
* feat(gui): add Sub2API balance autofill

Offer Sub2API alongside NewAPI in the custom provider's balance-token hint.
Fill /api/v1/user/profile and $data.balance, and describe both endpoints in
the existing translations.

Verified: native macOS build; 10 existing browser and translation checks;
Sub2API flows in Chromium and WebKit, four languages, at 900px and 440px;
live web assets. The original code fails the temporary two-shortcut check.
Full Go suite, cross-platform builds and live-account validation not run.

* fix(gui): preserve custom balance fields in account shortcuts

Use the same replacement rule for both account balance shortcuts, keeping
user-written expressions. Describe both endpoints in the key-only URL
warning and restore the rationale for flagging missing and key-only URLs.

Add browser cases for both URL states, new providers, saved form values,
narrow layouts and all four languages.

Validation: 111/111 related checks across Chromium and WebKit; native macOS
build; 38/38 after baseline failure checks. New button cases fail against
d9b2cdc5 app.js, and custom-field checks fail against cf3f3d9d app.js.
Full Go suite, cross-platform builds and live-account validation not run.
2026-10-07 19:11:01 +08:00
Fanbuz 5ebb053ce1 fix: 统一额度相关的中英文界面文案 (#493) 2026-10-02 09:37:00 +08:00
yetone c9e47f043e balance: a custom provider's balance token can't be left where it is never asked, and new-api's refusals say what to do (TJHHHH: OK了,希望有防呆机制 — a new-api relay's System Access Token pasted beside a Balance URL of /api/usage/token, no New-Api-User header, and the Usage page never showed a balance) — new-api has two balance queries: /api/usage/token tells a key what is left on it and takes the key alone, and /api/user/self tells the account's quota to the access token with the user's id in New-Api-User. A token beside the first could only ever be turned down, and the second without the header answered {"success":false,"message":"无权进行此操作,未提供 New-Api-User"}, which a 401 showed as JSON and a 200 read as a field missing. The editor now says so under the token as soon as it is there: beside …/api/usage/token, or with no Balance URL at all (the token field is now offered on every custom provider, not only one with a URL saved), a warning with one button, Use https://<site>/api/user/self, which sets the URL, sets the Balance field to $data.quota / 500000 when it was empty or named /api/usage/token's fields, and opens More endpoints to show it; once the URL is /api/user/self and no New-Api-User header has a value, it asks for New-Api-User = your user ID (shown in the site's personal settings) until one is typed. The URL is not switched behind the user's back: what the editor shows is what is asked, and the field typed for /api/usage/token's reply wouldn't read /api/user/self's anyway. Behind it, Balance never sends a token to /api/usage/token and says what to set instead; a reply of success:false with a message, at a 401 or a 200, is that message as the error, with the header to add put in front when it is about New-Api-User (not provided, format error or mismatch, in new-api's Chinese or English); and /api/user/self with an empty field reads the quota, $1 to 500000. The Balance field has a Check balance button (POST /api/provider/balance) that asks as the form has it, before a Save, the saved provider with the form's URL, field, headers and token; it and the Usage page's card say either fix plainly, the relay's own words on hover. A JWT beside new-api's URL is not warned about: new-api's own dashboard sign-ins are JWTs now, so a token's shape can't tell new-api from a sub2api panel. Tested with new TestKeyUsageWithAccessToken (never asked, the fix said, the key alone still asks), TestUserSelfDefaultField and TestNewAPIUserRefusal (401 and 200, Chinese and English, the mismatch, and an unrelated refusal left as it came), which all fail on main; and a new internal/gui/tests/balance-fix.test.cjs in Chromium and WebKit (the warning on the saved setup, the click, the header hint going once typed, Check balance with and without the header and what it posted, Save, the Usage card's words, every new string in Chinese, and a new provider with a token and no URL). go build (and GOOS=linux, GOOS=windows), go test -tags nogui ./... and the other GUI tests pass 2026-09-29 17:56:43 +08:00