A path through magpie's own screens was written with › in some places and → in others (11-17 scan, item 18). Every one the user reads is now ›: Settings › Network and sharing, Settings › Privacy, Library › MCP servers, Providers › … › Use it anyway, Settings › Usage, in the GUI and in the Go errors and notices that reach it, in every language. The GUI matches errNotAsked by its prefix, so it still finds it. Left as they are: gateway errors written for agents, AiHubMix's and Claude Desktop's own menu paths (their apps' words), the image MCP tool description (it goes to agents), and comments. Own tests: chatgpt-usage-why, websearch-places, library-mcp-hub, i18n-keys; Go: internal/library (TestPrivateRepoInstallsWithToken, red on the first try because skills.go still had →), internal/plugin (notplugin_test), internal/pii, internal/provider. Run (mote, Chromium and WebKit, en zh zh-TW ja de): - before the rebase, 23 GUI files: every one green except plugin-provider-options (my bug, fixed in this branch before the push) and settings-groups' "warm-ups and check-in in each service's provider editor", red the same way at fresh origin/main98c487d09(an extra "Spend extra usage" row; #6597, commented with the sha). - rebased on origin/main98c487d09: advanced-headings, plugin-provider-options, i18n-keys, routing-advanced, provider-prefs, settings-search, panel-profiles, builtins, chatgpt-usage-why, provider-concurrency, websearch-places, library-mcp-hub all green; go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS' ok; ./internal/library, pii, plugin, provider and access ok; go vet ok. No budget raised. Again at the pushed head, rebased on origin/main39c5040d7and07d19510f(mote, Chromium and WebKit, every language): advanced-headings, plugin-provider-options, i18n-keys, routing-advanced, provider-prefs, settings-search, panel-profiles, builtins, chatgpt-usage-why, provider-concurrency, websearch-places, library-mcp-hub, codex-client, codex-client-editor and nav-timeout all green; go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS' ok; ./internal/library, pii, plugin, provider, access, ghtoken, davsync and gwmw ok, and the gateway and agent tests whose strings changed; gofmt -l empty; go vet, GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./internal/... clean. (GOOS=linux go vet ./... without nogui stops in Wails' cgo-only webview_window_linux.go, the same on origin/main 39c5040d7.) Not tried: the real app window, and Linux/Windows runs (cross-OS go vet only).
71 lines
2.9 KiB
Go
71 lines
2.9 KiB
Go
package gui
|
||
|
||
import (
|
||
"encoding/json"
|
||
"fmt"
|
||
"net/http/httptest"
|
||
"os"
|
||
"path/filepath"
|
||
"strings"
|
||
"testing"
|
||
|
||
"github.com/yetone/magpie/internal/agent"
|
||
)
|
||
|
||
// Tystem on Discord: connecting Codex with no provider or subscription in
|
||
// magpie answered "Codex can't be connected to magpie", untranslated. The
|
||
// answer carries code no_models and the agent's name, which the GUI says
|
||
// in the reader's language.
|
||
func TestAgentConnectNoModels(t *testing.T) {
|
||
home := t.TempDir()
|
||
t.Setenv("HOME", home)
|
||
t.Setenv("USERPROFILE", 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, ".codex"), 0o755)
|
||
os.WriteFile(filepath.Join(home, ".codex", "config.toml"), []byte("model = \"gpt-5.5\"\n"), 0o600)
|
||
rec := httptest.NewRecorder()
|
||
Handler(nil, nil).ServeHTTP(rec, httptest.NewRequest("POST", "/api/agents/connect/codex", strings.NewReader("{}")))
|
||
var out map[string]string
|
||
json.Unmarshal(rec.Body.Bytes(), &out)
|
||
if rec.Code != 400 || out["code"] != "no_models" || out["agent"] != "Codex" || !strings.Contains(out["error"], "Add a provider or subscription") {
|
||
t.Fatalf("%d %s", rec.Code, rec.Body)
|
||
}
|
||
}
|
||
|
||
// Lumens on Discord: connecting WorkBuddy, whose one field puts magpie in
|
||
// its own picker, answered 200 with nothing added in magpie, so the page
|
||
// said it was connected and its switch went back off. It answers
|
||
// no_models now, as Codex does.
|
||
func TestAgentConnectNoModelsMagpieAsProvider(t *testing.T) {
|
||
home := t.TempDir()
|
||
t.Setenv("HOME", home)
|
||
t.Setenv("USERPROFILE", home)
|
||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||
t.Setenv("WORKBUDDY_CONFIG_DIR", "")
|
||
os.MkdirAll(filepath.Join(home, ".workbuddy"), 0o755)
|
||
os.WriteFile(filepath.Join(home, ".workbuddy", "models.json"), []byte("[]\n"), 0o600)
|
||
rec := httptest.NewRecorder()
|
||
Handler(nil, nil).ServeHTTP(rec, httptest.NewRequest("POST", "/api/agents/connect/workbuddy", strings.NewReader("{}")))
|
||
var out map[string]any
|
||
json.Unmarshal(rec.Body.Bytes(), &out)
|
||
if rec.Code != 400 || out["code"] != "no_models" || out["agent"] != "WorkBuddy" {
|
||
t.Fatalf("%d %s", rec.Code, rec.Body)
|
||
}
|
||
}
|
||
|
||
// znuaibot (#1989): magpie has models, none left in the agent's lists. The
|
||
// answer carries code all_hidden and the agent's name, which the GUI says
|
||
// in the reader's language, pointing at the agent's Model list.
|
||
func TestAgentConnectAllHidden(t *testing.T) {
|
||
rec := httptest.NewRecorder()
|
||
fail(rec, fmt.Errorf("connect: %w", &agent.AllHiddenError{Agent: "OpenCode"}))
|
||
var out map[string]string
|
||
json.Unmarshal(rec.Body.Bytes(), &out)
|
||
if rec.Code != 400 || out["code"] != "all_hidden" || out["agent"] != "OpenCode" || !strings.Contains(out["error"], "Model list › Pick") {
|
||
t.Fatalf("%d %s", rec.Code, rec.Body)
|
||
}
|
||
}
|