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.3 KB
Raw Blame
import { Text } from '@lobehub/ui';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import { checkDisplayTitle, useAcceptanceBundle } from '@/features/Acceptance';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';

/**
 * The panel already says it is a check; repeating "check detail" in the title
 * spends the one line that could say WHICH check — the only thing a reader
 * with several panels open needs to tell them apart.
 */
const Title = memo(() => {
  const { t } = useTranslation(['chat', 'verify']);
  const portal = useChatStore(chatPortalSelectors.acceptanceCheckPortal);
  const { data } = useAcceptanceBundle(portal?.acceptanceId ?? null);
  const check = data?.checks.find((item) => item.id === portal?.checkId);

  let title: string = t('taskDetail.acceptance.detailTitle');
  if (check) {
    const name = checkDisplayTitle(
      check.title,
      t('acceptance.checks.holisticTitle', { ns: 'verify' }),
    );
    title = check.seq ? `C${check.seq} · ${name}` : name;
  }

  return (
    <Text ellipsis={{ tooltipWhenOverflow: true }} style={{ minWidth: 0 }}>
      {title}
    </Text>
  );
});

Title.displayName = 'AcceptanceCheckPortalTitle';

export default Title;