π€― 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
π style(workflow): fold a finished tool list back down, open it straight to full (#19819)
Arvin Xubeec9081b41b
diff --git a/src/features/Conversation/ChatList/index.tsx b/src/features/Conversation/ChatList/index.tsxindex 8bead88509b..c59f71788a7 100644--- a/src/features/Conversation/ChatList/index.tsx+++ b/src/features/Conversation/ChatList/index.tsx@@ -46,11 +46,11 @@ export interface ChatListProps {/*** Default expand level for assistant workflow (tool-call) groups. When set,* pins the initial/reset state and overrides the built-in defaults- * (streaming `semi`, completion `full`). Users can still toggle locally.+ * (streaming `semi`, completion `collapsed`). Users can still toggle locally.* - 'collapsed': show summary only* - 'semi': constrained scrollable tool list* - 'full': all tool details expanded- * Pass an object (e.g. `{ completion: 'collapsed' }`) to override only one phase.+ * Pass an object (e.g. `{ completion: 'full' }`) 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 ebe24807e8c..c526d6bb7a1 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.test.tsx@@ -146,10 +146,12 @@ describe('WorkflowCollapse', () => {vi.useRealTimers();});- it('defaults to expanded while streaming', () => {+ it('defaults to the full list while streaming', () => {render(<WorkflowCollapse assistantMessageId="msg-1" blocks={makeBlocks()} />);expect(getExpandedKeys()).toBe('["workflow"]');+ // 'Collapse' is the full level's toggle label; 'Expand fully' would mean semi.+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();});it("respects defaultWorkflowExpandLevel='collapsed' while streaming", () => {@@ -215,11 +217,11 @@ describe('WorkflowCollapse', () => {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'.+ it('folds back to the summary row on completion by default', () => {+ // Regression: the built-in completion default was briefly 'full', so+ // opening a topic rendered every finished turn as a wall of tool rows.+ // A finished workflow collapses to its summary line again β one click+ // reopens it, and that click lands on the full list.const { rerender } = render(<WorkflowCollapse assistantMessageId="msg-1" blocks={makeBlocks()} />,);@@ -234,8 +236,20 @@ describe('WorkflowCollapse', () => {/>,);- expect(getExpandedKeys()).toBe('["workflow"]');- expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();+ expect(getExpandedKeys()).toBe('[]');+ });++ it('mounts a finished workflow collapsed', () => {+ // Entering a topic renders history straight at the completion level.+ mockIsGenerating = false;+ render(+ <WorkflowCollapse+ assistantMessageId="msg-1"+ blocks={makeBlocks({ result: { content: 'ok' } })}+ />,+ );++ expect(getExpandedKeys()).toBe('[]');});it('keeps the completion level while suppressAutoCollapse is set', () => {@@ -313,6 +327,9 @@ describe('WorkflowCollapse', () => {expect(screen.getByText('Awaiting your confirmation')).toBeInTheDocument();expect(screen.queryByText('Working...')).not.toBeInTheDocument();+ // The forced open lands on the full list like every other open does β the+ // card asking for confirmation must not be under the cap's scroll.+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();});it('pauses and hides elapsed time while confirmation is pending', () => {@@ -449,27 +466,28 @@ describe('WorkflowCollapse', () => {});it('cycles expand levels via the toggle button', () => {+ // The β€’ toggle is the only way into the capped level now: everything that+ // opens on its own opens full, and the toggle narrows it back down.render(<WorkflowCollapse assistantMessageId="msg-1" blocks={makeBlocks()} />);- const toggleButton = screen.getByRole('button', { name: 'Expand fully' });expect(getExpandedKeys()).toBe('["workflow"]');act(() => {- toggleButton.click();+ screen.getByRole('button', { name: 'Collapse' }).click();});expect(getExpandedKeys()).toBe('["workflow"]');- expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'Expand fully' })).toBeInTheDocument();act(() => {- screen.getByRole('button', { name: 'Collapse' }).click();+ screen.getByRole('button', { name: 'Expand fully' }).click();});expect(getExpandedKeys()).toBe('["workflow"]');- expect(screen.getByRole('button', { name: 'Expand fully' })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();});- it('expands to semi when accordion header is clicked from collapsed', () => {+ it('expands to full when the accordion header is clicked from collapsed', () => {render(<WorkflowCollapseassistantMessageId="msg-1"@@ -487,16 +505,15 @@ describe('WorkflowCollapse', () => {});expect(getExpandedKeys()).toBe('["workflow"]');- expect(screen.getByRole('button', { name: 'Expand fully' })).toBeInTheDocument();+ // 'Collapse' is the full level's toggle label; 'Expand fully' would mean semi.+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();});- it('reopens at full on the production prop shape with a semi streaming preference', () => {+ it('opens a finished workflow at full on the production prop shape', () => {// 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.+ // used to decide the manual open level too β opening a finished turn landed+ // on the height-capped list and needed a second β€’ click to read it.mockIsGenerating = false;render(<WorkflowCollapse@@ -506,12 +523,26 @@ describe('WorkflowCollapse', () => {/>,);- expect(getExpandedKeys()).toBe('["workflow"]');- expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();+ expect(getExpandedKeys()).toBe('[]');act(() => {screen.getByRole('button', { name: 'toggle-accordion-header' }).click();});++ expect(getExpandedKeys()).toBe('["workflow"]');+ // 'Collapse' is the full level's toggle label; 'Expand fully' would mean semi.+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();+ });++ it('opens a finished workflow at full with no expand prop at all', () => {+ mockIsGenerating = false;+ render(+ <WorkflowCollapse+ assistantMessageId="msg-1"+ blocks={makeBlocks({ result: { content: 'ok' } })}+ />,+ );+expect(getExpandedKeys()).toBe('[]');act(() => {@@ -522,15 +553,21 @@ describe('WorkflowCollapse', () => {expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();});- it('reopens at full with no expand prop at all', () => {+ it('opens at semi when a consumer pins completion to semi', () => {+ // An explicit semi completion override keeps the height cap, so the+ // consumer's compact completion experience survives a manual open.mockIsGenerating = false;render(<WorkflowCollapseassistantMessageId="msg-1"blocks={makeBlocks({ result: { content: 'ok' } })}+ defaultWorkflowExpandLevel={{ completion: 'semi' }}/>,);+ expect(getExpandedKeys()).toBe('["workflow"]');+ expect(screen.getByRole('button', { name: 'Expand fully' })).toBeInTheDocument();+act(() => {screen.getByRole('button', { name: 'toggle-accordion-header' }).click();});@@ -540,19 +577,17 @@ describe('WorkflowCollapse', () => {screen.getByRole('button', { name: 'toggle-accordion-header' }).click();});- expect(getExpandedKeys()).toBe('["workflow"]');- expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'Expand fully' })).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;+ it('opens a streaming workflow at full too', () => {+ // A run whose live list is pinned shut (the settings toggle off) still+ // opens on the full list when the user asks for it mid-run.render(<WorkflowCollapseassistantMessageId="msg-1"- blocks={makeBlocks({ result: { content: 'ok' } })}- defaultWorkflowExpandLevel={{ completion: 'collapsed' }}+ blocks={makeBlocks()}+ defaultWorkflowExpandLevel={{ streaming: 'collapsed' }}/>,);@@ -562,22 +597,32 @@ describe('WorkflowCollapse', () => {screen.getByRole('button', { name: 'toggle-accordion-header' }).click();});- expect(getExpandedKeys()).toBe('["workflow"]');+ expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();+ });++ it('opens a streaming workflow at semi only when that phase pins semi', () => {+ render(+ <WorkflowCollapse+ assistantMessageId="msg-1"+ blocks={makeBlocks()}+ defaultWorkflowExpandLevel={{ streaming: 'semi' }}+ />,+ );+expect(screen.getByRole('button', { name: 'Expand fully' })).toBeInTheDocument();});- it('manual expand jumps to full when any phase defaults to full (heterogeneous agents)', () => {- mockIsGenerating = false;+ it('manual expand jumps to full while streaming when that phase defaults to full', () => {+ // Heterogeneous agents pin streaming to full explicitly; all 40+ tool+ // calls stay visible mid-run and across a close/reopen.render(<WorkflowCollapseassistantMessageId="msg-1"- blocks={makeBlocks({ result: { content: 'ok' } })}+ blocks={makeBlocks()}defaultWorkflowExpandLevel={{ streaming: 'full' }}/>,);- // Completion default falls back to the built-in 'full' since only- // streaming is overridden β the workflow already renders expanded.expect(getExpandedKeys()).toBe('["workflow"]');act(() => {@@ -594,15 +639,11 @@ describe('WorkflowCollapse', () => {expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();});- it('collapses to collapsed when accordion header is clicked from full', () => {+ it('keeps a user-opened workflow open across a rerender', () => {const { rerender } = render(<WorkflowCollapse assistantMessageId="msg-1" blocks={makeBlocks()} />,);- act(() => {- screen.getByRole('button', { name: 'Expand fully' }).click();- });-expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();mockIsGenerating = false;diff --git a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsx b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsxindex ee334305dc4..19c4f5c7080 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/WorkflowCollapse.tsx@@ -45,8 +45,8 @@ const WORKFLOW_EXPAND_TOGGLE_TRANSITION = {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- * keep the built-in completion default. A plain string applies to both. */+ * should differ β e.g. a surface that wants the list open mid-run but folded+ * once the turn ends. A plain string applies to both. */export type WorkflowExpandLevelDefault =WorkflowExpandLevel | { completion?: WorkflowExpandLevel; streaming?: WorkflowExpandLevel };@@ -56,7 +56,7 @@ interface WorkflowCollapseProps {blocks: RenderableAssistantContentBlock[];/*** Fixed default expand level. When set, overrides the built-in defaults- * (streaming `semi`, completion `full`) for the initial state and resets.+ * (streaming `full`, completion `collapsed`) 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.@@ -204,24 +204,15 @@ const WorkflowCollapse = memo<WorkflowCollapseProps>(() => resolveExpandDefaults(defaultWorkflowExpandLevel),[defaultWorkflowExpandLevel],);- const streamingInitialLevel: WorkflowExpandLevel = streamingDefault ?? 'semi';- // 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' || completionInitialLevel === 'full' ? 'full' : 'semi';+ // Open means open: every level that isn't an explicit summary row resolves+ // to the full list. `semi`'s height cap only ever bought a second hop (β€’)+ // on exactly the long tool lists people open the row to read.+ const streamingInitialLevel: WorkflowExpandLevel = streamingDefault ?? 'full';+ // A finished turn folds back down to its summary row: opening a topic+ // should read as a conversation, not as a wall of every tool that ran.+ // Inspecting the list stays one click away β and that click lands on the+ // full list (see manualExpandLevel), so nothing is two hops deep.+ const completionInitialLevel: WorkflowExpandLevel = completionDefault ?? 'collapsed';const [expandLevel, setExpandLevel] = useState<WorkflowExpandLevel>(() =>allComplete ? completionInitialLevel : streamingInitialLevel,@@ -266,12 +257,19 @@ const WorkflowCollapse = memo<WorkflowCollapseProps>(]);const streaming = !allComplete;+ /** Where a manual open from the summary row lands: the full list, in both+ * phases. Opening a workflow means "show me everything that ran"; the+ * height cap only hides part of the answer behind another click. `semi`+ * survives as the β€’ toggle's other position and for a consumer that pins+ * that phase to it explicitly. */+ const manualExpandLevel: WorkflowExpandLevel =+ (streaming ? streamingDefault : completionDefault) === 'semi' ? 'semi' : 'full';const forceExpanded = streaming && pendingInterventionPresent;const isExpanded = forceExpanded || expandLevel !== 'collapsed';useEffect(() => {if (streaming && pendingInterventionPresent) {- setExpandLevel('semi');+ setExpandLevel('full');}}, [pendingInterventionPresent, streaming]);diff --git a/src/store/user/slices/settings/selectors/general.ts b/src/store/user/slices/settings/selectors/general.tsindex ba6f1c26a72..e74f9234c61 100644--- a/src/store/user/slices/settings/selectors/general.ts+++ b/src/store/user/slices/settings/selectors/general.ts@@ -40,8 +40,11 @@ const currentTimezone = (s: UserStore): string | undefined =>const enableAutoScrollOnStreaming = (s: UserStore) =>generalConfig(s).enableAutoScrollOnStreaming ?? true;const enableMessageLinkIcon = (s: UserStore) => generalConfig(s).enableMessageLinkIcon ?? true;+/** The setting is a boolean: either the live tool list is open or it is a+ * summary row. "Open" means the full list β the height-capped middle level+ * just hid part of what the user asked to see. */const workflowStreamingExpandLevel = (s: UserStore) =>- generalConfig(s).expandWorkflowWhileStreaming ? 'semi' : 'collapsed';+ generalConfig(s).expandWorkflowWhileStreaming ? 'full' : 'collapsed';export const userGeneralSettingsSelectors = {animationMode,