Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

5.3 KB
Raw Blame
import { type LucideIcon } from 'lucide-react';
import {
  BrainCircuit,
  FilePenIcon,
  FolderKanbanIcon,
  Image,
  LayoutDashboardIcon,
  LayoutGridPlus,
  LibraryBigIcon,
  ListTodoIcon,
  Settings,
  TargetIcon,
  Video,
} from 'lucide-react';

export interface NavigationRoute {
  /** CMDK i18n key in common namespace */
  cmdkKey: string;
  /** Electron i18n key in electron namespace */
  electronKey: string;
  /** Route icon component */
  icon: LucideIcon;
  /** Unique route identifier */
  id: string;
  /** Keywords for CMDK search (fallback) */
  keywords?: string[];
  /** i18n key for CMDK keywords in common namespace */
  keywordsKey?: string;
  /** Route path */
  path: string;
  /** Path prefix for checking current location */
  pathPrefix: string;
  /** Whether route supports dynamic titles (for specific items) */
  useDynamicTitle?: boolean;
}

/**
 * Shared navigation route configuration
 * Used by both Electron navigation and CommandMenu (CMDK)
 */
export const NAVIGATION_ROUTES: NavigationRoute[] = [
  {
    // Same label as the sidebar entry (common:tab.marketplace) in every locale.
    cmdkKey: 'tab.marketplace',
    electronKey: 'navigation.marketplace',
    icon: LayoutGridPlus,
    id: 'community',
    // "community" stays searchable for people who knew the page by its old name.
    keywords: [
      'marketplace',
      'market',
      'community',
      'discover',
      'agent',
      'skill',
      'connector',
      'model',
      'provider',
      'mcp',
    ],
    keywordsKey: 'cmdk.keywords.marketplace',
    path: '/marketplace',
    pathPrefix: '/marketplace',
  },
  {
    cmdkKey: 'cmdk.video',
    electronKey: 'navigation.video',
    icon: Video,
    id: 'video',
    keywords: ['video', 'generate', 'seedance', 'kling'],
    keywordsKey: 'cmdk.keywords.video',
    path: '/video',
    pathPrefix: '/video',
  },
  {
    cmdkKey: 'cmdk.painting',
    electronKey: 'navigation.image',
    icon: Image,
    id: 'image',
    keywords: ['painting', 'art', 'generate', 'draw'],
    keywordsKey: 'cmdk.keywords.painting',
    path: '/image',
    pathPrefix: '/image',
  },
  {
    cmdkKey: 'cmdk.resource',
    electronKey: 'navigation.resources',
    icon: LibraryBigIcon,
    id: 'resource',
    keywords: ['knowledge', 'files', 'library', 'documents'],
    keywordsKey: 'cmdk.keywords.resources',
    path: '/resource',
    pathPrefix: '/resource',
  },
  {
    cmdkKey: 'cmdk.pages',
    electronKey: 'navigation.pages',
    icon: FilePenIcon,
    id: 'page',
    keywords: ['documents', 'write', 'notes'],
    keywordsKey: 'cmdk.keywords.pages',
    path: '/page',
    pathPrefix: '/page',
    useDynamicTitle: true,
  },
  {
    cmdkKey: 'cmdk.memory',
    electronKey: 'navigation.memory',
    icon: BrainCircuit,
    id: 'memory',
    keywords: ['identities', 'contexts', 'preferences', 'experiences'],
    keywordsKey: 'cmdk.keywords.memory',
    path: '/memory',
    pathPrefix: '/memory',
  },
  {
    cmdkKey: 'cmdk.tasks',
    electronKey: 'navigation.tasks',
    icon: ListTodoIcon,
    id: 'tasks',
    keywords: ['tasks', 'todo', 'agent', 'kanban'],
    keywordsKey: 'cmdk.keywords.tasks',
    path: '/tasks',
    pathPrefix: '/tasks',
  },
  {
    cmdkKey: 'tab.projects',
    electronKey: 'navigation.projects',
    icon: FolderKanbanIcon,
    id: 'project',
    keywords: ['projects', 'workspace', 'team'],
    path: '/projects',
    pathPrefix: '/project',
  },
  {
    cmdkKey: 'tab.goals',
    electronKey: 'navigation.goals',
    icon: TargetIcon,
    id: 'goals',
    keywords: ['goals', 'objective', 'target', 'agent'],
    path: '/goals',
    pathPrefix: '/goals',
  },
  {
    cmdkKey: 'tab.dashboard',
    electronKey: 'navigation.dashboard',
    icon: LayoutDashboardIcon,
    id: 'dashboard',
    keywords: ['dashboard', 'monitor', 'metrics', 'widget'],
    path: '/dashboard',
    pathPrefix: '/dashboard',
  },
  {
    cmdkKey: 'cmdk.settings',
    electronKey: 'navigation.settings',
    icon: Settings,
    id: 'settings',
    keywords: ['settings', 'preferences', 'configuration', 'options'],
    keywordsKey: 'cmdk.keywords.settings',
    path: '/settings',
    pathPrefix: '/settings',
  },
];

/**
 * Get route configuration by id
 */
export const getRouteById = (id: string): NavigationRoute | undefined =>
  NAVIGATION_ROUTES.find((r) => r.id === id);

/**
 * Get navigable routes for CMDK (excludes settings which has separate handling).
 *
 * Image and video share a single "Generation" destination in the app sidebar
 * (see useNavLayout's bottomMenuItems β†’ tab.generation β†’ /image), so the command
 * palette mirrors that: one "Generation" entry pointing at /image, instead of
 * separate "Image" / "AI Video" entries. The merged keywords keep both image and
 * video terms searchable, and reusing tab.generation keeps the label in sync with
 * the sidebar across every locale.
 */
export const getNavigableRoutes = (): NavigationRoute[] =>
  NAVIGATION_ROUTES.filter((r) =>
    ['community', 'image', 'resource', 'page', 'memory'].includes(r.id),
  ).map((r) =>
    r.id === 'image'
      ? {
          ...r,
          cmdkKey: 'tab.generation',
          keywords: [
            'generation',
            'generate',
            'image',
            'painting',
            'art',
            'draw',
            'video',
            'seedance',
            'kling',
          ],
          keywordsKey: undefined,
        }
      : r,
  );