From c1934262ab8e952b85f591369439fd0db84797f0 Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 19 Nov 2026 11:18:11 +0800 Subject: [PATCH] routing: a group member sent Ultrafast says Ultrafast, not fast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OoopsHh on X: with Ultrafast picked on a routing group's member, the group list's card still said "· fast". The Routing page's summaries (the card's member line, the member menus' notes and the route view's tag) read Group.Fast alone. They now say Ultrafast where the group sends the member so and an account offers it (memberJSON.Ultra), as the editor's speed button and `magpie group` already did. The TUI's group view did the same and now says Ultrafast too. The route trace's Weighed gains Ultra so the route view's tag can tell the two apart (#7095). Fixes #6881 and #7095 (paul-tian). ggbdpq took #6881 and posted a patch on it; its TUI test and the Codex GPT-6-Astra fixture are ported here with credit. Siblings checked: `magpie group` (groups_cli.go) and the Agents page (agentspeed.js) and search tags (fastTag) already said Ultrafast; the tray has no group speed summary. Tests: - group-member-fast.test.cjs: a group "Astra" with an Ultrafast member; its card says "gpt-6.2-sol · Ultrafast" / "· 极速" (en, zh; Chromium, WebKit). Red on 7d5db0f29 (4 of 4: "Relay gpt-6.2-sol · fast"). The same card now also holds #6881's Codex gpt-6-astra member (ggbdpq's fixture) and checks it reads Ultrafast, not fast. - routing-ultra-row.test.cjs (new, #7095): the route view tags a member sent Ultrafast "Ultrafast" with its own title, and one sent fast "fast"; every language, Chromium and WebKit. Red on 7d5db0f29 (10 of 10: both tagged "fast"). - TestGroupMemberUltrafastShown (tui) and ggbdpq's TestGroupMemberUltraShown (a Codex gpt-6-astra member; a member set fast alone still says fast): both red on 7d5db0f29. - routing-service-tier.test.cjs: 20 of 20 green. - GUI run of the group-*, routing-*, panel-routing, fast-*, codex-service-tier, picker-speeds, agent-speed, i18n-*, gui-de/ja/zh-tw and header-relang files on mote: 4295 tests, 84 red in 10 files. The 10 files then run at this head and at origin/main 3869aee3b on mote: the same 84 reds on both, each filed: fast-pick/fast-ultra #6201, group-editor-selected #5049, gui-ja #7144, routing-pin-away #6512, routing-provider-off and routing-rows-fit #7016, routing-row-swap #3799, routing-signin #6520, routing-story-shrinks #3954. Co-authored-by: ggbdpq --- docs/subsystems/gateway-routing.md | 2 +- internal/gateway/groupfast.go | 2 +- internal/gateway/trace.go | 3 +- internal/gui/assets/plugins/routing/client.js | 15 ++-- internal/gui/assets/plugins/routing/i18n.js | 4 + internal/gui/tests/group-member-fast.test.cjs | 24 ++++-- internal/gui/tests/routing-ultra-row.test.cjs | 78 +++++++++++++++++++ internal/tui/group_member_ultra_test.go | 57 ++++++++++++++ internal/tui/groupfast_test.go | 21 +++++ internal/tui/i18n.go | 1 + internal/tui/routing.go | 6 +- 11 files changed, 198 insertions(+), 15 deletions(-) create mode 100644 internal/gui/tests/routing-ultra-row.test.cjs create mode 100644 internal/tui/group_member_ultra_test.go diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md index afaf1ab8c..ac58ec792 100644 --- a/docs/subsystems/gateway-routing.md +++ b/docs/subsystems/gateway-routing.md @@ -297,7 +297,7 @@ the key's leaves the call as asked, with a log line (`compactRefused`). - Each record keeps the service tier three ways (#1784): `tier_asked` is what the client's body asked (`bodyTier`; Claude's speed fast reads `fast`), `tier_sent` is what that try's last request went out with, noted in `forwardOnce` after every rewrite (fast picks, Ultrafast to priority on a plan without it) onto the per-attempt `wireAt`, and `tier_served` is only what the reply said it ran at (`upstreamTier`, read by the sniffer and the translated readers), empty when it says nothing; from the ChatGPT backend (CodexBase's host) its `auto` and `default` are empty too, since it says them whether priority ran or not (`servedTierAt`, applied in `attempt` and `codexUpstreamOn`). The route's tries carry `tier` and `tier_served` the same way, on Codex's own sign-in (`codexUpstreamOn`) too, which before set only the route's `tier`, so a `/fast` turn there showed nothing (Anotiaww on X). The Routing page's request row shows a try's tier as a quiet tag beside the model (`fast` for `priority`, `Ultrafast`, `flex`; an in-flight row the route's asked tier), with the served tier in its title when the reply said another (`rowTier` in [`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js), `routing-service-tier.test.cjs`). A bridge that doesn't go through `forwardOnce` (the Claude subscription, Cursor's built-in) leaves `tier_sent` empty. Through a Remote magpie the other magpie's word is taken (JackyFill on X: Codex → magpie1 → magpie2 → a ChatGPT account, Fast on in magpie2 alone, was logged `default` on magpie1): a try asked by another magpie (`magpieAsks`) says on its reply's header the tier it sent its vendor (`X-Magpie-Tier-Sent`, `none` for none) and, when that vendor's `auto`/`default` tell nothing, `X-Magpie-Tier-Unsaid: 1` (`stampTier`, from the holdWriter's `writeHeader`). The asking magpie takes them from a remote magpie's reply alone (`tierThere` in `heardReply`; a vendor's `X-Magpie-` headers are never passed) and records them as its try's `tier_sent` (`sentThere`) and an unknown `tier_served` (`servedThere`); a chain of magpies passes the farthest one's on. A reply whose headers a keepalive sent before the try answered carries neither, and the asking magpie keeps its own record. Code: [`tier_record.go`](../../internal/gateway/tier_record.go). - A record is priced at its tier (`Record.billedTier`: `tier_served` when the reply named one, so an OpenAI API call asked `priority` and run at `default` is billed at the default; else `tier_sent`, which is what a ChatGPT backend row has, its `tier_served` being empty). `catalog.TierPrice` reads the price from the model's models.dev `experimental.modes`: the mode whose `provider.body.service_tier` is the tier, or whose `speed` is `fast` for Claude's `fast`, under `openai` or `anthropic`. That price stands only where the row's price is that entry's standard one, so a relay's rate or the user's own price is left as it is. The pricing pages agree: OpenAI's Fast (Priority processing until 2026-07-30) is twice gpt-6.1-sol's standard and Ultrafast six times, Flex half; Anthropic's fast mode is twice Claude Opus 5.5's. A mode lists no long-context price or 1-hour write, so the standard's are scaled by the mode's own ratio. A tier OpenAI prices as a dated multiple of the standard (`tierTimes`: GPT-6.2 Astra's and Sol's Ultrafast, 3 times through 2027-02-28 and 6 times from 2027-03-01, Pacific time, which models.dev lists with no cost) is the standard times the multiple of the call's own day (`catalog.TierTimes`), every part and long-context rate with it; the price caches key on that day's rate (`Record.tierKey`), so calls either side of the change price apart (`TestDatedUltrafastPricedAtItsDay`, mu33410 on X; before, those calls were priced at the standard rate). The Usage page, a key's spend limit (`NewCoster`) and a subscription window's API value (`apiPricer`) all price through it (`TestFastCallsPricedAtTheirTier`, Archivemylife on X). Before this, every tier was priced at the standard rate. - An agent's fast pick (`settings.FastPicks`, the bolt in its picker, #954) may also be in `settings.UltraPicks` (#1954), offered by the GUI only where one of Codex's accounts lists Ultrafast on the model (`provider.CanUltra`, `UltraModels`). `fastPick` marks its candidates `ultra`; a try of one goes with `service_tier: "ultrafast"` on Chat and Responses, and an agent on Messages carries it in the context (`withUltra`) to `forwardTranslated`, which sets `Request.Ultrafast` for the ChatGPT backend. Either way the same check as a client's own Ultrafast ask applies, now on Chat as well as Responses: an account whose list doesn't offer it is put after a mate that does (`tierMate`), or, with none left, sent `priority`. A Chat body's own `service_tier: "ultrafast"` is parsed as Ultrafast too (`chat.go`). `TestUltraPickSentUltrafast`. -- A group's member may be Ultrafast as well as fast (`Group.Ultra`, a subset of `Fast`, `Group.SetMemberTier`; the member's button steps Standard speed, Fast, Ultrafast where `ultraOK`; `ultra=` in `magpie group`), and a model has its own speed (`settings.ModelTiers`, "/" to `priority` or `ultrafast`, `provider.SetModelTier`, Model settings and `magpie model tier`; kdajenks on X). The gateway sends it on a direct pick for an agent with no fast pick of its own (`provider.ModelTier`, the branch after `IsFastPick`), through the same `fastPick`, so an account without Ultrafast is sent `priority`. A group member goes as the group says. On a provider the user added by its address (`OwnFast`, a GPT or o-series model on an OpenAI API) the member's button goes on to Ultrafast when OpenAI offers the tier on the model: one of Codex's accounts lists it, or Codex's own `models_cache.json` entry for the slug does (`codexcat.OwnOffers`, the entry `ownTiers` already offers Codex), and the tier is only asked for, as its Fast is: a provider that turns the field away is asked again without it (KoiLx0 on X). A fast member never goes slower than the provider's extraBody asks: its `service_tier` `ultrafast` (forced or not) makes a Fast member go Ultrafast (`extraUltra`), a slower one (`flex`) gives way to the member's Fast, and a forced `!service_tier` still goes as written over all of them (`TestFastMemberOwnProviderExtraTier`, `TestCanUltraOwnProvider`, `group-member-fast.test.cjs`). `TestModelTierSentToEveryAgent`, `TestGroupMemberUltrafast`, `model-speed.test.cjs`. +- A group's member may be Ultrafast as well as fast (`Group.Ultra`, a subset of `Fast`, `Group.SetMemberTier`; the member's button steps Standard speed, Fast, Ultrafast where `ultraOK`; `ultra=` in `magpie group`), and a model has its own speed (`settings.ModelTiers`, "/" to `priority` or `ultrafast`, `provider.SetModelTier`, Model settings and `magpie model tier`; kdajenks on X). The gateway sends it on a direct pick for an agent with no fast pick of its own (`provider.ModelTier`, the branch after `IsFastPick`), through the same `fastPick`, so an account without Ultrafast is sent `priority`. A group member goes as the group says, and every summary of it says which: the group's card in Routing, its manual pick's buttons and menu (`speedIn` in [`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js), from the member info's `ultra`), the TUI's member list and `magpie group` say Ultrafast of an Ultrafast member and fast of a Fast one, and a route's try carries `Weighed.Ultra` beside `Fast` so its tag says Ultrafast too; before, all but the CLI said fast (OoopsHh on X, `group-member-fast.test.cjs`, `TestGroupMemberUltrafastShown`). On a provider the user added by its address (`OwnFast`, a GPT or o-series model on an OpenAI API) the member's button goes on to Ultrafast when OpenAI offers the tier on the model: one of Codex's accounts lists it, or Codex's own `models_cache.json` entry for the slug does (`codexcat.OwnOffers`, the entry `ownTiers` already offers Codex), and the tier is only asked for, as its Fast is: a provider that turns the field away is asked again without it (KoiLx0 on X). A fast member never goes slower than the provider's extraBody asks: its `service_tier` `ultrafast` (forced or not) makes a Fast member go Ultrafast (`extraUltra`), a slower one (`flex`) gives way to the member's Fast, and a forced `!service_tier` still goes as written over all of them (`TestFastMemberOwnProviderExtraTier`, `TestCanUltraOwnProvider`, `group-member-fast.test.cjs`). `TestModelTierSentToEveryAgent`, `TestGroupMemberUltrafast`, `model-speed.test.cjs`. - OpenAI's own API serves `service_tier: "ultrafast"` on the models its [Ultrafast mode](https://developers.openai.com/api/docs/guides/ultrafast-mode) names, GPT-6.2 Astra, GPT-6.2 Sol, GPT-6 Astra and GPT-6.1 Sol (`provider.OpenAIUltra`, a dated snapshot too), on its Responses only (OoopsHh on X: in Docker an OpenAI key's GPT-6 Astra had Fast and no Ultrafast, since every Ultrafast offer came from a Codex account's or CLI's list). On 11-18 api.openai.com's `/v1/responses` took the tier for those four and answered `Invalid service_tier argument` for GPT-6 Sol and GPT-6.1 Terra; `/v1/chat/completions` answered that for every model. So `UltraOn` offers Ultrafast on an OpenAI key's Responses (and on a provider added by its address, `OwnFast`) for those models, `buildResponses` sends it to api.openai.com for them alone (another model goes `priority`), and a Chat Completions request to api.openai.com that would carry it, a client's own ask included, goes `priority` instead (`chatNoUltra`, in the `tierMate` check). Another vendor's model is untouched. `TestOpenAIKeyUltrafast`, `TestCanUltraOwnProvider`. A Codex (ChatGPT) account's list is asked with the newest Codex magpie knows (`codexVersion`), and with none at hand, as in Docker, with `codexClientVersion` or npm's latest (`codexPublished`); the backend lists GPT-6.2 and Ultrafast only from 0.166.0, so the fallback is kept at or above it (`TestCodexFallbackListsUltrafast`). - Codex's service tier (`settings.CodexServiceTier`, a row in Codex's settings, JackyFill on X) sets the `service_tier` of every request of Codex's, whatever Codex's own `/fast` asked: empty is as Codex asks (the default, nothing changed), `default` sends none (standard), `priority` is Codex's Fast and `ultrafast` its Ultra Fast (the request values in Codex's `ServiceTier`; Flex is not offered, since the ChatGPT backend's requests drop it in `codex_request.go`). `codexTiered` ([`codex_tier.go`](../../internal/gateway/codex_tier.go)) rewrites the body as it comes in, on both of Codex's ways in: `codexBackend` (Codex signed in, `/backend-api/codex`) and the main handler's Codex-on-Responses block, which a websocket turn reaches too. Everything after treats it as Codex's own ask: an account whose list lacks Ultrafast is put after a mate that offers it (`tierMate`) or sent `priority`, and a provider that refuses a tier drops it. A model with no provider (`gpt-…`, Codex's own sign-in, whose plan magpie doesn't know) is sent `ultrafast` only where one of magpie's Codex accounts lists it on the model (`UltraModels`), else `priority`. Another agent's request is never touched, and fast picks still apply after. `TestCodexServiceTierSet`, `codex-service-tier.test.cjs`. - A client's `service_tier: "fast"`, Codex's own name for its Fast mode, is read as `priority` on Chat and Responses as the main handler takes the body (`fastTier` in [`codex_tier.go`](../../internal/gateway/codex_tier.go), before the Codex and key tiers above and before `tier_asked` is noted), and `codexBody` sends it as `priority` too. Codex itself never sends `fast`: its `ServiceTier::from_request_value` reads `fast` and `priority` alike as Fast and `request_value` sends `priority` (openai/codex `codex-rs/protocol/src/config_types.rs`). Before, `fast` was dropped on the way to a ChatGPT account (`codexBody` kept only `priority` and `ultrafast`) and never set the IR's Fast (Archivemylife on X). Claude's equivalent is `speed: "fast"` (Anthropic's own `service_tier`, `auto`/`standard_only`, is about capacity, not speed), already read as Fast. The ChatGPT backend's reply says `auto` and then `default` whether priority ran or not (`servedTierAt`): on gpt-6.1-sol a `fast` ask decoded at about 29 tok/s against about 22 without, both answered `default`. `TestFastTierWordReachesCodex`, `TestCodexBodyServiceTier`. diff --git a/internal/gateway/groupfast.go b/internal/gateway/groupfast.go index 8e9efc26b..9d16a38af 100644 --- a/internal/gateway/groupfast.go +++ b/internal/gateway/groupfast.go @@ -45,7 +45,7 @@ func fastPick(cands []candidate, pl planned, providerID, model string, ultra boo for _, ws := range [][]Weighed{pl.order, pl.left} { for i, w := range ws { if w.Provider == providerID && w.Model == model { - ws[i].Fast = true + ws[i].Fast, ws[i].Ultra = true, ultra } } } diff --git a/internal/gateway/trace.go b/internal/gateway/trace.go index 90d02afef..57c36f64b 100644 --- a/internal/gateway/trace.go +++ b/internal/gateway/trace.go @@ -328,6 +328,7 @@ type Weighed struct { Model string `json:"model"` Fixed string `json:"fixed,omitempty"` // the effort the group's member it is of is fixed at Fast bool `json:"fast,omitempty"` // the group's member it is of is sent fast + Ultra bool `json:"ultra,omitempty"` // and Ultrafast, where the account offers it (Group.Ultra, an Ultrafast pick) Routing string `json:"routing"` // its provider's: "", order, rotate, usage Fallback bool `json:"fallback,omitempty"` Shared bool `json:"shared,omitempty"` // its provider has more than one on @@ -614,7 +615,7 @@ type planned struct { } func weighed(c candidate, p provider.Provider, wg weighing, fallback bool, from provider.Protocol) Weighed { - w := Weighed{ID: c.rest, Provider: p.ID, Name: p.Name, Icon: p.Icon, Preset: p.Preset, Model: c.model, Fixed: c.effort, Fast: c.fast, + w := Weighed{ID: c.rest, Provider: p.ID, Name: p.Name, Icon: p.Icon, Preset: p.Preset, Model: c.model, Fixed: c.effort, Fast: c.fast, Ultra: c.fast && c.ultra, Routing: p.Routing, Fallback: fallback, Shared: c.rest != p.ID, Rank: c.rank, NoURL: c.noURL, Reserve: c.reserve, UseFirst: c.p.UseFirst} switch { case c.p.Account != nil: diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.js index f342bf3d5..03c535bf0 100644 --- a/internal/gui/assets/plugins/routing/client.js +++ b/internal/gui/assets/plugins/routing/client.js @@ -2846,8 +2846,8 @@ function routingPage(part) { if (w.fixed) b.title = t("{level} reasoning, fixed on this model in the group", { level: w.fixed }); if (w.fast) { // the group sends this member in its vendor's fast mode - const f = el("small", "fb", t("fast")); - f.title = t("Sent in its vendor's fast mode, as the group says"); + const f = el("small", "fb", t(w.ultra ? "Ultrafast" : "fast")); + f.title = t(w.ultra ? "Sent Ultrafast where the account offers it, as the group says" : "Sent in its vendor's fast mode, as the group says"); b.append(f); } if (w.fallback) b.append(el("small", "fb", t("fallback"))); @@ -6749,6 +6749,11 @@ function routingPage(part) { const memberNote = (id) => { const o = !subOf(id) && !modelOf(id) && offOf(id); return subOf(id) ? t("routing group") : [modelOf(id)?.providerName || o && `${o.name} · ${t("switched off")}`, memberAccount(id)?.name, drawerOf(id) && t("Image model"), fixedOf(id) && fixedWords(fixedOf(id))].filter(Boolean).join(" · "); }; // a member the group sends in its vendor's fast mode (Group.Fast) const fastIn = (g, id) => !!g?.fast?.includes(id) && !subOf(id); + // the word for a member's speed where it is said in a line: Ultrafast + // where the group sends it so and an account offers it (memberJSON.Ultra, + // as its button in the editor says), else fast (OoopsHh on X: a list + // card said fast of an Ultrafast member) + const speedIn = (g, id) => fastIn(g, id) && t(memberInfoOf(g, id)?.ultra ? "Ultrafast" : "fast"); // a member Free first and Cheapest first count as costing nothing: its // provider is Free for me, or its vendor serves it free (memberJSON.Free), // said whatever the group's routing, so it shows before Free first is @@ -6761,7 +6766,7 @@ function routingPage(part) { const i = memberInfoOf(g, id), m = modelOf(id), s = subOf(id), f = fixedOf(id); if (s) return { pv: t("routing group"), mn: s.name, at: "" }; const acct = memberAccount(id); - const at = (acct ? ` · ${acct.name}` : "") + (f ? ` · ${fixedWords(f)}` : "") + (fastIn(g, id) ? ` · ${t("fast")}` : "") + (freeIn(g, id) ? ` · ${t("free")}` : ""); + const at = (acct ? ` · ${acct.name}` : "") + (f ? ` · ${fixedWords(f)}` : "") + (fastIn(g, id) ? ` · ${speedIn(g, id)}` : "") + (freeIn(g, id) ? ` · ${t("free")}` : ""); if (m) return { pv: m.providerName, mn: modelName(m), at }; if (i?.providerOff) return { pv: i.name, mn: i.model, at: `${at} (${t("switched off")})` }; return i?.name ? { pv: i.name, mn: i.model, at } : { pv: "", mn: id, at: "" }; @@ -7740,7 +7745,7 @@ function routingPage(part) { b.setAttribute("aria-checked", String(on)); b.dataset.member = id; b.append(el("span", "dot"), memberIcon(id), el("span", "n", memberName(id))); - const note = [memberNote(id), fastIn(g, id) && t("fast"), freeIn(g, id) && t("free")].filter(Boolean).join(" · "); + const note = [memberNote(id), speedIn(g, id), freeIn(g, id) && t("free")].filter(Boolean).join(" · "); if (note) b.append(el("small", "", note)); b.title = on ? t("Every request goes to {name}", { name: memberLabel(g, id) }) : info?.providerOff ? offWords(info) @@ -9873,7 +9878,7 @@ function routingPage(part) { if (b.classList.contains("open")) return closeProtoMenu(); openProtoMenu(b, g.members.map((id) => { const info = g.memberInfo?.find((x) => x.id === id); - const note = [memberNote(id), fastIn(g, id) && t("fast"), freeIn(g, id) && t("free"), info && !info.ready && t("no provider serves it now")].filter(Boolean).join(" · "); + const note = [memberNote(id), speedIn(g, id), freeIn(g, id) && t("free"), info && !info.ready && t("no provider serves it now")].filter(Boolean).join(" · "); return { v: id, name: memberName(id), literalName: true, note, title: memberLabel(g, id) }; }), picked, async (id) => { closeProtoMenu(); diff --git a/internal/gui/assets/plugins/routing/i18n.js b/internal/gui/assets/plugins/routing/i18n.js index 55f584670..75a845dd6 100644 --- a/internal/gui/assets/plugins/routing/i18n.js +++ b/internal/gui/assets/plugins/routing/i18n.js @@ -381,6 +381,7 @@ magpie.strings({ "Off: kept in its place, sent nothing. Click to switch it on": "已停用:保留位置,不会收到请求。点击启用", "On: requests may go to it. Click to switch it off and keep its place": "已启用:请求可能发给它。点击停用(保留位置)", "Sent in its vendor's fast mode, as the group says": "按分组设置,以服务商的快速模式发送", + "Sent Ultrafast where the account offers it, as the group says": "按分组设置,账号支持极速就以极速发送", "Sent in its vendor's fast mode (service tier {tier}): quicker, at a higher price": "以服务商的快速模式发送(service tier {tier}):更快,价格更高", "Sent at its vendor's flex tier (service tier {tier}): slower, at a lower price": "以服务商的弹性档发送(service tier {tier}):更慢,价格更低", "Its reply said it ran at {tier}.": "回复说它以 {tier} 运行。", @@ -1146,6 +1147,7 @@ magpie.strings({ "Off: kept in its place, sent nothing. Click to switch it on": "已停用:保留位置,不會收到請求。點選啟用", "On: requests may go to it. Click to switch it off and keep its place": "已啟用:請求可能發給它。點選停用(保留位置)", "Sent in its vendor's fast mode, as the group says": "按分組設定,以服務商的快速模式傳送", + "Sent Ultrafast where the account offers it, as the group says": "按分組設定,帳號支援極速就以極速傳送", "Sent in its vendor's fast mode (service tier {tier}): quicker, at a higher price": "以服務商的快速模式傳送(service tier {tier}):更快,價格更高", "Sent at its vendor's flex tier (service tier {tier}): slower, at a lower price": "以服務商的彈性檔傳送(service tier {tier}):更慢,價格更低", "Its reply said it ran at {tier}.": "回覆說它以 {tier} 執行。", @@ -1909,6 +1911,7 @@ magpie.strings({ "Off: kept in its place, sent nothing. Click to switch it on": "オフ:位置は維持し、何も送りません。クリックでオン", "On: requests may go to it. Click to switch it off and keep its place": "オン:リクエストが送られることがあります。クリックで位置を維持したままオフ", "Sent in its vendor's fast mode, as the group says": "グループの設定どおり、ベンダーの高速モードで送ります", + "Sent Ultrafast where the account offers it, as the group says": "グループの設定どおり、アカウントが対応していれば超高速で送ります", "Sent in its vendor's fast mode (service tier {tier}): quicker, at a higher price": "ベンダーの高速モードで送りました(service tier {tier})。速くなりますが、料金は高くなります", "Sent at its vendor's flex tier (service tier {tier}): slower, at a lower price": "ベンダーの Flex 階層で送りました(service tier {tier})。遅くなりますが、料金は安くなります", "Its reply said it ran at {tier}.": "応答では {tier} で実行されたとのことです。", @@ -2674,6 +2677,7 @@ magpie.strings({ "Off: kept in its place, sent nothing. Click to switch it on": "Aus: behält seinen Platz, erhält nichts. Zum Einschalten klicken", "On: requests may go to it. Click to switch it off and keep its place": "An: Anfragen können dorthin gehen. Klicken, um es auszuschalten und den Platz zu behalten", "Sent in its vendor's fast mode, as the group says": "Im Schnellmodus des Anbieters gesendet, gemäß Gruppe", + "Sent Ultrafast where the account offers it, as the group says": "Ultrafast gesendet, wo das Konto es bietet, gemäß Gruppe", "Sent in its vendor's fast mode (service tier {tier}): quicker, at a higher price": "Im Schnellmodus des Anbieters gesendet (Service-Tier {tier}): schneller, zu höherem Preis", "Sent at its vendor's flex tier (service tier {tier}): slower, at a lower price": "In der Flex-Stufe des Anbieters gesendet (Service-Tier {tier}): langsamer, zu niedrigerem Preis", "Its reply said it ran at {tier}.": "Laut Antwort lief sie mit {tier}.", diff --git a/internal/gui/tests/group-member-fast.test.cjs b/internal/gui/tests/group-member-fast.test.cjs index 9222de75f..4bc127f2f 100644 --- a/internal/gui/tests/group-member-fast.test.cjs +++ b/internal/gui/tests/group-member-fast.test.cjs @@ -9,7 +9,8 @@ // leaves it. A GPT model on a provider the user added by its address // (ownFast, #1615) has the toggle too, off until clicked, and its title says // fast is asked of the provider; one OpenAI offers Ultrafast on (ultraOK) -// goes on to Ultrafast, and its title says that is asked for. In English and Chinese, Chromium and WebKit. +// goes on to Ultrafast, and its title says that is asked for. A group's +// card says "· Ultrafast" of a member sent so, not "· fast" (OoopsHh on X). In English and Chinese, Chromium and WebKit. const assert = require("node:assert/strict"); const fs = require("node:fs/promises"); const path = require("node:path"); @@ -25,20 +26,27 @@ const models = [ { id: "rl/o4-mini", name: "o4-mini", providerName: "Relay", icon: "generic", canFast: true, ownFast: true }, // one OpenAI offers Ultrafast on (KoiLx0 on X) { id: "rl/gpt-6.2-sol", name: "gpt-6.2-sol", providerName: "Relay", icon: "generic", canFast: true, ownFast: true, ultraOK: true }, + // #6881's member (paul-tian; ggbdpq's fixture): a Codex account's + // GPT-6-Astra set Ultrafast, which the list read as Fast + { id: "cx/gpt-6-astra", name: "gpt-6-astra", providerName: "Codex", icon: "generic", canFast: true, ultraOK: true }, ]; const members = ["oa/gpt-6.1-sol:high", "an/claude-opus-5-5", "rl/glm-5", "rl/o4-mini", "rl/gpt-6.2-sol"]; const groups = () => ({ models, pools: [], groups: [{ id: "sol", name: "Sol", members, fast: ["oa/gpt-6.1-sol:high"], routing: "order", ready: true, - memberInfo: members.map((id) => ({ id, ready: true, fast: id === "oa/gpt-6.1-sol:high", canFast: id !== "rl/glm-5", ownFast: id.startsWith("rl/") && id !== "rl/glm-5", ultraOK: id === "rl/gpt-6.2-sol" })) }], + memberInfo: members.map((id) => ({ id, ready: true, fast: id === "oa/gpt-6.1-sol:high", canFast: id !== "rl/glm-5", ownFast: id.startsWith("rl/") && id !== "rl/glm-5", ultraOK: id === "rl/gpt-6.2-sol" })) }, + // one sent Ultrafast: its card says Ultrafast, not fast (OoopsHh on X) + { id: "astra", name: "Astra", members: ["cx/gpt-6-astra", "rl/gpt-6.2-sol"], fast: ["cx/gpt-6-astra", "rl/gpt-6.2-sol"], ultra: ["cx/gpt-6-astra", "rl/gpt-6.2-sol"], routing: "order", ready: true, + memberInfo: [{ id: "cx/gpt-6-astra", ready: true, fast: true, ultra: true, canFast: true, ultraOK: true }, + { id: "rl/gpt-6.2-sol", ready: true, fast: true, ultra: true, canFast: true, ownFast: true, ultraOK: true }] }], }); const words = { - en: { edit: "Edit", save: "Save", fast: "Fast", std: "Standard speed", label: "gpt-6.1-sol · high reasoning · fast", remove: "Remove", + en: { edit: "Edit", save: "Save", fast: "Fast", std: "Standard speed", label: "gpt-6.1-sol · high reasoning · fast", ultraLabel: "gpt-6.2-sol · Ultrafast", codexLabel: "gpt-6-astra · Ultrafast", remove: "Remove", ownOff: 'Sent as the agent asks; click to ask your provider for OpenAI\'s fast mode (service_tier "priority")', ownOn: 'Asked for OpenAI\'s fast mode (service_tier "priority") whatever the agent asks: quicker, at a higher price, where your provider serves it. One that turns it away is asked without it', ultra: "Ultrafast", ownUltra: 'Asked for service_tier "ultrafast" whatever the agent asks, where your provider serves it. One that turns it away is asked without it. Click to send it at the usual speed' }, - zh: { edit: "编辑", save: "保存", fast: "快速", std: "标准速度", label: "gpt-6.1-sol · high 推理强度 · 快速", remove: "移除", + zh: { edit: "编辑", save: "保存", fast: "快速", std: "标准速度", label: "gpt-6.1-sol · high 推理强度 · 快速", ultraLabel: "gpt-6.2-sol · 极速", codexLabel: "gpt-6-astra · 极速", remove: "移除", ownOff: '按代理的请求发送;点击向你的服务商请求 OpenAI 的快速模式(service_tier "priority")', ownOn: '无论代理怎么请求,都向服务商请求 OpenAI 的快速模式(service_tier "priority"):服务商支持时更快,价格更高。服务商拒绝这个字段时,会去掉它再请求一次', ultra: "极速", ownUltra: '无论 Agent 要求什么,都向你的服务商请求极速(service_tier "ultrafast"),前提是它支持;不接受的会改为不带该字段重新请求。点一下改回标准速度' }, @@ -90,9 +98,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", page.on("pageerror", (e) => errors.push(e.message)); await page.route("**/*", serve(lang, posts)); await page.goto("http://magpie.test/?view=groups"); - const card = page.locator(".rt-group", { hasText: "Sol" }); + const card = page.locator('.rt-group[data-id="sol"]'); await card.waitFor(); assert((await card.locator(".mem").textContent()).includes(w.label), "the card says the member is sent fast"); + const ultraCard = (await page.locator('.rt-group[data-id="astra"]').locator(".mem").textContent()); + assert(ultraCard.includes(w.ultraLabel), `the card says the member is sent Ultrafast: ${ultraCard}`); + assert(ultraCard.includes(w.codexLabel) && !ultraCard.includes(`gpt-6-astra · ${w.label.split(" · ").pop()}`), `the card says #6881's Codex member is sent Ultrafast: ${ultraCard}`); await card.locator("button", { hasText: w.edit }).click(); const ed = page.locator(".rt-gedit"); @@ -161,7 +172,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.deepEqual(sent.body.ultra, ["rl/gpt-6.2-sol"]); const missing = await page.evaluate(() => [ - "fast", "Fast", "Standard speed", "Sent in its vendor's fast mode, as the group says", + "fast", "Fast", "Ultrafast", "Standard speed", "Sent in its vendor's fast mode, as the group says", + "Sent Ultrafast where the account offers it, as the group says", "Sent in its vendor's fast mode whatever the agent asks: quicker, at a higher price", "Sent at its vendor's usual speed; click to send it in fast mode", 'Asked for OpenAI\'s fast mode (service_tier "priority") whatever the agent asks: quicker, at a higher price, where your provider serves it. One that turns it away is asked without it', diff --git a/internal/gui/tests/routing-ultra-row.test.cjs b/internal/gui/tests/routing-ultra-row.test.cjs new file mode 100644 index 000000000..10846d1fa --- /dev/null +++ b/internal/gui/tests/routing-ultra-row.test.cjs @@ -0,0 +1,78 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// The Routing page's diagram tags an account a group sends in its +// vendor's fast mode: "fast", and "Ultrafast" where the group sends it +// Ultrafast and the account offers it (the trace's Weighed.Ultra). +// paul-tian's #7095: a Codex account sent ultrafast through a group was +// tagged Fast in the diagram while its request row said Ultrafast. +// Chromium and WebKit, in every language, the API faked. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); + +const assets = path.resolve(__dirname, "../assets"); +const now = new Date(); +const seat = (agent, ultra) => ({ id: `codex/${agent}`, provider: "codex", name: "Codex", who: `${agent}@example.com`, kind: "account", agent: "codex", model: "gpt-6.2-astra", routing: "order", fast: true, ...(ultra ? { ultra: true } : {}) }); +// one agent's request sent Ultrafast, another's fast alone +const routes = [["codex", true], ["opencode", false]].map(([agent, ultra], i) => ({ + id: 100 - i, seq: 100 - i, time: new Date(now.getTime() - 1000).toISOString(), agent, model: "group/astra", provider: "codex", tier: ultra ? "ultrafast" : "priority", + order: [seat(agent, ultra)], done: true, status: 200, ms: 500, ttft: 200, tokens: 100, + tries: [{ id: `codex/${agent}`, model: "gpt-6.2-astra", start: new Date(now.getTime() - 1000).toISOString(), done: true, status: 200, ms: 500, fast: true, tier: ultra ? "ultrafast" : "priority" }], +})); + +const W = { + en: { fast: "fast", ultra: "Ultrafast", g: "Sent in its vendor's fast mode, as the group says", u: "Sent Ultrafast where the account offers it, as the group says" }, + zh: { fast: "快速", ultra: "极速", g: "按分组设置,以服务商的快速模式发送", u: "按分组设置,账号支持极速就以极速发送" }, + "zh-TW": { fast: "快速", ultra: "極速", g: "按分組設定,以服務商的快速模式傳送", u: "按分組設定,帳號支援極速就以極速傳送" }, + ja: { fast: "高速", ultra: "超高速", g: "グループの設定どおり、ベンダーの高速モードで送ります", u: "グループの設定どおり、アカウントが対応していれば超高速で送ります" }, + de: { fast: "schnell", ultra: "Ultrafast", g: "Im Schnellmodus des Anbieters gesendet, gemäß Gruppe", u: "Ultrafast gesendet, wo das Konto es bietet, gemäß Gruppe" }, +}; + +function serve(lang) { + const state = { agents: [{ id: "codex", name: "Codex", path: "/test/config.toml", fields: [] }, { id: "opencode", name: "OpenCode", path: "/test/opencode.json", fields: [] }], profiles: [], settings: { lang, theme: "light" } }; + return async (route) => { + const url = new URL(route.request().url()); + const json = (data) => route.fulfill({ json: data }); + if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` }); + if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); + if (url.pathname === "/api/state") return json(state); + if (url.pathname === "/api/gateway/trace") { + if (url.searchParams.get("wait")) await new Promise((r) => setTimeout(r, 20e3)); + return json({ mine: true, now: now.toISOString(), seq: 100, totals: { requests: routes.length, rerouted: 0, errors: 0 }, routes }); + } + if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] }); + if (url.pathname === "/api/groups") return json({ groups: [] }); + if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } }); + if (url.pathname.startsWith("/api/")) return json({}); + const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); + const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)]; + await route.fulfill({ body: await fs.readFile(file), contentType }); + }; +} + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + for (const lang of Object.keys(W)) { + test(`${engine} ${lang}: the diagram tags an account sent Ultrafast as Ultrafast`, async (t) => { + const w = W[lang]; + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + t.after(() => browser.close()); + const page = await (await browser.newContext({ viewport: { width: 1000, height: 900 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + const errors = []; + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", serve(lang)); + await page.goto("http://magpie.test/?view=routing"); + await page.locator("li > b small.fb").nth(1).waitFor(); + const tags = (await page.locator("li > b").evaluateAll((bs) => bs.map((b) => { + const f = b.querySelector("small.fb"); + return f && { who: b.textContent, text: f.textContent.trim(), title: f.title }; + }))).filter(Boolean); + const of = (agent) => tags.find((x) => x.who.includes(`${agent}@example.com`)); + assert.deepEqual(of("codex") && [of("codex").text, of("codex").title], [w.ultra, w.u], JSON.stringify(tags)); + assert.deepEqual(of("opencode") && [of("opencode").text, of("opencode").title], [w.fast, w.g], JSON.stringify(tags)); + assert.deepEqual(errors, []); + }); + } +} diff --git a/internal/tui/group_member_ultra_test.go b/internal/tui/group_member_ultra_test.go new file mode 100644 index 000000000..d2c8d64a3 --- /dev/null +++ b/internal/tui/group_member_ultra_test.go @@ -0,0 +1,57 @@ +package tui + +import ( + "strings" + "testing" + + "github.com/yetone/magpie/internal/provider" +) + +// paul-tian's #6881: the routing group list said Fast for a member whose +// speed is set Ultrafast, while the group's editor said Ultrafast. The +// group view's member line says Ultrafast too: the tier is saved on the +// group (Group.Ultra), and a line that reads Fast alone mislabels it. +// ggbdpq's test, from the patch posted on #6881. +func TestGroupMemberUltraShown(t *testing.T) { + h := home(t) + fakeCodex(t, h) + // the group of the report: a Codex GPT-6-Astra member set Ultrafast + if err := provider.Save(provider.Provider{ID: "codex", Models: []string{"gpt-6-astra"}}); err != nil { + t.Fatal(err) + } + id := "codex/gpt-6-astra" + if err := provider.SaveGroup(provider.Group{ID: "gpt-6-astra-ultrafast", Name: "GPT-6-Astra-Ultrafast", Members: []string{id}, Fast: []string{id}, Ultra: []string{id}}); err != nil { + t.Fatal(err) + } + m := press(t, model{w: 120, h: 40}, "3", "enter") + if m.mode != modeGroup || m.gsel != 0 { + t.Fatalf("mode %d, picked %d", m.mode, m.gsel) + } + v := m.View() + if !strings.Contains(v, "· Ultrafast") { + t.Fatalf("the member set Ultrafast is not shown as Ultrafast:\n%s", v) + } + if strings.Contains(v, "· fast") { + t.Fatalf("the member set Ultrafast is shown as fast:\n%s", v) + } +} + +// A member set fast alone keeps the fast word: Ultrafast takes its place +// only on one the group sends Ultrafast (Group.Ultra is a part of Fast). +func TestGroupMemberFastStillShown(t *testing.T) { + home(t) + if err := provider.Save(provider.Provider{ID: "an", Name: "Anthropic", Key: "k", Anthropic: "https://api.anthropic.com", Models: []string{"claude-opus-5-5"}}); err != nil { + t.Fatal(err) + } + id := "an/claude-opus-5-5" + if err := provider.SaveGroup(provider.Group{ID: "opus", Name: "Opus", Members: []string{id}, Fast: []string{id}}); err != nil { + t.Fatal(err) + } + m := press(t, model{w: 120, h: 40}, "3", "enter") + if m.mode != modeGroup || m.gsel != 0 { + t.Fatalf("mode %d, picked %d", m.mode, m.gsel) + } + if v := m.View(); !strings.Contains(v, "· fast") || strings.Contains(v, "· Ultrafast") { + t.Fatalf("the member set fast is not shown as fast:\n%s", v) + } +} diff --git a/internal/tui/groupfast_test.go b/internal/tui/groupfast_test.go index 92d383ee1..fea3d9195 100644 --- a/internal/tui/groupfast_test.go +++ b/internal/tui/groupfast_test.go @@ -89,3 +89,24 @@ func TestGroupTakeOutKeepsARulesOtherModels(t *testing.T) { t.Fatalf("members %v rules %+v", g.Members, g.Rules) } } + +// A member sent Ultrafast reads "· Ultrafast" in the group's list, not +// "· fast", as the CLI and the GUI say it (OoopsHh on X). +func TestGroupMemberUltrafastShown(t *testing.T) { + home(t) + if err := provider.Save(provider.Provider{ID: "oa", Name: "OpenAI", Key: "k", Responses: "https://api.openai.com/v1", Models: []string{"gpt-6.2-sol", "gpt-6.1-sol"}}); err != nil { + t.Fatal(err) + } + if err := provider.SaveGroup(provider.Group{ID: "sol", Name: "Sol", Members: []string{"oa/gpt-6.2-sol", "oa/gpt-6.1-sol"}, + Fast: []string{"oa/gpt-6.2-sol", "oa/gpt-6.1-sol"}, Ultra: []string{"oa/gpt-6.2-sol"}}); err != nil { + t.Fatal(err) + } + m := press(t, model{w: 120, h: 40}, "3", "enter") + v := m.View() + if !strings.Contains(v, "gpt-6.2-sol · Ultrafast") || strings.Contains(v, "gpt-6.2-sol · fast") { + t.Fatalf("Ultrafast not shown:\n%s", v) + } + if !strings.Contains(v, "gpt-6.1-sol · fast") { + t.Fatalf("fast not shown:\n%s", v) + } +} diff --git a/internal/tui/i18n.go b/internal/tui/i18n.go index a5be7cd7f..941f7de75 100644 --- a/internal/tui/i18n.go +++ b/internal/tui/i18n.go @@ -333,6 +333,7 @@ var zh = map[string]string{ "found by magpie: a change makes it yours": "由 magpie 发现:修改后归你所有", "models · the first that can take a request gets it": "模型 · 由第一个能接受请求的模型处理", "fast": "快速", + "Ultrafast": "极速", "by pattern": "按模式匹配", "switched off: skipped until it is on again": "已关闭:开启前会被跳过", "patterns · every model they match now, after those named": "模式 · 在列出的模型之后,当前匹配到的所有模型", diff --git a/internal/tui/routing.go b/internal/tui/routing.go index 233f5ccfe..db101d216 100644 --- a/internal/tui/routing.go +++ b/internal/tui/routing.go @@ -706,7 +706,11 @@ func (m model) viewGroup() string { if i == m.gsel { marker, name = sCursor.Render("▸ "), sNameOn.Render(id) } - if g.IsFast(id) { + if g.IsUltra(id) { + // Ultrafast where an account offers it, as the CLI and the + // GUI's list say it (OoopsHh on X) + name += sMuted.Render(" · " + tr("Ultrafast")) + } else if g.IsFast(id) { name += sMuted.Render(" · " + tr("fast")) } if slices.Contains(g.Matched, id) {