diff --git a/internal/gateway/desktop.go b/internal/gateway/desktop.go index 7cf7eb7b1..5bd7d5c8a 100644 --- a/internal/gateway/desktop.go +++ b/internal/gateway/desktop.go @@ -59,19 +59,22 @@ func desktopAccepts(id string) bool { // it (its app.asar has neither mythos nor fable), so every reasoning-level // model listed by mythos-magpie- vanished from its menu // (sublatesublate-design). The version a User-Agent names ("Mozilla/5.0 … -// Claude/2.7032.0 Chrome/…") is the only word magpie gets of the build: 2 -// and up take mythos, anything older — or a version magpie cannot read — -// does not, and falls back to the plain alias every build keeps (no effort -// picker there, and those builds have no mythos effort table either). +// Claude/2.7032.0 Chrome/…") is the only word magpie gets of the build: one +// that says a version below 2 falls back to the plain alias every build +// keeps (no effort picker there, and those builds have no mythos effort +// table either). Anything else keeps the picker alias: 2 and up, and a +// request that names no build at all, as the Code tab's Claude Code +// ("claude-cli/… (external, claude-desktop)", known by its key) whose +// ids are mythos-magpie- already. var desktopUAVersion = regexp.MustCompile(` Claude/(\d+)`) func desktopKnowsMythos(ua string) bool { m := desktopUAVersion.FindStringSubmatch(ua) if m == nil { - return false + return true } n, err := strconv.Atoi(m[1]) - return err == nil && n >= 2 + return err != nil || n >= 2 } // desktopAlias is the prefix of the id a model is listed by to Claude diff --git a/internal/gateway/desktop_models_test.go b/internal/gateway/desktop_models_test.go index a00ac7c01..2e756e774 100644 --- a/internal/gateway/desktop_models_test.go +++ b/internal/gateway/desktop_models_test.go @@ -241,7 +241,7 @@ func TestClaudeDesktopOldBuildModels(t *testing.T) { const oldUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Claude/1.6608.2 Chrome/140.0.0.0 Electron/37.2.0 Safari/537.36" // the old build keeps every model it is shown - for _, ua := range []string{oldUA, ""} { + for _, ua := range []string{oldUA} { for catalog, id := range list(ua) { if !oldBuildKeeps(id) { t.Errorf("User-Agent %q: %s is listed as %s, which the build drops", ua, catalog, id) @@ -249,15 +249,18 @@ func TestClaudeDesktopOldBuildModels(t *testing.T) { } } - // a 2.x build is still offered the effort picker - ids := list("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Claude/2.7032.0 Chrome/140.0.0.0 Electron/37.2.0 Safari/537.36") - if id := ids["opencode-go/deepseek-v4.1-flash"]; !regexp.MustCompile(`^mythos-magpie-\d{10}$`).MatchString(id) { - t.Errorf("2.7032.0: deepseek-v4.1-flash is listed as %q, want the mythos picker alias", id) + // a 2.x build is still offered the effort picker, and so is a request + // that names no build (the Code tab's Claude Code, known by its key) + for _, ua := range []string{"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Claude/2.7032.0 Chrome/140.0.0.0 Electron/37.2.0 Safari/537.36", "claude-cli/2.1.295 (external, claude-desktop)", ""} { + if id := list(ua)["opencode-go/deepseek-v4.1-flash"]; !regexp.MustCompile(`^mythos-magpie-\d{10}$`).MatchString(id) { + t.Errorf("User-Agent %q: deepseek-v4.1-flash is listed as %q, want the mythos picker alias", ua, id) + } } } // desktopKnowsMythos, by the version a User-Agent names: 2.x takes the -// mythos effort alias, anything older or unreadable does not. +// mythos effort alias, an older one does not, and a request naming no +// build is listed as before. func TestDesktopKnowsMythos(t *testing.T) { for _, c := range []struct { ua string @@ -267,8 +270,11 @@ func TestDesktopKnowsMythos(t *testing.T) { {"Mozilla/5.0 … Claude/2 Chrome/…", true}, {"Mozilla/5.0 … Claude/1.6608.2 Chrome/… Safari/537.36", false}, {"Mozilla/5.0 … Claude/3.0.0 Chrome/… Safari/537.36", true}, - {"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", false}, - {"", false}, + // no build named (the Code tab's Claude Code, known by its key): + // listed as before, by the picker alias + {"claude-cli/2.1.295 (external, claude-desktop)", true}, + {"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", true}, + {"", true}, } { if got := desktopKnowsMythos(c.ua); got != c.want { t.Errorf("desktopKnowsMythos(%q) = %v, want %v", c.ua, got, c.want)