feat(maestro): terminal-native web UI pass + design kit
ci / rust (push) Successful in 4m26s

Live-review iteration on the browser SPA, driven by crit feedback.

Sidebar / session tree
- Compact single-line leaf rows; status shown as a faint "alive" row wash
  instead of per-row dots (exited rows dim + keep the "exited" badge).
- Host is now the first level of nesting (host → label path → session); the
  inline @daemon is dropped from rows.
- Flush, borderless search input spanning the sidebar; drag-to-resize grip on
  the sidebar edge (width persisted to localStorage); narrower default.
- Per-row clone action (opens the spawn modal prefilled); right-pointing
  chevron when collapsed.

Chrome / layout
- Buttons swapped to a bracket terminal style ([ + Spawn ]); ghost/icon drop
  the brackets. Old filled styles removed.
- Squared corners globally (radius tokens) and tighter, denser spacing.
- Session tally + daemon chips moved into the centered app header.
- Shorter control height; shared --bar-h aligns the search and attach bars.

Attach / terminal
- Useful attach title (name · command @ host) over a bare UUID.
- Robust fit: compute columns from the viewport's scrollbar-excluded
  clientWidth (fixes mobile under-fit and desktop overflow); ResizeObserver +
  font-load refit; full-bleed terminal on mobile.

Spawn / empty states
- Spawn modal accepts a prefill (clone); real "+ Spawn" buttons in welcome and
  no-sessions empty states.

Dev
- New ?kit design-kit page (kit.ts/kit.css, DEV-only) showcasing components.
- Richer ?mock fixture with deeper label nesting.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-20 12:11:43 +00:00
co-authored by Claude Opus 4.8
parent eb2162889e
commit c02ff02849
9 changed files with 1130 additions and 164 deletions
+119 -21
View File
@@ -34,11 +34,15 @@ function buildTree(sessions: Session[], filter: string): TreeNode {
for (const s of sessions) {
if (lc) {
const haystack = `${sessionName(s)} ${sessionLabel(s) ?? ""}`.toLowerCase();
const haystack =
`${s.daemon_id} ${sessionName(s)} ${sessionLabel(s) ?? ""}`.toLowerCase();
if (!haystack.includes(lc)) continue;
}
const label = sessionLabel(s);
const parts = label ? label.split("/").filter(Boolean) : [];
// Host is the first level of nesting; the label path nests beneath it, so
// the daemon no longer needs to ride along on each leaf.
const labelParts = label ? label.split("/").filter(Boolean) : [];
const parts = [s.daemon_id, ...labelParts];
let cursor = root;
for (const part of parts) {
const path = cursor.path ? `${cursor.path}/${part}` : part;
@@ -74,7 +78,9 @@ function renderNode(node: TreeNode, depth: number): HTMLElement {
header.style.paddingLeft = `${depth * 16}px`;
const isCollapsed = collapsed.has(node.path);
header.setAttribute("aria-expanded", String(!isCollapsed));
header.innerHTML = `<span class="chevron">${isCollapsed ? "▸" : "▾"}</span><span class="folder-name">${escapeHtml(node.name)}</span><span class="folder-count">${countLeaves(node)}</span>`;
// 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>`;
header.addEventListener("click", () => {
if (collapsed.has(node.path)) collapsed.delete(node.path);
else collapsed.add(node.path);
@@ -104,18 +110,25 @@ function renderNode(node: TreeNode, depth: number): HTMLElement {
"aria-label",
`${name}, ${running ? "running" : "exited"}, on daemon ${s.daemon_id}`,
);
// The host is now the enclosing folder, so only surface the command — and
// only when it isn't already what the name shows.
const showCmd = s.command !== name;
row.innerHTML = `
<span class="leaf-status" aria-hidden="true"></span>
<span class="leaf-main">
<span class="leaf-name">${escapeHtml(name)}</span>
<span class="leaf-meta">
<span class="leaf-daemon">${escapeHtml(s.daemon_id)}</span>
<span class="leaf-cmd">${escapeHtml(s.command)}</span>
</span>
</span>
<span class="leaf-name">${escapeHtml(name)}</span>
${showCmd ? `<span class="leaf-meta"><span class="leaf-cmd">${escapeHtml(s.command)}</span></span>` : ""}
${running ? "" : `<span class="leaf-badge">exited</span>`}
<button class="leaf-kill" type="button" title="Kill session" aria-label="Kill ${escapeHtml(name)}">✕</button>
<span class="leaf-actions">
<button class="leaf-act leaf-clone" type="button" title="Clone into a new session" aria-label="Clone ${escapeHtml(name)}">⧉</button>
<button class="leaf-act leaf-kill" type="button" title="Kill session" aria-label="Kill ${escapeHtml(name)}">✕</button>
</span>
`;
const cloneBtn = row.querySelector(".leaf-clone") as HTMLButtonElement;
cloneBtn.addEventListener("click", (ev) => {
ev.preventDefault();
ev.stopPropagation();
// The sidebar (which has the daemon list) opens the prefilled spawn modal.
document.dispatchEvent(new CustomEvent("catalog-clone", { detail: s }));
});
const killBtn = row.querySelector(".leaf-kill") as HTMLButtonElement;
killBtn.addEventListener("click", async (ev) => {
ev.preventDefault();
@@ -179,7 +192,11 @@ function renderStatusbar(daemons: DaemonInfo[], sessions: Session[]): HTMLElemen
return wrap;
}
function renderEmpty(noDaemons: boolean, filtering: boolean): HTMLElement {
function renderEmpty(
noDaemons: boolean,
filtering: boolean,
onSpawn: () => void,
): HTMLElement {
const el = document.createElement("div");
el.className = "empty";
if (filtering) {
@@ -200,7 +217,14 @@ function renderEmpty(noDaemons: boolean, filtering: boolean): HTMLElement {
el.innerHTML = `
<div class="empty-glyph" aria-hidden="true">+</div>
<div class="empty-title">No sessions yet</div>
<p class="empty-hint">Press <kbd>+ Spawn</kbd> to start your first session.</p>`;
<p class="empty-hint">Start your first session — it'll show up here.</p>
<div class="empty-actions"></div>`;
const spawn = document.createElement("button");
spawn.type = "button";
spawn.className = "btn btn-primary";
spawn.textContent = "+ Spawn session";
spawn.addEventListener("click", onSpawn);
(el.querySelector(".empty-actions") as HTMLElement).appendChild(spawn);
return el;
}
@@ -217,9 +241,32 @@ export function renderTopbar(store: CatalogStore): HTMLElement {
<span class="brand-dot" aria-hidden="true"></span>
<h1>maestro<span class="blink" aria-hidden="true">_</span></h1>
</a>
<div class="app-status"></div>
<div class="app-actions"></div>
`;
// Session tally + daemon chips live centered in the header (not the sidebar).
const statusHost = header.querySelector(".app-status") as HTMLElement;
const renderStatus = () => {
const state = store.snapshot();
statusHost.replaceChildren(
renderStatusbar([...state.daemons.values()], [...state.sessions.values()]),
);
};
store.subscribe(renderStatus);
renderStatus();
const actions = header.querySelector(".app-actions") as HTMLElement;
// DEV-only shortcut to the standalone design kit (?kit). Lets you reach it by
// clicking inside a proxied preview (e.g. crit live) that has no address bar.
if (import.meta.env.DEV) {
const kit = document.createElement("a");
kit.className = "btn btn-ghost";
kit.href = "?kit";
kit.textContent = "kit";
kit.title = "Open the design kit (DEV)";
actions.appendChild(kit);
}
actions.appendChild(createThemeToggle());
const spawnBtn = document.createElement("button");
spawnBtn.type = "button";
@@ -269,13 +316,50 @@ export function renderSidebar(store: CatalogStore): SidebarHandle {
`;
el.appendChild(searchHeader);
const statusHost = document.createElement("div");
el.appendChild(statusHost);
const treeHost = document.createElement("div");
treeHost.className = "tree";
el.appendChild(treeHost);
// Drag-to-resize handle on the sidebar's right edge. Persists the chosen
// width as a :root CSS var the shell grid reads; clamped to a sane range.
const SIDEBAR_W_KEY = "maestro-sidebar-w";
const storedW = localStorage.getItem(SIDEBAR_W_KEY);
if (storedW) document.documentElement.style.setProperty("--sidebar-w", storedW);
const handle = document.createElement("div");
handle.className = "sidebar-resize";
handle.setAttribute("aria-hidden", "true");
el.appendChild(handle);
let dragStartX = 0;
let dragStartW = 0;
let dragging = false;
handle.addEventListener("pointerdown", (e) => {
dragging = true;
dragStartX = e.clientX;
dragStartW = el.getBoundingClientRect().width;
handle.setPointerCapture(e.pointerId);
document.body.style.userSelect = "none";
e.preventDefault();
});
handle.addEventListener("pointermove", (e) => {
if (!dragging) return;
const w = Math.max(200, Math.min(560, dragStartW + (e.clientX - dragStartX)));
document.documentElement.style.setProperty("--sidebar-w", `${w}px`);
});
const endDrag = (e: PointerEvent) => {
if (!dragging) return;
dragging = false;
try {
handle.releasePointerCapture(e.pointerId);
} catch {
// pointer may already be released
}
document.body.style.userSelect = "";
const cur = document.documentElement.style.getPropertyValue("--sidebar-w");
if (cur) localStorage.setItem(SIDEBAR_W_KEY, cur);
};
handle.addEventListener("pointerup", endDrag);
handle.addEventListener("pointercancel", endDrag);
const search = searchHeader.querySelector(".search") as HTMLInputElement;
let filter = "";
search.addEventListener("input", () => {
@@ -299,14 +383,13 @@ export function renderSidebar(store: CatalogStore): SidebarHandle {
const refresh = () => {
const state = store.snapshot();
const sessions = [...state.sessions.values()];
statusHost.replaceChildren(
renderStatusbar([...state.daemons.values()], sessions),
);
const tree = buildTree(sessions, filter);
treeHost.replaceChildren();
if (sessions.length === 0) {
treeHost.appendChild(
renderEmpty(state.daemons.size === 0, filter.trim().length > 0),
renderEmpty(state.daemons.size === 0, filter.trim().length > 0, () =>
openSpawnModal(store.snapshot().daemons),
),
);
return;
}
@@ -319,6 +402,20 @@ export function renderSidebar(store: CatalogStore): SidebarHandle {
const rerenderHandler = () => refresh();
document.addEventListener("catalog-rerender", rerenderHandler);
// Clone a session: reopen the spawn modal prefilled with its options.
const cloneHandler = (ev: Event) => {
const s = (ev as CustomEvent<Session>).detail;
const rawName = typeof s.metadata?.name === "string" ? s.metadata.name : "";
openSpawnModal(store.snapshot().daemons, {
daemon_id: s.daemon_id,
cwd: s.cwd,
command: s.command,
name: rawName,
label: sessionLabel(s) ?? "",
});
};
document.addEventListener("catalog-clone", cloneHandler);
const unsubscribe = store.subscribe(refresh);
return {
@@ -329,6 +426,7 @@ export function renderSidebar(store: CatalogStore): SidebarHandle {
},
dispose() {
document.removeEventListener("catalog-rerender", rerenderHandler);
document.removeEventListener("catalog-clone", cloneHandler);
unsubscribe();
},
};