Skip to content

🤯 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.

✨ feat(goal): add task result review view (#19124)

Arvin Xu2467f69ba43b
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 8a3762e004d..05ebd8cfe0b 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -433,8 +433,10 @@
"goalDetail.notFoundTitle": "Goal not found",
"goalDetail.openExecution": "Open execution task",
"goalDetail.subtasks": "Subtasks",
+ "goalDetail.taskResult": "Task result",
"goalDetail.taskStatus": "Execution status",
"goalDetail.unnamedRun": "Untitled run",
+ "goalDetail.viewOriginalTask": "View task",
"goalDetail.viewPlan": "View execution plan",
"goalEmpty.create": "Create your first goal",
"goalEmpty.examples.backlog.requirement": "Tag each item with a type and priority, dedupe into one table, and list the 10 most frequent issues.",
@@ -1638,6 +1640,7 @@
"taskDetail.runFollowUp": "Ask a follow-up",
"taskDetail.runFollowUpPlaceholder": "Ask a follow-up about this run...",
"taskDetail.runNow": "Run now",
+ "taskDetail.runResults": "Run results",
"taskDetail.runTask": "Run",
"taskDetail.runTrigger.goal": "Goal loop",
"taskDetail.runTrigger.heartbeat": "Heartbeat",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index a31ca833b81..affbb460272 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -433,8 +433,10 @@
"goalDetail.notFoundTitle": "找不到目标",
"goalDetail.openExecution": "打开执行任务",
"goalDetail.subtasks": "子任务",
+ "goalDetail.taskResult": "任务结果",
"goalDetail.taskStatus": "执行状态",
"goalDetail.unnamedRun": "未命名运行",
+ "goalDetail.viewOriginalTask": "查看原始任务",
"goalDetail.viewPlan": "查看执行计划",
"goalEmpty.create": "创建第一个目标",
"goalEmpty.examples.backlog.requirement": "逐条标注类型与优先级,去重后汇总成一张表,并附出现最多的 10 个问题。",
@@ -1638,6 +1640,7 @@
"taskDetail.runFollowUp": "追问",
"taskDetail.runFollowUpPlaceholder": "对这次运行追问...",
"taskDetail.runNow": "立即运行",
+ "taskDetail.runResults": "运行结果",
"taskDetail.runTask": "运行",
"taskDetail.runTrigger.goal": "目标驱动",
"taskDetail.runTrigger.heartbeat": "心跳触发",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 53c98d8f810..e02f97ee7cb 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -1510,6 +1510,7 @@ export default {
'taskDetail.goalTimeline.rounds': '{{count}} rounds',
'taskDetail.goalTimeline.title': 'Round progress',
'taskDetail.activities': 'Activities',
+ 'taskDetail.runResults': 'Run results',
'taskDetail.activitiesEmpty': 'No activity yet',
'taskDetail.artifacts': 'Artifacts',
'taskDetail.untitled': 'Untitled',
@@ -1849,7 +1850,9 @@ export default {
'goalDetail.openExecution': 'Open execution task',
'goalDetail.subtasks': 'Subtasks',
'goalDetail.taskStatus': 'Execution status',
+ 'goalDetail.taskResult': 'Task result',
'goalDetail.unnamedRun': 'Untitled run',
+ 'goalDetail.viewOriginalTask': 'View task',
'goalDetail.viewPlan': 'View execution plan',
'goalProcess.frontier.title': 'Current tasks',
'goalProcess.frontier.add': 'Add task',
diff --git a/src/features/AgentGoals/ProcessControl/index.tsx b/src/features/AgentGoals/ProcessControl/index.tsx
index 794fd15ddab..cd1afaac2f2 100644
--- a/src/features/AgentGoals/ProcessControl/index.tsx
+++ b/src/features/AgentGoals/ProcessControl/index.tsx
@@ -48,7 +48,7 @@ const ProcessControl = memo<ProcessControlProps>(
const useFetchGoalGraph = useGoalStore((s) => s.useFetchGoalGraph);
const decideGoal = useGoalStore((s) => s.decideGoal);
const refreshGoalGraph = useGoalStore((s) => s.refreshGoalGraph);
- const openTaskDetail = useChatStore((s) => s.openTaskDetail);
+ const openTaskResult = useChatStore((s) => s.openTaskResult);
const openGoalNode = useChatStore((s) => s.openGoalNode);
useFetchGoalGraph(goalId);
const snapshot = useGoalStore(goalSelectors.goalGraph(goalId));
@@ -68,17 +68,17 @@ const ProcessControl = memo<ProcessControlProps>(
);
// Every click funnels here: keep the map highlight (spatial continuity) and
- // open the drill-down — a dispatched Task goes straight to its Task detail,
- // everything else opens the node view. This is the chain the page was
- // missing: node → task → topic conversation.
+ // open the drill-down — a dispatched Task lands on its result-focused
+ // review surface. The original editable Task remains one explicit step
+ // deeper, so Goal inspection does not begin with implementation metadata.
const select = useCallback(
(nodeId: string) => {
setSelectedId(nodeId);
const taskId = graph?.byId[nodeId]?.node.taskId;
- if (taskId) openTaskDetail(taskId);
+ if (taskId) openTaskResult(taskId);
else openGoalNode(goalId, nodeId);
},
- [goalId, graph, openGoalNode, openTaskDetail],
+ [goalId, graph, openGoalNode, openTaskResult],
);
// Task-carried goals share the `goals` table but never grow a graph. Nothing
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx
index c2ee8503603..673450f7dc7 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskActivities.tsx
@@ -128,7 +128,12 @@ const ActivityRow = memo<{ activity: TaskDetailActivity }>(({ activity }) => {
);
});
-const TaskActivities = memo(() => {
+interface TaskActivitiesProps {
+ /** Result review leads with run output and leaves the reply composer after the evidence. */
+ variant?: 'activity' | 'result';
+}
+
+const TaskActivities = memo<TaskActivitiesProps>(({ variant = 'activity' }) => {
const { t } = useTranslation('chat');
const activities = useTaskStore(taskActivitySelectors.activeTaskActivities);
const activeTaskId = useTaskStore(taskDetailSelectors.activeTaskId);
@@ -150,6 +155,8 @@ const TaskActivities = memo(() => {
[activities],
);
+ const commentInput = activeTaskId ? <CommentInput taskId={activeTaskId} /> : null;
+
return (
<Accordion defaultExpandedKeys={['activities']} gap={0}>
<AccordionItem
@@ -160,13 +167,13 @@ const TaskActivities = memo(() => {
<Flexbox horizontal align="center" gap={8}>
<Icon color={cssVar.colorTextDescription} icon={BotMessageSquare} size={16} />
<Text color={cssVar.colorTextSecondary} fontSize={13} weight={500}>
- {t('taskDetail.activities')}
+ {t(variant === 'result' ? 'taskDetail.runResults' : 'taskDetail.activities')}
</Text>
</Flexbox>
}
>
<Flexbox gap={12} paddingBlock={12} paddingInline={12}>
- {activeTaskId && <CommentInput taskId={activeTaskId} />}
+ {variant === 'activity' && commentInput}
{items.length > 0 ? (
// A goal loop can produce many rounds; only the newest run opens by
// default so the latest result is not buried under older ones.
@@ -206,6 +213,7 @@ const TaskActivities = memo(() => {
style={{ marginTop: 8 }}
/>
)}
+ {variant === 'result' && commentInput}
</Flexbox>
</AccordionItem>
</Accordion>
diff --git a/src/features/AgentTasks/AgentTaskDetail/useActiveTaskResult.ts b/src/features/AgentTasks/AgentTaskDetail/useActiveTaskResult.ts
new file mode 100644
index 00000000000..267924e4bf7
--- /dev/null
+++ b/src/features/AgentTasks/AgentTaskDetail/useActiveTaskResult.ts
@@ -0,0 +1,40 @@
+import { useEffect } from 'react';
+
+import { normalizeAsyncError } from '@/libs/swr/normalizeError';
+import { useTaskStore } from '@/store/task';
+
+interface ActiveTaskResultState {
+ error?: unknown;
+ isInitialLoading: boolean;
+ isNotFound: boolean;
+ onRetry: () => void;
+}
+
+/** Fetches only the Task snapshot needed by the result review surface. */
+export const useActiveTaskResult = (taskId?: string): ActiveTaskResultState => {
+ const setActiveTaskId = useTaskStore((state) => state.setActiveTaskId);
+ const useFetchTaskDetail = useTaskStore((state) => state.useFetchTaskDetail);
+ const hasTaskDetail = useTaskStore((state) =>
+ taskId ? Boolean(state.taskDetailMap[taskId]) : false,
+ );
+
+ useEffect(() => {
+ if (!taskId) return;
+ setActiveTaskId(taskId);
+ return () => setActiveTaskId(undefined);
+ }, [setActiveTaskId, taskId]);
+
+ const { error: taskError, mutate } = useFetchTaskDetail(taskId);
+
+ if (!taskId) return { isInitialLoading: false, isNotFound: false, onRetry: () => {} };
+
+ const settledWithoutDetail = Boolean(taskError) && !hasTaskDetail;
+ const isResolvedNotFound = normalizeAsyncError(taskError).code === 'TASK_NOT_FOUND';
+
+ return {
+ error: settledWithoutDetail && !isResolvedNotFound ? taskError : undefined,
+ isInitialLoading: !hasTaskDetail && !settledWithoutDetail,
+ isNotFound: settledWithoutDetail && isResolvedNotFound,
+ onRetry: () => mutate(),
+ };
+};
diff --git a/src/features/Portal/TaskResult/Body.tsx b/src/features/Portal/TaskResult/Body.tsx
new file mode 100644
index 00000000000..6b521f26c06
--- /dev/null
+++ b/src/features/Portal/TaskResult/Body.tsx
@@ -0,0 +1,59 @@
+import { Flexbox } from '@lobehub/ui';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import NotFound from '@/components/404';
+import AsyncError from '@/components/AsyncError';
+import TaskAcceptance from '@/features/AgentTasks/AgentTaskDetail/TaskAcceptance';
+import TaskActivities from '@/features/AgentTasks/AgentTaskDetail/TaskActivities';
+import TaskArtifacts from '@/features/AgentTasks/AgentTaskDetail/TaskArtifacts';
+import TaskDetailSkeleton from '@/features/AgentTasks/AgentTaskDetail/TaskDetailSkeleton';
+import TopicChatDrawer from '@/features/AgentTasks/AgentTaskDetail/TopicChatDrawer';
+import { useActiveTaskResult } from '@/features/AgentTasks/AgentTaskDetail/useActiveTaskResult';
+import { useChatStore } from '@/store/chat';
+import { chatPortalSelectors } from '@/store/chat/selectors';
+
+const Body = memo(() => {
+ const { t } = useTranslation('chat');
+ const taskId = useChatStore(chatPortalSelectors.taskResultId);
+ const { error, isInitialLoading, isNotFound, onRetry } = useActiveTaskResult(taskId);
+
+ if (!taskId) return null;
+ if (error)
+ return (
+ <Flexbox flex={1} height={'100%'} style={{ minHeight: 0, overflowY: 'auto' }}>
+ <AsyncError error={error} variant={'page'} onRetry={onRetry} />
+ </Flexbox>
+ );
+ if (isNotFound)
+ return (
+ <Flexbox flex={1} height={'100%'} style={{ minHeight: 0, overflowY: 'auto' }}>
+ <NotFound desc={t('taskDetail.notFound.desc')} title={t('taskDetail.notFound.title')} />
+ </Flexbox>
+ );
+
+ return (
+ <Flexbox
+ flex={1}
+ gap={24}
+ height={'100%'}
+ paddingBlock={20}
+ paddingInline={16}
+ style={{ minHeight: 0, overflowY: 'auto' }}
+ >
+ {isInitialLoading ? (
+ <TaskDetailSkeleton />
+ ) : (
+ <>
+ <TaskActivities variant={'result'} />
+ <TaskArtifacts />
+ <TaskAcceptance />
+ </>
+ )}
+ <TopicChatDrawer />
+ </Flexbox>
+ );
+});
+
+Body.displayName = 'TaskResultPortalBody';
+export default Body;
diff --git a/src/features/Portal/TaskResult/Header.tsx b/src/features/Portal/TaskResult/Header.tsx
new file mode 100644
index 00000000000..6a55d5055ab
--- /dev/null
+++ b/src/features/Portal/TaskResult/Header.tsx
@@ -0,0 +1,36 @@
+import { Button } from '@lobehub/ui/base-ui';
+import { ListTodo } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useChatStore } from '@/store/chat';
+import { chatPortalSelectors } from '@/store/chat/selectors';
+
+import PortalHeader from '../components/Header';
+import Title from './Title';
+
+const Header = memo(() => {
+ const { t } = useTranslation('chat');
+ const taskId = useChatStore(chatPortalSelectors.taskResultId);
+ const openTaskDetail = useChatStore((state) => state.openTaskDetail);
+
+ return (
+ <PortalHeader
+ title={<Title />}
+ rightExtra={
+ <Button
+ disabled={!taskId}
+ icon={ListTodo}
+ size={'small'}
+ type={'text'}
+ onClick={() => taskId && openTaskDetail(taskId)}
+ >
+ {t('goalDetail.viewOriginalTask')}
+ </Button>
+ }
+ />
+ );
+});
+
+Header.displayName = 'TaskResultPortalHeader';
+export default Header;
diff --git a/src/features/Portal/TaskResult/Title.tsx b/src/features/Portal/TaskResult/Title.tsx
new file mode 100644
index 00000000000..5e45c857116
--- /dev/null
+++ b/src/features/Portal/TaskResult/Title.tsx
@@ -0,0 +1,36 @@
+import { Flexbox } from '@lobehub/ui';
+import { Text } from '@lobehub/ui/base-ui';
+import { cssVar } from 'antd-style';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useChatStore } from '@/store/chat';
+import { chatPortalSelectors } from '@/store/chat/selectors';
+import { useTaskStore } from '@/store/task';
+import { oneLineEllipsis } from '@/styles';
+
+const Title = memo(() => {
+ const { t } = useTranslation('chat');
+ const taskId = useChatStore(chatPortalSelectors.taskResultId);
+ const detail = useTaskStore((state) => (taskId ? state.taskDetailMap[taskId] : undefined));
+
+ return (
+ <Flexbox horizontal align={'center'} flex={1} gap={8} style={{ minWidth: 0 }}>
+ <Text fontSize={14} weight={500}>
+ {t('goalDetail.taskResult')}
+ </Text>
+ {(detail?.identifier || detail?.name) && (
+ <Text
+ className={oneLineEllipsis}
+ fontSize={13}
+ style={{ color: cssVar.colorTextSecondary, flex: 1, minWidth: 0 }}
+ >
+ {[detail.identifier, detail.name].filter(Boolean).join(' · ')}
+ </Text>
+ )}
+ </Flexbox>
+ );
+});
+
+Title.displayName = 'TaskResultPortalTitle';
+export default Title;
diff --git a/src/features/Portal/TaskResult/index.ts b/src/features/Portal/TaskResult/index.ts
new file mode 100644
index 00000000000..e4fef23f528
--- /dev/null
+++ b/src/features/Portal/TaskResult/index.ts
@@ -0,0 +1,6 @@
+import { type PortalImpl } from '../type';
+import Body from './Body';
+import Header from './Header';
+import Title from './Title';
+
+export const TaskResult: PortalImpl = { Body, Header, Title };
diff --git a/src/features/Portal/portalWidth.test.ts b/src/features/Portal/portalWidth.test.ts
index c47ae98f6f0..a3c0fe25150 100644
--- a/src/features/Portal/portalWidth.test.ts
+++ b/src/features/Portal/portalWidth.test.ts
@@ -27,6 +27,7 @@ describe('getPortalViewMinWidth', () => {
PortalViewType.GoalMetric,
PortalViewType.GoalNode,
PortalViewType.TaskDetail,
+ PortalViewType.TaskResult,
PortalViewType.Thread,
PortalViewType.ToolUI,
]) {
@@ -43,7 +44,11 @@ describe('getPortalViewWidth', () => {
});
it('opens task and goal-node detail at the task width even when the legacy width is narrow', () => {
- for (const viewType of [PortalViewType.TaskDetail, PortalViewType.GoalNode]) {
+ for (const viewType of [
+ PortalViewType.TaskDetail,
+ PortalViewType.TaskResult,
+ PortalViewType.GoalNode,
+ ]) {
expect(getPortalViewWidth({ legacyWidth: CHAT_PORTAL_WIDTH, viewType })).toBe(
CHAT_PORTAL_TASK_WIDTH,
);
diff --git a/src/features/Portal/portalWidth.ts b/src/features/Portal/portalWidth.ts
index 464ab376a13..2f890843b31 100644
--- a/src/features/Portal/portalWidth.ts
+++ b/src/features/Portal/portalWidth.ts
@@ -26,6 +26,7 @@ const VIEW_MIN_WIDTH: PortalWidths = {
[PortalViewType.GoalMetric]: CHAT_PORTAL_TOOL_UI_WIDTH,
[PortalViewType.GoalNode]: CHAT_PORTAL_TOOL_UI_WIDTH,
[PortalViewType.TaskDetail]: CHAT_PORTAL_TOOL_UI_WIDTH,
+ [PortalViewType.TaskResult]: CHAT_PORTAL_TOOL_UI_WIDTH,
[PortalViewType.Thread]: CHAT_PORTAL_TOOL_UI_WIDTH,
[PortalViewType.ToolUI]: CHAT_PORTAL_TOOL_UI_WIDTH,
[PortalViewType.Topic]: CHAT_PORTAL_TOOL_UI_WIDTH,
@@ -44,6 +45,7 @@ const VIEW_DEFAULT_WIDTH: PortalWidths = {
// full document width crowds the page it sits next to.
[PortalViewType.GoalNode]: CHAT_PORTAL_TASK_WIDTH,
[PortalViewType.TaskDetail]: CHAT_PORTAL_TASK_WIDTH,
+ [PortalViewType.TaskResult]: CHAT_PORTAL_TASK_WIDTH,
};
const clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), max);
diff --git a/src/features/Portal/router.tsx b/src/features/Portal/router.tsx
index dcd285459e7..18c66861e59 100644
--- a/src/features/Portal/router.tsx
+++ b/src/features/Portal/router.tsx
@@ -22,6 +22,7 @@ import { MessageDetail } from './MessageDetail';
import { Notebook } from './Notebook';
import { Plugins } from './Plugins';
import { TaskDetail } from './TaskDetail';
+import { TaskResult } from './TaskResult';
import { Thread } from './Thread';
import { Topic } from './Topic';
import { TopicComments, TopicCommentThread } from './TopicComments';
@@ -48,6 +49,7 @@ const VIEW_COMPONENTS: Record<PortalViewType, PortalImpl> = {
[PortalViewType.MessageDetail]: MessageDetail,
[PortalViewType.ToolUI]: Plugins,
[PortalViewType.TaskDetail]: TaskDetail,
+ [PortalViewType.TaskResult]: TaskResult,
[PortalViewType.Thread]: Thread,
[PortalViewType.Topic]: Topic,
[PortalViewType.TopicCommentThread]: TopicCommentThread,
diff --git a/src/store/chat/slices/portal/action.test.ts b/src/store/chat/slices/portal/action.test.ts
index 2d75ea198db..7c5ac9b42cb 100644
--- a/src/store/chat/slices/portal/action.test.ts
+++ b/src/store/chat/slices/portal/action.test.ts
@@ -434,6 +434,26 @@ describe('chatDockSlice', () => {
expect(chatPortalSelectors.goalNodeView(result.current)?.nodeId).toBe('node_1');
});
+
+ it('opens a Task result and returns to it after inspecting the original Task', () => {
+ const { result } = renderHook(() => useChatStore());
+
+ act(() => {
+ result.current.openTaskResult('task_1');
+ });
+
+ expect(result.current.portalStack).toEqual([
+ { taskId: 'task_1', type: PortalViewType.TaskResult },
+ ]);
+ expect(chatPortalSelectors.taskResultId(result.current)).toBe('task_1');
+
+ act(() => {
+ result.current.openTaskDetail('task_1');
+ result.current.goBack();
+ });
+
+ expect(chatPortalSelectors.currentViewType(result.current)).toBe(PortalViewType.TaskResult);
+ });
});
describe('openLocalFile', () => {
diff --git a/src/store/chat/slices/portal/action.ts b/src/store/chat/slices/portal/action.ts
index f65bf90e985..93ad9ca824d 100644
--- a/src/store/chat/slices/portal/action.ts
+++ b/src/store/chat/slices/portal/action.ts
@@ -634,6 +634,10 @@ export class ChatPortalActionImpl {
this.#get().pushPortalView({ taskId, type: PortalViewType.TaskDetail });
};
+ openTaskResult = (taskId: string): void => {
+ this.#get().pushPortalView({ taskId, type: PortalViewType.TaskResult });
+ };
+
openGoalNode = (goalId: string, nodeId: string): void => {
this.#get().pushPortalView({ goalId, nodeId, type: PortalViewType.GoalNode });
};
diff --git a/src/store/chat/slices/portal/initialState.ts b/src/store/chat/slices/portal/initialState.ts
index 0c2f0f6d6e9..dc81380f575 100644
--- a/src/store/chat/slices/portal/initialState.ts
+++ b/src/store/chat/slices/portal/initialState.ts
@@ -24,6 +24,7 @@ export enum PortalViewType {
MessageDetail = 'messageDetail',
Notebook = 'notebook',
TaskDetail = 'taskDetail',
+ TaskResult = 'taskResult',
Thread = 'thread',
ToolUI = 'toolUI',
Topic = 'topic',
@@ -88,6 +89,7 @@ export type PortalViewData =
| { topicId: string; type: PortalViewType.Topic }
| { agentId: string; type: PortalViewType.GroupThread }
| { taskId: string; type: PortalViewType.TaskDetail }
+ | { taskId: string; type: PortalViewType.TaskResult }
| {
focusCommentId?: string;
initialReplyCount?: number;
diff --git a/src/store/chat/slices/portal/selectors.ts b/src/store/chat/slices/portal/selectors.ts
index 2c27e85347a..203f9a7f34d 100644
--- a/src/store/chat/slices/portal/selectors.ts
+++ b/src/store/chat/slices/portal/selectors.ts
@@ -249,6 +249,11 @@ const taskDetailId = (s: ChatStoreState): string | undefined => {
return view?.taskId;
};
+const taskResultId = (s: ChatStoreState): string | undefined => {
+ const view = getViewData(s, PortalViewType.TaskResult);
+ return view?.taskId;
+};
+
// Goal detail drill-down selectors
const goalNodeView = (s: ChatStoreState) => getViewData(s, PortalViewType.GoalNode);
const goalMetricView = (s: ChatStoreState) => getViewData(s, PortalViewType.GoalMetric);
@@ -353,6 +358,7 @@ export const chatPortalSelectors = {
// Task detail data
taskDetailId,
+ taskResultId,
// Topic chat data
portalTopicId,