Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
agent: a stopped WSL distro's files are never opened, which started it again (#3896)
yetonee54a7d50b948
diff --git a/internal/agent/dsh.go b/internal/agent/dsh.goindex 538dc2097..0e775c291 100644--- a/internal/agent/dsh.go+++ b/internal/agent/dsh.go@@ -96,7 +96,12 @@ func dshAt(at place) *Agent {// DeepSeek Harness Desktop, on this machine (a distro has none)desktop := func() bool { return at.spell == nil && (&Agent{ID: "dsh"}).HasApp() }path := filepath.Join(dir, "config.yaml")- if files := dshProfiles(dir); len(files) > 0 {+ // a stopped distro's folder is never listed: that starts it (#3896)+ var files []string+ if !at.cold {+ files = dshProfiles(dir)+ }+ if len(files) > 0 {path = files[0]} else if desktop() {path = dshDesktopFile(dir)diff --git a/internal/agent/grok.go b/internal/agent/grok.goindex f611edb93..9585c21f3 100644--- a/internal/agent/grok.go+++ b/internal/agent/grok.go@@ -257,34 +257,39 @@ func grokOwnOptions(dir, path, cur string) []Option {}out = append(out, o)}- if raw, err := os.ReadFile(filepath.Join(dir, "models_cache.json")); err == nil {- gjson.GetBytes(raw, "models").ForEach(func(k, v gjson.Result) bool {- if !v.Get("info.hidden").Bool() {- add(k.String(), v.Get("info.name").String(), "xAI")- }- return true- })+ // dir and path empty: a stopped distro's, whose files aren't read (#3896)+ if dir != "" {+ if raw, err := os.ReadFile(filepath.Join(dir, "models_cache.json")); err == nil {+ gjson.GetBytes(raw, "models").ForEach(func(k, v gjson.Result) bool {+ if !v.Get("info.hidden").Bool() {+ add(k.String(), v.Get("info.name").String(), "xAI")+ }+ return true+ })+ }}ms, _, _ := catalog.Live("grok")for _, m := range ms {add(m.ID, "", "xAI")}// the user's own [model."<id>"] tables, each on its own endpoint- if tables, err := edit.TOMLTables(path); err == nil {- for _, t := range tables {- id, ok := strings.CutPrefix(t, "model.")- if !ok {- continue- }- if u, err := strconv.Unquote(id); err == nil {- id = u- }- kv, _ := edit.GetTOMLTable(path, t)- direct := "xAI"- if h := hostOf(kv["base_url"]); h != "" {- direct = h+ if path != "" {+ if tables, err := edit.TOMLTables(path); err == nil {+ for _, t := range tables {+ id, ok := strings.CutPrefix(t, "model.")+ if !ok {+ continue+ }+ if u, err := strconv.Unquote(id); err == nil {+ id = u+ }+ kv, _ := edit.GetTOMLTable(path, t)+ direct := "xAI"+ if h := hostOf(kv["base_url"]); h != "" {+ direct = h+ }+ add(id, kv["name"], direct)}- add(id, kv["name"], direct)}}if cur != "" && !seen[cur] && !strings.HasPrefix(cur, magpieID+"/") {diff --git a/internal/agent/hermes.go b/internal/agent/hermes.goindex 54e82941b..43749d53a 100644--- a/internal/agent/hermes.go+++ b/internal/agent/hermes.go@@ -299,6 +299,10 @@ func hermesActive(at place) string {if at.getenv("HERMES_HOME") != "" && filepath.Base(filepath.Dir(home)) == "profiles" {return home}+ // a stopped distro's file is never opened: that starts it (#3896)+ if at.cold {+ return home+ }root := hermesRoot(at)b, err := os.ReadFile(filepath.Join(root, "active_profile"))if err != nil {diff --git a/internal/agent/wsl.go b/internal/agent/wsl.goindex 28d6f5c74..e79c13833 100644--- a/internal/agent/wsl.go+++ b/internal/agent/wsl.go@@ -291,7 +291,7 @@ var wslKinds = []wslKind{restart: newNotice("{agent} in WSL {distro} builds its model list at start-up — restart it, the app-server its sessions share ({command} there) and the Codex app's WSL connection to see this."),asleep: func(key string) func(map[string]string) []Option {switch key {- case "model", "subagent":+ case "model", "subagent", "memories":return func(map[string]string) []Option {// over several accounts magpie routes, so they are// offered via magpie too, as on a live Codex (#1603)@@ -305,6 +305,17 @@ var wslKinds = []wslKind{return func(cur map[string]string) []Option {return codexEfforts(append(catalog.Codex(), magpieModels("codex")...), cur["model"])}+ case "subagent_effort":+ return func(cur map[string]string) []Option {+ m := cur["subagent"]+ if m == "" {+ m = cur["model"]+ }+ if e := catalog.Efforts(append(catalog.Codex(), magpieModels("codex")...), m); len(e) > 0 {+ return static(e...)+ }+ return static("low", "medium", "high", "xhigh")+ }}return nil}},@@ -425,7 +436,20 @@ var wslKinds = []wslKind{restart: newNotice("{agent} in WSL {distro} uses this for new tasks in its Console — restart open morph chats to use it there.")},// no bin: grok is also other tools' name, as on this machine{id: "grok", name: "Grok Build", dir: ".grok", in: grokIn,- restart: newNotice("{agent} in WSL {distro} reads its settings at start-up — restart open grok sessions to use this.")},+ restart: newNotice("{agent} in WSL {distro} reads its settings at start-up — restart open grok sessions to use this."),+ asleep: func(key string) func(map[string]string) []Option {+ if key != "model" {+ return nil+ }+ // its models_cache.json and config.toml are the distro's files+ return func(cur map[string]string) []Option {+ opts := viaMagpie("grok", magpieID+"/")+ for i := range opts {+ opts[i].Same = opts[i].own+ }+ return append(grokOwnOptions("", "", cur["model"]), opts...)+ }+ }},{id: "droid", name: "Droid", dir: ".factory", bin: "droid", in: droidIn,restart: newNotice("{agent} in WSL {distro} reads its settings at start-up — restart open droid sessions to use this."),asleep: func(key string) func(map[string]string) []Option {@@ -460,6 +484,15 @@ var wslKinds = []wslKind{asleep: func(key string) func(map[string]string) []Option {// the thinking levels hang on which patch lists there are, the// distro's files: a dsh of today's (0.1.5 on) is taken+ if key == "model" {+ return func(map[string]string) []Option {+ own := append([]Option{}, dshModels...)+ for i := range own {+ own[i].Direct = "DeepSeek"+ }+ return append(own, viaMagpie("dsh", magpieID+"/")...)+ }+ }if key != "effort" {return nil}@@ -856,10 +889,12 @@ func wslAgents() []*Agent {func wslAgentsOf(ds []distro) []*Agent {var out []*Agentfor _, d := range ds {- // only the agents it has: magpie writes nothing for one that isn't there+ // only the agents it has: magpie writes nothing for one that isn't+ // there, and doesn't make it, which reads its files: a stopped+ // distro's files opened start it again (#3896)for _, k := range wslKinds {- if a := wslAgent(k, d); a.Detected() {- out = append(out, a)+ if k.found(d) {+ out = append(out, wslAgent(k, d))}}// the named omp profiles the probe remembered: the row is madediff --git a/internal/agent/wsl_cold_test.go b/internal/agent/wsl_cold_test.gonew file mode 100644index 000000000..86e49209a--- /dev/null+++ b/internal/agent/wsl_cold_test.go@@ -0,0 +1,72 @@+package agent++import (+ "os"+ "os/exec"+ "path/filepath"+ "strings"+ "testing"+)++// #3896: an agent made for a stopped distro opens none of its files, as+// opening one starts the distro again; the user stopped it, and magpie+// started it every few seconds while its window was up. Every kind is made+// at a cold place in a child run, whose -test.testlogfile lists each file+// the os package was asked to stat or open.+func TestWSLColdPlaceOpensNothing(t *testing.T) {+ if root := os.Getenv("MAGPIE_TEST_COLD_ROOT"); root != "" {+ for _, k := range wslKinds {+ d := distro{Name: "Stopped", Root: root, Home: "/home/me", Has: map[string]bool{"dir:." + k.id: true}}+ k.in(d.place(k.id + "@wsl:Stopped"))+ // and what the window asks of its row+ a := wslAgent(k, d)+ a.Values()+ a.Notice()+ a.Drift()+ a.Wired()+ for _, f := range a.Fields {+ if f.Options != nil {+ f.Options(a.Values())+ }+ }+ }+ return+ }+ root := t.TempDir()+ home := filepath.Join(root, "home", "me")+ // what each kind would read were it looking: Hermes's sticky profile+ // and dsh's profiles among them+ for _, f := range []string{".hermes/active_profile", ".hermes/profiles/work/config.yaml",+ ".dsh/profiles/web/cordis.patch.yml", ".claude/settings.json", ".codex/config.toml",+ ".config/opencode/opencode.json", ".kimi-code/config.toml", ".omp/agent/config.yml"} {+ p := filepath.Join(home, filepath.FromSlash(f))+ os.MkdirAll(filepath.Dir(p), 0o755)+ body := "{}"+ if strings.HasSuffix(f, "active_profile") {+ body = "work\n"+ }+ os.WriteFile(p, []byte(body), 0o644)+ }+ log := filepath.Join(t.TempDir(), "testlog")+ cmd := exec.Command(os.Args[0], "-test.run=^TestWSLColdPlaceOpensNothing$", "-test.testlogfile="+log)+ cmd.Env = append(os.Environ(), "MAGPIE_TEST_COLD_ROOT="+root)+ if out, err := cmd.CombinedOutput(); err != nil {+ t.Fatalf("%v\n%s", err, out)+ }+ b, err := os.ReadFile(log)+ if err != nil {+ t.Fatal(err)+ }+ var opened []string+ for _, line := range strings.Split(string(b), "\n") {+ if strings.Contains(line, root) {+ opened = append(opened, line)+ }+ }+ if len(opened) > 0 {+ t.Fatalf("a stopped distro's files were looked at:\n%s", strings.Join(opened, "\n"))+ }+ if !strings.Contains(string(b), "\nopen ") && !strings.Contains(string(b), "\nstat ") {+ t.Fatalf("the log records nothing, so it shows nothing:\n%.500s", b)+ }+}