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.

1.1 KB
Raw Blame
import { cssVar, Icon, Tooltip } from '@lobehub/ui';
import { LoaderCircleIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import { useChatInputStore } from '../store';

/**
 * A small spinner at the head of the send area while the agent runs, so it sits
 * beside the model selector that qualifies the run. Stop itself stays static.
 * Hosts that already show the run elsewhere turn it off with `hideRunningIndicator`.
 */
const RunningIndicator = memo(() => {
  const { t } = useTranslation('chat');
  const visible = useChatInputStore(
    (s) => !!s.sendButtonProps?.generating && !s.sendButtonProps.hideRunningIndicator,
  );

  if (!visible) return null;

  return (
    <Tooltip title={t('input.running')}>
      <Icon
        spin
        aria-label={t('input.running')}
        color={cssVar.colorTextTertiary}
        data-testid="chat-input-running-indicator"
        icon={LoaderCircleIcon}
        role={'status'}
        size={14}
      />
    </Tooltip>
  );
});

RunningIndicator.displayName = 'RunningIndicator';

export default RunningIndicator;