diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 061a585f5..457b60fe7 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -720,10 +720,9 @@ body.panel .view { padding-top: 2px; } .ptabs button.on { color: var(--fg); font-weight: 550; } .ptabs button[hidden] { display: none; } .ptabs em { font-style: normal; font-weight: 400; color: var(--faint); font-variant-numeric: tabular-nums; } -body.panel[data-ptab="usage"] :is(#agents, .profiles, #panelRouting), -body.panel[data-ptab="routing"] :is(#agents, .profiles, #panelQuota), -body.panel[data-ptab="profiles"] :is(#agents, #panelQuota, #panelRouting), -body.panel[data-ptab="agents"] :is(.profiles, #panelQuota, #panelRouting) { display: none; } +body.panel[data-ptab="usage"] :is(#agents, #panelRouting), +body.panel[data-ptab="routing"] :is(#agents, #panelQuota), +body.panel[data-ptab="agents"] :is(#panelQuota, #panelRouting) { display: none; } /* ---- the panel's agents: one quiet line each, opened in place ------------ */ /* icon · name · model · effort · chevron, the last three in columns of their @@ -800,10 +799,25 @@ body.panel .agent-fold-cap { padding-left: 12px; } /* "Show 9 more", the list's last line, where the names start */ body.panel .agent-more { justify-content: flex-start; gap: 6px; padding: 9px 14px; } -/* ---- the panel's profiles tab ---------------------------------------------- */ +/* ---- the panel's profiles: Profiles at the Agents tab's foot, left, opens + them over the list, upward from it ------------------------------------------ */ +.prof-btn { display: inline-flex; align-items: center; gap: 4px; margin-left: -7px; } +.prof-btn em { font-style: normal; color: var(--faint); font-variant-numeric: tabular-nums; } +.prof-btn[aria-expanded="true"] { color: var(--fg); background: var(--pill-hover); } +body.panel:not([data-ptab="agents"]) .prof-btn { display: none; } +body.panel .foot .status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +body.panel .profiles { display: none; } /* the chips a line of their own; a name field opened goes beside the button */ -body.panel .profiles { flex-wrap: wrap; align-items: center; gap: 8px; padding: 2px 0; } -body.panel .profiles > .label { display: none; } +body.panel .profiles.open { + display: flex; position: fixed; z-index: 30; left: 8px; width: min(360px, calc(100vw - 16px)); min-height: 0; + flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 8px; padding: 10px; overflow-y: auto; overscroll-behavior: contain; + background: var(--pop-bg); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); + border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); + transform-origin: 24px bottom; --pop-dy: 6px; + animation: pop-fade .18s ease-out, pop-in .42s cubic-bezier(.16, 1, .3, 1); +} +@media (prefers-reduced-motion: reduce) { body.panel .profiles.open { animation: pop-fade .12s ease-out; } } +body.panel .profiles > .label { display: block; flex: 1 1 100%; padding: 0 2px; } body.panel .profiles .chips { flex: 1 1 100%; flex-wrap: wrap; } body.panel .profiles .chips .hint { white-space: normal; line-height: 1.4; padding: 0 4px; color: var(--muted); } body.panel .profiles.naming .chips .hint { display: none; } diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 5db51ea10..3fd64160e 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -440,6 +440,7 @@ function renderProfiles() { $(".profiles > .chip-input")?.remove(); // a name field open goes with the list it was for $(".profiles").classList.remove("naming"); $("#save").textContent = t("+ Save current"); + $("#profN").textContent = state.profiles.length || ""; if (!state.profiles.length) chips.append(el("span", "hint", t("none yet · save the setup to switch back in one click"))); for (const p of state.profiles) { const c = el("button", "chip"); @@ -953,7 +954,7 @@ function fit(extra = 0, glide) { const body = document.body, tab = body.dataset.ptab; delete body.dataset.ptab; // extra is only ever the agents' (a row opening, the scroll unrolling) - const tallest = Math.max($("#agents").offsetHeight + extra, $(".profiles").offsetHeight, $("#panelQuota").offsetHeight, $("#panelRouting").offsetHeight); + const tallest = Math.max($("#agents").offsetHeight + extra, $("#panelQuota").offsetHeight, $("#panelRouting").offsetHeight); if (tab) body.dataset.ptab = tab; const h = $(".top").offsetHeight + $("#ptabs").offsetHeight + tallest + $(".foot").offsetHeight + 4; if (h === fit.last) return; @@ -1604,6 +1605,7 @@ async function profileAction(action, name, update) { state = data; renderAgents(); if (action === "use") { + closeProfiles(); // the agents, as they are now, in sight let msg = t(data.changed === 1 ? "{name} applied · {n} setting changed" : "{name} applied · {n} settings changed", { name, n: data.changed }); const lib = data.library; if (lib?.missing?.length) msg += " · " + t("skipped, no longer in the Library: {names}", { names: lib.missing.map((m) => m.replace(/^\w+:/, "")).join(", ") }); @@ -5221,16 +5223,49 @@ function planSpan(q) { return s; } -// The tray panel is four tabs over the one page: the agents, the allowances -// of every subscription and key (the "usage" tab, as it was named before), -// the gateway's latest requests (routing.js draws those) and the saved -// profiles. The tab is remembered. +// The tray panel is three tabs over the one page: the agents, the allowances +// of every subscription and key (the "usage" tab, as it was named before) +// and the gateway's latest requests (routing.js draws those). The saved +// profiles open from Profiles at the Agents tab's foot, over the list (a tab +// of their own was one too many). The tab is remembered. +const profBtn = $("#profBtn"), profBox = $(".profiles"); +function placeProfiles() { + if (!profBox.classList.contains("open")) return; + const r = profBtn.getBoundingClientRect(), top = $("#ptabs").getBoundingClientRect().bottom; + profBox.style.bottom = Math.round(innerHeight - r.top + 6) + "px"; + profBox.style.maxHeight = Math.max(120, Math.round(r.top - 6 - top - 4)) + "px"; +} +function openProfiles() { + profBox.classList.add("open"); + profBtn.setAttribute("aria-expanded", "true"); + placeProfiles(); +} +function closeProfiles() { + if (!profBox.classList.contains("open")) return; + profBox.classList.remove("open"); + profBtn.setAttribute("aria-expanded", "false"); + const f = $(".profiles > .chip-input"); + if (f) closeSave(f); +} +if (mode === "panel") { + profBtn.hidden = false; + document.body.append(profBox); // over the page, not in the list's scroll + profBtn.onclick = () => profBox.classList.contains("open") ? closeProfiles() : openProfiles(); + document.addEventListener("mousedown", (e) => { + if (profBox.classList.contains("open") && !profBox.contains(e.target) && !profBtn.contains(e.target)) closeProfiles(); + }, true); + // the name field's Escape is its own (it stops there) + document.addEventListener("keydown", (e) => { if (e.key === "Escape" && profBox.classList.contains("open")) { closeProfiles(); profBtn.focus({ preventScroll: true }); } }); + addEventListener("resize", placeProfiles); +} let panelTab = "agents"; try { panelTab = localStorage.getItem("magpie.panelTab") || "agents"; } catch {} function setPanelTab(tab) { const tabs = $("#ptabs"); - // no usage to show, no tab for it - if (tabs.querySelector(`[data-ptab="${tab}"]`)?.hidden) tab = "agents"; + // no usage to show, no tab for it (nor for profiles: they open from the foot) + const b = tabs.querySelector(`[data-ptab="${tab}"]`); + if (!b || b.hidden) tab = "agents"; + closeProfiles(); panelTab = tab; try { localStorage.setItem("magpie.panelTab", tab); } catch {} document.body.dataset.ptab = tab; diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index 01fd94a50..89eddecdf 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -47,7 +47,6 @@ -
@@ -243,6 +242,7 @@