Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(chat): fold a non-latest finished turn whole under the 已处理 header (#16700)

Arvin Xu801ac1477eae
diff --git a/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx b/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx
index a8846337e99..159766eb2d1 100644
--- a/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx
@@ -380,6 +380,62 @@ describe('Group', () => {
expect(screen.queryByTestId('answer-segment')).not.toBeInTheDocument();
});
+ it('folds a non-latest finished turn whole — final answer collapses into the fold too', () => {
+ render(
+ <Group
+ enableProcessFold
+ id="assistant-1"
+ isLatestItem={false}
+ messageIndex={0}
+ blocks={[
+ blk({
+ content: 'Running the checks.',
+ id: 'block-1',
+ tools: [
+ { apiName: 'bash', id: 'tool-1', result: { content: 'ok' } } as any,
+ { apiName: 'bash', id: 'tool-2', result: { content: 'ok' } } as any,
+ ],
+ }),
+ blk({ content: 'Here is the final answer.', id: 'block-2' }),
+ ]}
+ />,
+ );
+
+ const fold = screen.getByTestId('process-fold');
+ const answer = screen.getByTestId('answer-segment');
+ // The final answer renders INSIDE the fold, not as a visible sibling.
+ expect(fold.contains(answer)).toBe(true);
+ expect(fold.contains(screen.getByTestId('workflow-segment'))).toBe(true);
+ });
+
+ it('keeps the latest finished turn’s final answer visible outside the fold', () => {
+ render(
+ <Group
+ enableProcessFold
+ isLatestItem
+ id="assistant-1"
+ messageIndex={0}
+ blocks={[
+ blk({
+ content: 'Running the checks.',
+ id: 'block-1',
+ tools: [
+ { apiName: 'bash', id: 'tool-1', result: { content: 'ok' } } as any,
+ { apiName: 'bash', id: 'tool-2', result: { content: 'ok' } } as any,
+ ],
+ }),
+ blk({ content: 'Here is the final answer.', id: 'block-2' }),
+ ]}
+ />,
+ );
+
+ const fold = screen.getByTestId('process-fold');
+ const answer = screen.getByTestId('answer-segment');
+ // Latest turn: the answer stays out of the fold so it reads without expanding.
+ expect(fold.contains(answer)).toBe(false);
+ expect(fold.contains(screen.getByTestId('workflow-segment'))).toBe(true);
+ });
+
it('keeps assistant runtime errors outside the workflow collapse', () => {
const { container } = render(
<Group
diff --git a/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx b/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx
index 4821eba45a4..c2d83ce1136 100644
--- a/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx
@@ -553,13 +553,13 @@ const Group = memo<GroupChildrenProps>(
);
};
- // Codex-style turn folding: once the turn's op has ended, fold its whole
- // process (reasoning + tools + intermediate prose) under a single "已处理
- // {duration}" header, leaving the final answer always visible. The latest
- // turn folds only after a final answer exists; still-generating turns render
- // in full.
+ // Codex-style turn folding: once the turn's op has ended, fold it under a
+ // single "已处理 {duration}" header. A non-latest turn folds *whole* — its
+ // final answer collapses in too, so scrolled-past turns read as one compact
+ // row. The latest turn only folds its process and keeps the final answer
+ // visible (so a just-finished reply stays readable); still-generating turns
+ // render in full.
const { processSegments, finalSegments } = splitFinalAnswer(segments);
- const processStepCount = countFoldedProcessSteps(processSegments);
const foldProcess = shouldFoldProcess({
enabled: enableProcessFold,
hasFinalAnswer: hasRenderableFinalAnswer(finalSegments),
@@ -569,6 +569,12 @@ const Group = memo<GroupChildrenProps>(
processSegments,
});
+ // Non-latest turns collapse everything; the latest turn keeps its final
+ // answer out of the fold.
+ const foldedSegments = isLatestItem ? processSegments : segments;
+ const visibleSegments = isLatestItem ? finalSegments : [];
+ const processStepCount = countFoldedProcessSteps(foldedSegments);
+
const durationText =
turnDurationMs >= 1000 ? formatReasoningDuration(turnDurationMs) : undefined;
@@ -579,12 +585,12 @@ const Group = memo<GroupChildrenProps>(
<>
<ProcessFold durationText={durationText} stepCount={processStepCount}>
<Flexbox gap={8}>
- {processSegments.map((segment) =>
+ {foldedSegments.map((segment) =>
renderSegment(segment, segments.indexOf(segment)),
)}
</Flexbox>
</ProcessFold>
- {finalSegments.map((segment) => renderSegment(segment, segments.indexOf(segment)))}
+ {visibleSegments.map((segment) => renderSegment(segment, segments.indexOf(segment)))}
</>
) : (
<>