feat(maestro): multi-view web UI — splits, tabs, drag-dock, highlights
ci / rust (push) Successful in 5m46s
ci / rust (push) Successful in 5m46s
Render the content pane as tabs of nested split trees, each session leaf a live attach mounted through the multi-mount pool: - #30 arbitrarily-nested H/V splits with mouse-resizable dividers; per-pane ⏻/▥/▤/✕ tools; closing a pane collapses its parent split. - #31 tabs, each holding its own tree; add / switch / close. - #32 drag-to-dock: drag a pane title or a sidebar session onto a pane for a 5-zone dock (edges split, centre swaps/replaces); a sidebar drag moves an already-open session. - #33 focused pane at full strength, others dim; sidebar shows focused (loud) vs open-elsewhere (quiet) with a stable per-session colour mapping rows to panes. Opening a session fills the focused pane (single-pane parity by default); multi-pane is opt-in via split / drag / tabs. Panes auto-close when their session ends (guarded against eviction and intentional close). The steady "connected" label is hidden as noise. Closes #30, #31, #32, #33. Part of epic #37. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+58
-15
@@ -337,12 +337,24 @@ export function renderTopbar(store: CatalogStore): HTMLElement {
|
||||
return header;
|
||||
}
|
||||
|
||||
/** Two-tier sidebar highlight state (issue #33): which sessions are open in some
|
||||
* pane (quiet), which one is focused (loud), and a stable per-session colour so
|
||||
* a row maps to its pane. */
|
||||
export interface SidebarHighlights {
|
||||
open: Set<string>;
|
||||
focused: string | null;
|
||||
colors: Map<string, string>;
|
||||
}
|
||||
|
||||
/** 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. */
|
||||
/** Highlight the row for `id` (or clear it with `null`) as the focused session.
|
||||
* Back-compat shim over {@link setHighlights}. */
|
||||
setActive(id: string | null): void;
|
||||
/** Apply the full open/focused/colour highlight state. */
|
||||
setHighlights(h: SidebarHighlights): void;
|
||||
/** Tear down the store subscription + listeners. */
|
||||
dispose(): void;
|
||||
}
|
||||
@@ -354,7 +366,13 @@ export interface SidebarHandle {
|
||||
* 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 {
|
||||
export interface SidebarOptions {
|
||||
/** Pointerdown on a session row — the multi-view controller decides drag vs
|
||||
* tap (issue #32). Tap falls through to the row's normal click (open). */
|
||||
onLeafDrag?: (sessionId: string, e: PointerEvent) => void;
|
||||
}
|
||||
|
||||
export function renderSidebar(store: CatalogStore, opts: SidebarOptions = {}): SidebarHandle {
|
||||
const el = document.createElement("aside");
|
||||
el.className = "sidebar";
|
||||
|
||||
@@ -378,6 +396,21 @@ export function renderSidebar(store: CatalogStore): SidebarHandle {
|
||||
treeHost.className = "tree";
|
||||
el.appendChild(treeHost);
|
||||
|
||||
// Drag a session row into the canvas (issue #32). Delegated so it survives
|
||||
// tree re-renders; the controller handles drag-vs-tap (tap still navigates).
|
||||
treeHost.addEventListener("pointerdown", (e) => {
|
||||
if (e.button !== 0 || !opts.onLeafDrag) return;
|
||||
const leaf = (e.target as HTMLElement).closest<HTMLElement>(".tree-leaf");
|
||||
const id = leaf?.dataset.sessionId;
|
||||
if (id) opts.onLeafDrag(id, e);
|
||||
});
|
||||
// The rows are <a> elements, so the browser's native link drag-and-drop would
|
||||
// otherwise hijack pointermove and our live drop-zone preview wouldn't show
|
||||
// until release. Suppress it so the pointer-based drag runs from the start.
|
||||
treeHost.addEventListener("dragstart", (e) => {
|
||||
if ((e.target as HTMLElement).closest(".tree-leaf")) e.preventDefault();
|
||||
});
|
||||
|
||||
// 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";
|
||||
@@ -425,16 +458,18 @@ export function renderSidebar(store: CatalogStore): SidebarHandle {
|
||||
refresh();
|
||||
});
|
||||
|
||||
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");
|
||||
let highlights: SidebarHighlights = { open: new Set(), focused: null, colors: new Map() };
|
||||
const applyHighlights = () => {
|
||||
for (const n of treeHost.querySelectorAll<HTMLElement>(".tree-leaf")) {
|
||||
const id = n.dataset.sessionId;
|
||||
if (!id) continue;
|
||||
const focused = highlights.focused === id;
|
||||
const open = highlights.open.has(id);
|
||||
n.classList.toggle("is-active", focused);
|
||||
n.classList.toggle("is-open", open && !focused);
|
||||
const color = highlights.colors.get(id);
|
||||
if (color && (open || focused)) n.style.setProperty("--mv-color", color);
|
||||
else n.style.removeProperty("--mv-color");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -455,7 +490,7 @@ export function renderSidebar(store: CatalogStore): SidebarHandle {
|
||||
if (tree.kind === "folder") {
|
||||
for (const child of tree.children) treeHost.appendChild(renderNode(child, 0));
|
||||
}
|
||||
applyActive();
|
||||
applyHighlights();
|
||||
};
|
||||
|
||||
const rerenderHandler = () => refresh();
|
||||
@@ -484,8 +519,16 @@ export function renderSidebar(store: CatalogStore): SidebarHandle {
|
||||
return {
|
||||
el,
|
||||
setActive(id: string | null) {
|
||||
activeId = id;
|
||||
applyActive();
|
||||
highlights = {
|
||||
open: id ? new Set([id]) : new Set(),
|
||||
focused: id,
|
||||
colors: new Map(),
|
||||
};
|
||||
applyHighlights();
|
||||
},
|
||||
setHighlights(h: SidebarHighlights) {
|
||||
highlights = h;
|
||||
applyHighlights();
|
||||
},
|
||||
dispose() {
|
||||
document.removeEventListener("catalog-rerender", rerenderHandler);
|
||||
|
||||
Reference in New Issue
Block a user