Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Delete unused functions from the admin inline script (#1996)

Regan Bell4ad34ab53d3f
diff --git a/plugins/admin/public/index.html b/plugins/admin/public/index.html
index da6a1bb5b..04354b5c3 100644
--- a/plugins/admin/public/index.html
+++ b/plugins/admin/public/index.html
@@ -7027,28 +7027,12 @@
)
setStatus(statusId, "", "");
}
- function tableWrap(t) {
- const wrap = document.createElement("div");
- wrap.className = "tablewrap";
- wrap.appendChild(t);
- return wrap;
- }
function badge(text, kind) {
const s = document.createElement("span");
s.className = "badge" + (kind ? " " + kind : "");
s.textContent = text;
return s;
}
- function badgeList(items) {
- const wrap = document.createElement("div");
- wrap.className = "badges";
- items.filter(Boolean).forEach((item) => {
- if (item.node) wrap.appendChild(item.node);
- else if (Array.isArray(item)) wrap.appendChild(badge(item[0], item[1]));
- else wrap.appendChild(badge(item.text, item.kind));
- });
- return wrap;
- }
function deliveryFileBadges(filesPayload) {
const filesWithNames = (filesPayload || []).filter((f) => f && f.name);
if (!filesWithNames.length) return null;
@@ -7093,46 +7077,9 @@
if (background) parts.push(Number(background).toLocaleString() + " background");
return parts.join(" · ") || "no conversations";
}
- function linkedStacked(href, primary, secondary) {
- const d = stacked(primary, secondary);
- const a = document.createElement("a");
- a.href = href;
- a.target = "_blank";
- a.rel = "noopener";
- a.textContent = primary;
- d.querySelector(".primaryline").replaceChildren(a);
- return d;
- }
function deploymentHref(dep) {
return dep.publicUrl || "";
}
- function renderCell(td, cell) {
- if (cell && cell.cls) td.className = cell.cls;
- if (cell && cell.node) {
- td.appendChild(cell.node);
- } else if (cell && cell.badges) {
- td.appendChild(badgeList(cell.badges));
- } else if (cell && cell.badge !== undefined) {
- if (cell.badge) td.appendChild(badge(cell.badge, cell.kind || "admin"));
- else {
- td.textContent = "-";
- td.className = "num";
- }
- } else if (cell && cell.action) {
- const b = document.createElement("button");
- b.type = "button";
- b.className = "rowbtn" + (cell.action.danger ? " danger" : "");
- b.textContent = cell.action.label;
- b.disabled = !!cell.action.disabled;
- if (cell.action.title) b.title = cell.action.title;
- b.onclick = cell.action.run;
- td.appendChild(b);
- } else {
- const val = cell && typeof cell === "object" ? cell : { text: cell == null ? "" : String(cell) };
- td.textContent = val.text;
- if (val.cls) td.className = val.cls;
- }
- }
const shortId = (id, len = 8) => String(id || "").slice(0, len) || "-";
const titleCase = (s) =>
String(s || "")
@@ -7199,12 +7146,6 @@
function table(headers, rows, emptyMsg) {
return governanceUI.shared.node(governanceUI.shared.table(headers, rows, emptyMsg));
}
- function dataCard(title, desc, node) {
- return governanceUI.shared.node(governanceUI.shared.card(title, desc, node));
- }
- function bareDataCard(node) {
- return governanceUI.shared.node(governanceUI.shared.bareCard(node));
- }
function showView(which, label) {
for (const id of ["loading-view", "signin-view", "unavailable-view", "notadmin-view", "app-view"]) {
@@ -7873,66 +7814,6 @@
selectScope(scopeId);
}
- function scopeIndexList(items, { latestOf, noun, open, empty, extra }) {
- const groups = new Map();
- items.forEach((it) => {
- const sid = it.ownerScopeId || it.scopeId;
- const g = groups.get(sid) || { scopeId: sid, count: 0, latest: 0 };
- g.count += 1;
- g.latest = Math.max(g.latest, latestOf(it));
- groups.set(sid, g);
- });
- const rows = [...groups.values()].sort((a, b) => b.latest - a.latest);
- const hrefOf = (sid) => stateToUrl({ view, scope: sid, ...(scopeKind(sid) === "org" ? { own: "1" } : {}) });
- return denseList(
- rows,
- (g) => ({
- name: shortName(g.scopeId),
- preview: plural(g.count, noun),
- time: relTime(g.latest),
- href: hrefOf(g.scopeId),
- }),
- (g) => (open ? open(g.scopeId) : openScopeRow(g.scopeId, extra)),
- empty,
- );
- }
-
- const scopeSearchState = {};
- function wireScopeSearch({ key, indexWrap, listWrap, rows, names, noMatch, total, shell, placeholder, onQuery }) {
- const own = orgOwnView();
- const prev = scopeSearchState[key];
- const st =
- prev && prev.scope === scope && prev.own === own ? prev : (scopeSearchState[key] = { scope, own, q: "" });
- const applyFilter = (v) => {
- st.q = v;
- const q = v.trim().toLowerCase();
- if (indexWrap) {
- indexWrap.classList.toggle("hidden", !!q);
- listWrap.classList.toggle("hidden", !q);
- }
- let hits = 0;
- rows.forEach((row, i) => {
- const hit = !q || names[i].includes(q);
- row.classList.toggle("hidden", !hit);
- if (hit) hits += 1;
- });
- noMatch.classList.toggle("hidden", !total || hits > 0 || !!(onQuery && q));
- if (onQuery) onQuery(q);
- };
- const active = document.activeElement;
- const hadFocus = !!(active && active.closest(".shell-search"));
- const caret = hadFocus && active.selectionStart != null ? active.selectionStart : null;
- pageShell({ ...shell, search: { placeholder, onInput: applyFilter } });
- applyFilter(st.q);
- const input = $("shellbar").querySelector(".shell-search input");
- if (input && st.q) input.value = st.q;
- if (input && hadFocus) {
- input.focus();
- const pos = caret == null ? input.value.length : Math.min(caret, input.value.length);
- input.setSelectionRange(pos, pos);
- }
- }
-
const FOCUS_REFRESH_EXEMPT = new Set(["governance", "connectors", "slack-settings", "user"]);
window.addEventListener("focus", () => {
if ($("app-view").classList.contains("hidden")) return;
@@ -9527,12 +9408,6 @@
s.textContent = text;
return s;
}
- function timeCell(ts) {
- const s = document.createElement("span");
- s.textContent = relTime(ts);
- s.title = fmtTime(ts);
- return nodeCell(s, "num");
- }
async function adminErrors(query) {
const r = await api("GET", "/api/errors?" + query);
return r.ok ? r.data?.errors || [] : [];
@@ -9863,47 +9738,6 @@
document.addEventListener("click", closeOvMenus);
document.addEventListener("scroll", closeOvMenus, true);
window.addEventListener("resize", closeOvMenus);
- function overflowMenu(items) {
- const wrap = document.createElement("div");
- wrap.className = "ovwrap";
- const btn = document.createElement("button");
- btn.type = "button";
- btn.className = "rowbtn";
- btn.textContent = "⋯";
- btn.setAttribute("aria-label", "Actions");
- btn.setAttribute("aria-haspopup", "menu");
- btn.setAttribute("aria-expanded", "false");
- const menu = document.createElement("div");
- menu.className = "ovmenu hidden";
- menu.setAttribute("role", "menu");
- for (const it of items) {
- const b = document.createElement("button");
- b.type = "button";
- b.textContent = it.label;
- if (it.danger) b.className = "danger";
- if (it.title) b.title = it.title;
- b.onclick = (e) => {
- e.stopPropagation();
- closeOvMenus();
- it.onClick();
- };
- menu.appendChild(b);
- }
- btn.onclick = (e) => {
- e.stopPropagation();
- const wasOpen = openOvMenu && openOvMenu.menu === menu;
- closeOvMenus();
- if (wasOpen) return;
- menu.classList.remove("hidden");
- btn.setAttribute("aria-expanded", "true");
- openOvMenu = { menu, btn };
- const r = btn.getBoundingClientRect();
- menu.style.top = r.bottom + 4 + "px";
- menu.style.left = Math.max(8, r.right - menu.offsetWidth) + "px";
- };
- wrap.append(btn, menu);
- return wrap;
- }
function buildScopeMultiSelect(choices, selected, onChange) {
const pick = document.createElement("div");
pick.className = "scopepick";
@@ -10082,97 +9916,6 @@
function renderRetention(root, d) {
governanceUI.artifacts.retention(root, d);
}
- function actionTable(headers, items, cellsOf, emptyMsg) {
- if (!items.length) {
- const p = document.createElement("p");
- p.className = "empty";
- p.textContent = emptyMsg;
- return p;
- }
- const t = document.createElement("table");
- const thead = document.createElement("thead");
- const htr = document.createElement("tr");
- headers.forEach((h) => {
- const th = document.createElement("th");
- if (h && h.nodeType) th.appendChild(h);
- else th.textContent = h;
- htr.appendChild(th);
- });
- thead.appendChild(htr);
- t.appendChild(thead);
- const tb = document.createElement("tbody");
- items.forEach((it) => {
- const tr = document.createElement("tr");
- cellsOf(it).forEach((cell) => {
- const td = document.createElement("td");
- renderCell(td, cell);
- tr.appendChild(td);
- });
- tb.appendChild(tr);
- });
- t.appendChild(tb);
- return tableWrap(t);
- }
- async function changeUserAdmin(user, event) {
- event?.stopPropagation?.();
- const revoke = user.admin?.isAdmin;
- const principalId = user.principalId;
- if (!confirm((revoke ? "Revoke admin access for " : "Make admin: ") + principalId + "?")) return;
- const button = event?.currentTarget;
- if (button) button.disabled = true;
- setStatus("st-users", "");
- try {
- const r = revoke
- ? await api(
- "DELETE",
- "/api/grants/" +
- encodeURIComponent(principalId) +
- "?scope=" +
- encodeURIComponent(user.admin.scopeId) +
- "&role=" +
- encodeURIComponent(user.admin.role),
- )
- : await api("POST", "/api/grants", { principalId, role: "org_admin", scopeId: "org:" + orgId });
- if (r.ok) await renderData();
- else setStatus("st-users", r.data?.message || "Could not update admin access.", "err");
- } catch {
- setStatus("st-users", "Network error. Try again.", "err");
- } finally {
- if (button) button.disabled = false;
- }
- }
- async function revokeExternalUser(m) {
- const question =
- m.status === "active"
- ? 'Revoke access for "' + m.email + '"? They will no longer be able to sign in.'
- : 'Remove "' + m.email + '" from the list?';
- if (!confirm(question)) return;
- const r = await api("DELETE", "/api/external-users/" + encodeURIComponent(m.email));
- if (r.ok) renderData();
- else
- setStatus(
- "st-external",
- r.status === 403 ? "Only an admin may revoke." : r.data?.message || "Revoke failed.",
- "err",
- );
- }
- function keychainGrantStatus(g) {
- const expired = g.expiresAt && g.expiresAt <= Date.now();
- if (expired && g.status === "active") return ["expired", "warn"];
- let kind = "muted";
- if (g.status === "active") kind = "ok";
- else if (g.status === "revoked") kind = "err";
- else if (g.status === "used") kind = "info";
- return [g.status || "unknown", kind];
- }
- function keychainExpiry(ts) {
- if (!ts) return "No expiry";
- const prefix = ts <= Date.now() ? "Expired " : "Expires ";
- return prefix + fmtTime(ts);
- }
- function keychainPersonLabel(p) {
- return p.displayName ? `${p.displayName} (${p.principalId})` : p.principalId;
- }
function renderKeychain(root, d) {
governanceUI.keychain.keychain(root, d, {
defaultShell,
@@ -10620,58 +10363,6 @@
return { block, sync: () => {} };
}
- function openableTable(headers, items, cellsOf, onOpen, emptyMsg, opts = {}) {
- if (!items.length) {
- const p = document.createElement("p");
- p.className = "empty";
- p.textContent = emptyMsg;
- return p;
- }
- const t = document.createElement("table");
- if (opts.className) t.className = opts.className;
- if (opts.cols?.length) {
- const cg = document.createElement("colgroup");
- opts.cols.forEach((width) => {
- const col = document.createElement("col");
- col.style.width = width;
- cg.appendChild(col);
- });
- t.appendChild(cg);
- }
- const thead = document.createElement("thead");
- const htr = document.createElement("tr");
- headers.forEach((h) => {
- const th = document.createElement("th");
- if (h && h.nodeType) th.appendChild(h);
- else th.textContent = h;
- htr.appendChild(th);
- });
- thead.appendChild(htr);
- t.appendChild(thead);
- const tb = document.createElement("tbody");
- items.forEach((it) => {
- const tr = document.createElement("tr");
- tr.className = "openable";
- tr.onclick = () => onOpen(it);
- cellsOf(it).forEach((cell, i) => {
- const td = document.createElement("td");
- const val = cell && typeof cell === "object" ? cell : { text: cell == null ? "" : String(cell) };
- if (i === 0) {
- const open = document.createElement("div");
- open.className = "open";
- if (val.node) open.appendChild(val.node);
- else open.textContent = val.text;
- td.appendChild(open);
- } else renderCell(td, cell);
- if (val.cls) td.className = val.cls;
- tr.appendChild(td);
- });
- tb.appendChild(tr);
- });
- t.appendChild(tb);
- return tableWrap(t);
- }
-
function renderScopeIndex() {
++dataReq;
const root = $("view-data");
@@ -10742,27 +10433,6 @@
},
});
}
- function pager(total, limit, offset, onGo) {
- if (total <= limit) return document.createDocumentFragment();
- const wrap = document.createElement("div");
- wrap.className = "pager";
- const pages = Math.ceil(total / limit),
- cur = Math.floor(offset / limit) + 1;
- const btn = (label, target, disabled) => {
- const b = document.createElement("button");
- b.type = "button";
- b.className = "page";
- b.textContent = label;
- b.disabled = disabled;
- if (!disabled) b.onclick = () => onGo(target);
- return b;
- };
- const info = document.createElement("span");
- info.className = "pageinfo";
- info.textContent = `${offset + 1}–${Math.min(offset + limit, total)} of ${total}`;
- wrap.append(btn("← Prev", cur - 1, cur <= 1), info, btn("Next →", cur + 1, cur >= pages));
- return wrap;
- }
let userDetailRequest = 0;
async function showUserDetail(principalId) {
@@ -10791,12 +10461,6 @@
return governanceUI.transcript.contextPage(sessionId, turnSeq, transcriptServices());
}
- function emptyPara(text) {
- const p = document.createElement("p");
- p.className = "empty";
- p.textContent = text;
- return p;
- }
let slackContainers = null;
let slackContainersTruncated = false;
async function loadSlackContainers() {
@@ -11447,9 +11111,6 @@
});
return a;
}
- function renderLlmRequests(requests, opts = {}) {
- return governanceUI.transcript.requestsPanel(requests, transcriptServices(), opts);
- }
function renderFiles(root, d) {
governanceUI.artifacts.files(root, d, artifactContext());