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): show who each task is assigned to on the goal page (#19591)

Arvin Xuc2e0428beeab
diff --git a/apps/server/src/services/goal/index.test.ts b/apps/server/src/services/goal/index.test.ts
index b5fa387670d..eb6beaab4d2 100644
--- a/apps/server/src/services/goal/index.test.ts
+++ b/apps/server/src/services/goal/index.test.ts
@@ -796,6 +796,23 @@ describe('GoalService', () => {
await expect(service.updateRequirement('goal_missing', 'x')).rejects.toThrow();
});
+ it('names the agent each dispatched task node is assigned to', async () => {
+ await serverDB.insert(agents).values([{ id: 'agt_exec', slug: 'agt-exec', userId }]);
+ const service = new GoalService(serverDB, userId);
+ const graph = await service.create({
+ agentId: 'agt_exec',
+ tasks: ['Dispatched', 'Not yet'],
+ title: 'Who is on it',
+ });
+ const created = await service.tick(graph.goal.id);
+
+ const read = await service.graph(graph.goal.id);
+ const dispatched = read.nodes.find((node) => node.taskId === created.taskId)!;
+
+ // Only a node with a Task row has an assignee; the undispatched one has none.
+ expect(read.assignees).toEqual({ [dispatched.id]: 'agt_exec' });
+ });
+
it('hands the goal and its unfinished tasks to a new agent', async () => {
await serverDB.insert(agents).values([
{ id: 'agt_old', slug: 'agt-old', userId },
diff --git a/apps/server/src/services/goal/index.ts b/apps/server/src/services/goal/index.ts
index 78ab89c58a5..2e3e3311ef7 100644
--- a/apps/server/src/services/goal/index.ts
+++ b/apps/server/src/services/goal/index.ts
@@ -583,13 +583,39 @@ export class GoalService {
graph = async (goalId: string) => {
const graph = await this.requireGraph(goalId);
- const [runHeartbeats, deliveredAt, acceptances, spend] = await Promise.all([
+ const [runHeartbeats, deliveredAt, acceptances, assignees, spend] = await Promise.all([
this.collectRunHeartbeats(graph),
this.collectDeliveredAt(graph),
this.collectAcceptances(graph),
+ this.collectAssignees(graph),
this.resolveSpend(graph),
]);
- return { ...graph, acceptances, deliveredAt, runHeartbeats, spend };
+ return { ...graph, acceptances, assignees, deliveredAt, runHeartbeats, spend };
+ };
+
+ /**
+ * The agent each dispatched task node is assigned to. Read from the Task row
+ * rather than the goal config: a task can be reassigned on its own, and the
+ * row is what the runner actually dispatches to.
+ */
+ private collectAssignees = async (
+ graph: GoalGraphSnapshot,
+ ): Promise<Record<string, string> | undefined> => {
+ const taskNodes = graph.nodes.filter(
+ (node): node is GoalGraphNode & { taskId: string } => node.kind === 'task' && !!node.taskId,
+ );
+ if (taskNodes.length === 0) return undefined;
+
+ const nodeByTaskId = new Map(taskNodes.map((node) => [node.taskId, node.id]));
+ // Runs on every graph poll: read the one column, not whole task rows.
+ const tasks = await this.taskModel.findAssigneesByIds(taskNodes.map((node) => node.taskId));
+
+ const result: Record<string, string> = {};
+ for (const task of tasks) {
+ const nodeId = nodeByTaskId.get(task.id);
+ if (nodeId && task.assigneeAgentId) result[nodeId] = task.assigneeAgentId;
+ }
+ return Object.keys(result).length > 0 ? result : undefined;
};
/**
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 4cfe77d2415..bc40c4740fb 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -38,6 +38,7 @@
"agentProfile.files_other": "{{count}} files",
"agentProfile.knowledgeBases_one": "{{count}} library",
"agentProfile.knowledgeBases_other": "{{count}} libraries",
+ "agentProfile.runtime": "Runs on {{name}}",
"agentProfile.skills_one": "{{count}} skill",
"agentProfile.skills_other": "{{count}} skills",
"agentSignal.receipts.agentSignalLabel": "Agent Signal",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index ffa0e633576..62628dc8ccf 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -38,6 +38,7 @@
"agentProfile.files_other": "{{count}} 个文件",
"agentProfile.knowledgeBases_one": "{{count}} 个知识库",
"agentProfile.knowledgeBases_other": "{{count}} 个知识库",
+ "agentProfile.runtime": "运行时:{{name}}",
"agentProfile.skills_one": "{{count}} 项技能",
"agentProfile.skills_other": "{{count}} 项技能",
"agentSignal.receipts.agentSignalLabel": "代理信号",
diff --git a/packages/database/src/models/__tests__/task.test.ts b/packages/database/src/models/__tests__/task.test.ts
index 4a397250c56..3d1a9b2ce15 100644
--- a/packages/database/src/models/__tests__/task.test.ts
+++ b/packages/database/src/models/__tests__/task.test.ts
@@ -2026,6 +2026,25 @@ describe('TaskModel', () => {
});
});
+ describe('findAssigneesByIds', () => {
+ it('returns only id and assignee, scoped to the owner', async () => {
+ const model1 = new TaskModel(serverDB, userId);
+ const model2 = new TaskModel(serverDB, userId2);
+ const a = await model1.create({ instruction: 'A' });
+ const other = await model2.create({ instruction: 'Other user' });
+
+ const found = await model1.findAssigneesByIds([a.id, other.id]);
+
+ // The goal graph polls this; a full row (instruction, editor data, config)
+ // for every task node is exactly what it must not pull.
+ expect(found).toEqual([{ assigneeAgentId: a.assigneeAgentId, id: a.id }]);
+ });
+
+ it('returns an empty array for empty input', async () => {
+ expect(await new TaskModel(serverDB, userId).findAssigneesByIds([])).toEqual([]);
+ });
+ });
+
describe('resolve', () => {
it('should resolve by task id when value starts with task_', async () => {
const model = new TaskModel(serverDB, userId);
diff --git a/packages/database/src/models/task.ts b/packages/database/src/models/task.ts
index 8810f9cec01..52da551ba2f 100644
--- a/packages/database/src/models/task.ts
+++ b/packages/database/src/models/task.ts
@@ -404,6 +404,22 @@ export class TaskModel {
.where(and(inArray(tasks.id, ids), this.ownership()));
}
+ /**
+ * Only the assignee of each task. For callers on a polling path (the goal
+ * graph re-reads every few seconds while a goal advances) that would
+ * otherwise pull full rows — instruction, editor data, context, config — for
+ * up to hundreds of tasks just to read one column.
+ */
+ async findAssigneesByIds(
+ ids: string[],
+ ): Promise<{ assigneeAgentId: string | null; id: string }[]> {
+ if (ids.length === 0) return [];
+ return this.db
+ .select({ assigneeAgentId: tasks.assigneeAgentId, id: tasks.id })
+ .from(tasks)
+ .where(and(inArray(tasks.id, ids), this.ownership()));
+ }
+
async resolveMany(idsOrIdentifiers: string[]): Promise<TaskItem[]> {
if (idsOrIdentifiers.length === 0) return [];
const identifiers = idsOrIdentifiers.map((value) => value.toUpperCase());
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 94fccc47997..0a3464acba2 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -100,6 +100,7 @@ export default {
'agentProfile.files_other': '{{count}} files',
'agentProfile.knowledgeBases_one': '{{count}} library',
'agentProfile.knowledgeBases_other': '{{count}} libraries',
+ 'agentProfile.runtime': 'Runs on {{name}}',
'agentProfile.skills_one': '{{count}} skill',
'agentProfile.skills_other': '{{count}} skills',
'agentSignal.receipts.agentSignalLabel': 'Agent Signal',
diff --git a/packages/types/src/goal.ts b/packages/types/src/goal.ts
index 3fc98b088e6..96440fa8f31 100644
--- a/packages/types/src/goal.ts
+++ b/packages/types/src/goal.ts
@@ -485,6 +485,12 @@ export interface GoalGraphSnapshot {
* finished without saying whether it held up.
*/
acceptances?: Record<string, GoalNodeAcceptance>;
+ /**
+ * The agent each dispatched task node is assigned to, keyed by node id. A
+ * goal can route its tasks to an executor other than the supervising agent,
+ * and a task title alone never says who is doing the work.
+ */
+ assignees?: Record<string, string>;
decisions: GoalGraphDecision[];
/**
* When an active task node's newest run delivered, present only while that
diff --git a/src/features/AgentGoals/ProcessControl/AssigneeProfileAvatar.tsx b/src/features/AgentGoals/ProcessControl/AssigneeProfileAvatar.tsx
new file mode 100644
index 00000000000..4ae571bfd73
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/AssigneeProfileAvatar.tsx
@@ -0,0 +1,46 @@
+'use client';
+
+import { memo } from 'react';
+
+import AgentProfilePopup from '@/features/AgentProfileCard/AgentProfilePopup';
+import AssigneeAvatar from '@/features/AgentTasks/features/AssigneeAvatar';
+import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';
+
+interface AssigneeProfileAvatarProps {
+ agentId: string;
+ size?: number;
+}
+
+/**
+ * The agent doing a goal task, as its avatar with the agent's profile card on
+ * hover — the same card a group shows for its members, so "who is on it" reads
+ * as a person with a role rather than a bare name.
+ */
+const AssigneeProfileAvatar = memo<AssigneeProfileAvatarProps>(({ agentId, size }) => {
+ const meta = useAgentDisplayMeta(agentId);
+
+ return (
+ <AgentProfilePopup
+ agentId={agentId}
+ trigger={'hover'}
+ agent={
+ meta
+ ? { avatar: meta.avatar, backgroundColor: meta.backgroundColor, title: meta.title }
+ : undefined
+ }
+ >
+ {/* The card renders in a portal but its clicks still bubble through React:
+ without this, clicking inside it would also open the row / graph node. */}
+ <span
+ style={{ cursor: 'default', display: 'inline-flex', flex: 'none' }}
+ onClick={(event) => event.stopPropagation()}
+ >
+ <AssigneeAvatar agentId={agentId} size={size} />
+ </span>
+ </AgentProfilePopup>
+ );
+});
+
+AssigneeProfileAvatar.displayName = 'GoalAssigneeProfileAvatar';
+
+export default AssigneeProfileAvatar;
diff --git a/src/features/AgentGoals/ProcessControl/Frontier.tsx b/src/features/AgentGoals/ProcessControl/Frontier.tsx
index e624181f2ee..d733e16f7e7 100644
--- a/src/features/AgentGoals/ProcessControl/Frontier.tsx
+++ b/src/features/AgentGoals/ProcessControl/Frontier.tsx
@@ -15,6 +15,7 @@ import RunningGlyph from '@/features/Home/components/RunningGlyph';
import { useActivityTime } from '@/hooks/useActivityTime';
import { useChatStore } from '@/store/chat';
+import AssigneeProfileAvatar from './AssigneeProfileAvatar';
import {
coordinatorGateReason,
coordinatorNodeTitleKey,
@@ -392,6 +393,7 @@ const FrontierRow = memo<{
<Flexbox horizontal align={'center'} gap={10}>
{view.seq !== undefined && <span className={styles.num}>#{view.seq}</span>}
<RowGlyph kind={item.kind} view={view} />
+ {view.assigneeAgentId && <AssigneeProfileAvatar agentId={view.assigneeAgentId} />}
<Text ellipsis style={{ flexShrink: 1, maxWidth: '60%', minWidth: 0 }} weight={500}>
{coordinatorTitleKey ? t(coordinatorTitleKey as any) : node.title}
</Text>
diff --git a/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx b/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx
index 3cc1c25bedd..03f0451b268 100644
--- a/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx
+++ b/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx
@@ -12,6 +12,7 @@ import RunningGlyph from '@/features/Home/components/RunningGlyph';
import { shinyTextStyles } from '@/styles';
import type { GoalGraphNodeKind } from '../../Experiments/model';
+import AssigneeProfileAvatar from '../AssigneeProfileAvatar';
import { coordinatorNodeTitleKey } from '../coordinatorCopy';
import type { GoalNodeView } from '../goalGraphViewModel';
import { KIND_COLOR, KIND_ICON } from '../shared';
@@ -317,14 +318,11 @@ const GraphNodeView = memo<NodeProps>(({ data }) => {
<span className={styles.human}>@</span>
</Tooltip>
)}
- {/* Top-right corner: this Task carries its own verifier. Icon only —
- the word added nothing the hover hint doesn't say better. */}
- {isTask && node.taskId && (
- <Tooltip title={t('goalProcess.node.verifierTooltip')}>
- <span style={{ display: 'inline-flex', marginInlineStart: 'auto' }}>
- <Icon color={cssVar.colorTextTertiary} icon={ShieldCheck} size={13} />
- </span>
- </Tooltip>
+ {/* Top-right corner: who is doing this Task, with their profile on hover. */}
+ {isTask && view.assigneeAgentId && (
+ <span style={{ display: 'inline-flex', marginInlineStart: 'auto' }}>
+ <AssigneeProfileAvatar agentId={view.assigneeAgentId} size={16} />
+ </span>
)}
</div>
)}
@@ -347,6 +345,15 @@ const GraphNodeView = memo<NodeProps>(({ data }) => {
)}
{isTask && (
<div className={styles.metrics}>
+ {/* This Task carries its own verifier. Icon only — the word added
+ nothing the hover hint doesn't say better. */}
+ {node.taskId && (
+ <Tooltip title={t('goalProcess.node.verifierTooltip')}>
+ <span className={styles.metric}>
+ <Icon icon={ShieldCheck} size={13} />
+ </span>
+ </Tooltip>
+ )}
<Tooltip title={t('goalProcess.node.attemptsTooltip', { count: attempts })}>
<span className={styles.metric}>
<Icon icon={Repeat2} size={13} />
diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts
index ace1a7c20da..9684e00de2b 100644
--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts
+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts
@@ -199,6 +199,19 @@ describe('buildGoalGraphView', () => {
expect(view.needsYou).toBe(0);
});
+ it('carries the assigned agent onto the task view, and nothing for an unassigned one', () => {
+ const view = buildGoalGraphView(
+ snapshot({
+ assignees: { w1: 'agt_exec' },
+ nodes: [node('w1', { taskId: 'task-1' }), node('w2')],
+ }),
+ NOW,
+ );
+
+ expect(view.byId.w1.assigneeAgentId).toBe('agt_exec');
+ expect(view.byId.w2).not.toHaveProperty('assigneeAgentId');
+ });
+
it('never calls a node lost while its own acceptance says it is being judged', () => {
// The settle window and the acceptance row are two views of one fact. Read
// separately, an aged delivery timestamp put a red "lost" badge on the same
diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts
index dac3c724ead..1f00d49582d 100644
--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts
+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts
@@ -76,6 +76,8 @@ export interface GoalNodeView {
answers: GoalGraphNode[];
/** Deliverables this node produced, newest first. */
artifacts: GoalArtifactView[];
+ /** Agent the dispatched Task is assigned to — who is doing the work. */
+ assigneeAgentId?: string;
attempts: GoalAttempt[];
/** Unresolved `depends_on` targets — why this node cannot start. */
blockers: GoalGraphNode[];
@@ -277,6 +279,7 @@ export const buildGoalGraphView = (
): GoalGraphView => {
const {
acceptances,
+ assignees,
decisions,
deliveredAt,
edges,
@@ -384,6 +387,7 @@ export const buildGoalGraphView = (
? [...members].flatMap((id) => artifactsByNode.get(id) ?? [])
: (artifactsByNode.get(node.id) ?? []),
...(acceptances?.[node.id] ? { acceptance: acceptances[node.id] } : {}),
+ ...(assignees?.[node.id] ? { assigneeAgentId: assignees[node.id] } : {}),
attempts,
blockers: (dependsOn.get(node.id) ?? [])
.map((id) => nodeById.get(id))
diff --git a/src/features/AgentProfileCard/AgentProfilePopup.tsx b/src/features/AgentProfileCard/AgentProfilePopup.tsx
index 8b3bb806cca..b0161ae6265 100644
--- a/src/features/AgentProfileCard/AgentProfilePopup.tsx
+++ b/src/features/AgentProfileCard/AgentProfilePopup.tsx
@@ -5,7 +5,7 @@ import { Flexbox, Icon, Popover } from '@lobehub/ui';
import { ActionIcon, Skeleton, Text } from '@lobehub/ui/base-ui';
import { SkillsIcon } from '@lobehub/ui/icons';
import { createStaticStyles } from 'antd-style';
-import { BookOpen, FileText, Settings } from 'lucide-react';
+import { BookOpen, FileText, Settings, SquareTerminal } from 'lucide-react';
import { memo, type PropsWithChildren, useState } from 'react';
import { useTranslation } from 'react-i18next';
import useSWR from 'swr';
@@ -19,8 +19,11 @@ import { usePermission } from '@/hooks/usePermission';
import { agentProfileKeys } from '@/libs/swr/keys';
import { agentService } from '@/services/agent';
import { useAgentGroupStore } from '@/store/agentGroup';
+import { useHomeStore } from '@/store/home';
+import { homeAgentListSelectors } from '@/store/home/selectors';
import AgentProfileCard from '.';
+import { resolveAgentRuntimeLabel } from './runtime';
const styles = createStaticStyles(({ css, cssVar }) => ({
footer: css`
@@ -58,6 +61,7 @@ type AgentPreview = Pick<
>;
interface FetchedAgent extends Partial<AgentPreview> {
+ agencyConfig?: { heterogeneousProvider?: { type?: string | null } | null } | null;
files?: unknown[];
id?: string;
knowledgeBases?: unknown[];
@@ -91,6 +95,7 @@ const AgentProfilePopup = memo<AgentProfilePopupProps>(
(!groupId || (isGroupAccessResolved && canEditGroup));
const updateMemberAgentConfig = useAgentGroupStore((s) => s.updateMemberAgentConfig);
+ const listEntry = useHomeStore(homeAgentListSelectors.getAgentById(agentId));
const { data: fetched, isLoading } = useSWR(
open && canConfigure ? agentProfileKeys.detail(agentId) : null,
@@ -98,6 +103,12 @@ const AgentProfilePopup = memo<AgentProfilePopupProps>(
{ revalidateOnFocus: false },
);
+ const runtimeLabel = resolveAgentRuntimeLabel({
+ fetchedType: fetched?.agencyConfig?.heterogeneousProvider?.type,
+ listEntry,
+ });
+ const isExternal = !!runtimeLabel;
+
const merged: Partial<AgentPreview> = {
avatar: fetched?.avatar ?? agent?.avatar,
backgroundColor: fetched?.backgroundColor ?? agent?.backgroundColor,
@@ -143,8 +154,11 @@ const AgentProfilePopup = memo<AgentProfilePopupProps>(
const footerLoading = canConfigure && !groupId && isLoading && !fetched;
+ // An external agent picks its own model inside its CLI, so the LobeHub model
+ // on its config is not what runs it: name the runtime instead, and never
+ // offer a model switch that would not take effect.
const modelSection =
- canConfigure && groupId ? (
+ canConfigure && groupId && !isExternal ? (
merged.model && (
<Flexbox className={styles.section} gap={4}>
<div className={styles.sectionTitle}>{t('groupSidebar.agentProfile.model')}</div>
@@ -155,22 +169,31 @@ const AgentProfilePopup = memo<AgentProfilePopupProps>(
/>
</Flexbox>
)
- ) : footerLoading ? (
+ ) : footerLoading && !isExternal ? (
<Flexbox horizontal align={'center'} className={styles.footer} gap={14}>
<Skeleton height={16} width={90} />
<Skeleton height={16} width={60} />
</Flexbox>
- ) : canConfigure && (merged.model || hasStats) ? (
+ ) : isExternal || (canConfigure && (merged.model || hasStats)) ? (
<Flexbox horizontal align={'center'} className={styles.footer} gap={14} wrap={'wrap'}>
- {merged.model && (
+ {isExternal ? (
<Flexbox horizontal align={'center'} className={styles.statItem} gap={6}>
- <ModelIcon model={merged.model} size={14} />
+ <Icon icon={SquareTerminal} size={14} />
<Text fontSize={12} type={'secondary'}>
- {merged.model}
+ {t('agentProfile.runtime', { name: runtimeLabel })}
</Text>
</Flexbox>
+ ) : (
+ merged.model && (
+ <Flexbox horizontal align={'center'} className={styles.statItem} gap={6}>
+ <ModelIcon model={merged.model} size={14} />
+ <Text fontSize={12} type={'secondary'}>
+ {merged.model}
+ </Text>
+ </Flexbox>
+ )
)}
- {pluginCount > 0 && (
+ {canConfigure && pluginCount > 0 && (
<Flexbox horizontal align={'center'} className={styles.statItem} gap={4}>
<Icon icon={SkillsIcon} size={13} />
<Text fontSize={12} type={'secondary'}>
@@ -178,7 +201,7 @@ const AgentProfilePopup = memo<AgentProfilePopupProps>(
</Text>
</Flexbox>
)}
- {knowledgeCount > 0 && (
+ {canConfigure && knowledgeCount > 0 && (
<Flexbox horizontal align={'center'} className={styles.statItem} gap={4}>
<Icon icon={BookOpen} size={13} />
<Text fontSize={12} type={'secondary'}>
@@ -186,7 +209,7 @@ const AgentProfilePopup = memo<AgentProfilePopupProps>(
</Text>
</Flexbox>
)}
- {fileCount > 0 && (
+ {canConfigure && fileCount > 0 && (
<Flexbox horizontal align={'center'} className={styles.statItem} gap={4}>
<Icon icon={FileText} size={13} />
<Text fontSize={12} type={'secondary'}>
diff --git a/src/features/AgentProfileCard/runtime.test.ts b/src/features/AgentProfileCard/runtime.test.ts
new file mode 100644
index 00000000000..1ed17272b5a
--- /dev/null
+++ b/src/features/AgentProfileCard/runtime.test.ts
@@ -0,0 +1,22 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveAgentRuntimeLabel } from './runtime';
+
+describe('resolveAgentRuntimeLabel', () => {
+ it('names the external runtime of a Claude Code agent from the home agent list', () => {
+ // The card used to show the LobeHub model for a Claude Code agent, which is
+ // not what runs it.
+ expect(resolveAgentRuntimeLabel({ listEntry: { heterogeneousType: 'claude-code' } })).toBe(
+ 'Claude Code',
+ );
+ });
+
+ it('falls back to the fetched config for an agent outside the home list', () => {
+ expect(resolveAgentRuntimeLabel({ fetchedType: 'claude-code' })).toBe('Claude Code');
+ });
+
+ it('has no runtime label for a built-in agent', () => {
+ expect(resolveAgentRuntimeLabel({ listEntry: { heterogeneousType: null } })).toBeUndefined();
+ expect(resolveAgentRuntimeLabel({})).toBeUndefined();
+ });
+});
diff --git a/src/features/AgentProfileCard/runtime.ts b/src/features/AgentProfileCard/runtime.ts
new file mode 100644
index 00000000000..69595867a77
--- /dev/null
+++ b/src/features/AgentProfileCard/runtime.ts
@@ -0,0 +1,18 @@
+import { getHeterogeneousTypeLabel } from '@lobechat/heterogeneous-agents';
+
+/**
+ * Runtime label of an external agent (Claude Code, Codex, …), or `undefined`
+ * for a built-in agent and while it is not yet known which of the two it is.
+ *
+ * An external agent runs on its own CLI with its own model choice, so the
+ * LobeHub model on its config says nothing about what does the work — the card
+ * names the runtime instead. The home agent list answers instantly for agents
+ * in the sidebar; the fetched config covers the rest.
+ */
+export const resolveAgentRuntimeLabel = ({
+ fetchedType,
+ listEntry,
+}: {
+ fetchedType?: string | null;
+ listEntry?: { heterogeneousType?: string | null } | null;
+}): string | undefined => getHeterogeneousTypeLabel(listEntry?.heterogeneousType ?? fetchedType);
diff --git a/src/store/task/slices/detail/action.test.ts b/src/store/task/slices/detail/action.test.ts
index ec213943aaa..b954b461987 100644
--- a/src/store/task/slices/detail/action.test.ts
+++ b/src/store/task/slices/detail/action.test.ts
@@ -247,6 +247,42 @@ describe('TaskDetailSliceAction', () => {
await pending;
});
+ it('revalidates goal graphs when the assignee changes, so a goal page shows the new executor', async () => {
+ useTaskStore.setState({
+ taskDetailMap: { 'T-1': { identifier: 'T-1', instruction: 'x', status: 'backlog' } },
+ });
+ vi.mocked(taskService.update).mockResolvedValue({ success: true } as any);
+ const { mutate } = await import('@/libs/swr');
+
+ await useTaskStore.getState().updateTask('T-1', { assigneeAgentId: 'agt_2' });
+
+ // A paused goal does not poll, so without this its page kept the old avatar.
+ const matchers = vi
+ .mocked(mutate)
+ .mock.calls.map(([key]) => key)
+ .filter((key): key is (key: unknown) => boolean => typeof key === 'function');
+ const matchesGoalGraph = (key: unknown) => matchers.some((match) => match(key));
+ expect(matchesGoalGraph(['goal:graph', 'goal-1'])).toBe(true);
+ expect(matchesGoalGraph(['goal:graph', 'goal-1', 'ws-1'])).toBe(true);
+ expect(matchesGoalGraph(['task:detail', 'T-1'])).toBe(false);
+ });
+
+ it('leaves goal graphs alone when the assignee does not change', async () => {
+ useTaskStore.setState({
+ taskDetailMap: { 'T-1': { identifier: 'T-1', instruction: 'x', status: 'backlog' } },
+ });
+ vi.mocked(taskService.update).mockResolvedValue({ success: true } as any);
+ const { mutate } = await import('@/libs/swr');
+
+ await useTaskStore.getState().updateTask('T-1', { priority: 2 });
+
+ const matchers = vi
+ .mocked(mutate)
+ .mock.calls.map(([key]) => key)
+ .filter((key): key is (key: unknown) => boolean => typeof key === 'function');
+ expect(matchers.some((match) => match(['goal:graph', 'goal-1']))).toBe(false);
+ });
+
it('should clear stale editorData for instruction-only optimistic updates', async () => {
useTaskStore.setState({
activeTaskId: 'T-1',
diff --git a/src/store/task/slices/detail/action.ts b/src/store/task/slices/detail/action.ts
index 66f9b51a3ec..ef17a581927 100644
--- a/src/store/task/slices/detail/action.ts
+++ b/src/store/task/slices/detail/action.ts
@@ -4,7 +4,7 @@ import isEqual from 'fast-deep-equal';
import { t } from 'i18next';
import { mutate, useClientDataSWR } from '@/libs/swr';
-import { taskKeys } from '@/libs/swr/keys';
+import { goalKeys, taskKeys } from '@/libs/swr/keys';
import { taskService } from '@/services/task';
import { workService } from '@/services/work';
import type { StoreSetter } from '@/store/types';
@@ -532,7 +532,17 @@ export class TaskDetailSliceActionImpl {
data.parentTaskId !== undefined ||
data.priority !== undefined
) {
- await Promise.all([this.#get().refreshTaskList(), refreshPatchedTargets()]).catch(() => {});
+ await Promise.all([
+ this.#get().refreshTaskList(),
+ refreshPatchedTargets(),
+ // A goal page names each task's executor from its own graph snapshot,
+ // and only polls while the goal is advancing — a paused or finished
+ // goal would keep showing the old assignee. The task does not know its
+ // goal, so revalidate every goal graph; only mounted ones refetch.
+ assigneeAgentId !== undefined
+ ? mutate((key) => Array.isArray(key) && key[0] === goalKeys.graph.root)
+ : undefined,
+ ]).catch(() => {});
}
};