feat(maestro): per-host session counts + abbreviated folder paths
ci / rust (push) Successful in 4m54s
ci / rust (push) Successful in 4m54s
Sidebar UI tweaks from a live crit review: - Statusbar: drop the redundant global "N sessions / N live" tally; each daemon chip now carries its own green per-host session-count badge (tabular-nums, dimmed when 0). - Session tree: deep folder paths collapse leading segments to initials and keep the trailing dir name (~/git.naps.pt/naps62/maestro -> ~/g/n/maestro), with the stem dimmed and the full path in the tooltip. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+30
-17
@@ -116,7 +116,10 @@ function renderNode(node: TreeNode, depth: number): HTMLElement {
|
||||
header.setAttribute("aria-expanded", String(!isCollapsed));
|
||||
// Single down-chevron; CSS rotates it -90° (→ right) when collapsed, so the
|
||||
// glyph and the rotation never fight each other.
|
||||
header.innerHTML = `<span class="chevron">▾</span><span class="folder-name">${escapeHtml(node.name)}</span><span class="folder-count">${countLeaves(node)}</span>`;
|
||||
// A deep path (`~/git.naps.pt/naps62/maestro`) collapses its leading
|
||||
// segments to initials (`~/g/n/maestro`) so the dir name stays readable in
|
||||
// a narrow sidebar; the full path lives in the tooltip.
|
||||
header.innerHTML = `<span class="chevron">▾</span><span class="folder-name" title="${escapeHtml(node.name)}">${abbreviateFolderName(node.name)}</span><span class="folder-count">${countLeaves(node)}</span>`;
|
||||
header.addEventListener("click", () => {
|
||||
if (collapsed.has(node.path)) collapsed.delete(node.path);
|
||||
else collapsed.add(node.path);
|
||||
@@ -185,6 +188,21 @@ function countLeaves(node: TreeNode): number {
|
||||
return node.children.reduce((n, c) => n + countLeaves(c), 0);
|
||||
}
|
||||
|
||||
/** `~/git.naps.pt/naps62/maestro` → `~/g/n/maestro`: keep the last segment
|
||||
* verbatim, collapse every earlier one to its first character. Two-or-fewer
|
||||
* segments are left alone (nothing to gain). Returns escaped HTML with the
|
||||
* collapsed stem wrapped so CSS can dim it. */
|
||||
function abbreviateFolderName(name: string): string {
|
||||
const parts = name.split("/");
|
||||
if (parts.length <= 2) return escapeHtml(name);
|
||||
const last = parts[parts.length - 1];
|
||||
const stem = parts
|
||||
.slice(0, -1)
|
||||
.map((p) => (p === "~" ? "~" : Array.from(p)[0] ?? ""))
|
||||
.join("/");
|
||||
return `<span class="folder-stem">${escapeHtml(stem)}/</span>${escapeHtml(last)}`;
|
||||
}
|
||||
|
||||
function escapeHtml(s: string): string {
|
||||
return s
|
||||
.replace(/&/g, "&")
|
||||
@@ -197,20 +215,12 @@ function renderStatusbar(daemons: DaemonInfo[], sessions: Session[]): HTMLElemen
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = "statusbar";
|
||||
|
||||
const total = sessions.length;
|
||||
const live = sessions.filter((s) => s.status === "Running").length;
|
||||
const tally = document.createElement("div");
|
||||
tally.className = "session-tally";
|
||||
tally.innerHTML =
|
||||
total === 0
|
||||
? `<span>No sessions</span>`
|
||||
: `<span><b>${total}</b> session${total === 1 ? "" : "s"}</span>` +
|
||||
`<span class="tally-live"><b>${live}</b> live</span>`;
|
||||
wrap.appendChild(tally);
|
||||
|
||||
const spacer = document.createElement("div");
|
||||
spacer.className = "spacer";
|
||||
wrap.appendChild(spacer);
|
||||
// Per-host session counts replace the old global "N sessions / N live" tally:
|
||||
// each daemon chip carries its own green count, so the tally was redundant.
|
||||
const counts = new Map<string, number>();
|
||||
for (const s of sessions) {
|
||||
counts.set(s.daemon_id, (counts.get(s.daemon_id) ?? 0) + 1);
|
||||
}
|
||||
|
||||
const daemonsWrap = document.createElement("div");
|
||||
daemonsWrap.className = "daemons";
|
||||
@@ -218,10 +228,13 @@ function renderStatusbar(daemons: DaemonInfo[], sessions: Session[]): HTMLElemen
|
||||
daemonsWrap.innerHTML = `<span class="daemon-empty">no daemons connected</span>`;
|
||||
} else {
|
||||
for (const d of daemons) {
|
||||
const n = counts.get(d.daemon_id) ?? 0;
|
||||
const chip = document.createElement("span");
|
||||
chip.className = "daemon-chip";
|
||||
chip.title = `${d.hostname} · ${d.daemon_url}`;
|
||||
chip.textContent = d.daemon_id;
|
||||
chip.title = `${d.hostname} · ${d.daemon_url} · ${n} session${n === 1 ? "" : "s"}`;
|
||||
chip.innerHTML =
|
||||
`<span class="daemon-name">${escapeHtml(d.daemon_id)}</span>` +
|
||||
`<b class="daemon-count${n === 0 ? " is-empty" : ""}">${n}</b>`;
|
||||
daemonsWrap.appendChild(chip);
|
||||
}
|
||||
}
|
||||
|
||||
+29
-29
@@ -618,34 +618,6 @@ textarea {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.session-tally {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-13);
|
||||
}
|
||||
|
||||
.session-tally b {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.tally-live {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.tally-live::before {
|
||||
content: "";
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: var(--live);
|
||||
box-shadow: 0 0 6px var(--live-glow);
|
||||
}
|
||||
|
||||
.statusbar .spacer {
|
||||
/* zero basis: claim leftover space without inflating the bar's min width */
|
||||
flex: 1 1 0;
|
||||
@@ -668,7 +640,7 @@ textarea {
|
||||
background: var(--surface-2);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-pill);
|
||||
padding: 3px var(--sp-3) 3px var(--sp-2);
|
||||
padding: 3px var(--sp-2) 3px var(--sp-2);
|
||||
font-size: var(--fs-12);
|
||||
color: var(--ink);
|
||||
}
|
||||
@@ -682,6 +654,27 @@ textarea {
|
||||
box-shadow: 0 0 5px var(--live-glow);
|
||||
}
|
||||
|
||||
/* Green session count baked into each host chip (replaces the global tally). */
|
||||
.daemon-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 17px;
|
||||
height: 17px;
|
||||
padding: 0 5px;
|
||||
border-radius: var(--r-pill);
|
||||
font-size: var(--fs-11);
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--live);
|
||||
background: color-mix(in srgb, var(--live) 16%, transparent);
|
||||
}
|
||||
|
||||
.daemon-count.is-empty {
|
||||
color: var(--muted);
|
||||
background: var(--surface-2);
|
||||
}
|
||||
|
||||
.daemon-empty {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -753,6 +746,7 @@ textarea {
|
||||
|
||||
.folder-name {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
color: var(--ink);
|
||||
font-size: var(--fs-14);
|
||||
font-weight: 500;
|
||||
@@ -761,6 +755,12 @@ textarea {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Earlier path segments collapse to their initial; the trailing segment (the
|
||||
one that actually names the dir) stays full. Dim the collapsed prefix. */
|
||||
.folder-name .folder-stem {
|
||||
color: var(--faint);
|
||||
}
|
||||
|
||||
.folder-count {
|
||||
font-size: var(--fs-11);
|
||||
color: var(--muted);
|
||||
|
||||
Reference in New Issue
Block a user