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.

1.1 KB
Raw Blame
"use client";

import { useCallback, useState } from "react";
import { usePathname } from "next/navigation";
import type { AppDescriptor } from "../lib/types";

// URL → "show Home (no app pane)?" derivation, shared by the iOS / Android /
// Dashboard shells. A pathname naming an app slug shows that app's pane (UrlSync
// opens/focuses its window in the store); user gestures override, keyed to the
// pathname they were made at, so the derivation wins again when the URL actually
// changes — no effect-driven setState (react-hooks/set-state-in-effect).
export function useUrlHome(apps: AppDescriptor[]) {
  const pathname = usePathname();
  const urlSlug = pathname.split("/").filter(Boolean)[0];
  const urlIsApp = !!urlSlug && apps.some((a) => (a.slug ?? a.id) === urlSlug);
  const [homeChoice, setHomeChoice] = useState<{ key: string; home: boolean } | null>(null);
  const home = homeChoice?.key === pathname ? homeChoice.home : !urlIsApp;
  const setHome = useCallback(
    (h: boolean) => setHomeChoice({ key: pathname, home: h }),
    [pathname],
  );
  return { home, setHome };
}