agent-ecosystem/src/renderer/components/chat/items/TextItem.tsx
iliya 9678d790cd feat: enhance task review process with new event tracking
- Introduced a new function to determine the current review state based on task history events, improving the accuracy of review status tracking.
- Updated the requestReview, approveReview, and requestChanges functions to append corresponding review events to the task history, ensuring comprehensive tracking of review actions.
- Refactored task management logic to utilize the new historyEvents structure, replacing the previous statusHistory implementation for better clarity and maintainability.
- Enhanced tests to validate the new review event handling and ensure correct behavior across various task states.
2026-03-09 14:52:38 +02:00

83 lines
2.3 KiB
TypeScript

import React from 'react';
import { MessageSquare } from 'lucide-react';
import { highlightQueryInText } from '../searchHighlightUtils';
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;
/** Timestamp for display */
timestamp?: Date;
/** 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,
timestamp,
searchQueryOverride,
markdownItemId,
highlightClasses,
highlightStyle,
notificationDotColor,
}) => {
const fullContent = step.content.outputText ?? preview;
const truncatedPreview = truncateText(preview, 60);
const summary = searchQueryOverride
? highlightQueryInText(
truncatedPreview,
searchQueryOverride,
`${markdownItemId ?? step.id}:summary`,
{
forceAllActive: true,
}
)
: truncatedPreview;
// 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={summary}
tokenCount={tokenCount}
timestamp={timestamp}
onClick={onClick}
isExpanded={isExpanded}
highlightClasses={highlightClasses}
highlightStyle={highlightStyle}
notificationDotColor={notificationDotColor}
>
<MarkdownViewer
content={fullContent}
maxHeight="max-h-96"
copyable
itemId={markdownItemId}
searchQueryOverride={searchQueryOverride}
/>
</BaseItem>
);
};