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.
This commit is contained in:
parent
b14cef5f09
commit
af54cea68d
1 changed files with 37 additions and 3 deletions
|
|
@ -266,9 +266,43 @@ export const MemberLogsTab = ({
|
||||||
}, [shouldShowPreview, showLeadPreview, showSubagentPreview, sortedLogs, taskOwner]);
|
}, [shouldShowPreview, showLeadPreview, showSubagentPreview, sortedLogs, taskOwner]);
|
||||||
|
|
||||||
const allPreviewMessages = useMemo((): SubagentPreviewMessage[] => {
|
const allPreviewMessages = useMemo((): SubagentPreviewMessage[] => {
|
||||||
if (!previewChunks || previewChunks.length === 0) return [];
|
if (!previewChunks || previewChunks.length === 0) {
|
||||||
return extractSubagentPreviewMessages(previewChunks);
|
// For lead preview without chunks, fall back to lastOutputPreview from the log summary.
|
||||||
}, [previewChunks]);
|
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[] => {
|
const previewMessages = useMemo((): SubagentPreviewMessage[] => {
|
||||||
return allPreviewMessages.slice(0, previewVisibleCount);
|
return allPreviewMessages.slice(0, previewVisibleCount);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue