🤯 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(conversation): keep a running turn's process collapsed (#18928)
Innei8df2959eaf62
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex fe996b568f3..3f913a4f9fa 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -339,6 +339,9 @@"duplicateSession.title": "{{title}} Copy","duplicateTitle": "{{title}} Copy","editedFiles.hideChanges": "Hide changes",+ "editedFiles.showLess": "Show fewer files",+ "editedFiles.showMore_one": "Show {{count}} more file",+ "editedFiles.showMore_other": "Show {{count}} more files","editedFiles.singleTitle": "Edited {{path}}","editedFiles.title_one": "Edited {{count}} file","editedFiles.title_other": "Edited {{count}} files",diff --git a/locales/en-US/setting.json b/locales/en-US/setting.jsonindex f1669edafe8..a027eecf0c9 100644--- a/locales/en-US/setting.json+++ b/locales/en-US/setting.json@@ -944,6 +944,7 @@"settingChat.title": "Chat Settings","settingChatAppearance.autoScrollOnStreaming.desc": "Automatically scroll to bottom when AI is generating response","settingChatAppearance.autoScrollOnStreaming.title": "Auto-scroll During AI Response",+ "settingChatAppearance.chatBehavior.title": "Chat Behavior","settingChatAppearance.fontSize.desc": "Font size of messages","settingChatAppearance.fontSize.marks.normal": "Standard","settingChatAppearance.fontSize.title": "Font Size",@@ -959,6 +960,7 @@"settingChatAppearance.transitionMode.options.none.value": "None","settingChatAppearance.transitionMode.options.smooth": "Smooth","settingChatAppearance.transitionMode.title": "Transition Animation",+ "settingChatAppearance.workflowStreamingExpand.title": "Expand Tool Steps While Running","settingCommon.devMode.desc": "Show technical details and manual controls for chats, models, and local tools. This does not change model responses.","settingCommon.devMode.title": "Advanced tools","settingCommon.lang.autoMode": "Follow System",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 21c52ca41a2..48589a6aa98 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -339,6 +339,9 @@"duplicateSession.title": "{{title}} 副本","duplicateTitle": "{{title}} 副本","editedFiles.hideChanges": "收起更改",+ "editedFiles.showLess": "收起文件",+ "editedFiles.showMore_one": "展开另外 {{count}} 个文件",+ "editedFiles.showMore_other": "展开另外 {{count}} 个文件","editedFiles.singleTitle": "已编辑 {{path}}","editedFiles.title_one": "已编辑 {{count}} 个文件","editedFiles.title_other": "已编辑 {{count}} 个文件",diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.jsonindex a3bed798721..e7d5c31fb13 100644--- a/locales/zh-CN/setting.json+++ b/locales/zh-CN/setting.json@@ -944,6 +944,7 @@"settingChat.title": "聊天设置","settingChatAppearance.autoScrollOnStreaming.desc": "当 AI 正在生成回复时,自动滚动到底部","settingChatAppearance.autoScrollOnStreaming.title": "AI 回复时自动滚动",+ "settingChatAppearance.chatBehavior.title": "对话行为","settingChatAppearance.fontSize.desc": "消息字体大小","settingChatAppearance.fontSize.marks.normal": "标准","settingChatAppearance.fontSize.title": "字体大小",@@ -959,6 +960,7 @@"settingChatAppearance.transitionMode.options.none.value": "无","settingChatAppearance.transitionMode.options.smooth": "平滑","settingChatAppearance.transitionMode.title": "过渡动画",+ "settingChatAppearance.workflowStreamingExpand.title": "运行中展开工具步骤","settingCommon.devMode.desc": "显示对话、模型和本地工具的技术细节与手动控制项。不会改变模型回复方式。","settingCommon.devMode.title": "高级工具","settingCommon.lang.autoMode": "跟随系统",diff --git a/packages/builtin-tool-claude-code/src/client/Render/displayControls.test.ts b/packages/builtin-tool-claude-code/src/client/Render/displayControls.test.tsindex 9a509cae989..fd15e42929b 100644--- a/packages/builtin-tool-claude-code/src/client/Render/displayControls.test.ts+++ b/packages/builtin-tool-claude-code/src/client/Render/displayControls.test.ts@@ -63,7 +63,7 @@ describe('resolveClaudeCodeRenderDisplayControl', () => {});it('keeps the static map for every other api, regardless of pluginState', () => {- expect(resolveClaudeCodeRenderDisplayControl(ClaudeCodeApiName.Edit)).toBe('expand');+ expect(resolveClaudeCodeRenderDisplayControl(ClaudeCodeApiName.Edit)).toBe('collapsed');expect(resolveClaudeCodeRenderDisplayControl(ClaudeCodeApiName.TodoWrite)).toBe('expand');// An unrelated api with images on its result must not be force-expanded.expect(resolveClaudeCodeRenderDisplayControl(ClaudeCodeApiName.Grep, uploaded)).toBeUndefined();diff --git a/packages/builtin-tool-claude-code/src/client/Render/displayControls.ts b/packages/builtin-tool-claude-code/src/client/Render/displayControls.tsindex 30949e78148..0a4f5998bee 100644--- a/packages/builtin-tool-claude-code/src/client/Render/displayControls.ts+++ b/packages/builtin-tool-claude-code/src/client/Render/displayControls.ts@@ -17,12 +17,12 @@ import {* `getBuiltinRenderDisplayControl` as a fallback.*/const FixedClaudeCodeRenderDisplayControls: Record<string, RenderDisplayControl> = {- [ClaudeCodeApiName.Edit]: 'expand',+ [ClaudeCodeApiName.Edit]: 'collapsed',[ClaudeCodeApiName.SendMessage]: 'expand',[ClaudeCodeApiName.TaskList]: 'expand',[ClaudeCodeApiName.TaskUpdate]: 'expand',[ClaudeCodeApiName.TodoWrite]: 'expand',- [ClaudeCodeApiName.Write]: 'expand',+ [ClaudeCodeApiName.Write]: 'collapsed',...Object.fromEntries(LINEAR_MCP_TOOL_NAMES.map((tool) => [`${LINEAR_MCP_PREFIX}${tool}`, 'expand']),),diff --git a/packages/builtin-tools/src/codex/displayControls.ts b/packages/builtin-tools/src/codex/displayControls.tsindex 283c2788e87..e96ebeb8c71 100644--- a/packages/builtin-tools/src/codex/displayControls.ts+++ b/packages/builtin-tools/src/codex/displayControls.ts@@ -3,8 +3,8 @@ import type { RenderDisplayControl } from '@lobechat/types';export const CodexRenderDisplayControls: Record<string, RenderDisplayControl> = {collab_tool_call: 'expand',command_execution: 'collapsed',- file_change: 'expand',- mcp_tool_call: 'expand',+ file_change: 'collapsed',+ mcp_tool_call: 'collapsed',todo_list: 'expand',- web_search: 'expand',+ web_search: 'collapsed',};diff --git a/packages/builtin-tools/src/fileEditScan/index.ts b/packages/builtin-tools/src/fileEditScan/index.tsindex f09a17c7dc0..13d3e920639 100644--- a/packages/builtin-tools/src/fileEditScan/index.ts+++ b/packages/builtin-tools/src/fileEditScan/index.ts@@ -233,13 +233,38 @@ interface RenameOp extends EditOpBase {type EditOp = ChangeOp | RenameOp | WriteOp;+/**+ * Count changed lines in a unified patch. Some sources ship the patch but keep+ * their line counts one level up (Codex puts `linesAdded` on the tool state+ * root, not on each `changes[]` entry), which would otherwise leave every file+ * in the edited-files card reading "+0 -0". Header lines (`+++` / `---`) are+ * not content.+ */+const countPatchDeltas = (patch: string) => {+ let linesAdded = 0;+ let linesDeleted = 0;++ for (const line of patch.split('\n')) {+ if (line.startsWith('+++') || line.startsWith('---')) continue;+ if (line.startsWith('+')) linesAdded += 1;+ else if (line.startsWith('-')) linesDeleted += 1;+ }++ return { linesAdded, linesDeleted };+};+const emptyDeltas = (record: Record<string, unknown> | undefined,-): Pick<EditOpBase, 'diffText' | 'linesAdded' | 'linesDeleted'> => ({- diffText: record ? nonEmptyString(record.diffText) : undefined,- linesAdded: toNumber(record?.linesAdded),- linesDeleted: toNumber(record?.linesDeleted),-});+): Pick<EditOpBase, 'diffText' | 'linesAdded' | 'linesDeleted'> => {+ const diffText = record ? nonEmptyString(record.diffText) : undefined;+ const linesAdded = toNumber(record?.linesAdded);+ const linesDeleted = toNumber(record?.linesDeleted);++ if (diffText && linesAdded === 0 && linesDeleted === 0)+ return { diffText, ...countPatchDeltas(diffText) };++ return { diffText, linesAdded, linesDeleted };+};// ── Per-source extraction ────────────────────────────────────────────────────diff --git a/packages/builtin-tools/src/fileEditScan/patchDeltas.test.ts b/packages/builtin-tools/src/fileEditScan/patchDeltas.test.tsnew file mode 100644index 00000000000..1fe0ca5c228--- /dev/null+++ b/packages/builtin-tools/src/fileEditScan/patchDeltas.test.ts@@ -0,0 +1,43 @@+import { describe, expect, it } from 'vitest';++import { scanOperationFileEdits } from './index';++const codexRecord = (diffText: string) => [+ {+ apiName: 'file_change',+ arguments: '{}',+ identifier: 'codex',+ state: { changes: [{ diffText, kind: 'modified', path: '/repo/main/index.ts' }] },+ toolCallId: 'tc-1',+ },+];++describe('codex file_change line deltas', () => {+ it('counts them from the patch when the change entry carries no counts', () => {+ const patch = [+ '--- a/main/index.ts',+ '+++ b/main/index.ts',+ '@@ -1,3 +1,4 @@',+ ' keep',+ '-old line',+ '+new line',+ '+another new line',+ ].join('\n');++ const [entry] = scanOperationFileEdits(codexRecord(patch));++ expect(entry.linesAdded).toBe(2);+ expect(entry.linesDeleted).toBe(1);+ });++ it('keeps counts the source already provided', () => {+ const records = codexRecord('+++ b/x\n+a');+ (records[0].state.changes[0] as any).linesAdded = 9;+ (records[0].state.changes[0] as any).linesDeleted = 4;++ const [entry] = scanOperationFileEdits(records);++ expect(entry.linesAdded).toBe(9);+ expect(entry.linesDeleted).toBe(4);+ });+});diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 3f13bde7698..2d12cc27d62 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -245,6 +245,9 @@ export default {'editedFiles.title_one': 'Edited {{count}} file','editedFiles.title_other': 'Edited {{count}} files','editedFiles.hideChanges': 'Hide changes',+ 'editedFiles.showLess': 'Show fewer files',+ 'editedFiles.showMore_one': 'Show {{count}} more file',+ 'editedFiles.showMore_other': 'Show {{count}} more files','editedFiles.singleTitle': 'Edited {{path}}','editedFiles.viewChanges': 'View changes','emptyAgent': 'No Agents yet. Start with your first Agent—build your system over time.',diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.tsindex 97aa48c9ba7..4bc2f9ab7d4 100644--- a/packages/locales/src/default/setting.ts+++ b/packages/locales/src/default/setting.ts@@ -1088,6 +1088,8 @@ export default {'settingChatAppearance.autoScrollOnStreaming.desc':'Automatically scroll to bottom when AI is generating response','settingChatAppearance.autoScrollOnStreaming.title': 'Auto-scroll During AI Response',+ 'settingChatAppearance.chatBehavior.title': 'Chat Behavior',+ 'settingChatAppearance.workflowStreamingExpand.title': 'Expand Tool Steps While Running','settingChatAppearance.fontSize.desc': 'Font size of messages','settingChatAppearance.fontSize.marks.normal': 'Standard','settingChatAppearance.fontSize.title': 'Font Size',diff --git a/packages/types/src/user/settings/general.ts b/packages/types/src/user/settings/general.tsindex 1f6642d4362..a1340dbc2ef 100644--- a/packages/types/src/user/settings/general.ts+++ b/packages/types/src/user/settings/general.ts@@ -21,6 +21,12 @@ export interface UserGeneralConfig {* @default true*/enableMessageLinkIcon?: boolean;+ /**+ * Whether a turn's tool workflow starts expanded while the agent is still+ * running. Off keeps the running turn to a single live headline row.+ * @default false+ */+ expandWorkflowWhileStreaming?: boolean;fontSize: number;highlighterTheme?: HighlighterProps['theme'];isDevMode: boolean;diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsxindex 4098a3b9006..042d09c7c23 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx@@ -85,15 +85,7 @@ export const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(useGatewayReconnect(topicId, runningOperation, agentId);const itemContent = useCallback(- (index: number, id: string) => (- <MessageItem- disableEditing- defaultWorkflowExpandLevel="full"- id={id}- index={index}- key={id}- />- ),+ (index: number, id: string) => <MessageItem disableEditing id={id} index={index} key={id} />,[],);diff --git a/src/features/Conversation/Markdown/plugins/Link/Render/LinkChip.tsx b/src/features/Conversation/Markdown/plugins/Link/Render/LinkChip.tsxindex 2f7a0ffcd05..cdfe67d2cf7 100644--- a/src/features/Conversation/Markdown/plugins/Link/Render/LinkChip.tsx+++ b/src/features/Conversation/Markdown/plugins/Link/Render/LinkChip.tsx@@ -25,20 +25,17 @@ const styles = createStaticStyles(({ css, cssVar }) => ({vertical-align: -0.15em;`,sideBrowser: css`- pointer-events: none;- opacity: 0;- transition: opacity 0.15s;+ color: ${cssVar.colorTextTertiary};+ transition: color 0.15s;++ &:hover {+ color: ${cssVar.colorText};+ }`,wrapper: css`display: inline-flex;gap: 2px;align-items: center;-- &:hover [data-side-browser],- &:focus-within [data-side-browser] {- pointer-events: auto;- opacity: 1;- }`,}));diff --git a/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx b/src/features/Conversation/Messages/AssistantGroup/components/Group.tsxindex 306f3c759f2..d0bb3475db8 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/Group.tsx@@ -380,7 +380,7 @@ const Group = memo<GroupChildrenProps>(return (<MessageAggregationContext value={contextValue}>- <Flexbox className={styles.container} gap={8}>+ <Flexbox className={styles.container} gap={4}>{foldProcess ? (<><ProcessFold durationText={durationText} stepCount={llmCallCount}>diff --git a/src/features/Conversation/Messages/AssistantGroup/components/ProcessFold.tsx b/src/features/Conversation/Messages/AssistantGroup/components/ProcessFold.tsxindex bb0766d159c..206d4f1a388 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/ProcessFold.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/components/ProcessFold.tsx@@ -1,10 +1,39 @@-import { Accordion, AccordionItem, Flexbox } from '@lobehub/ui';-import { Text } from '@lobehub/ui/base-ui';-import { type Key, memo, type ReactNode, useMemo, useState } from 'react';+import { Flexbox, Icon } from '@lobehub/ui';+import { Accordion, Text } from '@lobehub/ui/base-ui';+import { Divider } from 'antd';+import { createStaticStyles } from 'antd-style';+import { ChevronRight } from 'lucide-react';+import { memo, type ReactNode, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';const PROCESS_KEY = 'process';+const styles = createStaticStyles(({ css, cssVar }) => ({+ title: css`+ min-width: 0;+ color: ${cssVar.colorTextTertiary};+ transition: color 150ms ${cssVar.motionEaseOut};++ &:hover {+ color: ${cssVar.colorText};+ }+ `,+}));++/**+ * The Accordion's borderless header paints a hover fill that bleeds outward+ * through a negative inline margin, and `message-body`'s `overflow: hidden`+ * clips that into cut corners. Stripping the header chrome leaves a bare text+ * row sitting on the answer's baseline, with hover reading as the text+ * brightening instead. Inline styles are deliberate — they outrank the+ * package's `:hover` background rule without an `!important`.+ */+const HEADER_STYLE = { background: 'transparent', margin: 0 } as const;+const TRIGGER_STYLE = { padding: 0 } as const;+/** The stripped header has no padding of its own, so the expanded process would+ * otherwise start flush against it. */+const CONTENT_STYLE = { paddingBlockStart: 8 } as const;+interface ProcessFoldProps {/** Rendered process (reasoning + tools + intermediate prose); shown only when expanded. */children: ReactNode;@@ -20,38 +49,45 @@ interface ProcessFoldProps {* Codex-style "已处理 {duration}" header that folds a finished turn's *process** (reasoning + tool calls + intermediate narration) into one persistent,* toggleable row. The turn's final answer is rendered separately and stays- * visible regardless of this state. Reuses the same Accordion chrome as- * WorkflowCollapse so the right-aligned expand chevron matches. Purely a view- * affordance — never persisted.+ * visible regardless of this state. Purely a view affordance — never persisted.*/const ProcessFold = memo<ProcessFoldProps>(({ children, durationText, stepCount, defaultExpanded = false }) => {const { t } = useTranslation('chat');const [expanded, setExpanded] = useState(defaultExpanded);- const expandedKeys = useMemo(() => (expanded ? [PROCESS_KEY] : []), [expanded]);+ const value = useMemo(() => (expanded ? [PROCESS_KEY] : []), [expanded]);const title = (- // minHeight matches WorkflowCollapse's 24px status-icon row so the header- // keeps the same height when the workflow is swapped for this fold.- <Flexbox horizontal align={'center'} style={{ minHeight: 24, minWidth: 0 }}>- <Text style={{ minWidth: 0 }} type={'secondary'}>+ <Flexbox horizontal align={'center'} className={styles.title} gap={6}>+ <Text style={{ color: 'inherit', minWidth: 0 }}>{durationText? t('turnProcess.ranFor', { count: stepCount, duration: durationText }): t('turnProcess.done', { count: stepCount })}</Text>+ <Icon+ icon={ChevronRight}+ size={14}+ style={{+ flex: 'none',+ transform: expanded ? 'rotate(90deg)' : undefined,+ transition: 'transform 200ms',+ }}+ /></Flexbox>);return (- <Accordion- expandedKeys={expandedKeys}- variant={'borderless'}- onExpandedChange={(keys: Key[]) => setExpanded(keys.includes(PROCESS_KEY))}- >- <AccordionItem itemKey={PROCESS_KEY} paddingBlock={4} paddingInline={4} title={title}>- {children}- </AccordionItem>- </Accordion>+ <>+ <Accordion+ hideIndicator+ items={[{ children, key: PROCESS_KEY, title }]}+ styles={{ content: CONTENT_STYLE, header: HEADER_STYLE, trigger: TRIGGER_STYLE }}+ value={value}+ variant={'borderless'}+ onValueChange={(next) => setExpanded(next.includes(PROCESS_KEY))}+ />+ <Divider style={{ marginBlock: 0 }} />+ </>);},);diff --git a/src/features/Conversation/Messages/AssistantGroup/components/segments.test.ts b/src/features/Conversation/Messages/AssistantGroup/components/segments.test.tsindex 3f1367f275c..a2fb4e6158f 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/segments.test.ts+++ b/src/features/Conversation/Messages/AssistantGroup/components/segments.test.ts@@ -2,7 +2,12 @@ import { describe, expect, it } from 'vitest';import { LOADING_FLAT } from '@/const/message';-import { countAssistantLlmCalls, hasRenderableFinalAnswer, shouldFoldProcess } from './segments';+import {+ countAssistantLlmCalls,+ hasRenderableFinalAnswer,+ resolveWorkflowExpandLevel,+ shouldFoldProcess,+} from './segments';const a = (id: string, content = 'answer') => ({block: { content, id } as any,@@ -137,3 +142,29 @@ describe('shouldFoldProcess', () => {).toBe(false);});});++describe('resolveWorkflowExpandLevel', () => {+ it('uses the setting when no override is given', () => {+ expect(resolveWorkflowExpandLevel(undefined, 'collapsed')).toEqual({ streaming: 'collapsed' });+ });++ it('lets an explicit streaming override win over the setting', () => {+ expect(resolveWorkflowExpandLevel({ streaming: 'full' }, 'collapsed')).toEqual({+ streaming: 'full',+ });+ });++ it('expands a string override into both phases and still wins', () => {+ expect(resolveWorkflowExpandLevel('full', 'collapsed')).toEqual({+ completion: 'full',+ streaming: 'full',+ });+ });++ it('keeps a completion-only override and fills streaming from the setting', () => {+ expect(resolveWorkflowExpandLevel({ completion: 'full' }, 'semi')).toEqual({+ completion: 'full',+ streaming: 'semi',+ });+ });+});diff --git a/src/features/Conversation/Messages/AssistantGroup/components/segments.ts b/src/features/Conversation/Messages/AssistantGroup/components/segments.tsindex f1b9ac825f3..b6922eae8e7 100644--- a/src/features/Conversation/Messages/AssistantGroup/components/segments.ts+++ b/src/features/Conversation/Messages/AssistantGroup/components/segments.ts@@ -3,6 +3,7 @@ import type { AssistantGroupSegment } from '@lobechat/conversation-flow';import { LOADING_FLAT } from '@/const/message';import type { RenderableAssistantContentBlock } from './types';+import type { WorkflowExpandLevel, WorkflowExpandLevelDefault } from './WorkflowCollapse';export type GroupRenderSegment = AssistantGroupSegment<RenderableAssistantContentBlock>;@@ -65,3 +66,18 @@ export const shouldFoldProcess = ({(!isLatestItem || !!hasFinalAnswer) &&!isGenerating &&processSegments.some((segment) => segment.kind === 'workflow');++/**+ * Merge the per-surface expand override with the user's streaming preference.+ * An explicit override always wins; the setting only fills a streaming phase+ * nobody asked for.+ */+export const resolveWorkflowExpandLevel = (+ override: WorkflowExpandLevelDefault | undefined,+ streamingSetting: WorkflowExpandLevel,+): WorkflowExpandLevelDefault => {+ const explicit =+ typeof override === 'string' ? { completion: override, streaming: override } : override;++ return { ...explicit, streaming: explicit?.streaming ?? streamingSetting };+};diff --git a/src/features/Conversation/Messages/AssistantGroup/index.tsx b/src/features/Conversation/Messages/AssistantGroup/index.tsxindex 369ec9a9f8e..1d504c0bb4a 100644--- a/src/features/Conversation/Messages/AssistantGroup/index.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/index.tsx@@ -47,6 +47,7 @@ import MessageWorks from '../MessageWorks';import SignalCallbacks from '../SignalCallbacks';import FileListViewer from '../User/components/FileListViewer';import Group from './components/Group';+import { resolveWorkflowExpandLevel } from './components/segments';import type { WorkflowExpandLevelDefault } from './components/WorkflowCollapse';const EditState = dynamic(() => import('./components/EditState'), {@@ -118,6 +119,14 @@ const GroupMessage = memo<GroupMessageProps>(const { t } = useTranslation('chat');const { count: commentCount, topicId: commentTopicId } = useMessageCommentCount(id);+ const streamingExpandLevel = useUserStore(+ userGeneralSettingsSelectors.workflowStreamingExpandLevel,+ );+ const workflowExpandLevel = useMemo(+ () => resolveWorkflowExpandLevel(defaultWorkflowExpandLevel, streamingExpandLevel),+ [defaultWorkflowExpandLevel, streamingExpandLevel],+ );+// Collect fileList from all children blocksconst aggregatedFileList = useMemo(() => {if (!children || children.length === 0) return [];@@ -250,24 +259,35 @@ const GroupMessage = memo<GroupMessageProps>() : undefined}actions={- !disableEditing && (- <>- {isDevMode && branch && (- <MessageBranch- activeBranchIndex={branch.activeBranchIndex}- count={branch.count}- messageId={id}- />- )}- {actionBarHolder}- </>- )+ <>+ {!disableEditing && (+ <>+ {isDevMode && branch && (+ <MessageBranch+ activeBranchIndex={branch.activeBranchIndex}+ count={branch.count}+ messageId={id}+ />+ )}+ {actionBarHolder}+ </>+ )}+ {/* Model + token usage rides the action row instead of claiming a+ band of its own between the answer and the round's artifacts. */}+ {isDevMode && model && (+ <Flexbox horizontal align={'center'} paddingInline={8}>+ <Usage model={model} performance={performance} provider={provider!} usage={usage} />+ </Flexbox>+ )}+ </>}- afterActions={+ belowMessage={// Virtual round artifacts (edited files / Goal handoffs) are derived// from the group's tool calls and stay visible after the tool steps- // collapse. Only mount the wrapper when one exists: a work anchor can- // be present while `MessageWorks` itself resolves to null.+ // collapse. They sit above the action row — they are the round's+ // result, while the action row is chrome about the message. Only+ // mount the wrapper when one exists: a work anchor can be present+ // while `MessageWorks` itself resolves to null.editedFiles.length > 0 || operationGoals.length > 0 ? (<Flexbox gap={8}>{editedFiles.length > 0 && <EditedFilesCard entries={editedFiles} />}@@ -309,7 +329,7 @@ const GroupMessage = memo<GroupMessageProps>(contentId={contentId}// Folding a finished turn's process is the default behavior now// (graduated from Labs) — always on for the conversation.- defaultWorkflowExpandLevel={defaultWorkflowExpandLevel}+ defaultWorkflowExpandLevel={workflowExpandLevel}disableEditing={disableEditing}id={id}isLatestItem={isLatestItem}@@ -323,7 +343,7 @@ const GroupMessage = memo<GroupMessageProps>(<Groupblocks={taskCompletions}contentId={taskCompletions.at(-1)?.id}- defaultWorkflowExpandLevel={defaultWorkflowExpandLevel}+ defaultWorkflowExpandLevel={workflowExpandLevel}disableEditing={disableEditing}id={id}messageIndex={index}@@ -337,9 +357,6 @@ const GroupMessage = memo<GroupMessageProps>(</div>)}{interrupted && <InterruptedHint />}- {isDevMode && model && (- <Usage model={model} performance={performance} provider={provider!} usage={usage} />- )}{footerRender}<Suspense fallback={null}>{editing && contentId && <EditState content={lastAssistantMsg?.content} id={contentId} />}diff --git a/src/features/Conversation/Messages/EditedFilesCard/index.test.ts b/src/features/Conversation/Messages/EditedFilesCard/index.test.tsindex 03afb1519f7..aaf2d88c1dc 100644--- a/src/features/Conversation/Messages/EditedFilesCard/index.test.ts+++ b/src/features/Conversation/Messages/EditedFilesCard/index.test.ts@@ -64,13 +64,13 @@ describe('getFilePathDisplayInfo', () => {});describe('SINGLE_EDITED_FILE_ICON_SIZE', () => {- it('keeps the single-file icon container compact', () => {+ it('matches the height of the two-line title block beside it', () => {expect(SINGLE_EDITED_FILE_ICON_SIZE).toBe(40);});});describe('AGGREGATE_EDITED_FILE_ICON_SIZE', () => {- it('keeps the multi-file summary as compact as the single-file card', () => {+ it('matches the single-file card so stacked cards share one icon scale', () => {expect(AGGREGATE_EDITED_FILE_ICON_SIZE).toBe(40);});});@@ -86,7 +86,7 @@ describe('SingleEditedFileCard', () => {expect(summary).toHaveTextContent('+7');expect(summary).toHaveTextContent('-2');expect(summary).not.toContainElement(action);- expect(action).toHaveAttribute('data-view-changes');+ expect(action.closest('[data-view-changes]')).not.toBeNull();expect(action).toHaveAttribute('aria-expanded', 'false');fireEvent.click(action);diff --git a/src/features/Conversation/Messages/EditedFilesCard/index.tsx b/src/features/Conversation/Messages/EditedFilesCard/index.tsxindex 8b169b07043..a173fe5b095 100644--- a/src/features/Conversation/Messages/EditedFilesCard/index.tsx+++ b/src/features/Conversation/Messages/EditedFilesCard/index.tsx@@ -12,7 +12,13 @@ import {import { Center, Flexbox, PatchDiff } from '@lobehub/ui';import { Button, Text } from '@lobehub/ui/base-ui';import { createStaticStyles, cx } from 'antd-style';-import { ArrowUpRightIcon, ChevronDownIcon, ChevronRightIcon, FilePenLineIcon } from 'lucide-react';+import {+ ArrowUpRightIcon,+ ChevronDownIcon,+ ChevronRightIcon,+ ChevronUpIcon,+ FilePenLineIcon,+} from 'lucide-react';import { type KeyboardEvent, memo, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -24,6 +30,9 @@ import { useOpenEditedFile } from './useOpenEditedFile';export const SINGLE_EDITED_FILE_ICON_SIZE = 40;export const AGGREGATE_EDITED_FILE_ICON_SIZE = 40;+/** Files listed before the "show N more" row, matching Codex's file toolbar. */+export const INITIAL_VISIBLE_EDITED_FILES = 3;+/** Fire a toggle on Enter/Space so the div-based expander is keyboard operable. */const toggleOnKey = (toggle: () => void) => (event: KeyboardEvent<HTMLDivElement>) => {if (event.key === 'Enter' || event.key === ' ') {@@ -43,27 +52,23 @@ const styles = createStaticStyles(({ css, cssVar }) => ({background: ${cssVar.colorBgElevated};`,header: css`- cursor: pointer;- padding-block: 10px;+ padding-block: 8px;padding-inline: 12px;-- &:hover {- background: ${cssVar.colorFillQuaternary};- }`,headerIcon: css`flex-shrink: 0;width: ${AGGREGATE_EDITED_FILE_ICON_SIZE}px;height: ${AGGREGATE_EDITED_FILE_ICON_SIZE}px;- border-radius: 10px;+ border-radius: 8px;color: ${cssVar.colorTextSecondary};background: ${cssVar.colorFillTertiary};`,singleHeader: css`- padding-block: 10px;+ position: relative;+ padding-block: 8px;padding-inline: 12px;&:hover [data-view-changes],@@ -80,47 +85,49 @@ const styles = createStaticStyles(({ css, cssVar }) => ({background: ${cssVar.colorFillQuaternary};}`,- singleIcon: css`- flex-shrink: 0;-- width: ${SINGLE_EDITED_FILE_ICON_SIZE}px;- height: ${SINGLE_EDITED_FILE_ICON_SIZE}px;- border-radius: 10px;-- background: ${cssVar.colorFillTertiary};- `,singleTitle: css`min-width: 0;font-size: 14px;font-weight: 500;`,+ /**+ * The action slides *over* the line stats instead of displacing them, so the+ * `+N -M` column stays put on hover. The two stacked gradients composite to+ * exactly the hovered row colour (fill over elevated), which is why the+ * opaque end shows no seam against the row behind it.+ */viewChanges: css`pointer-events: none;- transform: translateX(4px);+ position: absolute;+ inset-block: 0;+ inset-inline-end: 0;- align-self: center;-- height: 22px;- padding: 0;+ display: flex;+ align-items: center;+ justify-content: flex-end;- color: ${cssVar.colorTextSecondary};+ padding-inline: 56px 12px;opacity: 0;+ background:+ linear-gradient(to left, ${cssVar.colorFillQuaternary} 62%, transparent),+ linear-gradient(to left, ${cssVar.colorBgElevated} 62%, transparent);- transition:- opacity 150ms ease,- transform 150ms ease;+ transition: opacity 160ms ${cssVar.motionEaseOut};@media (hover: none) {pointer-events: auto;- transform: translateX(0);opacity: 1;}`,+ viewChangesButton: css`+ height: 22px;+ padding: 0;+ color: ${cssVar.colorTextSecondary};+ `,viewChangesVisible: css`pointer-events: auto;- transform: translateX(0);opacity: 1;`,chevron: css`@@ -138,7 +145,21 @@ const styles = createStaticStyles(({ css, cssVar }) => ({list: css`border-block-start: 1px solid ${cssVar.colorBorderSecondary};`,+ showMore: css`+ cursor: pointer;++ padding-block: 7px;+ padding-inline: 12px;++ font-size: 13px;+ color: ${cssVar.colorTextSecondary};++ &:hover {+ background: ${cssVar.colorFillQuaternary};+ }+ `,row: css`+ position: relative;padding-block: 6px;padding-inline: 12px;@@ -211,22 +232,26 @@ const EditedFileRow = memo<{ entry: EditedFileEntry; onOpen?: () => void }>(({ elinesDeleted={entry.linesDeleted}/>{onOpen && hasDiff && (- <Button+ <divdata-view-changes- aria-expanded={expanded}className={cx(styles.viewChanges, expanded && styles.viewChangesVisible)}- size={'small'}- type={'text'}- // Enter/Space on the button must not bubble into the row's own- // key handler, which would also open the file preview.- onKeyDown={(event) => event.stopPropagation()}- onClick={(event) => {- event.stopPropagation();- setExpanded((prev) => !prev);- }}>- {t(expanded ? 'editedFiles.hideChanges' : 'editedFiles.viewChanges')}- </Button>+ <Button+ aria-expanded={expanded}+ className={styles.viewChangesButton}+ size={'small'}+ type={'text'}+ // Enter/Space on the button must not bubble into the row's own+ // key handler, which would also open the file preview.+ onKeyDown={(event) => event.stopPropagation()}+ onClick={(event) => {+ event.stopPropagation();+ setExpanded((prev) => !prev);+ }}+ >+ {t(expanded ? 'editedFiles.hideChanges' : 'editedFiles.viewChanges')}+ </Button>+ </div>)}{!onOpen &&hasDiff &&@@ -289,9 +314,10 @@ const SingleEditedFileCard = memo<{ entry: EditedFileEntry; onOpen?: () => voidonClick={onOpen}onKeyDown={onOpen ? toggleOnKey(onOpen) : undefined}>- <Center className={styles.singleIcon}>- <FileIcon fileName={getEditedFileIconName(entry.path)} size={24} />- </Center>+ <FileIcon+ fileName={getEditedFileIconName(entry.path)}+ size={SINGLE_EDITED_FILE_ICON_SIZE}+ /><Flexbox flex={1} gap={2}><Text ellipsis className={styles.singleTitle}>{t('editedFiles.singleTitle', { path: displayPath })}@@ -304,24 +330,28 @@ const SingleEditedFileCard = memo<{ entry: EditedFileEntry; onOpen?: () => void/></Flexbox>{hasDiff && (- <Button+ <divdata-view-changes- aria-expanded={showDiff}className={cx(styles.viewChanges, showDiff && styles.viewChangesVisible)}- icon={<ArrowUpRightIcon size={14} />}- iconPosition={'end'}- size={'small'}- type={'text'}- onKeyDown={(event) => event.stopPropagation()}- onClick={(event) => {- // The header itself may open the file preview — keep the diff- // toggle from also triggering it.- event.stopPropagation();- setShowDiff((prev) => !prev);- }}>- {t(showDiff ? 'editedFiles.hideChanges' : 'editedFiles.viewChanges')}- </Button>+ <Button+ aria-expanded={showDiff}+ className={styles.viewChangesButton}+ icon={<ArrowUpRightIcon size={14} />}+ iconPosition={'end'}+ size={'small'}+ type={'text'}+ onKeyDown={(event) => event.stopPropagation()}+ onClick={(event) => {+ // The header itself may open the file preview — keep the diff+ // toggle from also triggering it.+ event.stopPropagation();+ setShowDiff((prev) => !prev);+ }}+ >+ {t(showDiff ? 'editedFiles.hideChanges' : 'editedFiles.viewChanges')}+ </Button>+ </div>)}</Flexbox>{hasDiff && showDiff && (@@ -353,7 +383,7 @@ SingleEditedFileCard.displayName = 'SingleEditedFileCard';*/const EditedFilesCard = memo<EditedFilesCardProps>(({ entries }) => {const { t } = useTranslation('chat');- const [expanded, setExpanded] = useState(false);+ const [showAll, setShowAll] = useState(false);const getOpenAction = useOpenEditedFile();if (entries.length === 0) return null;@@ -361,24 +391,19 @@ const EditedFilesCard = memo<EditedFilesCardProps>(({ entries }) => {return <SingleEditedFileCard entry={entries[0]} onOpen={getOpenAction(entries[0])} />;const totals = summarizeEditedFilesTotals(entries);+ // The edited-file set is the round's *result*, not one of its steps — it opens+ // with the first few files already listed and defers only the long tail.+ const hiddenCount = entries.length - INITIAL_VISIBLE_EDITED_FILES;+ const visible = showAll ? entries : entries.slice(0, INITIAL_VISIBLE_EDITED_FILES);+ const toggleShowAll = () => setShowAll((prev) => !prev);return (<Flexbox className={styles.card}>- <Flexbox- horizontal- align={'center'}- aria-expanded={expanded}- className={styles.header}- gap={10}- role={'button'}- tabIndex={0}- onClick={() => setExpanded((prev) => !prev)}- onKeyDown={toggleOnKey(() => setExpanded((prev) => !prev))}- >+ <Flexbox horizontal align={'center'} className={styles.header} gap={10}><Center className={styles.headerIcon}>- <FilePenLineIcon size={24} />+ <FilePenLineIcon size={20} /></Center>- <Flexbox flex={1} gap={3} style={{ minWidth: 0 }}>+ <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}><Text ellipsis className={styles.title}>{t('editedFiles.title', { count: entries.length })}</Text>@@ -389,19 +414,34 @@ const EditedFilesCard = memo<EditedFilesCardProps>(({ entries }) => {linesDeleted={totals.linesDeleted}/></Flexbox>- {expanded ? (- <ChevronDownIcon className={styles.chevron} size={16} />- ) : (- <ChevronRightIcon className={styles.chevron} size={16} />+ </Flexbox>+ <Flexbox className={styles.list}>+ {visible.map((entry) => (+ <EditedFileRow entry={entry} key={entry.path} onOpen={getOpenAction(entry)} />+ ))}+ {hiddenCount > 0 && (+ <Flexbox+ horizontal+ align={'center'}+ aria-expanded={showAll}+ className={styles.showMore}+ gap={6}+ role={'button'}+ tabIndex={0}+ onClick={toggleShowAll}+ onKeyDown={toggleOnKey(toggleShowAll)}+ >+ {showAll+ ? t('editedFiles.showLess')+ : t('editedFiles.showMore', { count: hiddenCount })}+ {showAll ? (+ <ChevronUpIcon className={styles.chevron} size={14} />+ ) : (+ <ChevronDownIcon className={styles.chevron} size={14} />+ )}+ </Flexbox>)}</Flexbox>- {expanded && (- <Flexbox className={styles.list}>- {entries.map((entry) => (- <EditedFileRow entry={entry} key={entry.path} onOpen={getOpenAction(entry)} />- ))}- </Flexbox>- )}</Flexbox>);});diff --git a/src/features/Portal/Topic/Chat/index.tsx b/src/features/Portal/Topic/Chat/index.tsxindex b942f711bce..b6227858638 100644--- a/src/features/Portal/Topic/Chat/index.tsx+++ b/src/features/Portal/Topic/Chat/index.tsx@@ -117,9 +117,7 @@ const TopicChat = memo(() => {{topicPending ? (<TopicMigrationPlaceholder agentId={activeAgentId} topicId={portalTopicId} />) : (- <ChatList- defaultWorkflowExpandLevel={isHeterogeneousAgent ? { streaming: 'full' } : undefined}- />+ <ChatList />)}</Flexbox></Suspense>diff --git a/src/features/Settings/chat-appearance/features/ChatAppearance/index.tsx b/src/features/Settings/chat-appearance/features/ChatAppearance/index.tsxindex de2d064f7f9..e2d0b78bb8e 100644--- a/src/features/Settings/chat-appearance/features/ChatAppearance/index.tsx+++ b/src/features/Settings/chat-appearance/features/ChatAppearance/index.tsx@@ -1,12 +1,13 @@'use client';-import { Flexbox, FormGroup, highlighterThemes, mermaidThemes, Skeleton } from '@lobehub/ui';+import { Flexbox, Form, FormGroup, highlighterThemes, mermaidThemes, Skeleton } from '@lobehub/ui';import { Select, Switch, Tabs } from '@lobehub/ui/base-ui';import isEqual from 'fast-deep-equal';import { memo, useState } from 'react';import { useTranslation } from 'react-i18next';import AutoSaveHint from '@/components/Editor/AutoSaveHint';+import { FORM_STYLE } from '@/const/layoutTokens';import { useSaveState } from '@/hooks/useSaveState';import { useUserStore } from '@/store/user';import { settingsSelectors } from '@/store/user/selectors';@@ -70,41 +71,59 @@ const ChatAppearance = memo(() => {<ChatTransitionPreview key={general.transitionMode} mode={general.transitionMode} /></FormGroup>- <FormGroup- active={false}- collapsible={false}- title={t('settingChatAppearance.autoScrollOnStreaming.title')}- variant={'filled'}- extra={- <Flexbox horizontal align={'center'} gap={8}>- {renderSaveHint('enableAutoScrollOnStreaming')}- <Switch- checked={general.enableAutoScrollOnStreaming ?? true}- onChange={(checked) => handleChange('enableAutoScrollOnStreaming', checked)}- />- </Flexbox>- }- >- {null}- </FormGroup>-- <FormGroup+ <Formcollapsible={false}- gap={16}- title={t('settingChatAppearance.linkIcon.title')}+ itemsType={'group'}variant={'filled'}- extra={- <Flexbox horizontal align={'center'} gap={8}>- {renderSaveHint('enableMessageLinkIcon')}- <Switch- checked={general.enableMessageLinkIcon ?? true}- onChange={(checked) => handleChange('enableMessageLinkIcon', checked)}- />- </Flexbox>- }- >- <LinkIconPreview />- </FormGroup>+ items={[+ {+ children: [+ {+ children: (+ <Flexbox horizontal align={'center'} gap={8}>+ {renderSaveHint('enableAutoScrollOnStreaming')}+ <Switch+ checked={general.enableAutoScrollOnStreaming ?? true}+ onChange={(checked) => handleChange('enableAutoScrollOnStreaming', checked)}+ />+ </Flexbox>+ ),+ label: t('settingChatAppearance.autoScrollOnStreaming.title'),+ minWidth: undefined,+ },+ {+ children: (+ <Flexbox horizontal align={'center'} gap={8}>+ {renderSaveHint('expandWorkflowWhileStreaming')}+ <Switch+ checked={general.expandWorkflowWhileStreaming ?? false}+ onChange={(checked) => handleChange('expandWorkflowWhileStreaming', checked)}+ />+ </Flexbox>+ ),+ label: t('settingChatAppearance.workflowStreamingExpand.title'),+ minWidth: undefined,+ },+ {+ children: (+ <Flexbox horizontal align={'center'} gap={8}>+ {renderSaveHint('enableMessageLinkIcon')}+ <Switch+ checked={general.enableMessageLinkIcon ?? true}+ onChange={(checked) => handleChange('enableMessageLinkIcon', checked)}+ />+ </Flexbox>+ ),+ desc: <LinkIconPreview />,+ label: t('settingChatAppearance.linkIcon.title'),+ minWidth: undefined,+ },+ ],+ title: t('settingChatAppearance.chatBehavior.title'),+ },+ ]}+ {...FORM_STYLE}+ /><FormGroupcollapsible={false}diff --git a/src/features/Work/WorkSummaryCard.tsx b/src/features/Work/WorkSummaryCard.tsxindex 0decfd1870d..73d04786393 100644--- a/src/features/Work/WorkSummaryCard.tsx+++ b/src/features/Work/WorkSummaryCard.tsx@@ -100,7 +100,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({`,title: css`min-width: 0;- font-size: 14px;+ font-size: 15px;font-weight: 500;`,}));@@ -229,7 +229,7 @@ const WorkSummaryCard = memo<WorkSummaryCardProps>(<Flexbox align={'center'} className={styles.icon} justify={'center'}><Icon size={18} /></Flexbox>- <Flexbox flex={1} gap={6} style={{ minWidth: 0 }}>+ <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}><Flexbox horizontal align={'center'} gap={8} justify={'space-between'}><Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0 }}><Text ellipsis className={styles.title}>@@ -258,7 +258,7 @@ const WorkSummaryCard = memo<WorkSummaryCardProps>()}</Flexbox>{description && (- <Text ellipsis className={styles.description} fontSize={13}>+ <Text ellipsis className={styles.description} fontSize={12}>{description}</Text>)}diff --git a/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx b/src/routes/(main)/agent/features/Conversation/ConversationArea.tsxindex 7df6e0a4d52..3144fe8a4b2 100644--- a/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx+++ b/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx@@ -156,7 +156,6 @@ const Conversation = memo(() => {<TopicMigrationPlaceholder agentId={context.agentId} topicId={context.topicId} />) : (<ChatList- defaultWorkflowExpandLevel={isHeterogeneousAgent ? { streaming: 'full' } : undefined}headerSlot={<div aria-hidden className={styles.floatingHeaderSpacer} />}welcome={<AgentHome />}footerSlot={diff --git a/src/store/user/slices/settings/selectors/general.ts b/src/store/user/slices/settings/selectors/general.tsindex d9d5c68f77b..ecea5d5c0cb 100644--- a/src/store/user/slices/settings/selectors/general.ts+++ b/src/store/user/slices/settings/selectors/general.ts@@ -35,6 +35,8 @@ const telemetry = (s: UserStore) => generalConfig(s).telemetry;const enableAutoScrollOnStreaming = (s: UserStore) =>generalConfig(s).enableAutoScrollOnStreaming ?? true;const enableMessageLinkIcon = (s: UserStore) => generalConfig(s).enableMessageLinkIcon ?? true;+const workflowStreamingExpandLevel = (s: UserStore) =>+ generalConfig(s).expandWorkflowWhileStreaming ? 'semi' : 'collapsed';export const userGeneralSettingsSelectors = {animationMode,@@ -51,4 +53,5 @@ export const userGeneralSettingsSelectors = {responseLanguage,telemetry,transitionMode,+ workflowStreamingExpandLevel,};