ysm119 (Discord) ticked four models on the Codex subscription and Codex's picker offered three. GPT-6.1 Terra is "visibility": "hide" in Codex's models_cache.json, so catalog.Codex() leaves it out of Codex's own list, and viaMagpieFor dropped every codex/… entry as only a hop, so it was offered nowhere. codexViaMagpieFor now drops a codex/… entry only when Codex's own list already has its model; the rest stay, via magpie. Both pickers (live Codex and Codex in WSL) take it; viaMagpieFor had no other caller and is gone. Run: TestCodexHiddenTickedModelOffered is red with the codex/… entries dropped as before ([OpenAI:gpt-a]) and green with the fix; go test ./internal/agent -run 'Codex|WSL|Wsl|Via|Magpie' ok; go vet darwin and GOOS=windows; gofmt clean. Not tried: picking gpt-6.1-terra with a real ChatGPT account.
48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package agent
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// A model Codex hides from its own picker (gpt-6.1-terra) but the user
|
|
// ticked on the Codex subscription is still offered in Codex's picker,
|
|
// via magpie, while one Codex lists is offered once, as Codex's own
|
|
// (ysm119 on Discord: 4 ticked, 3 to pick from).
|
|
func TestCodexHiddenTickedModelOffered(t *testing.T) {
|
|
claims := func(m map[string]any) string {
|
|
b, _ := json.Marshal(m)
|
|
return "h." + base64.RawURLEncoding.EncodeToString(b) + ".s"
|
|
}
|
|
me, _ := json.Marshal(map[string]any{"auth_mode": "chatgpt", "tokens": map[string]any{
|
|
"id_token": claims(map[string]any{"email": "me@example.com"}),
|
|
"access_token": claims(map[string]any{"exp": time.Now().Add(time.Hour).Unix()}),
|
|
"refresh_token": "r", "account_id": "acct-1"}})
|
|
home, _ := codexHome(t, string(me), "model = \"gpt-a\"\n")
|
|
os.WriteFile(filepath.Join(home, ".codex", "models_cache.json"), []byte(`{"models":[
|
|
{"slug":"gpt-a","display_name":"A","priority":1},
|
|
{"slug":"gpt-h","display_name":"H","priority":2,"visibility":"hide"}]}`), 0o644)
|
|
if err := provider.Save(provider.Provider{ID: "codex", Models: []string{"gpt-a", "gpt-h"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
seen := map[string]int{}
|
|
var all []string
|
|
for _, o := range codex(home).Fields[0].Options(nil) {
|
|
all = append(all, o.Group+":"+o.Value)
|
|
m := o.Value
|
|
if own := codexOwnOf(o.Value); own != "" {
|
|
m = own
|
|
}
|
|
seen[m]++
|
|
}
|
|
if seen["gpt-h"] != 1 || seen["gpt-a"] != 1 {
|
|
t.Fatalf("want gpt-a and gpt-h once each: %v", all)
|
|
}
|
|
}
|