Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

1.1 KB
Raw Blame
import * as React from 'react';
import { Navigate, useLocation } from 'react-router-dom';

import { isChromelessShellPath, settingsOverlayOriginFromState } from '@/lib/settingsOverlay';
import { useModelHubCapability } from './useModelHubCapability';
import { modelHubDisabledRedirect } from './modelHubRoutes';

export const ModelHubRenderBoundary: React.FC<{
  enabled: boolean | null;
  disabled?: React.ReactNode;
  children: React.ReactNode;
}> = ({ enabled, disabled = null, children }) => {
  if (enabled === null) return null;
  return enabled ? children : disabled;
};

export const ModelHubCapabilityGate: React.FC<{ children: React.ReactNode }> = ({ children }) => {
  const enabled = useModelHubCapability();
  const location = useLocation();
  const overSetup = isChromelessShellPath(
    settingsOverlayOriginFromState(location.state)?.location.pathname ?? '',
  );
  return (
    <ModelHubRenderBoundary
      enabled={enabled}
      disabled={<Navigate to={modelHubDisabledRedirect(overSetup)} replace state={location.state} />}
    >
      {children}
    </ModelHubRenderBoundary>
  );
};