isymbo's ChatGPT account ran out for the week, they set Codex's sign-in to
magpie API and picked DeepSeek, and the Codex app still showed "Codex 和
工作使用额度已用完" and sent nothing. The Agents row said "重开 Codex
后,/model 中既有它自己的模型,也有 magpie 的模型": the ChatGPT state
they had just left.
The config was right (model_provider = "magpie", magpie's catalog), but
the codex.joined mark from an earlier Join stayed, and Joined() read it
whenever openai_base_url was magpie's, which it also is with magpie as the
provider. Joined is now false while magpie is Codex's provider; the mark
itself stays, so Sync still puts Codex back beside the sign-in once the
account has room (codex.out), as before.
Why the app blocks: ChatGPT.app 26.1007.21159's two composer gates (FN in
app-primary and Cui/kui's hardBlocked in app-initial) both require the
app-server's getAuthStatus authMethod to be "chatgpt" and
rate_limit.allowed false. With magpie as the provider the app-server
reports no ChatGPT auth, so neither gate applies, but the app reads it
from the app-server it started with: it has to be quit and reopened. The
row now says "Reopen Codex, then pick any model in /model". Asked the
reporter to restart and, if it still blocks, for versions and config.
Test: TestCodexProviderIsNotJoined joins, picks a magpie model, sets
magpie API (provider, not joined, still wired), back to ChatGPT (joined),
held by the app (provider, not joined), room again (joined). Red with
Joined: joined ("magpie API: joined true").
Run, both commits together on 5618ade1e: gofmt -l clean; go vet ./...
for GOOS=darwin and windows clean, GOOS=linux clean on the 68 packages
that don't import Wails (the root, internal/cli and internal/gui need
cgo for Linux, which a Mac cross-vet can't do); set -o pipefail; go test
-p 4 -timeout 40m ./... green (rc 0).
63 lines
2.1 KiB
Go
63 lines
2.1 KiB
Go
package agent
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// isymbo (#2267): Codex joined beside its ChatGPT sign-in, a magpie model
|
|
// picked, then magpie API chosen. The config had magpie as Codex's
|
|
// provider, but the joined mark stayed, so the Agents row still said
|
|
// Codex's own models stay in /model beside magpie's: the ChatGPT state
|
|
// the user had just left, which is the one the Codex app blocks sending
|
|
// in while the account is out. Joined is false while magpie is Codex's
|
|
// provider, and true again once it is back beside the sign-in.
|
|
func TestCodexProviderIsNotJoined(t *testing.T) {
|
|
home, read := codexHome(t, `{"tokens":{"access_token":"x","id_token":"x.e30.x"}}`, `model = "gpt-5.5"`+"\n")
|
|
cx := codex(home)
|
|
if ok, err := cx.Join(); err != nil || !ok || !cx.Joined() {
|
|
t.Fatalf("join: %v %v, joined %v", ok, err, cx.Joined())
|
|
}
|
|
if err := cx.Fields[0].Set("fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !cx.Joined() || !cx.Beside() {
|
|
t.Fatalf("a magpie model beside the sign-in: joined %v, beside %v", cx.Joined(), cx.Beside())
|
|
}
|
|
if err := cx.Field("login").Set("api"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg := read(); !strings.Contains(cfg, `model_provider = "magpie"`) {
|
|
t.Fatalf("api:\n%s", cfg)
|
|
}
|
|
if cx.Joined() || cx.Beside() {
|
|
t.Fatalf("magpie API: joined %v, beside %v", cx.Joined(), cx.Beside())
|
|
}
|
|
if !cx.Wired() {
|
|
t.Fatal("magpie API: not wired")
|
|
}
|
|
|
|
// the ChatGPT account held by the Codex app: magpie its provider too
|
|
if err := cx.Field("login").Set(""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !cx.Joined() {
|
|
t.Fatal("back beside the sign-in: not joined")
|
|
}
|
|
codexUsedUp = func() bool { return true }
|
|
t.Cleanup(func() { codexUsedUp = func() bool { return false } })
|
|
if err := cx.Sync(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg := read(); !strings.Contains(cfg, `model_provider = "magpie"`) || cx.Joined() {
|
|
t.Fatalf("held: joined %v\n%s", cx.Joined(), cfg)
|
|
}
|
|
codexUsedUp = func() bool { return false }
|
|
if err := cx.Sync(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg := read(); strings.Contains(cfg, "model_provider =") || !cx.Joined() {
|
|
t.Fatalf("room again: joined %v\n%s", cx.Joined(), cfg)
|
|
}
|
|
}
|