After #2081 gave Desktop a subagent model, its effort still came from the request. Add subagent_effort beside that model, using the existing effort slider. The live setting DesktopSubagentEffort belongs to magpie; no Claude client file or binary is changed. Empty preserves the request's effort, including disabled thinking. A pick applies only to Desktop requests with an agent id and tools, independently of model replacement: unset, equal and unavailable model picks all work. Reuse the attempt-level fitting; fixed group-member efforts and reasonless models keep their existing precedence. count_tokens applies the pick after unmasked-body restoration. A Codex SubagentPick is not evidence of a Desktop tool turn. Route.Effort keeps the incoming level, SubagentEffort records the configured pick, and tries/usage keep the actual level. Routing explains the pick even without a model replacement. Options follow the target model; a saved level survives a model change. POST /api/settings preserves it. Disconnected preferences, Disconnect/reconnect and restored settings work; a Live pick gives restart advice only when it actually connects the agent. Codex's own settings and default-effort explanation are unchanged. Verification onb9c589ebplus this change, with temp HOME and pinned Go caches: - go test -tags nogui ./...: 53 packages pass. - Gateway effort tests under -race -count=20: pass. - gofmt -l: empty; darwin, linux nogui and windows vet/build: exit 0. - 23 intentional Go behavior breaks produce real FAILs, then pass restored: application, scope, model independence, Default/none, disabled thinking, fitting/member priority, counts, next request, trace, saving/validation, Live notices and model-dependent options. - Three UI breaks fail in both engines at 1100/420: default explanation, missing effort story and missing translation. Restored: Desktop's new controls/story matrix passes 20/20 across five languages. Desktop, Codex, tier/effort and translation regressions pass 97/97. - Desktop-bundled Claude Code 2.1.295 runs real Agent calls through the built gateway, temporary HOME and loopback-only sandbox, all replies local fixtures. Low/high/Default sends its child low/high/xhigh on m2; its lead remains xhigh on m1. All three runs exit 0. The expanded Routing run is not green: Chromium 510/525, WebKit 485/525. These failures reproduce on untouchedb9c589eb, including targeted reruns. The day/row anchor assertions conflict with #2134's at-top rule: undoing that one guard makes all 12 tests pass. A narrow request lies below the viewport; user wheel input makes the failed click pass. WorkBuddy's wheel pointer/hidden-button failures overlap #2115; moving the wheel to the view gutter fixes 3/4 selected cases, one WebKit 420 case remains. The held-member clipping assertion also reproduces on base; its timing cause is not established. This baseline evidence is reported separately in the follow-up feature issue, not counted as passed or fixed here. Not run: the complete GUI suite, the Electron window/Cowork, native Linux/Windows or WebKitGTK. Cross-builds are not runtime checks. Reported-by: Koohoko
102 lines
3.3 KiB
Go
102 lines
3.3 KiB
Go
package provider
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// desktopSubagentHome is a fresh home for magpie's files.
|
|
func desktopSubagentHome(t *testing.T) {
|
|
t.Helper()
|
|
isolate(t)
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
|
if err := Save(Provider{ID: "fake", Name: "Fake", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"m1"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// The model set for Desktop's subagents is kept trimmed, a bare name or a
|
|
// half id is refused, and "" clears it.
|
|
func TestDesktopSubagentModelRoundTrip(t *testing.T) {
|
|
desktopSubagentHome(t)
|
|
release := Hold()
|
|
defer release()
|
|
for _, id := range []string{" fake/m1 ", " group/workers ", "missing/m", ""} {
|
|
if err := SetDesktopSubagentModel(id); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := DesktopSubagentModel(); got != strings.TrimSpace(id) || got != settings.Load().DesktopSubagentModel {
|
|
t.Fatalf("model %q, stored %q, input %q", got, settings.Load().DesktopSubagentModel, id)
|
|
}
|
|
}
|
|
for _, id := range []string{"gpt-6", "/m", "p/"} {
|
|
if err := SetDesktopSubagentModel(id); err == nil {
|
|
t.Errorf("accepted invalid model %q", id)
|
|
}
|
|
if DesktopSubagentModel() != "" {
|
|
t.Error("invalid pick changed the model")
|
|
}
|
|
}
|
|
}
|
|
|
|
// A provider renamed after its model was set is read by its new id.
|
|
func TestDesktopSubagentModelRenamed(t *testing.T) {
|
|
desktopSubagentHome(t)
|
|
if err := SetDesktopSubagentModel("fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := Rename("fake", "renamed"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := DesktopSubagentModel(); got != "renamed/m1" {
|
|
t.Fatalf("model after rename %q, want renamed/m1", got)
|
|
}
|
|
if why := DesktopSubagentUnserved("fake/m1"); why != "" {
|
|
t.Fatalf("renamed model unserved: %s", why)
|
|
}
|
|
}
|
|
|
|
// Only a model or group magpie serves by that exact id is served: another
|
|
// model name under a provider that is on is not.
|
|
func TestDesktopSubagentUnserved(t *testing.T) {
|
|
desktopSubagentHome(t)
|
|
if err := SaveGroup(Group{ID: "workers", Name: "Workers", Members: []string{"fake/m1"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for id, want := range map[string]string{"fake/m1": "", "group/workers": "", "fake/missing": "magpie doesn't serve it now", "missing/m": "magpie doesn't serve it now"} {
|
|
if got := DesktopSubagentUnserved(id); got != want {
|
|
t.Errorf("%s: %q, want %q", id, got, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestDesktopSubagentEffortRoundTrip(t *testing.T) {
|
|
desktopSubagentHome(t)
|
|
release := Hold()
|
|
defer release()
|
|
for _, level := range append(append([]string{}, MemberEfforts...), " HIGH ", "") {
|
|
if err := SetDesktopSubagentEffort(level); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := DesktopSubagentEffort(); got != strings.ToLower(strings.TrimSpace(level)) {
|
|
t.Fatalf("effort %q, input %q", got, level)
|
|
}
|
|
}
|
|
if err := SetDesktopSubagentEffort("high"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, bad := range []string{"hard", "ultra", "high:low"} {
|
|
if err := SetDesktopSubagentEffort(bad); err == nil || DesktopSubagentEffort() != "high" {
|
|
t.Fatalf("invalid pick %q changed the effort: %v", bad, err)
|
|
}
|
|
}
|
|
for _, model := range []string{"fake/m1", "missing/m", ""} {
|
|
if err := SetDesktopSubagentModel(model); err != nil || DesktopSubagentEffort() != "high" {
|
|
t.Fatalf("model change lost effort: %v", err)
|
|
}
|
|
}
|
|
}
|