Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
gui: a new partner puts a still dot on Providers in the sidebar
yetoneef3b9f85a467
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex 4ddbda09a..127987155 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -5819,7 +5819,7 @@ let providersEarly = null;function prefetchProviders() {if (providers || providersEarly) return;const e = providersEarly = { read: api("providers") };- e.read.then((s) => { e.got = s; }, () => { if (providersEarly === e) providersEarly = null; });+ e.read.then((s) => { e.got = s; markNewPartners(); }, () => { if (providersEarly === e) providersEarly = null; });}// The page's first reading, while it is on its way, is the one every ask@@ -7632,14 +7632,20 @@ function countPartner(what, ids) {// a partner listed since the add sheet last showed the partners puts a// small dot on the add button, its name in the button's title, until the-// sheet shows it (yetone: 有了新的合作伙伴的时候…提醒吸引用户点击查看)+// sheet shows it (yetone: 有了新的合作伙伴的时候…提醒吸引用户点击查看),+// and a still one on Providers in the sidebar, as Plugins has for an+// update, so it is seen from any page (yetone: 侧边栏…不要太打扰用户)function markNewPartners() {- const b = $("#addProvider");- if (!b) return;- const fresh = adding ? [] : (providers?.presets || []).filter((p) => p.kind === "partner" && p.new && !p.added && partnerShown(p));- b.classList.toggle("has-new", fresh.length > 0);- if (fresh.length) b.title = t("New in Partners: {names}", { names: fresh.map((p) => p.name).join(", ") });- else b.removeAttribute("title");+ const list = providers || providersEarly?.got;+ const fresh = adding ? [] : (list?.presets || []).filter((p) => p.kind === "partner" && p.new && !p.added && partnerShown(p));+ const title = fresh.length ? t("New in Partners: {names}", { names: fresh.map((p) => p.name).join(", ") }) : "";+ const nav = mode === "window" && document.querySelector('#nav button[data-view="providers"]');+ for (const [b, cls] of [[$("#addProvider"), "has-new"], [nav, "has-dot"]]) {+ if (!b) continue;+ b.classList.toggle(cls, fresh.length > 0);+ if (title) b.title = title;+ else b.removeAttribute("title");+ }}// partners new when the sheet showed them, each dotted until opened, thisdiff --git a/internal/gui/tests/partners.test.cjs b/internal/gui/tests/partners.test.cjsindex 516638dac..6bc4784bf 100644--- a/internal/gui/tests/partners.test.cjs+++ b/internal/gui/tests/partners.test.cjs@@ -170,11 +170,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",const dot = await add.evaluate((b) => { const s = getComputedStyle(b, "::after"); const r = b.getBoundingClientRect(); return { w: s.width, h: s.height, bg: s.backgroundColor, over: b.scrollWidth > b.clientWidth + 1, right: r.right <= innerWidth }; });assert.deepEqual([dot.w, dot.h, dot.over, dot.right], ["6px", "6px", false, true]);assert.notEqual(dot.bg, "rgba(0, 0, 0, 0)");+ // Providers in the sidebar has the same news, a still dot+ const nav = page.locator('#nav button[data-view="providers"]');+ assert.equal(await nav.evaluate((b) => b.classList.contains("has-dot")), true);+ assert.equal(await nav.getAttribute("title"), title);// the sheet shows them: no dot, then or after the page comes backawait add.click();await page.locator("#addSheet .tile").first().waitFor();assert.equal(await add.evaluate((b) => b.classList.contains("has-new")), false);+ assert.equal(await nav.evaluate((b) => b.classList.contains("has-dot")), false);+ assert.equal(await nav.getAttribute("title"), null);// each new partner's tile has its own dot, inside the tile, and one// listed only in another language isn't there to have oneconst tileDots = () => page.locator("#addSheet .tile").evaluateAll((ts) => ts.filter((x) => x.querySelector(".new-dot")).map((x) => {@@ -223,6 +229,45 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",await page.context().close();});}+ // the app opened on another page reads the list in the background and+ // dots Providers in the sidebar from it: small, still, inside the row,+ // in the accent; the page opened keeps it until the sheet shows them+ // 1280 has the sidebar, 900 the header's tabs+ for (const lang of ["en", "zh"]) for (const width of [1280, 900]) await t.test(`new partner dot in the nav ${lang} ${width}`, async () => {+ const page = await (await browser.newContext({ viewport: { width, height: 800 } })).newPage();+ const errors = [];+ page.on("pageerror", (e) => errors.push(e.message));+ const counted = [];+ await page.route("**/*", server(lang, partners.map((p) => ({ ...p, new: true })), counted));+ await page.goto("http://magpie.test/?view=agents");+ const nav = page.locator('#nav button[data-view="providers"]');+ await nav.waitFor();+ await page.waitForFunction(() => document.querySelector('#nav button[data-view="providers"]').classList.contains("has-dot"));+ assert.equal(await nav.getAttribute("title"), lang === "en" ? "New in Partners: Acme AI" : "合作伙伴有新成员:Acme AI, China Only");+ const dot = await nav.evaluate((b) => {+ const s = getComputedStyle(b, "::after"), r = b.getBoundingClientRect();+ return { side: document.body.classList.contains("side-nav"), w: s.width, h: s.height, bg: s.backgroundColor, anim: s.animationName, inside: parseFloat(s.right) + parseFloat(s.width) <= r.width };+ });+ const px = width === 1280 ? "6px" : "5px";+ assert.deepEqual([dot.side, dot.w, dot.h, dot.anim, dot.inside], [width === 1280, px, px, "none", true]);+ assert.notEqual(dot.bg, "rgba(0, 0, 0, 0)");+ await nav.click();+ const add = page.locator("#addProvider");+ await add.waitFor();+ assert.equal(await nav.evaluate((b) => b.classList.contains("has-dot")), true);+ await add.click();+ await page.locator("#addSheet .tile").first().waitFor();+ assert.equal(await nav.evaluate((b) => b.classList.contains("has-dot")), false);+ await page.keyboard.press("Escape");+ await page.locator("#addSheet").waitFor({ state: "hidden" });+ // read again, the list says they were shown+ await page.reload();+ await nav.waitFor();+ await page.waitForTimeout(300);+ assert.equal(await nav.evaluate((b) => b.classList.contains("has-dot")), false);+ assert.deepEqual(errors, []);+ await page.context().close();+ });await t.test("no partners, no heading", async () => {const page = await (await browser.newContext({ viewport: { width: 900, height: 800 } })).newPage();await page.route("**/*", server("en", []));