Commit Graph
3 Commits
Author SHA1 Message Date
yetone becdf36fc3 gui tests: zcode-site starts ZCode's sign-in on the Providers page with its list read — subOf tells a subscription moved onto its plugin from that list (pluginSubs reads providers.plugins), so starting the sign-in on the Agents page before /api/providers was ever read threw and the site step never came. The app only starts a sign-in from the Providers page, which reads the list first. Passes in Chromium and WebKit, en and zh; failed on 6e623d16. 2026-10-06 05:56:47 +08:00
yetone 0df1798b7d gui: a Codex account's Auto-use of its banked resets is a standing setting on its card, held resets or not, and says both times it uses one (#719, thedavidweng: the Usage card's Auto-use only showed with resets held, said only "when the week is used up" while the use before a reset expires (#624) was in the tooltip alone, was hidden in the multi-account brief rows, and zh called both the window's 额度重置 and the credit 重置) — every named Codex (ChatGPT) account's full card, on the Usage page and in the menu bar panel, now has a row of its own under its windows: "Auto-use resets: when the week runs out, or before one expires" (zh 「自动使用重置卡: 周额度用完时 · 重置卡到期前」) with a switch (lib-switch, role=switch, aria-checked) that posts settings/codex-auto-reset as the old toggle did, so codexAutoReset in settings keeps every existing user's on/off; it shows with 0 resets, so it can be set ahead of one. Holding resets, the row of them keeps "Use a reset" / "Use one…" and says after the nearest expiry whether that one is protected: "· auto-used before it expires" (zh 「· 到期前自动使用」, accent) or "· not auto-used" (「· 不会自动使用」), its tooltip saying how (about 3 hours before, if the account's windows have been used) or that it is lost unless used by hand. An account in brief says it beside its name: "↺ 2 · Auto-use: on" / "Auto-use: off" (zh 「自动用卡:开/关」), its full say in the title. The switch's tooltips name both triggers, one a week at most and the five hours never using one; the status after turning it on is "{who} uses a reset by itself when its week runs out, or before one expires". zh: the credit is 重置卡 throughout (1 张重置卡, 用一张重置卡, 用一张…, 用一张 Codex 重置卡?, the routing notes, outcomes and the GLM team's 5 小时/每周重置卡), the window's renewal stays 重置. A GLM team's resets, a plugin's and an account with no name get no switch, as before. magpie quota auto-reset's help and its on/status lines say the expiry use too. codex-auto-reset.test.cjs is rewritten (window and panel, en and zh: the say's visible words with both triggers, the switch for an account holding no reset, the quick switch with resets and the kept/not kept words turning, the brief rows' off/on and resets held, posts per account, no scroll, no left border, no native select, every string's zh, the credit 张/重置卡 in zh) and fails on the old code; routing-auto-reset and zcode-site expect the new zh words; quota-curve expects the Auto-use row between the curve and the next account. go vet, builds (darwin, GOOS=linux -tags nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass; codex-auto-reset, routing-auto-reset, quota-curve, usage-fold, click-scroll, account-mask, agent-models and routing-served pass in webkit; the rest of internal/gui/tests fails only where a clean checkout fails too, or passes alone; zcode-site and old-webkit fail before and after the change the same way (zcode-site times out at its sign-in step before reaching the reset words). Not tried with real Codex accounts. 2026-10-04 06:35:20 +08:00
yetone 8117d6f4a9 zcode: a seat on a team's GLM Coding Plan (团队套餐) is signed in, routed and metered as ZCode does it, on BigModel (智谱) as well as Z.ai, and a Zhipu key on a team plan shows its 5-hour and weekly windows and resets (#236 EZN7L2C3: a BigModel team GLM Coding Plan, the sign-in refused it and the usage was never read) — magpie's ZCode sign-in only went to Z.ai and only looked for the account's own coding-plan key, so a member of a team's plan, whose seat lives in a team project, was refused, and a key on a team plan read nothing from /api/monitor/usage/quota/limit. Read from ZCode.app 3.14.3 (host/index.js and config/provider/zcode-builtin.json): the team rules account:{zai|bigmodel}-team-coding-plan use the individual plans' base URLs with no extra inference headers; getCustomerInfo lists the projects, projectType "2" being a team's (isBigModelTeamCodingPlanProject); fetchTeamCodingPlanEntitlement asks /api/biz/team/subscribe/product/querySubscribeDetail (EFFECTIVE + memberGrantStatus VALID usable, UNASSIGNED no seat, EXPIRED run out); ensureBigModelTeamPlanProjectApiKeyWithStatus / copyBigModelTeamPlanProjectApiKeySecret find or create "zcode-team-api-key" (keyType 2) in the team project and copy its secret; createBigModelBizHeaders sends the access token bare in Authorization with bigmodel-organization / bigmodel-project; resolveAccountTeamPlanRuntimeApiKey takes the stored oauth:{family}:access_token (skipping BigModel's when it equals zcodejwttoken); buildQuotaLimitUrl adds type=2 and createBigModelUsageHeaders sends the key with the org/project headers; ZCode keeps the chosen team in ~/.zcode/v2/setting.json providerFamilyConnectionSelections (legacy modelProviderFamilySelectedKeys "team-plan:builtin:…", migrateLegacyAccountConnectionSettings); pollPendingOAuth/startOAuthWithPolling init with {provider:"zai"|"bigmodel"}, BigModel's redirect param being redirect, its token the poll's bigmodel.access_token. Now: the sign-in first asks where the account is — Z.ai or BigModel (智谱) (POST /api/signin takes a site, StartSignInAt, "zcode:bigmodel" too) — and on its site tries the account's own plan, then a team project with a usable seat (a new zcode_team.go: zcodeTeamSignIn keeps the team key, org, project and the biz token, the plan named by its product, "GLM Coding Team" otherwise), then the Start Plan; a team seat not yet granted or a team plan expired is refused saying so ("…has no seat on it yet — ask the team's admin…"), and an account with none of them names both plans and the site's subscribe page. ZCode's own team login is read from its credentials and setting.json (zcodeOwnTeam), its key minted lazily and kept (zcodeTeamKeyOf, retried after a minute, "sign in to ZCode again" when refused). Team requests go to the family's Anthropic base signed with the team key, no ZCode headers, never the Start Plan. Team usage asks bigmodel.cn (or api.z.ai) /api/monitor/usage/quota/limit?type=2 with the key and Authorization, Bigmodel-Organization, Bigmodel-Project, Set-Language, Accept-Language: CREDIT_LIMIT windows, unit 3 "5 hours" and unit 6 weekly, "current / total" when there is no remaining; /api/biz/customer-package-reset/list?targetType=TEAM gives the resets, fiveHourResets and weekResets counted where available is true, the soonest expireTime as until; the plan's end from querySubscribeDetail, Renew off. ResetCredits gains byWindow/fiveHour/weekly and Words(), "2 five-hour resets · 1 weekly reset" in the CLI, TUI and GUI (en and zh), with no "Use a reset" button for them since they are spent on the vendor's page. The Zhipu GLM key provider (planquota.go) falls back to the team query when the personal one fails or has no windows, adding the team headers when a ZCode team login holds that key. Personal accounts, Coding Plan and Start Plan, are routed, signed and metered as before. Tested with a new internal/provider/zcode_team_test.go against a fake bigmodel.cn/Z.ai in a sandbox HOME, no real tokens: a BigModel team sign-in through StartSignIn("zcode:bigmodel") is added (redirect param, plan "GLM Coding Team Pro", key made with keyType 2, org/project kept), its requests at the BigModel base signed with the team key and no ZCode headers, usage 5 hours 42% "420 / 1000" with a 5h span and weekly 10%, the quota headers sent, resets 2 five-hour and 1 weekly until 2026-10-05, plan until 2026-12-31; an unassigned seat is refused with no key made; ZCode's own team login from credentials + setting.json is found and metered while an individual plan stays as it was; the key provider's team fallback. TestPlanQuotas gains the type=2 case; the zcode Start Plan and account tests pass. A new internal/gui/tests/zcode-site.test.cjs, Chromium and WebKit, en and zh: starting ZCode's sign-in asks the site and posts nothing, BigModel posts {agent:"zcode",site:"bigmodel"} and keeps it, and the by-window resets read in both languages; signin-callback, click-scroll and login-import pass. go vet ./internal/..., go build -tags nogui (and GOOS=linux, GOOS=windows) and go test -tags nogui ./... pass (TestUserPath timed out under load and passes alone). Not tried against a real account: BigModel's OAuth sign-in and poll shape, the Set-Language values, customer-package-reset's field formats, querySubscribeDetail on Z.ai, type=2 for a pasted key with no org/project, and the time formats are from ZCode's code, not seen on the wire; not tried in the real Wails window. 2026-09-30 04:15:06 +08:00