feat(maestro): web UI persistent sidebar + content split w/ background connection pool (NAP-338)
ci / rust (push) Successful in 5m24s
ci / rust (push) Successful in 5m24s
Replace the full-screen route-swap SPA with a persistent two-pane layout: - Global top bar (brand + Spawn + theme) above a sidebar (search + status + session tree, highlights the active session) and a content pane (welcome or the attached terminal). Selecting a row swaps only the content pane; the sidebar and its store subscription persist. - New `connections.ts` ConnectionPool: attach connections (terminal + WS) are decoupled from the UI — navigating away parks a session (keeps it streaming) rather than tearing it down, so switching back is instant with scrollback intact. LRU-bounded (MAX_LIVE=6); explicit `⏻` disconnect distinct from nav. - `attach.ts` → mountable `createAttachConnection`; `catalog.ts` exposes `renderTopbar` + `renderSidebar`; `main.ts` is the shell + hash router. - Responsive: desktop side-by-side; mobile single-pane (list ↔ terminal). Single session viewed at a time (split panes deferred). Typecheck + production build green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+79
-35
@@ -204,61 +204,97 @@ function renderEmpty(noDaemons: boolean, filtering: boolean): HTMLElement {
|
||||
return el;
|
||||
}
|
||||
|
||||
export function renderCatalog(root: HTMLElement, store: CatalogStore): () => void {
|
||||
root.innerHTML = "";
|
||||
|
||||
const shell = document.createElement("div");
|
||||
shell.className = "catalog";
|
||||
|
||||
/**
|
||||
* The global app header (full width, above the sidebar/content split): brand +
|
||||
* the app-level actions (spawn, theme toggle). Kept out of the sidebar so these
|
||||
* stay put and reachable regardless of which pane is showing.
|
||||
*/
|
||||
export function renderTopbar(store: CatalogStore): HTMLElement {
|
||||
const header = document.createElement("header");
|
||||
header.className = "catalog-header";
|
||||
header.className = "app-header";
|
||||
header.innerHTML = `
|
||||
<div class="brand">
|
||||
<a class="brand" href="#/" aria-label="maestro — clear selection">
|
||||
<span class="brand-dot" aria-hidden="true"></span>
|
||||
<h1>maestro<span class="blink" aria-hidden="true">_</span></h1>
|
||||
</div>
|
||||
<div class="catalog-actions">
|
||||
<input
|
||||
type="search"
|
||||
class="search"
|
||||
placeholder="Search sessions…"
|
||||
aria-label="Search sessions"
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
<div class="app-actions"></div>
|
||||
`;
|
||||
shell.appendChild(header);
|
||||
|
||||
const actions = header.querySelector(".catalog-actions") as HTMLElement;
|
||||
const actions = header.querySelector(".app-actions") as HTMLElement;
|
||||
actions.appendChild(createThemeToggle());
|
||||
const spawnBtn = document.createElement("button");
|
||||
spawnBtn.type = "button";
|
||||
spawnBtn.className = "btn btn-primary spawn-btn";
|
||||
spawnBtn.textContent = "+ Spawn";
|
||||
spawnBtn.addEventListener("click", () => {
|
||||
openSpawnModal(store.snapshot().daemons);
|
||||
});
|
||||
actions.appendChild(spawnBtn);
|
||||
return header;
|
||||
}
|
||||
|
||||
/** Live handle to the persistent sidebar (built once, survives navigation). */
|
||||
export interface SidebarHandle {
|
||||
/** The `<aside>` element to mount into the shell. */
|
||||
el: HTMLElement;
|
||||
/** Highlight the row for `id` (or clear it with `null`) as the open session. */
|
||||
setActive(id: string | null): void;
|
||||
/** Tear down the store subscription + listeners. */
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the persistent session sidebar: brand, search, spawn, theme toggle, a
|
||||
* live daemon/session status line, and the folder-grouped session tree. Unlike
|
||||
* the old full-screen catalog this is mounted once by the shell and stays put
|
||||
* while the content pane swaps between sessions — so the store subscription and
|
||||
* scroll position survive navigation. The active session is highlighted.
|
||||
*/
|
||||
export function renderSidebar(store: CatalogStore): SidebarHandle {
|
||||
const el = document.createElement("aside");
|
||||
el.className = "sidebar";
|
||||
|
||||
const searchHeader = document.createElement("header");
|
||||
searchHeader.className = "sidebar-search";
|
||||
searchHeader.innerHTML = `
|
||||
<input
|
||||
type="search"
|
||||
class="search"
|
||||
placeholder="Search sessions…"
|
||||
aria-label="Search sessions"
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
`;
|
||||
el.appendChild(searchHeader);
|
||||
|
||||
const statusHost = document.createElement("div");
|
||||
shell.appendChild(statusHost);
|
||||
el.appendChild(statusHost);
|
||||
|
||||
const treeHost = document.createElement("div");
|
||||
treeHost.className = "tree";
|
||||
shell.appendChild(treeHost);
|
||||
el.appendChild(treeHost);
|
||||
|
||||
root.appendChild(shell);
|
||||
|
||||
const search = header.querySelector(".search") as HTMLInputElement;
|
||||
const search = searchHeader.querySelector(".search") as HTMLInputElement;
|
||||
let filter = "";
|
||||
search.addEventListener("input", () => {
|
||||
filter = search.value;
|
||||
refresh();
|
||||
});
|
||||
|
||||
spawnBtn.addEventListener("click", () => {
|
||||
openSpawnModal(store.snapshot().daemons);
|
||||
});
|
||||
let activeId: string | null = null;
|
||||
const applyActive = () => {
|
||||
for (const n of treeHost.querySelectorAll(".tree-leaf.is-active")) {
|
||||
n.classList.remove("is-active");
|
||||
}
|
||||
if (activeId) {
|
||||
const row = treeHost.querySelector(
|
||||
`.tree-leaf[data-session-id="${CSS.escape(activeId)}"]`,
|
||||
);
|
||||
row?.classList.add("is-active");
|
||||
}
|
||||
};
|
||||
|
||||
const refresh = () => {
|
||||
const state = store.snapshot();
|
||||
@@ -277,6 +313,7 @@ export function renderCatalog(root: HTMLElement, store: CatalogStore): () => voi
|
||||
if (tree.kind === "folder") {
|
||||
for (const child of tree.children) treeHost.appendChild(renderNode(child, 0));
|
||||
}
|
||||
applyActive();
|
||||
};
|
||||
|
||||
const rerenderHandler = () => refresh();
|
||||
@@ -284,8 +321,15 @@ export function renderCatalog(root: HTMLElement, store: CatalogStore): () => voi
|
||||
|
||||
const unsubscribe = store.subscribe(refresh);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener("catalog-rerender", rerenderHandler);
|
||||
unsubscribe();
|
||||
return {
|
||||
el,
|
||||
setActive(id: string | null) {
|
||||
activeId = id;
|
||||
applyActive();
|
||||
},
|
||||
dispose() {
|
||||
document.removeEventListener("catalog-rerender", rerenderHandler);
|
||||
unsubscribe();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user