diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 5015f1f7d..639bc61f8 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -3909,6 +3909,9 @@ body.window .row + .row.agent.conn > .who { min-height: 41px; } /* the line abov .ag-st { flex: 0 0 100%; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 18px; color: var(--muted); } .ag-st .ag-st-t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ag-st .ag-st-t b { font-weight: 600; color: var(--fg-2); } +.ag-st.why { align-items: flex-start; } +.ag-st.why .ag-st-t { white-space: normal; overflow-wrap: anywhere; } +.ag-st.why .ag-dot { margin-top: 6px; } .ag-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--faint); } .ag-st.on .ag-dot { background: var(--green); } .ag-st.wait .ag-dot, .ag-warn .ag-dot { background: var(--amber); } diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 18dcb34bf..ea9a83593 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -1145,12 +1145,14 @@ function connectSwitch(a) { // lists, what a new session starts on, the files magpie changed, and the // way back. -// agents with no way onto magpie: no switch, the reason instead +// agents with no way onto magpie: no switch, the reason instead, and that +// it is why (@G_Z_Y on X read "Only Cursor's own models" beside "Can't +// connect" as two things, and looked for Cursor CLI elsewhere) const NATIVE_ONLY = { - cursor: "Only Cursor's own models", - copilot: "Only GitHub Copilot's own models", - goose: "Only Goose's own providers", - devin: "Only Devin's own models", + cursor: "Uses only Cursor's own models, so magpie can't connect it", + copilot: "Uses only GitHub Copilot's own models, so magpie can't connect it", + goose: "Uses only Goose's own providers, so magpie can't connect it", + devin: "Uses only Devin's own models, so magpie can't connect it", }; // agents that pick no model once started: the one they start on stays in // the row @@ -1282,7 +1284,8 @@ function connectLine(a, kind) { const words = el("span", "ag-st-t"); line.append(dot, words); const say = (s, cls) => { words.textContent = s; if (cls) line.classList.add(cls); }; - if (kind === "no") { say(t(NATIVE_ONLY[a.id])); return line; } + // the reason wraps, never cut short: it is the row's only words + if (kind === "no") { say(t(NATIVE_ONLY[a.id]), NATIVE_ONLY[a.id] ? "why" : ""); return line; } if (kind === "link") { if (a.added == null) say(t("Opens {name} to add magpie as a provider — confirm it there", { name: a.name })); else if (a.added) say(t("Added · magpie is a provider in {agent}", { agent: a.name }), "on"); diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 30dc7761b..3b3823507 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -525,10 +525,10 @@ const I18N = { "magpie takes out everything it wrote into {agent}'s config — its endpoint, key, models and effort — and puts back the settings {agent} had before. magpie's providers and accounts stay as they are.": "移除 magpie 写入 {agent} 配置的所有内容(接口地址、密钥、模型和推理强度),还原 {agent} 之前的设置。magpie 的供应商和账号不受影响。", "Disconnect": "断开", "Not connected · {agent} uses its own settings": "未接入 · 用 {agent} 自己的设置", - "Only Cursor's own models": "只能用 Cursor 自己的模型", - "Only GitHub Copilot's own models": "只能用 GitHub Copilot 自己的模型", - "Only Goose's own providers": "只能用 Goose 自己的供应商", - "Only Devin's own models": "只能用 Devin 自己的模型", + "Uses only Cursor's own models, so magpie can't connect it": "只能用 Cursor 自己的模型,magpie 无法接入", + "Uses only GitHub Copilot's own models, so magpie can't connect it": "只能用 GitHub Copilot 自己的模型,magpie 无法接入", + "Uses only Goose's own providers, so magpie can't connect it": "只能用 Goose 自己的供应商,magpie 无法接入", + "Uses only Devin's own models, so magpie can't connect it": "只能用 Devin 自己的模型,magpie 无法接入", "Gemini CLI's requests all go through magpie; its Google sign-in is turned off first and comes back when you disconnect": "Gemini CLI 的请求都走 magpie,Google 登录会先关掉,断开时恢复", "Add a key or a subscription first; then there are models to connect": "先添加一个 key 或订阅,接入后才有模型可选", "Not connected · once connected, start it with magpie's command": "未接入 · 接入后要用 magpie 给的命令启动", @@ -4187,10 +4187,10 @@ const I18N = { "magpie takes out everything it wrote into {agent}'s config — its endpoint, key, models and effort — and puts back the settings {agent} had before. magpie's providers and accounts stay as they are.": "移除 magpie 寫入 {agent} 設定的所有內容(介面位址、金鑰、模型和推理強度),還原 {agent} 之前的設定。magpie 的供應商和帳號不受影響。", "Disconnect": "斷開", "Not connected · {agent} uses its own settings": "未接入 · 用 {agent} 自己的設定", - "Only Cursor's own models": "只能用 Cursor 自己的模型", - "Only GitHub Copilot's own models": "只能用 GitHub Copilot 自己的模型", - "Only Goose's own providers": "只能用 Goose 自己的供應商", - "Only Devin's own models": "只能用 Devin 自己的模型", + "Uses only Cursor's own models, so magpie can't connect it": "只能用 Cursor 自己的模型,magpie 無法接入", + "Uses only GitHub Copilot's own models, so magpie can't connect it": "只能用 GitHub Copilot 自己的模型,magpie 無法接入", + "Uses only Goose's own providers, so magpie can't connect it": "只能用 Goose 自己的供應商,magpie 無法接入", + "Uses only Devin's own models, so magpie can't connect it": "只能用 Devin 自己的模型,magpie 無法接入", "Gemini CLI's requests all go through magpie; its Google sign-in is turned off first and comes back when you disconnect": "Gemini CLI 的請求都走 magpie,Google 登入會先關掉,斷開時恢復", "Add a key or a subscription first; then there are models to connect": "先新增一個 key 或訂閱,接入後才有模型可選", "Not connected · once connected, start it with magpie's command": "未接入 · 接入後要用 magpie 給的命令啟動", @@ -7815,10 +7815,10 @@ const I18N = { "magpie takes out everything it wrote into {agent}'s config — its endpoint, key, models and effort — and puts back the settings {agent} had before. magpie's providers and accounts stay as they are.": "magpie は {agent} の設定に書き込んだ内容(エンドポイント、キー、モデル、推論レベル)をすべて削除し、{agent} を以前の設定に戻します。magpie のプロバイダとアカウントはそのままです。", "Disconnect": "切断", "Not connected · {agent} uses its own settings": "未接続 · {agent} は独自の設定を使用", - "Only Cursor's own models": "Cursor 独自のモデルのみ", - "Only GitHub Copilot's own models": "GitHub Copilot 独自のモデルのみ", - "Only Goose's own providers": "Goose 独自のプロバイダのみ", - "Only Devin's own models": "Devin 独自のモデルのみ", + "Uses only Cursor's own models, so magpie can't connect it": "Cursor 独自のモデルしか使えないため、magpie から接続できません", + "Uses only GitHub Copilot's own models, so magpie can't connect it": "GitHub Copilot 独自のモデルしか使えないため、magpie から接続できません", + "Uses only Goose's own providers, so magpie can't connect it": "Goose 独自のプロバイダしか使えないため、magpie から接続できません", + "Uses only Devin's own models, so magpie can't connect it": "Devin 独自のモデルしか使えないため、magpie から接続できません", "Gemini CLI's requests all go through magpie; its Google sign-in is turned off first and comes back when you disconnect": "Gemini CLI のリクエストはすべて magpie を経由します。Google のサインインは先にオフになり、切断すると元に戻ります", "Add a key or a subscription first; then there are models to connect": "まずキーかサブスクリプションを追加してください。接続できるモデルがそこで用意されます", "Not connected · once connected, start it with magpie's command": "未接続 · 接続後は magpie のコマンドで起動します", @@ -11460,10 +11460,10 @@ const I18N = { "magpie takes out everything it wrote into {agent}'s config — its endpoint, key, models and effort — and puts back the settings {agent} had before. magpie's providers and accounts stay as they are.": "magpie entfernt alles, was es in die Konfiguration von {agent} geschrieben hat — Endpunkt, Schlüssel, Modelle und Reasoning-Effort — und stellt die vorherigen Einstellungen von {agent} wieder her. Anbieter und Konten in magpie bleiben unverändert.", "Disconnect": "Trennen", "Not connected · {agent} uses its own settings": "Nicht verbunden · {agent} nutzt eigene Einstellungen", - "Only Cursor's own models": "Nur die eigenen Modelle von Cursor", - "Only GitHub Copilot's own models": "Nur die eigenen Modelle von GitHub Copilot", - "Only Goose's own providers": "Nur die eigenen Anbieter von Goose", - "Only Devin's own models": "Nur die eigenen Modelle von Devin", + "Uses only Cursor's own models, so magpie can't connect it": "Nutzt nur die eigenen Modelle von Cursor, daher kann magpie es nicht verbinden", + "Uses only GitHub Copilot's own models, so magpie can't connect it": "Nutzt nur die eigenen Modelle von GitHub Copilot, daher kann magpie es nicht verbinden", + "Uses only Goose's own providers, so magpie can't connect it": "Nutzt nur die eigenen Anbieter von Goose, daher kann magpie es nicht verbinden", + "Uses only Devin's own models, so magpie can't connect it": "Nutzt nur die eigenen Modelle von Devin, daher kann magpie es nicht verbinden", "Gemini CLI's requests all go through magpie; its Google sign-in is turned off first and comes back when you disconnect": "Alle Anfragen von Gemini CLI laufen über magpie; die Google-Anmeldung wird zuvor ausgeschaltet und beim Trennen wiederhergestellt", "Add a key or a subscription first; then there are models to connect": "Zuerst einen Schlüssel oder ein Abo hinzufügen; dann gibt es Modelle zum Verbinden", "Not connected · once connected, start it with magpie's command": "Nicht verbunden · nach dem Verbinden mit dem Befehl von magpie starten", diff --git a/internal/gui/tests/agent-native-only.test.cjs b/internal/gui/tests/agent-native-only.test.cjs new file mode 100644 index 000000000..9717d7339 --- /dev/null +++ b/internal/gui/tests/agent-native-only.test.cjs @@ -0,0 +1,98 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// @G_Z_Y on X installed cursor-agent and didn't find it on the Agents page: +// its row was "Cursor", with no version, and "Only Cursor's own models" +// beside "Can't connect". The row is Cursor CLI, with what cursor-agent +// --version says, and its line says why magpie can't connect it, whole, +// never cut. So for every agent with no way onto magpie. In the window, +// wide and narrow, in every language. No backend: the API is faked here. +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"); +const field = (value) => [{ key: "model", label: "model", value, options: [{ value }] }]; +const AGENTS = [ + { id: "cursor", name: "Cursor CLI", icon: "cursor", path: "~/.cursor/cli-config.json", fields: field("auto") }, + { id: "copilot", name: "GitHub Copilot CLI", path: "~/.copilot/config.json", fields: field("gpt-5") }, + { id: "goose", name: "Goose", path: "~/.config/goose/config.yaml", fields: field("gpt-5") }, + { id: "devin", name: "Devin", path: "~/.devin/config.json", fields: field("swe-1") }, +]; +const CLIS = { cursor: { version: "2026.10.01-e373342", path: "/Users/me/.local/bin/cursor-agent" } }; +const WHY = { + cursor: "Uses only Cursor's own models, so magpie can't connect it", + copilot: "Uses only GitHub Copilot's own models, so magpie can't connect it", + goose: "Uses only Goose's own providers, so magpie can't connect it", + devin: "Uses only Devin's own models, so magpie can't connect it", +}; + +function server(lang) { + return async (route) => { + const req = route.request(), url = new URL(req.url()); + 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 route.fulfill({ json: { agents: AGENTS, profiles: [], settings: { lang, theme: "light" } } }); + if (url.pathname === "/api/agents/cli" && req.method() === "GET") return route.fulfill({ json: { agents: CLIS, pending: false } }); + if (url.pathname === "/api/agents/install") return route.fulfill({ json: [] }); + if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] }); + if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } }); + if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } }); + if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [{ id: "relay", name: "Relay", models: ["glm-4.6"] }], gateway: { running: true } } }); + if (url.pathname.startsWith("/api/")) return route.fulfill({ 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 }); + }; +} + +const row = (id) => `.row.agent[data-id="${id}"]`; +const said = (page, lang, key) => page.evaluate(([lang, key]) => (lang === "en" ? key : I18N[lang]?.[key]) || null, [lang, key]); +const noSideScroll = (page) => page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1); + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + test(engine + ": an agent magpie can't connect says why, whole, and Cursor CLI is called so", async (t) => { + assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit"); + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + const errors = []; + t.after(async () => { + if (errors.length) console.log(errors); + await browser.close(); + }); + for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) { + for (const width of [1100, 420]) { + await t.test(`${lang} ${width}`, async () => { + const page = await (await browser.newContext({ viewport: { width, height: 760 } })).newPage(); + page.setDefaultTimeout(5000); + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", server(lang)); + await page.goto("http://magpie.test/"); + await page.locator(`${row("cursor")} .ag-ver`).waitFor(); + assert.equal(await page.locator(`${row("cursor")} .name`).first().textContent(), "Cursor CLI"); + assert.equal(await page.locator(`${row("cursor")} .ag-ver`).textContent(), "2026.10.01-e373342"); + for (const id of Object.keys(WHY)) { + const want = await said(page, lang, WHY[id]); + assert(want, `${id}'s reason has no ${lang}`); + // it says that magpie is what can't connect it + assert(want.includes("magpie"), `${lang} ${id}: ${want}`); + const words = page.locator(`${row(id)} .ag-st-t`); + assert(await words.isVisible(), `${id}'s reason isn't shown`); + assert.equal(await words.textContent(), want, id); + assert(await words.evaluate((b) => b.scrollWidth <= b.clientWidth + 1 && b.scrollHeight <= b.clientHeight + 1), `${lang} ${width}: ${id}'s reason is cut`); + // inside its row + const inside = await page.locator(row(id)).evaluate((r, sel) => { + const a = r.getBoundingClientRect(), b = r.querySelector(sel).getBoundingClientRect(); + return b.left >= a.left - 0.5 && b.right <= a.right + 0.5 && b.bottom <= a.bottom + 0.5; + }, ".ag-st-t"); + assert(inside, `${id}'s reason is off its row`); + assert.equal(await page.locator(`${row(id)} .ag-conn`).count(), 0, id + " has a switch"); + } + assert(await noSideScroll(page), "the page scrolls sideways"); + await page.screenshot({ path: path.join(process.env.SHOTS || "/tmp", `native-only-${engine}-${lang}-${width}.png`), fullPage: true }).catch(() => {}); + await page.context().close(); + }); + } + } + assert.deepEqual(errors, []); + }); +}