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.

886 B
Raw Blame
"use client";

import { useMemo, type ReactNode } from "react";
import { HostApiProvider } from "@/features/appshell";
import { useSession } from "@/features/auth";
import { useAppearance } from "@/lib/appearance";
import { IS_DEMO } from "@/lib/demo";
import { HttpAdapter } from "@/lib/os-api/http-adapter";
import { MockAdapter } from "@/lib/os-api/mock-adapter";

/** MSO composition: choose mock/live adapter, then inject the generic host port. */
export function OsApiProvider({ children }: { children: ReactNode }) {
  const { tweaks } = useAppearance();
  const { status, role } = useSession();
  const mode = IS_DEMO || status !== "in" ? "mock" : tweaks.server.mode;
  const api = useMemo(
    () => (mode === "live" ? HttpAdapter({ url: "", role: role ?? "viewer" }) : MockAdapter()),
    [mode, role],
  );
  return <HostApiProvider api={api}>{children}</HostApiProvider>;
}