gateway: the page is left as it is when nothing on it changed — coming back to the window no longer wipes it to placeholders and redraws, which put the reader back at the top; a reload draws again only what changed (the calls alone when only they did) and keeps where the reader was. The model list folds away under its heading, with its count, so Recent calls sits under Connect; the fold is remembered. Asked on Discord
This commit is contained in:
@@ -720,6 +720,12 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
#view-gateway .row-head, #view-usage .row-head { margin: 14px 0 6px; padding: 0 2px; }
|
||||
#view-usage .row-head.quota-head { margin: 6px 0 6px; }
|
||||
#view-gateway .row-head .note { font-size: 11px; color: var(--faint); }
|
||||
/* the Models head folds the list away: a chevron, the label, how many */
|
||||
.fold { display: inline-flex; align-items: center; gap: 5px; margin-left: -4px; padding: 3px 6px 3px 4px; border-radius: 6px; color: var(--faint); transition: background .12s, color .12s; }
|
||||
.fold:hover { background: var(--pill); color: var(--muted); }
|
||||
.fold svg { flex: none; transform: rotate(90deg); transition: transform .15s ease-out; }
|
||||
.fold[aria-expanded="false"] svg { transform: none; }
|
||||
.fold .note { font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* the connect card: label column, then the value with a copy button */
|
||||
.connect { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px 14px; align-items: start; padding: 12px 14px 14px; }
|
||||
|
||||
@@ -1201,14 +1201,25 @@ $("#save").onclick = () => {
|
||||
// the local gateway in whichever API the agent speaks.
|
||||
|
||||
async function loadProviders() {
|
||||
if (view === "gateway") renderGatewayLoading();
|
||||
else if (!providers) renderProvidersLoading();
|
||||
// the skeletons only while there is nothing yet: a reload keeps what is
|
||||
// drawn, and where the reader is in it, until the new one is in
|
||||
if (!providers) { if (view === "gateway") renderGatewayLoading(); else renderProvidersLoading(); }
|
||||
const was = providers;
|
||||
providers = await api("providers");
|
||||
// a reload's provider may be gone since
|
||||
if (typeof editing === "string" && !providers.providers.some((p) => p.id === editing)) editing = null;
|
||||
if (!providers.providers.length && editing === null) adding = true;
|
||||
if (view === "gateway") renderGatewayView();
|
||||
else renderProviders();
|
||||
if (view === "gateway") {
|
||||
// the gateway page is looked at and left open: coming back to the window
|
||||
// redraws it only when something on it changed, and when only the calls
|
||||
// did, only them (an account's last sign-in check isn't on it)
|
||||
const json = (a) => JSON.stringify(a, (k, v) => (k === "seen" ? undefined : v));
|
||||
const same = (a, b) => json(a) === json(b);
|
||||
if (was && !$("#view-gateway").classList.contains("loading") && same({ ...was, gateway: { ...was.gateway, calls: 0 } }, { ...providers, gateway: { ...providers.gateway, calls: 0 } })) {
|
||||
if (!same(was.gateway.calls, providers.gateway.calls)) renderActivity();
|
||||
} else renderGatewayView();
|
||||
backToReader($("#view-gateway"));
|
||||
} else renderProviders();
|
||||
}
|
||||
|
||||
// Rows in the shape of the list while it is first asked for; a reload keeps
|
||||
@@ -1645,10 +1656,27 @@ function highlight(code, lang) {
|
||||
}
|
||||
|
||||
let modelQuery = "";
|
||||
// The model list can be folded away, so Recent calls sits under Connect;
|
||||
// the fold is remembered.
|
||||
let modelsFolded = false;
|
||||
try { modelsFolded = localStorage.getItem("magpie.gwModelsFolded") === "1"; } catch {}
|
||||
$("#foldModels").prepend(svg(CHEV_R, 11, 1.6));
|
||||
$("#foldModels").onclick = () => {
|
||||
modelsFolded = !modelsFolded;
|
||||
try { localStorage.setItem("magpie.gwModelsFolded", modelsFolded ? "1" : "0"); } catch {}
|
||||
renderGatewayModels();
|
||||
backToReader($("#view-gateway"));
|
||||
};
|
||||
|
||||
function renderGatewayModels() {
|
||||
const list = $("#gwModels");
|
||||
list.replaceChildren();
|
||||
const all = gatewayModels();
|
||||
const fold = $("#foldModels");
|
||||
fold.setAttribute("aria-expanded", String(!modelsFolded));
|
||||
fold.title = t(modelsFolded ? "Show the models" : "Fold the models away");
|
||||
$("#modelsCount").textContent = all.length ? String(all.length) : "";
|
||||
list.hidden = modelsFolded && all.length > 0;
|
||||
// the search sits in the section head, beside Copy all ids; typing
|
||||
// redraws only the list, so it keeps its focus
|
||||
let q = $("#findModel");
|
||||
@@ -1660,13 +1688,13 @@ function renderGatewayModels() {
|
||||
q.onkeydown = (e) => { e.stopPropagation(); if (e.key === "Escape" && q.value) { q.value = modelQuery = ""; renderGatewayModels(); } };
|
||||
$("#copyModels").before(q);
|
||||
}
|
||||
q.hidden = all.length < 8;
|
||||
q.hidden = all.length < 8 || list.hidden;
|
||||
const words = modelQuery.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
||||
const models = q.hidden ? all : all.filter((m) => {
|
||||
const hay = `${m.id} ${m.name || ""} ${m.provider.name}`.toLowerCase();
|
||||
return words.every((w) => hay.includes(w));
|
||||
});
|
||||
$("#copyModels").hidden = !models.length;
|
||||
$("#copyModels").hidden = !models.length || list.hidden;
|
||||
$("#copyModels").onclick = () => copy(models.map((m) => m.id).join("\n"), t("Model ids"));
|
||||
if (!all.length) {
|
||||
const empty = el("div", "empty-state", "");
|
||||
|
||||
@@ -521,6 +521,8 @@ const I18N = {
|
||||
"Add a provider, or sign in to Codex or Copilot; their models show up here for every agent.": "添加一个供应商,或登录 Codex / Copilot;它们的模型会出现在这里,供所有 Agent 使用。",
|
||||
"Use this model in the snippets": "在示例中使用此模型",
|
||||
"Recent calls": "最近调用",
|
||||
"Show the models": "展开模型列表",
|
||||
"Fold the models away": "收起模型列表",
|
||||
"shown by the magpie that serves the gateway": "由提供网关的那个 magpie 显示",
|
||||
"No requests yet. Point an agent at a model, or run the example above; every call shows up here as it happens.": "还没有请求。让某个 Agent 使用一个模型,或运行上面的示例;每次调用都会实时显示在这里。",
|
||||
"Show request and response bodies": "查看请求体和响应体",
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
</div>
|
||||
<div class="row-head"><span class="label" data-t>Connect</span><span class="grow"></span><span class="note" id="connectNote"></span></div>
|
||||
<section class="list connect" id="connect"></section>
|
||||
<div class="row-head"><span class="label" data-t>Models</span><span class="grow"></span><button class="text" id="copyModels" data-t>Copy all ids</button></div>
|
||||
<div class="row-head"><button class="fold" id="foldModels" aria-expanded="true" aria-controls="gwModels"><span class="label" data-t>Models</span><span class="note" id="modelsCount"></span></button><span class="grow"></span><button class="text" id="copyModels" data-t>Copy all ids</button></div>
|
||||
<div class="list" id="gwModels"></div>
|
||||
<div class="row-head"><span class="label" data-t>Recent calls</span><span class="grow"></span><span class="note" id="callsNote"></span></div>
|
||||
<div class="list activity" id="activity"></div>
|
||||
|
||||
Reference in New Issue
Block a user