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.4 KB
Raw Blame
import { useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';

import { SETTINGS_LANDING_PATH } from '@/lib/adminNavigation';
import {
  DESKTOP_OPEN_SETTINGS_EVENT,
  DESKTOP_OPEN_SHORTCUT_SETTINGS_EVENT,
  isDesktopShell,
} from '@/lib/desktopShell';

/**
 * Answers the desktop shell's Settings… menu item. It navigates like the
 * sidebar's own Settings control, so the Settings overlay boundary it renders
 * under records the covered surface and leaving Settings returns to it. Mount it
 * inside `SettingsOverlayNavigationBoundary`.
 */
export const DesktopSettingsCommand = () => {
  const navigate = useNavigate();
  const { pathname } = useLocation();

  useEffect(() => {
    if (!isDesktopShell()) return undefined;
    const open = (event: Event) => {
      event.preventDefault();
      if (pathname !== SETTINGS_LANDING_PATH) navigate(SETTINGS_LANDING_PATH);
    };
    const openShortcuts = (event: Event) => {
      event.preventDefault();
      if (pathname !== '/settings/shortcuts') navigate('/settings/shortcuts');
    };
    window.addEventListener(DESKTOP_OPEN_SETTINGS_EVENT, open);
    window.addEventListener(DESKTOP_OPEN_SHORTCUT_SETTINGS_EVENT, openShortcuts);
    return () => {
      window.removeEventListener(DESKTOP_OPEN_SETTINGS_EVENT, open);
      window.removeEventListener(DESKTOP_OPEN_SHORTCUT_SETTINGS_EVENT, openShortcuts);
    };
  }, [navigate, pathname]);

  return null;
};