🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(conversation): keep a turn's final answer visible when a queued follow-up continues it (#21306)
AmAzing-cc3422dd5da3
diff --git a/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx b/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsxindex 507319cfd3e..ac3794b5755 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/Group.test.tsx@@ -937,7 +937,7 @@ describe('Group', () => {expect(screen.queryByTestId('process-fold')).not.toBeInTheDocument();});- it('folds each turn separately and keeps the steer bubble between the folds', () => {+ it('folds each turn separately and keeps every turn’s final answer outside its fold', () => {mockOperations = [];const { container } = render(@@ -967,13 +967,43 @@ describe('Group', () => {Array.from(root.querySelectorAll('[data-testid="answer-segment"]')).map((node) => JSON.parse(node.getAttribute('data-block') || '{}').id,);- expect(idsIn(folds[0]!)).toEqual(['a1', 'a2']);+ expect(idsIn(folds[0]!)).toEqual(['a1']);expect(idsIn(folds[1]!)).toEqual(['b1']);- const outside = Array.from(container.querySelectorAll('[data-testid="answer-segment"]'))- .filter((node) => !folds.some((fold) => fold.contains(node)))- .map((node) => JSON.parse(node.getAttribute('data-block') || '{}').id);- expect(outside).toEqual(['b2']);+ // A queued follow-up is only sent after the turn it follows has finished,+ // so that turn's answer is a real reply and must stay readable, sitting+ // between its own fold and the steer bubble.+ const sequence = Array.from(container.querySelectorAll('[data-testid]'))+ .filter((node) => !folds.some((fold) => fold !== node && fold.contains(node)))+ .map((node) =>+ node.getAttribute('data-testid') === 'answer-segment'+ ? JSON.parse(node.getAttribute('data-block') || '{}').id+ : node.getAttribute('data-testid'),+ );+ expect(sequence).toEqual(['process-fold', 'a2', 'steer-message', 'process-fold', 'b2']);+ });++ it('folds the whole of an earlier turn that stopped on a tool call', () => {+ mockOperations = [];++ render(+ <Group+ enableProcessFold+ isLatestItem+ blocks={[chain1[0]!]}+ continuations={[{ blocks: chain2, id: 'group-2', steerUserId: 'steer-1' }]}+ id="group-1"+ messageIndex={0}+ />,+ );++ const folds = screen.getAllByTestId('process-fold');+ expect(folds).toHaveLength(2);+ expect(+ Array.from(folds[0]!.querySelectorAll('[data-testid="answer-segment"]')).map(+ (node) => JSON.parse(node.getAttribute('data-block') || '{}').id,+ ),+ ).toEqual(['a1']);});it('keeps the loading placeholder of a continuation that is still being created', () => {diff --git a/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx b/src/features/Conversation/Messages/AssistantGroup/components/Group.tsxindex 13ed51d1aa9..94fabe8aaba 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx@@ -185,23 +185,24 @@ const Group = memo<GroupChildrenProps>(// that is the turn's payload; only the process collapses. The latest turn// is eligible only once its final answer exists (so a tool-only latest turn// does not collapse into a lone header); still-generating turns render in- // full. Steered continuations fold per turn: every earlier turn's output is- // process, only the last turn's final answer stays visible, and each steer- // bubble sits between the fold it interrupted and the fold it started.- const { processSegments, finalSegments } = splitAssistantGroupFinalAnswer(lastView.segments);- const processSegmentsOf = (view: GroupChainView) =>- view === lastView ? processSegments : view.segments;+ // full. Steered continuations fold per turn, and each turn keeps its own+ // final answer: a queued follow-up is only sent once the turn before it has+ // finished, so that turn's answer is a real reply, not process. Each steer+ // bubble sits after the answer of the turn it followed. A turn that stopped+ // on a tool call has no final answer and folds whole.+ const splits = views.map((view) => splitAssistantGroupFinalAnswer(view.segments));+ const finalSegments = splits.at(-1)!.finalSegments;const foldProcess = shouldFoldProcess({enabled: enableProcessFold,hasFinalAnswer: hasRenderableFinalAnswer(finalSegments),isGenerating,isLatestItem,operationEnded: !views.some((view) => view.hasActiveOperation),- processSegments: views.flatMap(processSegmentsOf),+ processSegments: splits.flatMap((split) => split.processSegments),});const renderFold = (view: GroupChainView, index: number) => {- const segments = processSegmentsOf(view);+ const segments = splits[index]!.processSegments;if (segments.length === 0) return null;const durationMs = chainDurations[index] ?? 0;return (@@ -220,14 +221,19 @@ const Group = memo<GroupChildrenProps>({views.map((view, index) => (<Fragment key={view.id}>{view.steerUserId && <SteerMessage id={view.steerUserId} />}- {foldProcess ? renderFold(view, index) : renderChain(view, view.segments, 'process')}+ {foldProcess ? (+ <>+ {renderFold(view, index)}+ {renderChain(view, splits[index]!.finalSegments, 'final')}+ </>+ ) : (+ renderChain(view, view.segments, 'process')+ )}</Fragment>))}- {foldProcess- ? renderChain(lastView, finalSegments, 'final')- : lastView.showTailRunningIndicator && (- <ContentLoading id={lastView.id} startTime={lastBlockCreatedAt} />- )}+ {!foldProcess && lastView.showTailRunningIndicator && (+ <ContentLoading id={lastView.id} startTime={lastBlockCreatedAt} />+ )}</Flexbox>);},