agent-ecosystem/src/renderer/components/chat/items/TextItem.tsx
iliya 3a8179d980 feat: enhance TeamProvisioningService and UI components for improved caching and search functionality
- Introduced caching mechanisms in TeamProvisioningService to optimize probe results and reduce redundant calls.
- Refactored warmup logic to utilize a new getCachedOrProbeResult method for better performance.
- Enhanced DisplayItemList, TextItem, and ThinkingItem components to support optional search query overrides for improved inline highlighting.
- Updated MarkdownViewer to handle search highlighting more effectively, accommodating local search queries.
- Improved TaskAttachments and TaskDetailDialog components with better handling of task assignment visibility and user experience.
2026-03-05 17:59:49 +02:00

68 lines
1.9 KiB
TypeScript

import React from 'react';
import { MessageSquare } from 'lucide-react';
import { MarkdownViewer } from '../viewers';
import { BaseItem } from './BaseItem';
import { truncateText } from './baseItemHelpers';
import type { SemanticStep } from '@renderer/types/data';
import type { TriggerColor } from '@shared/constants/triggerColors';
interface TextItemProps {
step: SemanticStep;
preview: string;
onClick: () => void;
isExpanded: boolean;
/** Optional local search query for inline highlighting */
searchQueryOverride?: string;
/** Optional stable item id for search highlighting */
markdownItemId?: string;
/** Additional classes for highlighting (e.g., error deep linking) */
highlightClasses?: string;
/** Inline styles for highlighting (used by custom hex colors) */
highlightStyle?: React.CSSProperties;
/** Notification dot color for custom triggers */
notificationDotColor?: TriggerColor;
}
export const TextItem: React.FC<TextItemProps> = ({
step,
preview,
onClick,
isExpanded,
searchQueryOverride,
markdownItemId,
highlightClasses,
highlightStyle,
notificationDotColor,
}) => {
const fullContent = step.content.outputText ?? preview;
const truncatedPreview = truncateText(preview, 60);
// Get token count from step.tokens.output or step.content.tokenCount
const tokenCount = step.tokens?.output ?? step.content.tokenCount ?? 0;
return (
<BaseItem
icon={<MessageSquare className="size-4" />}
label="Output"
summary={truncatedPreview}
tokenCount={tokenCount}
onClick={onClick}
isExpanded={isExpanded}
highlightClasses={highlightClasses}
highlightStyle={highlightStyle}
notificationDotColor={notificationDotColor}
>
<MarkdownViewer
content={fullContent}
maxHeight="max-h-96"
copyable
itemId={markdownItemId}
searchQueryOverride={searchQueryOverride}
/>
</BaseItem>
);
};