feat: enhance filterVisibleParts to conditionally handle synthetic parts based on non-synthetic presence

This commit is contained in:
Bohdan Triapitsyn
2025-12-28 02:38:43 +02:00
parent 5b24345013
commit 21f164ea73
@@ -28,10 +28,18 @@ interface VisibleFilterOptions {
export const filterVisibleParts = (parts: Part[], options: VisibleFilterOptions = {}): Part[] => {
const { includeReasoning = true } = options;
// Check if there are any non-synthetic parts
const hasNonSynthetic = parts.some((part) => {
const partWithSynthetic = part as PartWithSynthetic;
return !partWithSynthetic.synthetic;
});
return parts.filter((part) => {
const partWithSynthetic = part as PartWithSynthetic;
const isSynthetic = Boolean(partWithSynthetic.synthetic);
if (isSynthetic) {
// Only filter out synthetic parts if there are non-synthetic parts present
// Otherwise, show synthetic parts so the message is displayed
if (isSynthetic && hasNonSynthetic) {
return false;
}
if (!includeReasoning && part.type === 'reasoning') {