feat(maestro): persist multi-view layout per device
ci / rust (push) Successful in 5m21s

Save the layout tree (tabs + splits + focus + ratios) to localStorage,
debounced, on every structural/focus/resize change; restore it on boot. Load
rebuilds with fresh node ids and defensively drops malformed data — a corrupt or
versioned-out blob falls back to a single empty tab. Sessions that no longer
exist when restored aren't pruned eagerly (the session list isn't known at
boot); their panes attach, the broker closes the dead socket, and the pane
auto-closes.

Closes #34. Part of epic #37.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 09:24:57 +00:00
co-authored by Claude Opus 4.8
parent 159b7ecd6e
commit d272210ecd
3 changed files with 114 additions and 3 deletions
+8
View File
@@ -33,6 +33,9 @@ export interface MultiViewOptions {
onDisconnect: (sessionId: string) => void;
/** Welcome content for an empty tab. */
renderWelcome: () => HTMLElement;
/** Called after any layout change (structure, focus, or divider resize) so the
* shell can persist it (issue #34). */
onLayoutChange?: () => void;
}
export interface MultiView {
@@ -53,6 +56,7 @@ export interface MultiView {
export function createMultiView(opts: MultiViewOptions): MultiView {
const { pool, layout, sidebar, infoFor, onDisconnect, renderWelcome } = opts;
const persist = () => opts.onLayoutChange?.();
const el = document.createElement("div");
el.className = "mv";
@@ -96,6 +100,7 @@ export function createMultiView(opts: MultiViewOptions): MultiView {
if (tab.focusedLeafId === leafId) return;
tab.focusedLeafId = leafId;
syncFocus();
persist();
}
// ---- pane + split DOM ----
@@ -193,6 +198,7 @@ export function createMultiView(opts: MultiViewOptions): MultiView {
}
divider.removeEventListener("pointermove", move);
divider.removeEventListener("pointerup", up);
persist(); // save the new split ratio
};
divider.addEventListener("pointermove", move);
divider.addEventListener("pointerup", up);
@@ -320,6 +326,7 @@ export function createMultiView(opts: MultiViewOptions): MultiView {
pool.setFocus(null);
canvas.appendChild(renderWelcome());
sidebar.setHighlights({ open: openSessions(layout), focused: null, colors: colorMap() });
persist();
return;
}
@@ -332,6 +339,7 @@ export function createMultiView(opts: MultiViewOptions): MultiView {
canvas.appendChild(buildTree(tab.root, hosts));
pool.setVisible(hosts.map((h) => ({ id: h.id, pane: h.host, info: h.info })));
syncFocus();
persist();
}
function closeSession(sessionId: string): void {