🤯 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(task): polish run card — rich-text result, colors, per-run follow-up (LOBE-11396) (#16751)
Arvin Xu2c69c1836176
diff --git a/.agents/skills/agent-testing/references/common-mistakes.md b/.agents/skills/agent-testing/references/common-mistakes.mdindex 7dd1560addb..5cc6a7fbe6b 100644--- a/.agents/skills/agent-testing/references/common-mistakes.md+++ b/.agents/skills/agent-testing/references/common-mistakes.md@@ -205,6 +205,31 @@ background process holds), build whatever fixture data the surface needs (createthrowaway git repo, `git worktree add` a second tree, point a fresh conversation'sworking directory at it, etc.), capture the real rendered screenshot/GIF, verifyit by opening the PNG, and publish the `/verify` report. Only surface a-plan-approval question when the *product decision* is ambiguous (what to test),-never for *environment mechanics* (how to render it). Env obstacles are the+plan-approval question when the _product decision_ is ambiguous (what to test),+never for _environment mechanics_ (how to render it). Env obstacles are theskill's job to solve and then iterate back into these logs.++---++## Case 9 — Self-judging a screenshot as "too costly" and asking the user to picture the result++**Wrong approach**: after a small user-facing UI change (a padding tweak), skipping+the rendered screenshot with "it's a trivial style change; restarting Electron to+screenshot costs more than the change is worth — tell me if you want one." I decided+the cost/benefit for the user and shipped a diff they had to picture in their head.++**Why it's wrong**: whether a verification artifact is "worth it" is **not mine to+decide**. The measuring stick is _whether the user can conveniently inspect the+product_, not how much effort _I_ spend rendering it. Making the user guess the visual+effect from a code diff is the actually-expensive outcome.++**What it breaks**: the user can't check the deliverable, loses trust, and has to push+back (" 成本高不高不是你自己说了算,而是用户是否方便检查产物作为衡量标准。你让用户猜效果+这个成本才高,别瞎揣测和偷懒 ") — burning a round to get the screenshot I should have+produced up front.++**Correct approach**: for ANY user-facing change (even one line of padding/color),+default to rendering it and attaching the screenshot to the verify report as a record+point — open the PNG to confirm, publish. Never offer the screenshot as an opt-in+("want me to screenshot?"); just produce it. Env/restart cost is the skill's job to+absorb, not a reason to shift the checking burden onto the user.diff --git a/apps/server/src/services/task/index.test.ts b/apps/server/src/services/task/index.test.tsindex 3a8cbbba82f..7260f274b03 100644--- a/apps/server/src/services/task/index.test.ts+++ b/apps/server/src/services/task/index.test.ts@@ -630,6 +630,61 @@ describe('TaskService', () => {expect(result?.activities?.[1].type).toBe('topic');});+ it('exposes the run last message (handoff.content) alongside the summary (LOBE-11396)', async () => {+ const task = {+ assigneeAgentId: null,+ assigneeUserId: null,+ createdAt: null,+ description: null,+ error: null,+ heartbeatInterval: null,+ heartbeatTimeout: null,+ id: 'task_001',+ identifier: 'TASK-1',+ instruction: null,+ lastHeartbeatAt: null,+ name: 'Task 1',+ parentTaskId: null,+ priority: 'normal',+ status: 'todo',+ totalTopics: 0,+ };++ const topics = [+ {+ createdAt: new Date('2024-01-03T00:00:00Z'),+ handoff: {+ content: 'The raw last assistant message shown as the run result.',+ summary: 'A short synthesized summary.',+ title: 'Topic A',+ },+ seq: 1,+ status: 'completed',+ topicId: 'topic-1',+ },+ ];++ mockTaskModel.resolve.mockResolvedValue(task);+ mockTaskModel.findAllDescendants.mockResolvedValue([]);+ mockTaskModel.getDependencies.mockResolvedValue([]);+ mockTaskTopicModel.findWithHandoff.mockResolvedValue(topics);+ mockBriefModel.findByTaskId.mockResolvedValue([]);+ mockTaskModel.getComments.mockResolvedValue([]);+ mockTaskModel.getTreePinnedDocuments.mockResolvedValue({ nodeMap: {}, tree: [] });+ mockTaskModel.findByIds.mockResolvedValue([]);+ mockTaskModel.getCheckpointConfig.mockReturnValue({});+ mockTaskModel.getVerifyConfig.mockReturnValue(undefined);++ const service = new TaskService(db, userId);+ const result = await service.getTaskDetail('TASK-1');++ const topicActivity = result?.activities?.find((a) => a.type === 'topic');+ expect(topicActivity?.summary).toBe('A short synthesized summary.');+ expect(topicActivity?.content).toBe(+ 'The raw last assistant message shown as the run result.',+ );+ });+it('should resolve author info for activities', async () => {const task = {assigneeAgentId: 'agt_assignee',diff --git a/apps/server/src/services/task/index.ts b/apps/server/src/services/task/index.tsindex 67a3733cc6e..8b827942d09 100644--- a/apps/server/src/services/task/index.ts+++ b/apps/server/src/services/task/index.ts@@ -736,6 +736,9 @@ export class TaskService {return {author: topicAgentId ? authorMap.get(topicAgentId) : undefined,completedAt: toISO(t.completedAt),+ // Raw last assistant message of the run (LOBE-11396), shown alongside+ // the synthesized summary on the run card.+ content: handoff?.content,id: t.topicId ?? undefined,operationId: t.operationId ?? null,runningOperation: t.metadata?.runningOperation ?? null,diff --git a/apps/server/src/services/taskLifecycle/index.ts b/apps/server/src/services/taskLifecycle/index.tsindex 1ae0e81c422..8d6f0c466ff 100644--- a/apps/server/src/services/taskLifecycle/index.ts+++ b/apps/server/src/services/taskLifecycle/index.ts@@ -125,7 +125,7 @@ export class TaskLifecycleService {// 1. Update topic statusif (topicId) await this.taskTopicModel.updateStatus(taskId, topicId, 'completed');- // 2. Generate handoff summary + topic title+ // 2. Generate handoff summary + topic title (best-effort LLM synthesis).if (topicId && lastAssistantContent) {await this.generateHandoff(taskId,@@ -136,6 +136,18 @@ export class TaskLifecycleService {);}+ // 2b. Persist the raw last message as the run card's result (LOBE-11396).+ // Done independently of (and after) generateHandoff via a jsonb_set+ // patch, so `handoff.content` is written even when the summary LLM in+ // step 2 throws — otherwise a completed run would show no result.+ if (topicId && lastAssistantContent) {+ try {+ await this.taskTopicModel.updateHandoffContent(taskId, topicId, lastAssistantContent);+ } catch (e) {+ console.warn('[TaskLifecycle] persisting run last message failed:', e);+ }+ }+// 3. Delivery acceptance now runs through Verify: the verify// run settles asynchronously (agent verifier) and drives the task to its// terminal state via `driveTaskFromVerify`. The legacy eval-rubric@@ -440,7 +452,9 @@ export class TaskLifecycleService {await this.topicModel.update(topicId, { title: handoff.title });}- // Store handoff in task_topics dedicated fields+ // Store handoff in task_topics dedicated fields. `handoff.content` (the raw+ // last message) is persisted separately in onTopicComplete so it survives+ // even when this LLM synthesis throws.await this.taskTopicModel.updateHandoff(taskId, topicId, handoff);log('handoff generated for topic %s: title=%s', topicId, handoff.title);diff --git a/apps/server/src/services/taskLifecycle/onTopicComplete.test.ts b/apps/server/src/services/taskLifecycle/onTopicComplete.test.tsindex 5a7d671ebe2..bcf41b8176b 100644--- a/apps/server/src/services/taskLifecycle/onTopicComplete.test.ts+++ b/apps/server/src/services/taskLifecycle/onTopicComplete.test.ts@@ -67,6 +67,7 @@ describe('TaskLifecycleService.onTopicComplete', () => {taskModel.shouldPauseOnTopicComplete = vi.fn().mockReturnValue(true);// Avoid generateHandoff side effects by skipping when lastAssistantContent is undefined(service as any).taskTopicModel.updateStatus = updateTopicStatus;+ (service as any).taskTopicModel.updateHandoffContent = vi.fn().mockResolvedValue(undefined);(service as any).briefModel.create = createBrief;(service as any).briefModel.hasUnresolvedUrgentByTask = vi.fn().mockResolvedValue(false);});@@ -92,6 +93,30 @@ describe('TaskLifecycleService.onTopicComplete', () => {expect(updateStatus).not.toHaveBeenCalledWith('task-1', 'paused', expect.anything());});+ it('persists the run last message independently of handoff summary (LOBE-11396)', async () => {+ const task = baseTask({ automationMode: 'heartbeat' });+ findById.mockResolvedValue(task);+ // Model the summary path as a no-op (e.g. its LLM call failed and was+ // swallowed) — the raw last message must still be persisted for the card.+ vi.spyOn(service as any, 'generateHandoff').mockResolvedValue(undefined);+ const updateHandoffContent = (service as any).taskTopicModel.updateHandoffContent;++ await service.onTopicComplete({+ lastAssistantContent: 'the raw last assistant message',+ operationId: 'op-1',+ reason: 'done',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ expect(updateHandoffContent).toHaveBeenCalledWith(+ 'task-1',+ 'topic-1',+ 'the raw last assistant message',+ );+ });+it('schedule-mode task → status="scheduled"', async () => {const task = baseTask({ automationMode: 'schedule' });findById.mockResolvedValue(task);diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 0eb8099a9bb..fd6ae37d2dd 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -484,7 +484,6 @@"messages.modelCard.pricing.inputTokens": "Input {{amount}} credits · ${{amount}}/M","messages.modelCard.pricing.outputTokens": "Output {{amount}} credits · ${{amount}}/M","messages.modelCard.pricing.writeCacheInputTokens": "Cache write {{amount}} credits · ${{amount}}/M",- "messages.sentBy": "Sent by {{name}}","messages.tokenDetails.average": "Average unit price","messages.tokenDetails.cacheRate": "Cache rate","messages.tokenDetails.input": "Input",@@ -604,6 +603,7 @@"resources.knowledgePicker.publicAgentHint": "Public agents can only reference workspace resources. Publish a private resource to the workspace first if you want to attach it.","resources.mode.privateHint": "Your own drawer — only you can see these files","resources.mode.workspaceHint": "Shared with everyone in this workspace",+ "resources.publishToWorkspace.confirm": "Other workspace members will be able to see this file. You will not be able to make it private again.","resources.publishToWorkspace.error": "Failed to publish file to workspace","resources.publishToWorkspace.menu": "Publish to Workspace","resources.publishToWorkspace.success": "Published to workspace",@@ -857,6 +857,8 @@"taskDetail.runAll.skipped.blockedExternally": "{{count}} task(s) waiting on a blocker outside this batch — will run automatically when unblocked","taskDetail.runAll.skipped.ineligible": "{{count}} task(s) running or scheduled — skipped","taskDetail.runAll.title": "Run subtasks in dependency order",+ "taskDetail.runFollowUp": "Ask a follow-up",+ "taskDetail.runFollowUpPlaceholder": "Ask a follow-up about this run...","taskDetail.runNow": "Run now","taskDetail.runTask": "Run","taskDetail.saveModelConfig": "Save",@@ -889,7 +891,7 @@"taskList.assigneeSearch.placeholder": "Search agent...","taskList.breadcrumb.task": "Task","taskList.contextMenu.copyConfirm": "Copy",- "taskList.contextMenu.copyDescription": "You can copy to personal or workspaces that have permission to create a task.",+ "taskList.contextMenu.copyDescription": "Clone this task (and all its subtasks) into another workspace. Status resets to backlog.","taskList.contextMenu.copyFailed": "Failed to copy task","taskList.contextMenu.copyId": "Copy ID","taskList.contextMenu.copyIdSuccess": "ID copied",@@ -902,7 +904,7 @@"taskList.contextMenu.runNow": "Run now","taskList.contextMenu.status": "Status","taskList.contextMenu.transferConfirm": "Transfer",- "taskList.contextMenu.transferDescription": "You can move to personal or workspaces that have permission to create a task.",+ "taskList.contextMenu.transferDescription": "Move this task (and all its subtasks) to another workspace. Identifiers will be re-assigned.","taskList.contextMenu.transferFailed": "Failed to transfer task","taskList.contextMenu.transferSuccess": "Task transferred","taskList.contextMenu.transferTitle": "Transfer task",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex 447d940e454..437ffd793b5 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -484,7 +484,6 @@"messages.modelCard.pricing.inputTokens": "输入 {{amount}} 积分 · ${{amount}}/M","messages.modelCard.pricing.outputTokens": "输出 {{amount}} 积分 · ${{amount}}/M","messages.modelCard.pricing.writeCacheInputTokens": "缓存写入 {{amount}} 积分 · ${{amount}}/M",- "messages.sentBy": "由 {{name}} 发送","messages.tokenDetails.average": "平均单价","messages.tokenDetails.cacheRate": "缓存率","messages.tokenDetails.input": "输入",@@ -604,6 +603,7 @@"resources.knowledgePicker.publicAgentHint": "公共 Agent 仅可关联工作区资源。要挂载私人内容,请先在资源库中「发布到工作区」。","resources.mode.privateHint": "只有您自己能看到的抽屉","resources.mode.workspaceHint": "与工作区成员共享",+ "resources.publishToWorkspace.confirm": "工作区的其他成员将可以看到该文件,发布后无法再设为私人。","resources.publishToWorkspace.error": "发布文件到工作区失败","resources.publishToWorkspace.menu": "发布到工作区","resources.publishToWorkspace.success": "已发布到工作区",@@ -857,6 +857,8 @@"taskDetail.runAll.skipped.blockedExternally": "{{count}} 个任务被本批次外的依赖阻塞 —— 解除阻塞后将自动运行","taskDetail.runAll.skipped.ineligible": "{{count}} 个任务正在运行或已排期 —— 已跳过","taskDetail.runAll.title": "按依赖顺序运行子任务",+ "taskDetail.runFollowUp": "追问",+ "taskDetail.runFollowUpPlaceholder": "对这次运行追问...","taskDetail.runNow": "立即运行","taskDetail.runTask": "运行","taskDetail.saveModelConfig": "保存",@@ -889,7 +891,7 @@"taskList.assigneeSearch.placeholder": "搜索 Agent...","taskList.breadcrumb.task": "任务","taskList.contextMenu.copyConfirm": "复制",- "taskList.contextMenu.copyDescription": "您可以拷贝到有权限创建任务的个人账户或工作区。",+ "taskList.contextMenu.copyDescription": "将此任务(及其所有子任务)克隆到另一个工作区。状态将重置为待办。","taskList.contextMenu.copyFailed": "任务复制失败","taskList.contextMenu.copyId": "复制 ID","taskList.contextMenu.copyIdSuccess": "ID 已复制",@@ -902,7 +904,7 @@"taskList.contextMenu.runNow": "立即运行","taskList.contextMenu.status": "状态","taskList.contextMenu.transferConfirm": "转移",- "taskList.contextMenu.transferDescription": "您可以移动到有权限创建任务的个人账户或工作区。",+ "taskList.contextMenu.transferDescription": "将此任务(及其所有子任务)移动到另一个工作区。标识符将重新分配。","taskList.contextMenu.transferFailed": "任务转移失败","taskList.contextMenu.transferSuccess": "任务已转移","taskList.contextMenu.transferTitle": "转移任务",diff --git a/packages/database/src/models/taskTopic.ts b/packages/database/src/models/taskTopic.tsindex 75e21bf430b..5f3552c6d9b 100644--- a/packages/database/src/models/taskTopic.ts+++ b/packages/database/src/models/taskTopic.ts@@ -147,6 +147,22 @@ export class TaskTopicModel {.where(and(eq(taskTopics.taskId, taskId), eq(taskTopics.topicId, topicId), this.ownership()));}+ /**+ * Patch the raw run output into `handoff.content` (LOBE-11396) without+ * disturbing other handoff keys. Uses `jsonb_set` so it is order-independent+ * with respect to `updateHandoff` — critically, this lets the caller persist+ * the last message even when the (separate) handoff-summary LLM call fails, so+ * the run card always has a result to show.+ */+ async updateHandoffContent(taskId: string, topicId: string, content: string): Promise<void> {+ await this.db+ .update(taskTopics)+ .set({+ handoff: sql`jsonb_set(COALESCE(${taskTopics.handoff}, '{}'::jsonb), '{content}', ${JSON.stringify(content)}::jsonb)`,+ })+ .where(and(eq(taskTopics.taskId, taskId), eq(taskTopics.topicId, topicId), this.ownership()));+ }+async updateReview(taskId: string,topicId: string,diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex de06d008c10..522fe9eb1ff 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -400,7 +400,6 @@ export default {'messageLongCollapse.expand': 'Show more','messages.dm.sentTo': 'Visible only to {{name}}','messages.dm.title': 'DM',- 'messages.sentBy': 'Sent by {{name}}','messages.modelCard.credit': 'Credits','messages.modelCard.creditPricing': 'Pricing','messages.modelCard.creditTooltip':@@ -535,6 +534,8 @@ export default {'Other workspace members will be able to use this agent. You will not be able to make it private again.','agent.publishToWorkspaceSuccess': 'Published to workspace','resources.publishToWorkspace.menu': 'Publish to Workspace',+ 'resources.publishToWorkspace.confirm':+ 'Other workspace members will be able to see this file. You will not be able to make it private again.','resources.publishToWorkspace.success': 'Published to workspace','resources.publishToWorkspace.error': 'Failed to publish file to workspace','resources.visibility.privateTooltip': 'Only you can see this file',@@ -932,6 +933,8 @@ export default {'taskDetail.comment.save': 'Save','taskDetail.commentPlaceholder':'Leave feedback to guide the agent — your comments shape the next run...',+ 'taskDetail.runFollowUp': 'Ask a follow-up',+ 'taskDetail.runFollowUpPlaceholder': 'Ask a follow-up about this run...','taskDetail.collapseReply': 'Collapse','taskDetail.replyInThread': 'Reply in this thread','taskDetail.replyPlaceholder': 'Reply in this thread...',@@ -1076,7 +1079,7 @@ export default {'taskList.assigneeSearch.placeholder': 'Search agent...','taskList.contextMenu.copyConfirm': 'Copy','taskList.contextMenu.copyDescription':- 'You can copy to personal or workspaces that have permission to create a task.',+ 'Clone this task (and all its subtasks) into another workspace. Status resets to backlog.','taskList.contextMenu.copyFailed': 'Failed to copy task','taskList.contextMenu.copyId': 'Copy ID','taskList.contextMenu.copyIdSuccess': 'ID copied',@@ -1090,7 +1093,7 @@ export default {'taskList.contextMenu.status': 'Status','taskList.contextMenu.transferConfirm': 'Transfer','taskList.contextMenu.transferDescription':- 'You can move to personal or workspaces that have permission to create a task.',+ 'Move this task (and all its subtasks) to another workspace. Identifiers will be re-assigned.','taskList.contextMenu.transferFailed': 'Failed to transfer task','taskList.contextMenu.transferSuccess': 'Task transferred','taskList.contextMenu.transferTitle': 'Transfer task',diff --git a/packages/types/src/task/index.ts b/packages/types/src/task/index.tsindex bab8c14b4e9..6121f65f15f 100644--- a/packages/types/src/task/index.ts+++ b/packages/types/src/task/index.ts@@ -111,6 +111,12 @@ export interface TaskTopicHandoff {* about the brief delivery itself, written by the lifecycle service.*/briefDecision?: BriefDecision;+ /**+ * Raw last assistant message of the run, captured on completion (LOBE-11396).+ * Shown on the run card alongside the LLM-synthesized `summary` so the feed+ * surfaces the actual run output, not only the summary.+ */+ content?: string;keyFindings?: string[];nextAction?: string;summary?: string;diff --git a/src/features/AgentTasks/AgentTaskDetail/RunReplyEditor.tsx b/src/features/AgentTasks/AgentTaskDetail/RunReplyEditor.tsxnew file mode 100644index 00000000000..fcd6ba09894--- /dev/null+++ b/src/features/AgentTasks/AgentTaskDetail/RunReplyEditor.tsx@@ -0,0 +1,86 @@+import { ChatInput, Editor, SendButton, useEditor } from '@lobehub/editor/react';+import { Flexbox } from '@lobehub/ui';+import { Button } from '@lobehub/ui/base-ui';+import { cssVar } from 'antd-style';+import { ChevronLeft } from 'lucide-react';+import { memo, useCallback, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { useEnterToSend } from '@/hooks/useEnterToSend';++interface RunReplyEditorProps {+ onCancel: () => void;+ onSubmit: (text: string) => Promise<void> | void;+ placeholder?: string;+}++/**+ * Compact inline reply editor for a task run — the Brief-card style (a+ * button + a small ChatInput with cancel/send), popped in place beneath the+ * run's message rather than opening a separate conversation window.+ */+const RunReplyEditor = memo<RunReplyEditorProps>(({ onSubmit, onCancel, placeholder }) => {+ const { t } = useTranslation('chat');+ const editor = useEditor();+ const [submitting, setSubmitting] = useState(false);+ const shouldSendOnEnter = useEnterToSend();++ const handleSubmit = useCallback(async () => {+ const content = String(editor?.getDocument?.('markdown') ?? '').trim();+ if (!content || submitting) return;+ setSubmitting(true);+ try {+ await onSubmit(content);+ } finally {+ setSubmitting(false);+ }+ }, [editor, onSubmit, submitting]);++ return (+ <ChatInput+ gap={8}+ maxHeight={120}+ minHeight={30}+ resize={false}+ footer={+ <Flexbox horizontal align={'center'} gap={8} justify={'space-between'} padding={8}>+ <Button+ disabled={submitting}+ icon={<ChevronLeft size={14} />}+ size={'small'}+ style={{ color: cssVar.colorTextDescription }}+ type={'text'}+ onClick={onCancel}+ >+ {t('cancel', { ns: 'common' })}+ </Button>+ <SendButton+ loading={submitting}+ shape={'round'}+ title={t('taskDetail.runFollowUp')}+ type={'primary'}+ onClick={handleSubmit}+ />+ </Flexbox>+ }+ >+ <Editor+ content={''}+ editor={editor}+ enablePasteMarkdown={false}+ markdownOption={false}+ placeholder={placeholder ?? t('taskDetail.runFollowUpPlaceholder')}+ type={'text'}+ variant={'chat'}+ onPressEnter={({ event }) => {+ if (shouldSendOnEnter(event)) {+ handleSubmit();+ return true;+ }+ }}+ />+ </ChatInput>+ );+});++export default RunReplyEditor;diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsxindex 08c881c240e..257da4c7073 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicCard.tsx@@ -6,21 +6,27 @@ import {type DropdownItem,DropdownMenu,Flexbox,+ Markdown,+ MaskShadow,stopPropagation,Tag,Text,} from '@lobehub/ui';import { confirmModal } from '@lobehub/ui/base-ui';+import { useSize } from 'ahooks';import { cssVar } from 'antd-style';-import { CircleDot, CircleStop, Copy, ExternalLink, MoreHorizontal } from 'lucide-react';-import { memo, useCallback, useEffect, useState } from 'react';+import { CircleDot, CircleStop, Copy, ExternalLink, MoreHorizontal, SquarePen } from 'lucide-react';+import { memo, useCallback, useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import AgentProfilePopup from '@/features/AgentProfileCard/AgentProfilePopup';import { useActivityTime } from '@/hooks/useActivityTime';+import { usePermission } from '@/hooks/usePermission';import { useTaskStore } from '@/store/task';+import { taskDetailSelectors } from '@/store/task/selectors';import { styles } from '../shared/style';+import RunReplyEditor from './RunReplyEditor';import TopicStatusIcon from './TopicStatusIcon';const formatDuration = (ms: number): string => {@@ -32,6 +38,33 @@ const formatDuration = (ms: number): string => {return `${hours}h ${minutes % 60}m`;};+// The run's last message (`content`) is the raw assistant output — markdown, and+// often long. Render it as rich text, but keep it a bounded preview in the feed:+// clamp overflow with a fade and let the whole card open the run drawer for the+// full message (progressive disclosure). `pointerEvents: none` keeps every click+// — including on links/code inside the markdown — falling through to the card.+const RUN_CONTENT_MAX_HEIGHT = 160;++const RunContent = memo<{ content: string }>(({ content }) => {+ const ref = useRef<HTMLDivElement>(null);+ const size = useSize(ref);+ const isOverflow = !!size && size.height > RUN_CONTENT_MAX_HEIGHT;++ const markdown = (+ <Markdown ref={ref} style={{ overflow: 'unset', pointerEvents: 'none' }} variant={'chat'}>+ {content}+ </Markdown>+ );++ return isOverflow ? (+ <MaskShadow size={32} style={{ maxHeight: RUN_CONTENT_MAX_HEIGHT }}>+ {markdown}+ </MaskShadow>+ ) : (+ markdown+ );+});+interface TopicCardProps {activity: TaskDetailActivity;}@@ -40,7 +73,17 @@ const TopicCard = memo<TopicCardProps>(({ activity }) => {const { t } = useTranslation('chat');const openTopicDrawer = useTaskStore((s) => s.openTopicDrawer);const cancelTopic = useTaskStore((s) => s.cancelTopic);+ const addComment = useTaskStore((s) => s.addComment);+ const activeTaskId = useTaskStore(taskDetailSelectors.activeTaskId);+ const { allowed: canEditTask } = usePermission('create_content');+ const [commenting, setCommenting] = useState(false);const isRunning = activity.status === 'running';+ // A descendant run shown in a parent detail belongs to `sourceTaskId`, not the+ // currently open parent (`activeTaskId`) — file the follow-up on the task that+ // owns the run so it appears where the run lives. Direct runs fall back to the+ // active task.+ const runTaskId = activity.sourceTaskId ?? activeTaskId;+ const canFollowUp = canEditTask && !!runTaskId;const finalDuration =!isRunning && activity.time && activity.completedAt@@ -202,10 +245,39 @@ const TopicCard = memo<TopicCardProps>(({ activity }) => {</Flexbox></Flexbox>- {activity.summary && (- <Text fontSize={13} style={{ color: cssVar.colorTextSecondary, whiteSpace: 'pre-wrap' }}>- {activity.summary}- </Text>+ {(activity.summary || activity.content || canFollowUp) && (+ <Flexbox gap={8} paddingInline={4}>+ {activity.summary && (+ <Text+ fontSize={13}+ style={{ color: cssVar.colorTextDescription, whiteSpace: 'pre-wrap' }}+ >+ {activity.summary}+ </Text>+ )}+ {activity.content && <RunContent content={activity.content} />}+ {canFollowUp &&+ (commenting ? (+ <Flexbox onClick={stopPropagation}>+ <RunReplyEditor+ onCancel={() => setCommenting(false)}+ onSubmit={async (text) => {+ await addComment(runTaskId!, text, { topicId: activity.id });+ setCommenting(false);+ }}+ />+ </Flexbox>+ ) : (+ <Flexbox horizontal justify={'flex-end'} onClick={stopPropagation}>+ <ActionIcon+ icon={SquarePen}+ size={'small'}+ title={t('taskDetail.runFollowUp')}+ onClick={() => setCommenting(true)}+ />+ </Flexbox>+ ))}+ </Flexbox>)}</Block>);