From af54cea68d934861b22a29bcd58b743bc38e6ce4 Mon Sep 17 00:00:00 2001 From: iliya Date: Sun, 15 Mar 2026 21:34:48 +0200 Subject: [PATCH] feat: enhance member logs preview handling for lead users - Improved the logic for displaying preview messages in the MemberLogsTab component. - Added fallback mechanisms to show the last output preview when no preview chunks are available, specifically for lead users. - Filtered out user messages for lead previews to focus on AI outputs, ensuring clarity in displayed results. - Enhanced overall message retrieval logic to provide a more robust user experience in the logs tab. --- .../components/team/members/MemberLogsTab.tsx | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/team/members/MemberLogsTab.tsx b/src/renderer/components/team/members/MemberLogsTab.tsx index f9aee3f6..41eb74a9 100644 --- a/src/renderer/components/team/members/MemberLogsTab.tsx +++ b/src/renderer/components/team/members/MemberLogsTab.tsx @@ -266,9 +266,43 @@ export const MemberLogsTab = ({ }, [shouldShowPreview, showLeadPreview, showSubagentPreview, sortedLogs, taskOwner]); const allPreviewMessages = useMemo((): SubagentPreviewMessage[] => { - if (!previewChunks || previewChunks.length === 0) return []; - return extractSubagentPreviewMessages(previewChunks); - }, [previewChunks]); + if (!previewChunks || previewChunks.length === 0) { + // For lead preview without chunks, fall back to lastOutputPreview from the log summary. + if (showLeadPreview && previewLog?.lastOutputPreview) { + return [ + { + id: `${previewLog.sessionId}:lastOutput`, + timestamp: new Date(previewLog.startTime), + kind: 'output', + label: 'Output', + content: previewLog.lastOutputPreview, + }, + ]; + } + return []; + } + const raw = extractSubagentPreviewMessages(previewChunks); + // For lead preview, user messages are system-generated prompts (not useful). + // Show only AI outputs — the actual work results. + // If no outputs found, fall back to lastOutputPreview from the log summary. + if (showLeadPreview) { + const outputs = raw.filter((m) => m.kind !== 'user'); + if (outputs.length > 0) return outputs; + if (previewLog?.lastOutputPreview) { + return [ + { + id: `${previewLog.sessionId}:lastOutput`, + timestamp: new Date(previewLog.startTime), + kind: 'output', + label: 'Output', + content: previewLog.lastOutputPreview, + }, + ]; + } + return raw; // ultimate fallback: show everything including user messages + } + return raw; + }, [previewChunks, showLeadPreview, previewLog]); const previewMessages = useMemo((): SubagentPreviewMessage[] => { return allPreviewMessages.slice(0, previewVisibleCount);