#834: after v0.1.931 Claude Code's row showed its current model and a full picker, but Grok Build and Antigravity CLI hadn't caught up and Codex's list had no "via magpie". Grok Build listed none of its own models unless a Grok subscription was signed in in magpie. Now it lists: - the models it last listed itself (models_cache.json, hidden ones left out, by their names); - those magpie listed for a Grok subscription; - the user's own [model."<id>"] tables. Each says "direct, not via magpie" (xAI, or the table's host). Antigravity CLI's own custom models say direct, to Anthropic, OpenAI or Google by their apiProvider. Codex's own models say "direct, not via magpie" (OpenAI, or the user's own provider) when not routed, and "via magpie" (Option.Via) while its base URL or its provider points at magpie's gateway. #842: under the Agents page's fold, a hidden agent's Show sat on its name's line, about 9px above the row's middle. It now stands in the row, level with the row's picker. A grip's dots, hover-only, were cut: their box was 5px wide with columns 3.5px apart, so the right column was half gone. This was most visible on the Usage page's cards beside the logo. The Agents, Providers and Usage grips' boxes now hold both columns whole: 6px, columns 3px apart, 1px further left. Checked in screenshots (dark theme, Qoder CN card). Tests: - TestOwnModelsSayTheirPath covers: - Codex not routed, routed by base URL, and on a provider of its own; - Grok's cache, hidden model and own table; - agy's custom model. - agent-own-path.test.cjs and fold-show-grip.test.cjs (WebKit, en and zh) fail on the old code: - no tag on Codex's routed own model; - Show 9px above the picker; - grip w 5 < its two columns. agent-start-pick, agent-grip, show-unset-agent, usage-arrange, usage-quota-head, click-scroll, provider-order, import-row, agent-layout, desktop-model-menu, agent-leave-magpie and usage-card-refresh pass on WebKit. go vet and the builds pass (darwin, GOOS=linux nogui, GOOS=windows). go test -tags nogui -count=1 ./... under a temp HOME passes; TestCloudflareDecideModelsTested failed once in the full run and passed on rerun, alone and in its package.
90 lines
3.3 KiB
Go
90 lines
3.3 KiB
Go
package agent
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// Every agent's own models say which way they go, as Claude Code's do
|
|
// (EZN7L2C3, #834: Codex 下拉选项中没有 via magpie; agy 和 grok 没有同步):
|
|
// Codex's go to OpenAI directly until it is routed through magpie, then
|
|
// via magpie; Grok Build lists the models it last listed itself, straight
|
|
// to xAI, and its own tables' to their endpoint; Antigravity CLI's own
|
|
// custom models go to their provider.
|
|
func TestOwnModelsSayTheirPath(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("USERPROFILE", home)
|
|
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
|
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
|
t.Setenv("CODEX_HOME", "")
|
|
t.Setenv("GROK_HOME", filepath.Join(home, "grok"))
|
|
|
|
// Codex
|
|
dir := filepath.Join(home, ".codex")
|
|
os.MkdirAll(dir, 0o755)
|
|
os.WriteFile(filepath.Join(dir, "models_cache.json"), []byte(`{"models":[{"slug":"gpt-a","display_name":"A","priority":1}]}`), 0o644)
|
|
os.WriteFile(filepath.Join(dir, "auth.json"), []byte(`{"tokens":{"access_token":"x","id_token":"x.e30.x"}}`), 0o600)
|
|
cfg := filepath.Join(dir, "config.toml")
|
|
ownOf := func(a *Agent, group string) []Option {
|
|
var out []Option
|
|
for _, o := range a.Field("model").Options(a.Values()) {
|
|
if o.Group == group {
|
|
out = append(out, o)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
own := ownOf(codex(home), "OpenAI")
|
|
if len(own) == 0 {
|
|
t.Fatal("Codex lists none of its own")
|
|
}
|
|
for _, o := range own {
|
|
if o.Direct != "OpenAI" || o.Via {
|
|
t.Errorf("not routed, %s goes straight to OpenAI: %+v", o.Value, o)
|
|
}
|
|
}
|
|
os.WriteFile(cfg, []byte(`openai_base_url = "`+codexGatewayURL()+`"`+"\n"), 0o644)
|
|
for _, o := range ownOf(codex(home), "OpenAI") {
|
|
if !o.Via || o.Direct != "" {
|
|
t.Errorf("routed, %s goes via magpie: %+v", o.Value, o)
|
|
}
|
|
}
|
|
os.WriteFile(cfg, []byte("model_provider = \"mine\"\n[model_providers.mine]\nbase_url = \"https://relay.example/v1\"\n"), 0o644)
|
|
for _, o := range ownOf(codex(home), "mine") {
|
|
if o.Direct != "mine" || o.Via {
|
|
t.Errorf("on a provider of its own, %s goes to it: %+v", o.Value, o)
|
|
}
|
|
}
|
|
|
|
// Grok Build, no Grok subscription in magpie
|
|
g := filepath.Join(home, "grok")
|
|
os.MkdirAll(g, 0o755)
|
|
os.WriteFile(filepath.Join(g, "models_cache.json"), []byte(`{"models":{
|
|
"grok-4.7":{"info":{"id":"grok-4.7","name":"Grok 4.7","hidden":false}},
|
|
"grok-old":{"info":{"id":"grok-old","name":"Old","hidden":true}}}}`), 0o644)
|
|
os.WriteFile(filepath.Join(g, "config.toml"), []byte("[model.\"my-own\"]\nmodel = \"x\"\nbase_url = \"https://x.example/v1\"\n"), 0o644)
|
|
got := map[string]Option{}
|
|
for _, o := range ownOf(grok(home), "Grok Build") {
|
|
got[o.Value] = o
|
|
}
|
|
if o := got["grok-4.7"]; o.Direct != "xAI" || o.Label != "Grok 4.7" {
|
|
t.Errorf("Grok's own listed model: %+v", o)
|
|
}
|
|
if _, ok := got["grok-old"]; ok {
|
|
t.Error("a hidden model listed")
|
|
}
|
|
if o := got["my-own"]; o.Direct != "x.example" {
|
|
t.Errorf("Grok's own table: %+v", o)
|
|
}
|
|
|
|
// Antigravity CLI
|
|
ag := filepath.Join(home, ".gemini", "antigravity-cli")
|
|
os.MkdirAll(ag, 0o755)
|
|
os.WriteFile(filepath.Join(ag, "settings.json"), []byte(`{"customModelsConfig":{"customModels":{"mine":{"apiProvider":"API_PROVIDER_ANTHROPIC","modelName":"claude-x"}}}}`), 0o644)
|
|
if o := ownOf(agy(home), "Antigravity CLI"); len(o) != 1 || o[0].Direct != "Anthropic" {
|
|
t.Errorf("agy's own: %+v", o)
|
|
}
|
|
}
|