Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gui: a provider's editor grows from where its row was pressed

yetone3d56822d41e1
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 21387bdbc..c824c9b0f 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -8518,10 +8518,12 @@ function calm() { return matchMedia("(prefers-reduced-motion: reduce)").matches;
// what was last pressed, and a way to find it again once re-rendered
let pressed = null;
document.addEventListener("pointerdown", (e) => {
- const at = e.target.closest?.("[data-pick], .row.provider[data-id], button");
+ // a provider's logo is its row's handle: pressed, the row opens, and
+ // the editor grows from the row drawn again
+ const at = e.target.closest?.(".pv-handle")?.closest(".row.provider[data-id]") || e.target.closest?.("[data-pick], .row.provider[data-id], button");
if (!at || at.closest("#modal")) return;
const find = at.dataset.pick ? `[data-pick="${CSS.escape(at.dataset.pick)}"]` : at.matches(".row.provider") ? `.row.provider[data-id="${CSS.escape(at.dataset.id)}"]` : null;
- pressed = { el: at, find, time: performance.now() };
+ pressed = { el: at, find, time: performance.now(), x: e.clientX };
}, true);
// Text cut short with an ellipsis says its whole self on hover (#721): an
// agent's status line, a long model name. Which lines are cut depends on the
@@ -8549,14 +8551,16 @@ let modalOrigin = null, modalDone = null;
function originRect(o) {
const at = o && (o.el.isConnected ? o.el : o.find ? document.querySelector(o.find) : null);
if (!at || at.closest("[hidden]")) return null;
- const r = at.matches(".row.provider") ? rowOwnRect(at) : at.getBoundingClientRect();
+ const r = at.matches(".row.provider") ? rowOwnRect(at, o.x) : at.getBoundingClientRect();
return r.width && r.height && r.bottom > 0 && r.top < innerHeight ? r : null;
}
// rowOwnRect: a provider row as a tile in the add sheet is, its icon and
// name. The whole row is wider than the dialog, so the dialog couldn't
// shrink into it and opened as a full-size strip widening (the owner: "太
// 生硬", the add sheet's tiles "特别完美"); out of this it zooms as they do.
-function rowOwnRect(row) {
+// Pressed past them, it grows from where it was pressed (the owner: 应该从
+// 点击处放大): that much of the row, around the press.
+function rowOwnRect(row, x) {
const r = row.getBoundingClientRect(), who = row.querySelector(".who");
if (!who) return r;
// where its words end: a range over the block itself spans its width
@@ -8566,8 +8570,9 @@ function rowOwnRect(row) {
text.selectNodeContents(n);
end = Math.max(end, text.getBoundingClientRect().right);
}
- const right = Math.min(r.right, end + 12);
- return new DOMRect(r.left, r.top, right - r.left, r.height);
+ const w = Math.min(r.right, end + 12) - r.left;
+ const left = x > r.left + w ? Math.max(r.left, Math.min(r.right - w, x - w / 2)) : r.left;
+ return new DOMRect(left, r.top, w, r.height);
}
// fromRect: the transform putting the dialog (at `to`) over the rect `from`
function fromRect(from, to) {
diff --git a/internal/gui/tests/modal-morph.test.cjs b/internal/gui/tests/modal-morph.test.cjs
index 8f893ed32..a4404aaea 100644
--- a/internal/gui/tests/modal-morph.test.cjs
+++ b/internal/gui/tests/modal-morph.test.cjs
@@ -95,8 +95,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.evaluate(() => { window.__hold = true; });
const r = await row.boundingBox();
- // held at the start: a strip of the dialog over the row
- await row.locator(".name, .who").first().click();
+ // held at the start: a strip of the dialog over the row, pressed on
+ // its logo, the row's handle (it rose from below, 10-24)
+ await row.locator(".pv-handle").click();
await page.locator("#modal:not([hidden]) > .dialog").waitFor();
const start = await shown(page, 0);
assert.match(start.clip, /^inset\(/, `${engine} ${width}: the opening clips the dialog: ${start.clip}`);
@@ -151,12 +152,23 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.locator("#modal").waitFor({ state: "hidden" });
assert.equal(await page.locator("#modal > .dialog").evaluate((d) => d.style.clipPath), "", "no clip left behind");
- // opened again: it grows from the row again
+ // opened again from past its name: it grows from where it was
+ // pressed (the owner, 10-24: 应该从点击处放大), and folds back there
await page.evaluate(() => { window.__hold = true; });
- await row.locator(".name, .who").first().click();
+ const px = r.width * .62;
+ await row.click({ position: { x: px, y: r.height / 2 } });
await page.locator("#modal:not([hidden]) > .dialog").waitFor();
const again = await shown(page, 0);
near(again.top, r.y, "again: the strip's top on the row's");
+ near(again.bottom, r.y + r.height, "again: the strip's bottom on the row's");
+ near((again.left + again.right) / 2, r.x + px, "again: the strip centred on the press");
+ near(again.right - again.left, start.right - start.left, "again: as wide as the icon and name were");
+ assert(again.left >= r.x - 1 && again.right <= r.x + r.width + 1, `${engine} ${width}: again inside the row: ${JSON.stringify(again)}`);
+ await page.evaluate(() => { for (const a of document.querySelector("#modal").getAnimations({ subtree: true })) a.finish(); });
+ await page.keyboard.press("Escape");
+ await page.locator("#modal.out").waitFor({ state: "attached" });
+ const back = await shown(page, 1);
+ near((back.left + back.right) / 2, r.x + px, "closed again: back where it was pressed");
assert.deepEqual(errors, []);
});
}