Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

905 B
Raw Blame
"use client";

import { useCallback, useState } from "react";
import { DEFAULT_LAYOUT, findLayout } from "./layout";

// Workspace layout preset id, persisted to localStorage. Read lazily on first
// client render — the reel app mounts client-side only (window bundles load
// post-hydration), so the initializer never runs during SSR markup.
export function useLayout(): [string, (id: string) => void] {
  const [layout, setLayoutState] = useState<string>(() => {
    if (typeof window === "undefined") return DEFAULT_LAYOUT;
    const v = localStorage.getItem("reel.layout");
    return v && findLayout(v).id === v ? v : DEFAULT_LAYOUT;
  });

  const setLayout = useCallback((id: string) => {
    setLayoutState(id);
    try {
      localStorage.setItem("reel.layout", id);
    } catch {
      /* private mode / quota — layout just won't persist */
    }
  }, []);

  return [layout, setLayout];
}