feat(web-hud): seed default layout with orchestration widgets
All checks were successful
ci/woodpecker/push/web Pipeline was successful

This commit is contained in:
Jason Woltje
2026-02-17 16:07:09 -06:00
parent d34f097a5c
commit ab902250f8
2 changed files with 78 additions and 6 deletions

View File

@@ -14,6 +14,70 @@ const DEFAULT_LAYOUT_NAME = "default";
*/
const WORKSPACE_KEY = "mosaic-workspace-id";
function createDefaultLayout(): LayoutConfig {
return {
id: DEFAULT_LAYOUT_NAME,
name: "Default Layout",
layout: [
{
i: "tasks-1",
x: 0,
y: 0,
w: 2,
h: 3,
minW: 1,
minH: 2,
isDraggable: true,
isResizable: true,
},
{
i: "calendar-1",
x: 2,
y: 0,
w: 2,
h: 2,
minW: 1,
minH: 2,
isDraggable: true,
isResizable: true,
},
{
i: "agent-status-1",
x: 2,
y: 2,
w: 2,
h: 2,
minW: 1,
minH: 1,
isDraggable: true,
isResizable: true,
},
{
i: "orchestrator-events-1",
x: 0,
y: 3,
w: 2,
h: 2,
minW: 1,
minH: 1,
isDraggable: true,
isResizable: true,
},
{
i: "quick-capture-1",
x: 2,
y: 4,
w: 2,
h: 1,
minW: 1,
minH: 1,
isDraggable: true,
isResizable: true,
},
],
};
}
interface UseLayoutReturn {
layouts: Record<string, LayoutConfig>;
currentLayout: LayoutConfig | undefined;
@@ -45,7 +109,18 @@ export function useLayout(): UseLayoutReturn {
if (stored) {
const emptyFallback: Record<string, LayoutConfig> = {};
const parsed = safeJsonParse(stored, isLayoutConfigRecord, emptyFallback);
setLayouts(parsed as Record<string, LayoutConfig>);
const parsedLayouts = parsed as Record<string, LayoutConfig>;
if (Object.keys(parsedLayouts).length > 0) {
setLayouts(parsedLayouts);
} else {
setLayouts({
[DEFAULT_LAYOUT_NAME]: createDefaultLayout(),
});
}
} else {
setLayouts({
[DEFAULT_LAYOUT_NAME]: createDefaultLayout(),
});
}
// Load current layout ID preference
@@ -195,11 +270,7 @@ export function useLayout(): UseLayoutReturn {
const resetLayout = useCallback(() => {
setLayouts({
[DEFAULT_LAYOUT_NAME]: {
id: DEFAULT_LAYOUT_NAME,
name: "Default Layout",
layout: [],
},
[DEFAULT_LAYOUT_NAME]: createDefaultLayout(),
});
setCurrentLayoutId(DEFAULT_LAYOUT_NAME);
}, []);