Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

1.4 KB
Raw Blame
import { Suspense, type ReactNode } from "react";
import { useLocation, useNavigation } from "react-router";

import { Skeleton } from "@/components/ui/skeleton";
import { useT } from "@/i18n/use-translation";
import { routeLayoutKey } from "./route-layout-key";
import { shellExtrasMessages as m } from "./shell-extras.messages";

function ContentLoading() {
  const t = useT();
  return (
    <div
      role="status"
      aria-label={t(m.loadingContent)}
      aria-busy="true"
      className="route-loading-surface min-w-0 flex-1 space-y-4 p-6"
    >
      <span className="sr-only">{t(m.loadingContentStatus)}</span>
      <Skeleton className="h-6 w-40" />
      <Skeleton className="h-24 w-full" />
    </div>
  );
}

const CONTENT_LOADING = <ContentLoading />;

/** Secondary navigation survives both route-module and query loading. */
export function RouteContentBoundary({ children }: { children: ReactNode }) {
  const location = useLocation();
  const navigation = useNavigation();
  const next = navigation.location?.pathname;
  const changingContent =
    navigation.state !== "idle" &&
    next !== undefined &&
    next !== location.pathname &&
    routeLayoutKey(next) === routeLayoutKey(location.pathname);
  return changingContent ? (
    CONTENT_LOADING
  ) : (
    <Suspense key={location.pathname} fallback={CONTENT_LOADING}>
      {children}
    </Suspense>
  );
}