gui(agents): fold the agents nothing is set on behind Show N more (#41)

The agents card lists every detected agent, and on most machines
most of those rows read "default" — nothing has been set on them.
This keeps the ones that have a model or an effort of their own and
folds the rest behind a "Show N more" row at the end of the list.

A magpie with nothing set yet still shows every agent, since folding
all of them would leave the card empty. The toggle only appears when
something is actually folded.

Frontend only — three files under internal/gui/assets, no change to
state() or to settings.
This commit is contained in:
elonnzhang
2026-09-25 01:40:07 +08:00
committed by GitHub
parent 37e8f7c045
commit 2432d2ca88
3 changed files with 18 additions and 1 deletions
+4
View File
@@ -210,6 +210,10 @@ body.window .row .ic { width: 22px; height: 22px; }
.empty-state { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty-state b { display: block; color: var(--fg); font-weight: 500; margin-bottom: 4px; }
/* the last row of the list: the agents nothing is set on, folded away */
.agent-more { display: block; width: 100%; border: 0; border-top: 1px solid var(--line-2); background: none; font: inherit; font-size: 12px; color: var(--muted); padding: 9px; cursor: pointer; }
.agent-more:hover { color: var(--fg); background: var(--card-2); }
/* an agent row: logo, name, then one pop-up button per setting */
/* two columns: the model, then the smaller setting; single controls sit at the end.
Fixed widths keep every chevron on the same vertical line down the list. */
+12 -1
View File
@@ -16,6 +16,7 @@ let state = { agents: [], profiles: [], catalog: "", settings: {} };
let prefs = null; // the settings page: theme, lang, version, dir, gateway
let providers = null; // { providers, presets, gateway }
let view = "agents";
let showAllAgents = false; // the agents no one has set anything on, folded away
let period = "30d"; // usage window
let usage = null; // last usage summary
let pick = null; // { agent, field, options, items, cursor, anchor }
@@ -131,7 +132,11 @@ function renderAgents() {
e.append(el("b", "", t("No agents found")), el("span", "", t("Install Claude Code, Codex, Gemini CLI, OpenCode… and magpie will list them here.")));
list.append(e);
}
for (const a of state.agents) {
// An agent no one has set anything on is noise in a picker: fold it away,
// unless that is all of them (a fresh magpie has nothing to show otherwise).
const used = state.agents.filter((a) => a.fields.some((f) => f.value));
const rows = showAllAgents || !used.length ? state.agents : used;
for (const a of rows) {
const row = el("div", "row agent");
row.dataset.id = a.id;
row.title = a.path;
@@ -164,6 +169,12 @@ function renderAgents() {
row.append(icon(a.icon), who, fields);
list.append(row);
}
if (used.length && used.length < state.agents.length) {
const n = state.agents.length - used.length;
const more = el("button", "agent-more", showAllAgents ? t("Show less") : t("Show {n} more", { n }));
more.onclick = () => { showAllAgents = !showAllAgents; renderAgents(); };
list.append(more);
}
const chips = $("#profiles");
chips.replaceChildren();
+2
View File
@@ -19,6 +19,8 @@ const I18N = {
// agents
"No agents found": "没有找到 Agent",
"Install Claude Code, Codex, Gemini CLI, OpenCode… and magpie will list them here.": "安装 Claude Code、Codex、Gemini CLI、OpenCode…… 之后,magpie 会在这里列出它们。",
"Show {n} more": "显示其余 {n} 个",
"Show less": "收起",
"model": "模型",
"effort": "推理强度",
"thinking": "思考",