diff --git a/ui/desktop/src/components/ProgressiveMessageList.tsx b/ui/desktop/src/components/ProgressiveMessageList.tsx index d7633b2efd..a0ae74eaac 100644 --- a/ui/desktop/src/components/ProgressiveMessageList.tsx +++ b/ui/desktop/src/components/ProgressiveMessageList.tsx @@ -201,7 +201,7 @@ export default function ProgressiveMessageList({ {isUser ? ( <> {hasCompactionMarker && hasCompactionMarker(message) ? ( - + ) : ( !hasOnlyToolResponses(message) && ( {hasCompactionMarker && hasCompactionMarker(message) ? ( - + ) : ( = ({ } // Fallback: Look for agent-visible but not user-visible messages (actual summary) + // Skip messages that contain the "summary that was prepared" text for (let i = messages.length - 1; i >= 0; i--) { const msg = messages[i]; if (msg.metadata?.agentVisible === true && msg.metadata?.userVisible === false) { - // Check if it contains text that looks like a summary + // Check if it contains text content const textContent = msg.content.find((c) => c.type === 'text'); - if (textContent && 'text' in textContent && textContent.text.includes('summary')) { + if (textContent && 'text' in textContent) { + const text = textContent.text; + // Skip the "summary that was prepared" message + if ( + text.includes('summary that was prepared') || + text.includes('Do not mention that you read a summary') + ) { + continue; + } + // This should be the actual summary return { message: msg, - content: textContent.text, + content: text, }; } } diff --git a/ui/desktop/src/components/alerts/AlertBox.tsx b/ui/desktop/src/components/alerts/AlertBox.tsx index 2e199ae461..36a81991b4 100644 --- a/ui/desktop/src/components/alerts/AlertBox.tsx +++ b/ui/desktop/src/components/alerts/AlertBox.tsx @@ -53,12 +53,22 @@ export const AlertBox = ({ alert, className, messages }: AlertBoxProps) => { } // Fallback: Look for agent-visible but not user-visible messages (actual summary) + // Skip messages that contain the "summary that was prepared" text for (let i = messages.length - 1; i >= 0; i--) { const msg = messages[i]; if (msg.metadata?.agentVisible === true && msg.metadata?.userVisible === false) { - // Check if it contains text that looks like a summary + // Check if it contains text content const textContent = msg.content.find((c) => c.type === 'text'); - if (textContent && 'text' in textContent && textContent.text.includes('summary')) { + if (textContent && 'text' in textContent) { + const text = textContent.text; + // Skip the "summary that was prepared" message + if ( + text.includes('summary that was prepared') || + text.includes('Do not mention that you read a summary') + ) { + continue; + } + // If we found text that doesn't match the skip patterns, it's likely a summary return true; } } diff --git a/ui/desktop/src/components/context_management/CompactionMarker.tsx b/ui/desktop/src/components/context_management/CompactionMarker.tsx index 9944f7d9c8..f72a03affd 100644 --- a/ui/desktop/src/components/context_management/CompactionMarker.tsx +++ b/ui/desktop/src/components/context_management/CompactionMarker.tsx @@ -6,9 +6,10 @@ import SummaryViewModal from '../SummaryViewModal'; interface CompactionMarkerProps { message: Message; + messages?: Message[]; } -export const CompactionMarker: React.FC = ({ message }) => { +export const CompactionMarker: React.FC = ({ message, messages }) => { const [showSummaryModal, setShowSummaryModal] = useState(false); const compactionContent = message.content.find( @@ -32,11 +33,12 @@ export const CompactionMarker: React.FC = ({ message }) = View Summary )} - {showSummaryModal && summaryText && ( + {showSummaryModal && ( setShowSummaryModal(false)} - summaryText={summaryText} + messages={messages} + summaryText={summaryText || undefined} /> )}