π€― 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
β¨ feat(workflow): keep finished tool lists expanded by default (#19741)
Arvin Xu77c68eb7f737
diff --git a/src/features/Conversation/ChatList/index.tsx b/src/features/Conversation/ChatList/index.tsxindex 3bc6136bdc1..8bead88509b 100644--- a/src/features/Conversation/ChatList/index.tsx+++ b/src/features/Conversation/ChatList/index.tsx@@ -45,12 +45,12 @@ MessageAuthorConfigLoader.displayName = 'MessageAuthorConfigLoader';export interface ChatListProps {/*** Default expand level for assistant workflow (tool-call) groups. When set,- * pins the initial/reset state and skips the built-in auto-collapse after- * streaming. Users can still toggle locally.+ * pins the initial/reset state and overrides the built-in defaults+ * (streaming `semi`, completion `full`). Users can still toggle locally.* - 'collapsed': show summary only* - 'semi': constrained scrollable tool list* - 'full': all tool details expanded- * Pass an object (e.g. `{ streaming: 'full' }`) to override only one phase.+ * Pass an object (e.g. `{ completion: 'collapsed' }`) to override only one phase.* Only applies to the default item renderer; ignored when `itemContent` is supplied.*/defaultWorkflowExpandLevel?: WorkflowExpandLevelDefault;diff --git a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsx b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsxindex 964e763d75f..ebe24807e8c 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsx@@ -202,7 +202,24 @@ describe('WorkflowCollapse', () => {expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();});- it('auto-collapses on completion by default', () => {+ it("respects defaultWorkflowExpandLevel='collapsed' after completion", () => {+ mockIsGenerating = false;+ render(+ <WorkflowCollapse+ assistantMessageId="msg-1"+ blocks={makeBlocks({ result: { content: 'ok' } })}+ defaultWorkflowExpandLevel="collapsed"+ />,+ );++ expect(getExpandedKeys()).toBe('[]');+ });++ it('keeps the full list expanded on completion by default', () => {+ // Regression: the built-in completion default used to be 'collapsed', so+ // inspecting a finished turn's long tool list took three hops (open fold β+ // semi scroll β β€’ full). Full is the built-in default now; users who want+ // the old summary-only row pass defaultWorkflowExpandLevel='collapsed'.const { rerender } = render(<WorkflowCollapse assistantMessageId="msg-1" blocks={makeBlocks()} />,);@@ -217,11 +234,12 @@ describe('WorkflowCollapse', () => {/>,);- expect(getExpandedKeys()).toBe('[]');+ expect(getExpandedKeys()).toBe('["workflow"]');+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();});- it('skips the completion auto-collapse while suppressAutoCollapse is set', () => {- // Regression: the animated semi β collapsed transition used to run right+ it('keeps the completion level while suppressAutoCollapse is set', () => {+ // Regression: the animated full β collapsed transition used to run right// before the parent folded the whole workflow into ProcessFold, shrinking// the layout twice and making the conversation visibly jitter.const { rerender } = render(@@ -242,12 +260,21 @@ describe('WorkflowCollapse', () => {expect(getExpandedKeys()).toBe('["workflow"]');});- it('collapses late when suppressAutoCollapse is released after completion', () => {+ it('applies the completion level when suppressAutoCollapse is released after completion', () => {// The turn ended but never folded (e.g. tool-only turn with no final- // answer), so nothing else collapses the workflow β the late release must.+ // answer), so nothing else applies the completion level β the late+ // release must. The { completion: 'collapsed' } override pins completion+ // down while streaming keeps the built-in semi, so the release has an+ // observable effect.const { rerender } = render(- <WorkflowCollapse suppressAutoCollapse assistantMessageId="msg-1" blocks={makeBlocks()} />,+ <WorkflowCollapse+ suppressAutoCollapse+ assistantMessageId="msg-1"+ blocks={makeBlocks()}+ defaultWorkflowExpandLevel={{ completion: 'collapsed' }}+ />,);+ expect(getExpandedKeys()).toBe('["workflow"]');mockIsGenerating = false;rerender(@@ -255,6 +282,7 @@ describe('WorkflowCollapse', () => {suppressAutoCollapseassistantMessageId="msg-1"blocks={makeBlocks({ result: { content: 'ok' } })}+ defaultWorkflowExpandLevel={{ completion: 'collapsed' }}/>,);expect(getExpandedKeys()).toBe('["workflow"]');@@ -263,6 +291,7 @@ describe('WorkflowCollapse', () => {<WorkflowCollapseassistantMessageId="msg-1"blocks={makeBlocks({ result: { content: 'ok' } })}+ defaultWorkflowExpandLevel={{ completion: 'collapsed' }}suppressAutoCollapse={false}/>,);@@ -461,6 +490,82 @@ describe('WorkflowCollapse', () => {expect(screen.getByRole('button', { name: 'Expand fully' })).toBeInTheDocument();});+ it('reopens at full on the production prop shape with a semi streaming preference', () => {+ // Regression: the production caller always passes `{ streaming: <setting> }`+ // and never a completion phase, so the common 'semi' streaming preference+ // resolved manualExpandLevel to 'semi' while the workflow itself rendered at+ // the built-in 'full'. Closing and reopening the finished workflow therefore+ // dropped back to the height-capped list β reintroducing the extra β€’ click+ // this default is meant to remove.+ mockIsGenerating = false;+ render(+ <WorkflowCollapse+ assistantMessageId="msg-1"+ blocks={makeBlocks({ result: { content: 'ok' } })}+ defaultWorkflowExpandLevel={{ streaming: 'semi' }}+ />,+ );++ expect(getExpandedKeys()).toBe('["workflow"]');+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();++ act(() => {+ screen.getByRole('button', { name: 'toggle-accordion-header' }).click();+ });+ expect(getExpandedKeys()).toBe('[]');++ act(() => {+ screen.getByRole('button', { name: 'toggle-accordion-header' }).click();+ });++ expect(getExpandedKeys()).toBe('["workflow"]');+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();+ });++ it('reopens at full with no expand prop at all', () => {+ mockIsGenerating = false;+ render(+ <WorkflowCollapse+ assistantMessageId="msg-1"+ blocks={makeBlocks({ result: { content: 'ok' } })}+ />,+ );++ act(() => {+ screen.getByRole('button', { name: 'toggle-accordion-header' }).click();+ });+ expect(getExpandedKeys()).toBe('[]');++ act(() => {+ screen.getByRole('button', { name: 'toggle-accordion-header' }).click();+ });++ expect(getExpandedKeys()).toBe('["workflow"]');+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();+ });++ it('still reopens at semi when a consumer pins completion below full', () => {+ // An explicit non-full completion override keeps the semi cap, so the+ // consumer's compact completion experience is preserved on manual reopen.+ mockIsGenerating = false;+ render(+ <WorkflowCollapse+ assistantMessageId="msg-1"+ blocks={makeBlocks({ result: { content: 'ok' } })}+ defaultWorkflowExpandLevel={{ completion: 'collapsed' }}+ />,+ );++ expect(getExpandedKeys()).toBe('[]');++ act(() => {+ screen.getByRole('button', { name: 'toggle-accordion-header' }).click();+ });++ expect(getExpandedKeys()).toBe('["workflow"]');+ expect(screen.getByRole('button', { name: 'Expand fully' })).toBeInTheDocument();+ });+it('manual expand jumps to full when any phase defaults to full (heterogeneous agents)', () => {mockIsGenerating = false;render(@@ -471,15 +576,21 @@ describe('WorkflowCollapse', () => {/>,);- // Completion default falls back to 'collapsed' since only streaming is overridden.- expect(getExpandedKeys()).toBe('[]');+ // Completion default falls back to the built-in 'full' since only+ // streaming is overridden β the workflow already renders expanded.+ expect(getExpandedKeys()).toBe('["workflow"]');act(() => {screen.getByRole('button', { name: 'toggle-accordion-header' }).click();});+ expect(getExpandedKeys()).toBe('[]');+ // Collapsed shows no toggle; re-expanding must land at full (not semi cap).+ act(() => {+ screen.getByRole('button', { name: 'toggle-accordion-header' }).click();+ });+expect(getExpandedKeys()).toBe('["workflow"]');- // The toggle next to the header would offer "collapse" because we landed at 'full' directly.expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();});diff --git a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsx b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsxindex 39729d6d51b..ee334305dc4 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsx@@ -46,7 +46,7 @@ export type WorkflowExpandLevel = 'collapsed' | 'semi' | 'full';/** Per-phase initial level. Pass an object when streaming and completion* should differ β e.g. heterogeneous agents want full while streaming but- * still collapse once a turn finishes. A plain string applies to both. */+ * keep the built-in completion default. A plain string applies to both. */export type WorkflowExpandLevelDefault =WorkflowExpandLevel | { completion?: WorkflowExpandLevel; streaming?: WorkflowExpandLevel };@@ -55,17 +55,17 @@ interface WorkflowCollapseProps {assistantMessageId: string;blocks: RenderableAssistantContentBlock[];/**- * Fixed default expand level. When set, overrides the built-in auto- * behavior (expand while streaming, collapse after completion) for the- * initial state and resets. Users can still toggle locally.- * Pass an object to override only one phase (e.g. `{ streaming: 'full' }`).- * Undefined = legacy auto behavior. Pending intervention still forces open.+ * Fixed default expand level. When set, overrides the built-in defaults+ * (streaming `semi`, completion `full`) for the initial state and resets.+ * Users can still toggle locally. Pass an object to override only one+ * phase (e.g. `{ streaming: 'collapsed' }`). Undefined = built-in defaults.+ * Pending intervention still forces open.*/defaultWorkflowExpandLevel?: WorkflowExpandLevelDefault;disableEditing?: boolean;/**- * Skip the completion auto-collapse (semi β collapsed, an animated Accordion- * height transition) because the parent is about to fold the whole workflow+ * Skip applying the completion level (an animated Accordion height+ * transition) because the parent is about to fold the whole workflow* into `ProcessFold` in a single commit. Collapsing twice β once as a* multi-frame animation, once as the fold swap β is what makes the* conversation visibly jitter when a turn with tool calls finishes.@@ -205,13 +205,23 @@ const WorkflowCollapse = memo<WorkflowCollapseProps>([defaultWorkflowExpandLevel],);const streamingInitialLevel: WorkflowExpandLevel = streamingDefault ?? 'semi';- const completionInitialLevel: WorkflowExpandLevel = completionDefault ?? 'collapsed';- /** When a consumer opts any phase into `full`, treat the workflow as a- * "fully expanded" experience β manual expands from collapsed go to- * `full` instead of the legacy `semi` cap. Heterogeneous agents rely on- * this so all 40+ tool calls stay visible after the user re-expands. */+ // Completion defaults to the full list, not a summary-only row: the whole+ // point of opening a finished turn (or its ProcessFold) is seeing what ran,+ // and semi's height cap forces a third hop (β€’) for long tool lists. The+ // base-ui panel unmounts children when folded, so history messages kept at+ // full pay no render cost while the fold is closed. Consumers pin the old+ // summary row with defaultWorkflowExpandLevel='collapsed'.+ const completionInitialLevel: WorkflowExpandLevel = completionDefault ?? 'full';+ /** Where a manual re-expand from collapsed lands. Derived from the+ * *effective* completion level rather than the raw prop: the production+ * caller always passes `{ streaming: <setting> }` and no completion phase,+ * so keying off `completionDefault` alone reopened at the legacy `semi`+ * cap while the same workflow had just rendered at `full`. Consumers that+ * pin completion below full keep that compact level; a `full` streaming+ * phase keeps the fully expanded experience heterogeneous agents need+ * (all 40+ tool calls visible after a re-expand). */const manualExpandLevel: WorkflowExpandLevel =- streamingDefault === 'full' || completionDefault === 'full' ? 'full' : 'semi';+ streamingDefault === 'full' || completionInitialLevel === 'full' ? 'full' : 'semi';const [expandLevel, setExpandLevel] = useState<WorkflowExpandLevel>(() =>allComplete ? completionInitialLevel : streamingInitialLevel,