Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

1.2 KB
Raw Blame
import { Alert } from 'react-native';
import { useTranslation } from 'react-i18next';
import { MessageSquareQuote } from 'lucide-react-native';
import { quoteSourceDisplayLabel, type ChatQuote } from '@cindy/maker-shared/chat-quotes';
import { InlineReferenceChip } from '@/session/InlineReferenceChip';
import { compactQuoteLabel } from '@/session/quotePresentation';
import { iconSize, iconStroke, useTheme } from '@/theme';

/** One quote per chip, shared geometry with message-anchor references. */
export function InlineQuoteChip({
  interactive = true,
  quote,
}: {
  interactive?: boolean;
  quote: ChatQuote;
}) {
  const { t } = useTranslation();
  const { colors } = useTheme();
  const source = quoteSourceDisplayLabel(quote);
  const label = compactQuoteLabel(quote.text);
  return (
    <InlineReferenceChip
      accessibilityLabel={quote.text}
      icon={<MessageSquareQuote color={colors.textSecondary} size={iconSize.sm} strokeWidth={iconStroke.regular} />}
      label={label}
      onPress={interactive
        ? () => Alert.alert(
            t('message.quote.previewTitle'),
            [`“${quote.text}”`, source].filter(Boolean).join('\n\n'),
          )
        : undefined}
      testID="message.quoteChip"
    />
  );
}