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.

2.0 KB
Raw Blame
import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';
import { Divider, Flexbox } from '@lobehub/ui';
import { memo } from 'react';

import { useActiveLocation } from '@/hooks/useActiveLocation';
import { useDeferredMount } from '@/hooks/useDeferredMount';
import { electronStylish } from '@/styles/electron';
import { getPlatform } from '@/utils/platform';

import AutoEnrollWorkspaceDevice from '../connection/AutoEnrollWorkspaceDevice';
import Connection from '../connection/Connection';
import DeviceGateway from '../connection/DeviceGateway';
import { useWatchThemeUpdate } from '../system/useWatchThemeUpdate';
import { UpdateNotification } from '../updater/UpdateNotification';
import { getTitleBarLayoutConfig } from './layout';
import NavigationBar from './NavigationBar';
import { isStatusHidden } from './statusHidden';
import TabBar from './TabBar';
import WinControl from './WinControl';

const platform = getPlatform();

const TitleBar = memo(() => {
  useWatchThemeUpdate();
  const tabBarMounted = useDeferredMount();
  const statusHidden = isStatusHidden(useActiveLocation().pathname);

  const { padding, showCustomWinControl } = getTitleBarLayoutConfig(platform);

  return (
    <Flexbox
      horizontal
      align={'center'}
      className={electronStylish.draggable}
      height={TITLE_BAR_HEIGHT}
      justify={'space-between'}
      style={{ minHeight: TITLE_BAR_HEIGHT, padding }}
      width={'100%'}
    >
      <NavigationBar />
      {tabBarMounted && <TabBar />}

      <Flexbox horizontal align={'center'} gap={4}>
        <Flexbox horizontal className={electronStylish.nodrag} gap={8}>
          <UpdateNotification />
          <DeviceGateway hidden={statusHidden} />
          <AutoEnrollWorkspaceDevice />
          <Connection statusHidden={statusHidden} />
        </Flexbox>
        {showCustomWinControl && (
          <>
            <Divider orientation={'vertical'} style={{ marginInline: 8 }} />
            <WinControl />
          </>
        )}
      </Flexbox>
    </Flexbox>
  );
});

export default TitleBar;