Kylin_Cloud (X, 11-06, v0.1.2606): DeepSeek Harness's direct models in magpie listed deepseek-v4-flash, which dsh doesn't have, and showed deepseek-flash as "DeepSeek-V41-Flash"; dsh's built-ins are only DeepSeek-V4.1-Flash and DeepSeek-V4-Pro. Cause: dshModels is a table copied by hand from dsh 0.1.5 (4091b9dfd), not generated from models.dev and not a label prettifier. dsh's own table is @deepseek-ai/dsh-llm-deepseek's DEFAULT_MODELS; packed from npm: 0.1.0-rc.8, 0.1.2-rc.1 deepseek-v4-flash, deepseek-v4-pro (+ vision-exp) 0.1.5-rc.3 deepseek-flash "DeepSeek-V41-Flash", v4-flash, v4-pro 0.1.6-alpha.2..0.2.0 deepseek-flash "DeepSeek-V41-Flash", deepseek-v4-pro 0.2.1-rc.5, 0.2.2-rc.1 deepseek-flash "DeepSeek-V4.1-Flash", deepseek-v4-pro The installed dsh here (0.2.1-rc.2) has the same two. So "V41" was dsh's own name from 0.1.5 to 0.2.0, kept after dsh renamed it, and deepseek-v4-flash left dsh in 0.1.6 while magpie kept offering it. No other code makes a label from "4.1": V41 is in dsh.go alone. Now dshModels is dsh's two, named as dsh 0.2.1 on names them. The WSL (stopped distro) picker reads the same table. A profile already starting on deepseek-v4-flash: magpie reads it as it is and doesn't rewrite settings.yaml or the patch list; it is no longer offered in the list. Since dsh 0.1.6 dsh itself refuses it (dsh-api-session-controller requireModel: "Select an available model before sending a message.", it checks listModels, i.e. DEFAULT_MODELS), so that start was already broken in dsh before this change; picking either model in magpie or in dsh fixes it. Siblings pinning the old three: internal/gui's TestAgentOwnModelsHidden (red under the full suite with the new table, now dsh's two) and the GUI fixture agent-models-own.test.cjs, which also had made-up labels. Run (mote, rebased on origin/mainf47390bf3): - TestDshOwnModelsAreDshs: red on the old table (lists deepseek-v4-flash, "DeepSeek-V41-Flash"), and red again with only the label fixed (still lists deepseek-v4-flash); green with the change. - go test ./internal/agent: ok. - node --test agent-models-own.test.cjs (chromium + webkit, en/zh/de/ja, narrow and wide): 16/16 ok. i18n-keys: "a plugin's words are its own" red, the same three words already filed (#5327, #5332, #5426, #5482), not touched by this change. - go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., GOOS=linux/windows go build: ok. gofmt -l: nothing. - go test -timeout 45m ./... (shared lock): every package ok but gui and provider. gui: TestAgentOwnModelsHidden (fixed above), and TestMainWindowCorners (#3949) and TestPanelHiddenByWailsMarksPageOutOfSight (#5322), both filed; provider: TestRenewLoginsKeepsClaudeReading (#5481, filed). After the fix go test ./internal/gui: only TestMainWindowCorners (#3949) red. Not tried: a real dsh session started on deepseek-v4-flash (the refusal above is read from dsh's source); dsh before 0.1.5 (it had no deepseek-flash; every dsh on npm since 0.1.6 has it); Windows/WSL run. At the pushed head (rebased onb020ae102, which touches gateway, provider and agent's Claude Desktop only): go vet ./internal/agent ./internal/gui, go test ./internal/agent -run Dsh and ./internal/gui -run TestAgentOwnModels: ok.
114 lines
3.5 KiB
Go
114 lines
3.5 KiB
Go
package gui
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"path/filepath"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/agent"
|
|
"github.com/yetone/magpie/internal/provider"
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// DeepSeek Harness's own DeepSeek models, beside magpie's in its picker,
|
|
// can be left out (MizuIro-H, #1642): the agent's model list has a switch
|
|
// for them, its pickers then offer magpie's alone, the model it is set to
|
|
// stays, and another agent's pickers are as they were.
|
|
func TestAgentOwnModelsHidden(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("USERPROFILE", home)
|
|
t.Setenv("DSH_HOME", "")
|
|
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
|
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
|
t.Setenv("CODEX_HOME", filepath.Join(home, ".codex"))
|
|
os.MkdirAll(filepath.Join(home, ".dsh"), 0o755)
|
|
if err := provider.Save(provider.Provider{ID: "relay", Name: "Relay", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"m1", "m2"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
mux := http.NewServeMux()
|
|
agentModelsAPI(mux)
|
|
call := func(method, body string) (out struct {
|
|
Own, OwnHidden bool
|
|
}) {
|
|
t.Helper()
|
|
w := httptest.NewRecorder()
|
|
mux.ServeHTTP(w, httptest.NewRequest(method, "/api/agent-models/dsh", strings.NewReader(body)))
|
|
if w.Code != 200 {
|
|
t.Fatalf("%s %d %s", method, w.Code, w.Body)
|
|
}
|
|
json.Unmarshal(w.Body.Bytes(), &out)
|
|
return out
|
|
}
|
|
dsh, err := agent.Find("dsh")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
values := func(a *agent.Agent, vals map[string]string) (own, magpie []string) {
|
|
for _, f := range agentFields(a, vals) {
|
|
if f.Key != "model" {
|
|
continue
|
|
}
|
|
for _, o := range f.Options {
|
|
if o.Ref != "" {
|
|
magpie = append(magpie, o.Value)
|
|
} else {
|
|
own = append(own, o.Value)
|
|
}
|
|
}
|
|
}
|
|
return own, magpie
|
|
}
|
|
all := []string{"deepseek-flash", "deepseek-v4-pro"}
|
|
|
|
if got := call("GET", ""); !got.Own || got.OwnHidden {
|
|
t.Fatalf("dsh's list: %+v, want its own models there and shown", got)
|
|
}
|
|
if own, magpie := values(dsh, map[string]string{}); !slices.Equal(own, all) || len(magpie) == 0 {
|
|
t.Fatalf("before: own %v, magpie's %v", own, magpie)
|
|
}
|
|
|
|
if got := call("POST", `{"ownHidden":true}`); !got.OwnHidden {
|
|
t.Fatalf("answered %+v", got)
|
|
}
|
|
if s := settings.Load().OwnModelsHidden; !slices.Equal(s, []string{"dsh"}) {
|
|
t.Fatalf("saved %v", s)
|
|
}
|
|
if got := call("GET", ""); !got.Own || !got.OwnHidden {
|
|
t.Fatalf("dsh's list after: %+v", got)
|
|
}
|
|
own, magpie := values(dsh, map[string]string{})
|
|
if len(own) != 0 || !slices.Contains(magpie, "magpie/relay/m1") {
|
|
t.Fatalf("hidden: own %v left, magpie's %v", own, magpie)
|
|
}
|
|
// the one it is set to stays, the others go
|
|
if own, _ := values(dsh, map[string]string{"model": "deepseek-v4-pro"}); !slices.Equal(own, []string{"deepseek-v4-pro"}) {
|
|
t.Fatalf("set to deepseek-v4-pro: own %v", own)
|
|
}
|
|
// another agent's pickers are as they were
|
|
if provider.OwnModelsHidden("codex") {
|
|
t.Fatal("codex hides its own too")
|
|
}
|
|
// the effort field, not a picker of magpie's models, keeps every level
|
|
for _, f := range agentFields(dsh, map[string]string{}) {
|
|
if f.Key == "effort" && len(f.Options) == 0 {
|
|
t.Fatal("effort lost its levels")
|
|
}
|
|
}
|
|
|
|
if got := call("POST", `{"ownHidden":false}`); got.OwnHidden {
|
|
t.Fatalf("answered %+v", got)
|
|
}
|
|
if own, _ := values(dsh, map[string]string{}); !slices.Equal(own, all) {
|
|
t.Fatalf("shown again: own %v", own)
|
|
}
|
|
if s := settings.Load().OwnModelsHidden; len(s) != 0 {
|
|
t.Fatalf("saved %v", s)
|
|
}
|
|
}
|