From c47b22ee27e36273b56eccba2fb44ea66bd32f29 Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 1 Oct 2026 00:56:00 +0800 Subject: [PATCH] =?UTF-8?q?agents:=20"Hide=20all"=20in=20an=20agent's=20mo?= =?UTF-8?q?del=20list=20keeps=20its=20line,=20and=20an=20uninstalled=20Gem?= =?UTF-8?q?ini=20CLI=20goes=20from=20the=20Agents=20page=20(#356,=20#230)?= =?UTF-8?q?=20=E2=80=94=20the=20line=20under=20an=20agent=20("Showing=200?= =?UTF-8?q?=20/=20N=20models")=20came=20only=20when=20a=20picker=20still?= =?UTF-8?q?=20listed=20one=20of=20magpie's=20models,=20so=20hiding=20them?= =?UTF-8?q?=20all=20took=20away=20the=20one=20way=20back;=20it=20now=20sta?= =?UTF-8?q?ys=20while=20any=20is=20hidden.=20Gemini=20CLI=20was=20taken=20?= =?UTF-8?q?as=20present=20from=20what=20it=20leaves=20in=20~/.gemini=20(se?= =?UTF-8?q?ttings.json,=20.env,=20installation=5Fid=E2=80=A6),=20which=20s?= =?UTF-8?q?tays=20after=20it=20is=20uninstalled,=20so=20its=20row=20stayed?= =?UTF-8?q?,=20offering=20to=20set=20up=20a=20CLI=20that=20can't=20run;=20?= =?UTF-8?q?it=20is=20now=20its=20gemini=20binary.=20TestAgentModelLineAllH?= =?UTF-8?q?idden=20and=20TestGeminiNotAntigravity=20fail=20without=20the?= =?UTF-8?q?=20change;=20agent-models-all-hidden.test.cjs=20(Chromium,=20We?= =?UTF-8?q?bKit,=20en/zh)=20added.=20go=20vet,=20go=20build=20-tags=20nogu?= =?UTF-8?q?i=20(darwin,=20GOOS=3Dlinux),=20GOOS=3Dwindows=20go=20build,=20?= =?UTF-8?q?go=20test=20-tags=20nogui=20./internal/agent=20./internal/gui?= =?UTF-8?q?=20./internal/library=20./internal/provider=20pass;=20agent-mod?= =?UTF-8?q?els,=20click-scroll,=20old-webkit=20pass.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/agent/gemini.go | 22 +-- internal/agent/gemini_detect_test.go | 30 ++--- internal/gui/agent_models.go | 30 +++++ internal/gui/agent_models_test.go | 44 ++++++ internal/gui/api.go | 13 +- internal/gui/tests/README.md | 9 +- .../tests/agent-models-all-hidden.test.cjs | 126 ++++++++++++++++++ internal/library/library_test.go | 7 +- internal/provider/google.go | 12 -- 9 files changed, 231 insertions(+), 62 deletions(-) create mode 100644 internal/gui/tests/agent-models-all-hidden.test.cjs diff --git a/internal/agent/gemini.go b/internal/agent/gemini.go index 95600b806..5f474f528 100644 --- a/internal/agent/gemini.go +++ b/internal/agent/gemini.go @@ -2,7 +2,6 @@ package agent import ( "fmt" - "os" "os/exec" "path/filepath" "strings" @@ -164,25 +163,16 @@ func gemini(home string) *Agent { ID: "gemini", Name: "Gemini CLI", Icon: "geminicli-color", Aliases: []string{"gemini-cli"}, UA: []string{"geminicli", "gemini-cli"}, Bin: "gemini", Dir: dir, Path: path, - // Antigravity keeps its folders under ~/.gemini too (antigravity, - // antigravity-cli, config) and reads GEMINI.md there, so the folder - // alone is no sign of Gemini CLI (#330): only what Gemini CLI itself - // writes there, or its binary, is + // Gemini CLI is its binary. What it leaves in ~/.gemini stays when it + // is uninstalled (#230), and Antigravity keeps its folders there too + // (antigravity, antigravity-cli, config) and reads GEMINI.md (#330), + // so nothing there says Gemini CLI is here: a row for it would set + // up a CLI that can't run. The desktop app's PATH has the user's + // shell's (proc.UserPath). detect: func() bool { if Taken(dir) { return false } - for _, f := range []string{"settings.json", ".env", "google_accounts.json", "installation_id", "trustedFolders.json", "mcp-oauth-tokens.json"} { - if _, err := os.Stat(filepath.Join(dir, f)); err == nil { - return true - } - } - // a sign-in another app's OAuth client minted there isn't - // Gemini CLI's (#143) - creds := filepath.Join(dir, "oauth_creds.json") - if _, err := os.Stat(creds); err == nil && !provider.AnotherAppsGoogleSignIn(creds) { - return true - } _, err := exec.LookPath("gemini") return err == nil }, diff --git a/internal/agent/gemini_detect_test.go b/internal/agent/gemini_detect_test.go index 56f4828ac..44467ca60 100644 --- a/internal/agent/gemini_detect_test.go +++ b/internal/agent/gemini_detect_test.go @@ -1,7 +1,6 @@ package agent import ( - "encoding/base64" "os" "path/filepath" "runtime" @@ -9,7 +8,8 @@ import ( ) // TestGeminiNotAntigravity: a ~/.gemini holding only what Antigravity keeps -// there is no Gemini CLI (#330); what Gemini CLI writes, or its binary, is. +// there is no Gemini CLI (#330), nor one holding what Gemini CLI left when +// it was uninstalled (#230); its binary is. func TestGeminiNotAntigravity(t *testing.T) { home := t.TempDir() t.Setenv("HOME", home) @@ -27,26 +27,14 @@ func TestGeminiNotAntigravity(t *testing.T) { t.Fatal("agy not detected from ~/.gemini/antigravity-cli") } - // a sign-in Antigravity's OAuth client minted there isn't Gemini CLI's - creds := filepath.Join(dir, "oauth_creds.json") - claims := base64.RawURLEncoding.EncodeToString([]byte(`{"azp":"other.apps.googleusercontent.com","aud":"other.apps.googleusercontent.com"}`)) - os.WriteFile(creds, []byte(`{"refresh_token":"r","id_token":"e30.`+claims+`.sig"}`), 0o600) + // what Gemini CLI leaves behind when it is uninstalled (#230): its + // settings, its sign-in, its ids, all of it + os.WriteFile(filepath.Join(dir, "oauth_creds.json"), []byte(`{"refresh_token":"r"}`), 0o600) + for _, f := range []string{"settings.json", ".env", "google_accounts.json", "installation_id", "trustedFolders.json", "mcp-oauth-tokens.json"} { + os.WriteFile(filepath.Join(dir, f), []byte("{}"), 0o644) + } if gemini(home).Detected() { - t.Fatal("another app's sign-in taken for Gemini CLI") - } - os.WriteFile(creds, []byte(`{"refresh_token":"r"}`), 0o600) - if !gemini(home).Detected() { - t.Fatal("Gemini CLI's sign-in not detected") - } - os.Remove(creds) - - for _, f := range []string{"settings.json", ".env", "google_accounts.json", "installation_id"} { - p := filepath.Join(dir, f) - os.WriteFile(p, []byte("{}"), 0o644) - if !gemini(home).Detected() { - t.Fatalf("%s not taken for Gemini CLI", f) - } - os.Remove(p) + t.Fatal("an uninstalled Gemini CLI's leftovers taken for it") } if runtime.GOOS == "windows" { diff --git a/internal/gui/agent_models.go b/internal/gui/agent_models.go index 48c356bc3..317ec8c7b 100644 --- a/internal/gui/agent_models.go +++ b/internal/gui/agent_models.go @@ -50,6 +50,36 @@ func takesCatalog(fields []fieldJSON) bool { return false } +// agentFields are an agent's pickers as the Agents page draws them. +func agentFields(a *agent.Agent, vals map[string]string) []fieldJSON { + out := []fieldJSON{} + for _, f := range a.Fields { + opts := f.Options(vals) + if opts == nil { + opts = []agent.Option{} + } + out = append(out, fieldJSON{Key: f.Key, Label: f.Label, Value: vals[f.Key], Options: opts}) + } + return out +} + +// agentModelCount is the line under an agent's name, nil for an agent that +// doesn't pick among the catalog. Its pickers list only the models shown, so +// with every one taken out they have no catalog entry left, yet the line is +// the one way to put them back (#356): it stays while any is hidden. +func agentModelCount(id string, fields []fieldJSON) *modelCountJSON { + if takesCatalog(fields) { + return modelCount(id) + } + if len(provider.HiddenModels(id)) == 0 { + return nil + } + if c := modelCount(id); c.Shown < c.Listed { + return c + } + return nil +} + func modelCount(id string) *modelCountJSON { listed, _ := provider.ListedFor(id) off := provider.HiddenModels(id) diff --git a/internal/gui/agent_models_test.go b/internal/gui/agent_models_test.go index ffa60d24d..75d86da28 100644 --- a/internal/gui/agent_models_test.go +++ b/internal/gui/agent_models_test.go @@ -10,6 +10,7 @@ import ( "strings" "testing" + "github.com/yetone/magpie/internal/agent" "github.com/yetone/magpie/internal/provider" "github.com/yetone/magpie/internal/settings" ) @@ -75,3 +76,46 @@ func TestAgentModelsAPI(t *testing.T) { t.Fatalf("%+v", got.Count) } } + +// Every model taken out of an agent's lists leaves its pickers no catalog +// entry, yet the line under its name stays, "Showing 0 / N", as the way to +// put them back (#356). +func TestAgentModelLineAllHidden(t *testing.T) { + home := t.TempDir() + t.Setenv("HOME", 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) + 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) + } + a, err := agent.Find("codex") + if err != nil { + t.Fatal(err) + } + line := func() *modelCountJSON { return agentModelCount(a.ID, agentFields(a, a.Values())) } + c := line() + if c == nil || c.Shown != c.Listed || c.Listed < 2 { + t.Fatalf("all shown: %+v", c) + } + var all []string + listed, _ := provider.ListedFor("codex") + for _, e := range listed { + all = append(all, e.ID) + } + if err := provider.SetHiddenModels("codex", all); err != nil { + t.Fatal(err) + } + if takesCatalog(agentFields(a, a.Values())) { + t.Fatal("a picker still lists a catalog entry; the case isn't reached") + } + if c := line(); c == nil || c.Shown != 0 || c.Listed != len(all) { + t.Fatalf("all hidden: %+v", c) + } + provider.SetHiddenModels("codex", nil) + if c := line(); c == nil || c.Shown != c.Listed { + t.Fatalf("put back: %+v", c) + } +} diff --git a/internal/gui/api.go b/internal/gui/api.go index b991e74ae..7ec167eaa 100644 --- a/internal/gui/api.go +++ b/internal/gui/api.go @@ -728,17 +728,8 @@ func state() stateJSON { } for _, a := range agent.Detected() { vals := a.Values() - aj := agentJSON{ID: a.ID, Name: a.Name, Icon: a.Icon, Path: tilde(a.Path), Fields: []fieldJSON{}} - for _, f := range a.Fields { - opts := f.Options(vals) - if opts == nil { - opts = []agent.Option{} - } - aj.Fields = append(aj.Fields, fieldJSON{Key: f.Key, Label: f.Label, Value: vals[f.Key], Options: opts}) - } - if takesCatalog(aj.Fields) { - aj.Models = modelCount(a.ID) - } + aj := agentJSON{ID: a.ID, Name: a.Name, Icon: a.Icon, Path: tilde(a.Path), Fields: agentFields(a, vals)} + aj.Models = agentModelCount(a.ID, aj.Fields) aj.Drift = a.Drift() if a.Import != nil { aj.Import, aj.Added = a.Import(), a.Added != nil && a.Added() diff --git a/internal/gui/tests/README.md b/internal/gui/tests/README.md index b7b7816cd..4829d2d17 100644 --- a/internal/gui/tests/README.md +++ b/internal/gui/tests/README.md @@ -52,6 +52,13 @@ it and over no other icon (the browser's tooltip put Devin's name on ZCode's Z), moves at once to the next icon, and goes on a click, on leaving, and when Esc closes the picker; a rail icon focused from the keyboard is named too. +`agent-models-all-hidden.test.cjs` takes every model out of DeepSeek +Harness's lists with "Hide all" (#356): the line under its name reads +"Showing 0 / 3 models" (显示 0 / 3 个模型), stays once the list is closed and +the agents are drawn again from the state, and opens the list again, where +"Show all" puts them back; no click moves the page. Chromium and WebKit, +English and Chinese. + `agent-models.test.cjs` opens Codex's model list from the line under its name, in Chromium and WebKit, English and Chinese: the line reads "Showing 8 / 31 models" under the name, opening it moves nothing and puts it on the screen @@ -464,7 +471,7 @@ and the next stop is the lowest level. Chromium and WebKit. With Node.js and Playwright available: ```sh -node --test internal/gui/tests/menu-scroll.test.cjs internal/gui/tests/click-scroll.test.cjs internal/gui/tests/panel-fold.test.cjs internal/gui/tests/panel-routing.test.cjs internal/gui/tests/gateway-fold.test.cjs internal/gui/tests/routing-kind.test.cjs internal/gui/tests/balance-fix.test.cjs internal/gui/tests/cli-update.test.cjs internal/gui/tests/login-import.test.cjs internal/gui/tests/agy-launch.test.cjs internal/gui/tests/currency.test.cjs internal/gui/tests/usage-ledger.test.cjs internal/gui/tests/update-check.test.cjs internal/gui/tests/omarchy.test.cjs internal/gui/tests/brand.test.cjs node --test internal/gui/tests/signin-callback.test.cjs internal/gui/tests/routing-steady.test.cjs internal/gui/tests/old-webkit.test.cjs internal/gui/tests/session-terminal.test.cjs internal/gui/tests/text-size.test.cjs internal/gui/tests/zcode-site.test.cjs internal/gui/tests/rail-tip.test.cjs internal/gui/tests/sync-update.test.cjs internal/gui/tests/plugin-signin.test.cjs internal/gui/tests/plugin-market.test.cjs internal/gui/tests/s3-sync.test.cjs internal/gui/tests/routing-wb-refused.test.cjs internal/gui/tests/market-have.test.cjs internal/gui/tests/sessions-today.test.cjs internal/gui/tests/routing-side-calls.test.cjs internal/gui/tests/import-all-skills.test.cjs internal/gui/tests/routing-flood.test.cjs internal/gui/tests/routing-busy.test.cjs internal/gui/tests/own-skill.test.cjs internal/gui/tests/routing-manual.test.cjs internal/gui/tests/tray-usages.test.cjs internal/gui/tests/provider-remove.test.cjs internal/gui/tests/signin-link.test.cjs internal/gui/tests/tray-inuse.test.cjs internal/gui/tests/codex-auto-reset.test.cjs internal/gui/tests/routing-auto-reset.test.cjs internal/gui/tests/claude-resets.test.cjs internal/gui/tests/library-toggle-status.test.cjs internal/gui/tests/library-all.test.cjs internal/gui/tests/routing-reroute-title.test.cjs internal/gui/tests/plain-names.test.cjs internal/gui/tests/panel-effort.test.cjs +node --test internal/gui/tests/menu-scroll.test.cjs internal/gui/tests/click-scroll.test.cjs internal/gui/tests/panel-fold.test.cjs internal/gui/tests/panel-routing.test.cjs internal/gui/tests/gateway-fold.test.cjs internal/gui/tests/routing-kind.test.cjs internal/gui/tests/balance-fix.test.cjs internal/gui/tests/cli-update.test.cjs internal/gui/tests/login-import.test.cjs internal/gui/tests/agy-launch.test.cjs internal/gui/tests/currency.test.cjs internal/gui/tests/usage-ledger.test.cjs internal/gui/tests/update-check.test.cjs internal/gui/tests/omarchy.test.cjs internal/gui/tests/brand.test.cjs node --test internal/gui/tests/signin-callback.test.cjs internal/gui/tests/routing-steady.test.cjs internal/gui/tests/old-webkit.test.cjs internal/gui/tests/session-terminal.test.cjs internal/gui/tests/text-size.test.cjs internal/gui/tests/zcode-site.test.cjs internal/gui/tests/rail-tip.test.cjs internal/gui/tests/sync-update.test.cjs internal/gui/tests/plugin-signin.test.cjs internal/gui/tests/plugin-market.test.cjs internal/gui/tests/s3-sync.test.cjs internal/gui/tests/routing-wb-refused.test.cjs internal/gui/tests/market-have.test.cjs internal/gui/tests/sessions-today.test.cjs internal/gui/tests/routing-side-calls.test.cjs internal/gui/tests/import-all-skills.test.cjs internal/gui/tests/routing-flood.test.cjs internal/gui/tests/routing-busy.test.cjs internal/gui/tests/own-skill.test.cjs internal/gui/tests/routing-manual.test.cjs internal/gui/tests/tray-usages.test.cjs internal/gui/tests/provider-remove.test.cjs internal/gui/tests/signin-link.test.cjs internal/gui/tests/tray-inuse.test.cjs internal/gui/tests/codex-auto-reset.test.cjs internal/gui/tests/routing-auto-reset.test.cjs internal/gui/tests/claude-resets.test.cjs internal/gui/tests/library-toggle-status.test.cjs internal/gui/tests/library-all.test.cjs internal/gui/tests/routing-reroute-title.test.cjs internal/gui/tests/plain-names.test.cjs internal/gui/tests/panel-effort.test.cjs internal/gui/tests/agent-models-all-hidden.test.cjs ``` If Playwright is installed outside the repository, set `NODE_PATH` to the diff --git a/internal/gui/tests/agent-models-all-hidden.test.cjs b/internal/gui/tests/agent-models-all-hidden.test.cjs new file mode 100644 index 000000000..b3ab53bb1 --- /dev/null +++ b/internal/gui/tests/agent-models-all-hidden.test.cjs @@ -0,0 +1,126 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// Every model taken out of an agent's lists (#356, DeepSeek Harness): the +// line under its name stays, "Showing 0 / 3 models", and opens the list to +// put them back. Its pickers then list only the agent's own models, and the +// line had gone with the catalog entries, leaving no way back. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); + +const assets = path.resolve(__dirname, "../assets"); + +function fixture(lang) { + const list = ["deepseek-v4-pro", "deepseek-v4-flash", "deepseek-r2"].map((m) => + ({ id: "deepseek/" + m, name: m, group: "DeepSeek", icon: "deepseek-color", context: 1e6 })); + const posts = []; + let stateCalls = 0; + const count = () => ({ shown: list.filter((m) => !m.hidden).length, listed: list.length }); + const state = () => { + stateCalls++; + // its own models, and the catalog's shown ones + const options = [{ value: "deepseek-v4-pro", label: "DeepSeek-V4-Pro", group: "DeepSeek Harness" }, + ...list.filter((m) => !m.hidden).map((m) => ({ value: "magpie/" + m.id, label: m.name, ref: m.id }))]; + return { + agents: [{ + id: "dsh", name: "DeepSeek Harness", path: "/test/.dsh/config.json", icon: "deepseek-color", + fields: [{ key: "model", label: "model", value: "deepseek-v4-pro", options }], + models: count(), + }], + profiles: [], settings: { lang, theme: "light" }, + }; + }; + async function serve(route) { + const req = route.request(); + const url = new URL(req.url()); + const json = (data) => route.fulfill({ json: data }); + if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` }); + if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); + if (url.pathname === "/api/state") return json(state()); + if (url.pathname === "/api/agent-models/dsh") { + if (req.method() === "POST") { + const { hidden } = req.postDataJSON(); + posts.push(hidden); + for (const m of list) m.hidden = hidden.includes(m.id); + return json({ models: list, count: count() }); + } + return json({ models: list }); + } + if (url.pathname === "/api/plugins") return json({ plugins: [] }); + if (url.pathname === "/api/groups") return json({ groups: [] }); + if (url.pathname === "/api/providers") return json({ providers: [], gateway: { running: true, window: true } }); + if (url.pathname.startsWith("/api/")) return json({}); + const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); + const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)]; + await route.fulfill({ body: await fs.readFile(file), contentType }); + } + return { serve, posts, stateCalls: () => stateCalls }; +} + +const W = { + en: { all: "All 3 models", none: "Showing 0 / 3 models", hideAll: "Hide all", showAll: "Show all" }, + zh: { all: "全部 3 个模型", none: "显示 0 / 3 个模型", hideAll: "全部隐藏", showAll: "全部显示" }, +}; + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + for (const lang of ["en", "zh"]) { + test(`${engine} ${lang}: every model hidden, the line stays to put them back`, async (t) => { + const w = W[lang]; + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + const page = await browser.newPage({ viewport: { width: 1000, height: 700 } }); + page.setDefaultTimeout(5000); + const errors = []; + page.on("pageerror", (e) => errors.push(e.message)); + const fx = fixture(lang); + await page.route("**/*", fx.serve); + t.after(async () => { + if (process.env.ARTIFACT_DIR) { + await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true }); + await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-all-hidden.png`) }); + } + await browser.close(); + }); + await page.goto("http://magpie.test/"); + const entry = page.locator('.row.agent[data-id="dsh"] .ag-models'); + await entry.waitFor(); + assert.equal((await entry.innerText()).trim(), w.all); + const scroll = () => page.evaluate(() => [scrollY, document.scrollingElement.scrollTop, $("#view-agents").scrollTop]); + const was = await scroll(); + + await entry.click(); + const pop = page.locator(".am-pop:not(.leaving)"); + await pop.waitFor(); + await pop.locator(".am-hide").click(); + await page.waitForTimeout(150); + assert.equal(fx.posts.at(-1).length, 3); + assert.equal((await entry.innerText()).trim(), w.none); + + // closed, the agents are drawn again from the state: the line stays + const before = fx.stateCalls(); + await page.keyboard.press("Escape"); + await pop.waitFor({ state: "detached" }); + await page.waitForTimeout(300); + assert(fx.stateCalls() > before, "the state is asked for again"); + await entry.waitFor(); + assert.equal((await entry.innerText()).trim(), w.none); + assert.equal(await entry.locator("b").innerText(), "0"); + + // and opens the list to show them all again + await entry.click(); + await pop.waitFor(); + const showAll = pop.locator(".am-reset:not(.am-hide)"); + assert.equal(await showAll.innerText(), w.showAll); + await showAll.click(); + await page.waitForTimeout(150); + assert.deepEqual(fx.posts.at(-1), []); + assert.equal((await entry.innerText()).trim(), w.all); + await page.keyboard.press("Escape"); + await pop.waitFor({ state: "detached" }); + await page.waitForTimeout(300); + assert.equal((await entry.innerText()).trim(), w.all); + assert.deepEqual(await scroll(), was, "no click moved the page"); + assert.deepEqual(errors, []); + }); + } +} diff --git a/internal/library/library_test.go b/internal/library/library_test.go index 897942c72..3a9425a41 100644 --- a/internal/library/library_test.go +++ b/internal/library/library_test.go @@ -28,7 +28,12 @@ func sandbox(t *testing.T) string { t.Setenv("HOME", h) t.Setenv("USERPROFILE", h) t.Setenv("XDG_CONFIG_HOME", filepath.Join(h, ".config")) - t.Setenv("PATH", "") + // Gemini CLI is found by its binary alone + bin := filepath.Join(h, "bin") + write(t, filepath.Join(bin, "gemini"), "#!/bin/sh\n") + os.Chmod(filepath.Join(bin, "gemini"), 0o755) + write(t, filepath.Join(bin, "gemini.exe"), "") + t.Setenv("PATH", bin) // never the machine's global node_modules roots := piGlobalRoots piGlobalRoots = func() []string { return nil } diff --git a/internal/provider/google.go b/internal/provider/google.go index d5ac211cb..df7ed5a6a 100644 --- a/internal/provider/google.go +++ b/internal/provider/google.go @@ -165,18 +165,6 @@ func geminiOwnLogin() (googleAccount, bool) { return googleAccount{app: app, user: user, auth: a, own: true}, true } -// AnotherAppsGoogleSignIn reports whether the Google sign-in in the -// oauth_creds.json at path was minted by an OAuth client other than Gemini -// CLI's (Antigravity's, #143): the file is then no sign of Gemini CLI. -func AnotherAppsGoogleSignIn(path string) bool { - var id struct { - IDToken string `json:"id_token"` - } - readJSON(path, &id) - c := googleClientOf(id.IDToken) - return c != "" && c != geminiApp.clientID -} - // googleClientOf is the OAuth client a Google ID token was minted for, "" // when there is none to tell. func googleClientOf(idToken string) string {