π€― 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
π fix(goal): keep the exploration map still on clicks and stream running tasks in the result panel (#19535)
Arvin Xu3fe7a8ea5842
diff --git a/src/features/AgentGoals/ProcessControl/Graph/index.tsx b/src/features/AgentGoals/ProcessControl/Graph/index.tsxindex ddb00a3eb94..457aef6997e 100644--- a/src/features/AgentGoals/ProcessControl/Graph/index.tsx+++ b/src/features/AgentGoals/ProcessControl/Graph/index.tsx@@ -39,6 +39,7 @@ import ExplorationEdge from './ExplorationEdge';import { explorationMap } from './explorationMap';import GraphNodeView, { GhostNodeView, type GraphNodeData } from './GraphNode';import { hideKinds, layoutGraph, NODE_WIDTH } from './layout';+import { revealCenter } from './revealNode';import { useExplorationNavigation } from './useExplorationNavigation';import { useFitViewOnResize } from './useFitViewOnResize';@@ -299,7 +300,7 @@ const Canvas = memo<className: string;fullscreen: boolean;hiddenKinds: ReadonlySet<GoalGraphNodeKind>;- /** Bump to refit after the frame around the canvas changes size. */+ /** Bump after the frame around the canvas changes size to keep the selection in view. */refitKey?: boolean;view: GraphViewMode;collapsed: ReadonlySet<string>;@@ -323,7 +324,7 @@ const Canvas = memo<navigation,view,}) => {- const { fitView } = useReactFlow();+ const { fitView, getInternalNode, getViewport, setCenter } = useReactFlow();const hasNavigation = !!navigation;const fitOptions = useMemo(() => ({@@ -568,13 +569,31 @@ const Canvas = memo<return () => clearTimeout(timer);}, [view, collapsed, allNodes.length, hiddenKinds, fitView, fitOptions]);- // The portal panel borrows width from the canvas; wait out its slide- // animation before refitting, or the fit is computed mid-transition.+ // The portal panel borrows width from the canvas. Refitting the whole map+ // when it slid open rescaled the graph on every first click; keep the zoom+ // and only pan when the selected card ended up under the panel. Wait out+ // the slide animation, or the canvas is measured mid-transition.useEffect(() => {- if (refitKey === undefined) return;- const timer = setTimeout(() => fitView(fitOptions), 280);+ if (refitKey === undefined || !selectedId) return;+ const timer = setTimeout(() => {+ const node = getInternalNode(selectedId);+ const container = containerRef.current;+ if (!node || !container) return;+ const viewport = getViewport();+ const { height, width } = container.getBoundingClientRect();+ const center = revealCenter(+ {+ ...node.internals.positionAbsolute,+ height: node.measured.height ?? 0,+ width: node.measured.width ?? 0,+ },+ viewport,+ { height, width },+ );+ if (center) void setCenter(center.x, center.y, { duration: 200, zoom: viewport.zoom });+ }, 280);return () => clearTimeout(timer);- }, [refitKey, fitView, fitOptions]);+ }, [refitKey, selectedId, getInternalNode, getViewport, setCenter]);return (<div@@ -826,7 +845,10 @@ const Graph = memo<GraphProps>(({ fullscreen, onFullscreenChange, ...props }) =>view={scopeId ? 'all' : view}navigation={<Flexbox gap={8}>- {titleAndViews}+ {/* Title and view switch share one row, as in the inline header. */}+ <Flexbox horizontal align={'center'} gap={12}>+ {titleAndViews}+ </Flexbox>{overview}{breadcrumbs}</Flexbox>diff --git a/src/features/AgentGoals/ProcessControl/Graph/revealNode.test.ts b/src/features/AgentGoals/ProcessControl/Graph/revealNode.test.tsnew file mode 100644index 00000000000..66dbb4da0e7--- /dev/null+++ b/src/features/AgentGoals/ProcessControl/Graph/revealNode.test.ts@@ -0,0 +1,26 @@+import { describe, expect, it } from 'vitest';++import { revealCenter } from './revealNode';++const box = { height: 100, width: 200, x: 800, y: 100 };++describe('revealCenter', () => {+ it('leaves the viewport alone when the node is already visible', () => {+ expect(+ revealCenter(box, { x: 0, y: 0, zoom: 1 }, { height: 600, width: 1200 }),+ ).toBeUndefined();+ });++ it('centers on a node the opening panel pushed out of view', () => {+ expect(revealCenter(box, { x: 0, y: 0, zoom: 1 }, { height: 600, width: 700 })).toEqual({+ x: 900,+ y: 150,+ });+ });++ it('measures visibility at the current zoom', () => {+ expect(+ revealCenter(box, { x: 0, y: 0, zoom: 0.5 }, { height: 600, width: 700 }),+ ).toBeUndefined();+ });+});diff --git a/src/features/AgentGoals/ProcessControl/Graph/revealNode.ts b/src/features/AgentGoals/ProcessControl/Graph/revealNode.tsnew file mode 100644index 00000000000..67d42254ed4--- /dev/null+++ b/src/features/AgentGoals/ProcessControl/Graph/revealNode.ts@@ -0,0 +1,30 @@+interface Box {+ height: number;+ width: number;+ x: number;+ y: number;+}++interface Viewport {+ x: number;+ y: number;+ zoom: number;+}++/**+ * Where to center the viewport so a node becomes visible, or nothing when it+ * already is. The zoom never changes: a panel opening beside the map should+ * leave the map where the reader put it, not rescale it.+ */+export const revealCenter = (+ box: Box,+ viewport: Viewport,+ size: { height: number; width: number },+): { x: number; y: number } | undefined => {+ const left = box.x * viewport.zoom + viewport.x;+ const top = box.y * viewport.zoom + viewport.y;+ const right = left + box.width * viewport.zoom;+ const bottom = top + box.height * viewport.zoom;+ if (left >= 0 && top >= 0 && right <= size.width && bottom <= size.height) return;+ return { x: box.x + box.width / 2, y: box.y + box.height / 2 };+};diff --git a/src/features/AgentGoals/ProcessControl/Graph/useExplorationNavigation.test.ts b/src/features/AgentGoals/ProcessControl/Graph/useExplorationNavigation.test.tsindex ccef0478566..699a155e3c5 100644--- a/src/features/AgentGoals/ProcessControl/Graph/useExplorationNavigation.test.ts+++ b/src/features/AgentGoals/ProcessControl/Graph/useExplorationNavigation.test.ts@@ -64,6 +64,28 @@ describe('experiment navigation', () => {expect(result.current.path).toEqual([]);expect(result.current.collapsed.size).toBe(3);});+ it('keeps the collapsed set identity across re-renders that do not change it', () => {+ const { result, rerender } = renderHook((props) => useExplorationNavigation('g', props), {+ initialProps: graph,+ });+ const initial = result.current.collapsed;+ // A graph poll hands over a new snapshot with the same content.+ rerender({ nodes: [...nodes], edges: [...edges] });+ expect(result.current.collapsed).toBe(initial);++ act(() => result.current.toggle('a'));+ expect(result.current.collapsed).not.toBe(initial);+ });+ it('keeps an empty collapsed set stable for graphs without experiments', () => {+ const plain = { nodes: [{ id: 't', kind: 'task' }] as GoalGraphNode[], edges: [] };+ const { result, rerender } = renderHook((props) => useExplorationNavigation('g', props), {+ initialProps: plain,+ });+ const initial = result.current.collapsed;+ rerender({ ...plain, nodes: [...plain.nodes] });+ expect(result.current.collapsed).toBe(initial);+ expect(initial.size).toBe(0);+ });it('bulk controls act on the current scope without collapsing its ancestor', () => {const { result } = renderHook(() => useExplorationNavigation('g', graph));act(() => result.current.expandAll(true));diff --git a/src/features/AgentGoals/ProcessControl/Graph/useExplorationNavigation.ts b/src/features/AgentGoals/ProcessControl/Graph/useExplorationNavigation.tsindex 5f54b3d3fa5..efc6da097e1 100644--- a/src/features/AgentGoals/ProcessControl/Graph/useExplorationNavigation.ts+++ b/src/features/AgentGoals/ProcessControl/Graph/useExplorationNavigation.ts@@ -1,6 +1,6 @@import type { GoalGraphSnapshot } from '@lobechat/types';import { experimentMembers } from '@lobechat/utils/goalGraph';-import { useState } from 'react';+import { useMemo, useState } from 'react';type Graph = Pick<GoalGraphSnapshot, 'nodes' | 'edges'>;@@ -18,7 +18,17 @@ export const useExplorationNavigation = (goalId: string, graph: Graph) => {(edge) => ids.has(edge.sourceNodeId) && ids.has(edge.targetNodeId),);const experiments = nodes.filter((node) => node.kind === 'experiment');- const collapsed = new Set(experiments.filter((n) => !state.expanded.has(n.id)).map((n) => n.id));+ // The canvas refits whenever `collapsed` changes identity, so it must only+ // change when its contents do β a fresh Set per render refit the map on every+ // node click and every graph poll.+ const collapsedKey = experiments+ .filter((n) => !state.expanded.has(n.id))+ .map((n) => n.id)+ .join('\n');+ const collapsed = useMemo(+ () => new Set(collapsedKey ? collapsedKey.split('\n') : []),+ [collapsedKey],+ );return {collapsed,diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.tsindex 40ea89508f4..ace1a7c20da 100644--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts@@ -15,6 +15,7 @@ import {hasReviewableResult,isRunningNode,isTroubledTaskNode,+ opensOnResultSurface,} from './goalGraphViewModel';const T0 = new Date('2026-08-01T00:00:00Z');@@ -682,6 +683,57 @@ describe('hasReviewableResult', () => {});});+describe('opensOnResultSurface', () => {+ it('opens a healthy running task on the result surface to watch the live run', () => {+ const view = buildGoalGraphView(+ snapshot({+ events: [event('w1', 'activated', 110)],+ nodes: [node('w1', { status: 'active', taskId: 'task-1', updatedAt: at(115) })],+ }),+ NOW,+ );++ expect(opensOnResultSurface(view.byId.w1)).toBe(true);+ });++ it('opens a settled task on the result surface', () => {+ const view = buildGoalGraphView(+ snapshot({+ events: [event('w1', 'activated', 100), event('w1', 'resolved', 110)],+ nodes: [+ node('w1', {+ resolvedAt: at(110),+ status: 'resolved',+ taskId: 'task-1',+ updatedAt: at(110),+ }),+ ],+ }),+ NOW,+ );++ expect(opensOnResultSurface(view.byId.w1)).toBe(true);+ });++ it('keeps undispatched and stale tasks on the original task detail', () => {+ const proposed = buildGoalGraphView(+ snapshot({ nodes: [node('w1', { status: 'proposed', taskId: 'task-1' })] }),+ NOW,+ );+ const stale = buildGoalGraphView(+ snapshot({+ events: [event('w1', 'activated', 30)],+ nodes: [node('w1', { status: 'active', taskId: 'task-1', updatedAt: at(0) })],+ }),+ NOW,+ );++ expect(opensOnResultSurface(proposed.byId.w1)).toBe(false);+ expect(stale.byId.w1.isStale).toBe(true);+ expect(opensOnResultSurface(stale.byId.w1)).toBe(false);+ });+});+describe('experiment navigation', () => {it('keeps historical branching separate from dependencies and excludes terminal acceptance', () => {const view = buildGoalGraphView(diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.tsindex 0f0d300ea80..dac3c724ead 100644--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts@@ -132,6 +132,19 @@ export const hasReviewableResult = (view: GoalNodeView): boolean => {return view.node.status === 'resolved' || view.isVerifying;};+/**+ * Whether clicking a Task node opens its result surface rather than the+ * original Task detail. A delivery to read opens there, and so does a healthy+ * run in flight: the result panel shows the live run as it happens, and the+ * same panel turns into the report once the run settles β one place to watch+ * and then read. Troubled Tasks still open the original Task detail.+ */+export const opensOnResultSurface = (view: GoalNodeView): boolean => {+ if (view.node.kind !== 'task') return false;+ if (isTroubledTaskNode(view)) return false;+ return hasReviewableResult(view) || isRunningNode(view);+};+/*** Whether a node reads as "running" on the map β the animated ring, the chip* and the elapsed clock all hang off this.diff --git a/src/features/AgentGoals/ProcessControl/index.tsx b/src/features/AgentGoals/ProcessControl/index.tsxindex 5397ded9cac..2fd85e490ec 100644--- a/src/features/AgentGoals/ProcessControl/index.tsx+++ b/src/features/AgentGoals/ProcessControl/index.tsx@@ -19,7 +19,7 @@ import Activity from './Activity';import Deliverables from './Deliverables';import Findings from './Findings';import Frontier, { type FrontierActions } from './Frontier';-import { buildGoalGraphView, hasReviewableResult } from './goalGraphViewModel';+import { buildGoalGraphView, opensOnResultSurface } from './goalGraphViewModel';import Graph from './Graph';/**@@ -75,11 +75,10 @@ const ProcessControl = memo<ProcessControlProps>();// Every click funnels here: keep the map highlight (spatial continuity) and- // open the drill-down. Only a Task with a delivery to read β settled, or- // delivered and under Acceptance judgment β lands on its result-focused- // review surface; a Task still running, waiting, or in trouble opens the- // original Task detail, because its result panel would be an empty shell- // and the question is what the run is doing, not what it produced.+ // open the drill-down. A Task with a delivery to read, or a healthy run in+ // flight, lands on its result surface β the live run while it works, the+ // report once it settles. A Task waiting or in trouble opens the original+ // Task detail, where configuration and failure context live.const select = useCallback((nodeId: string) => {setSelectedId(nodeId);@@ -97,7 +96,7 @@ const ProcessControl = memo<ProcessControlProps>())openTaskDetail(taskId);- else if (view && hasReviewableResult(view)) openTaskResult(taskId);+ else if (view && opensOnResultSurface(view)) openTaskResult(taskId);else openTaskDetail(taskId);},[goalId, graph, openGoalNode, openTaskDetail, openTaskResult],diff --git a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsxindex 43435ad25a4..fb33a164171 100644--- a/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx+++ b/src/features/AgentTasks/AgentTaskDetail/TopicChatDrawer/index.tsx@@ -1,7 +1,7 @@'use client';import { AGENT_CHAT_TOPIC_URL } from '@lobechat/const';-import type { ConversationContext } from '@lobechat/types';+import type { ConversationContext, TaskDetailActivity } from '@lobechat/types';import type { DropdownItem } from '@lobehub/ui';import { copyToClipboard, DropdownMenu, Flexbox, Freeze } from '@lobehub/ui';import { ActionIcon, confirmModal, FloatingPanel, Tag, Text, toast } from '@lobehub/ui/base-ui';@@ -52,11 +52,16 @@ export interface TopicChatDrawerBodyProps {agentId: string;defaultInputExpanded?: boolean;disableInputCollapse?: boolean;+ /**+ * The run to resume streaming from. Hosts that embed the body outside the+ * drawer pass it themselves; the drawer falls back to its own topic's run.+ */+ runningOperation?: TaskDetailActivity['runningOperation'];topicId: string;}export const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(- ({ agentId, defaultInputExpanded, disableInputCollapse, topicId }) => {+ ({ agentId, defaultInputExpanded, disableInputCollapse, runningOperation, topicId }) => {const isLogin = useUserStore(authSelectors.isLogin);const useHydrateAgentConfig = useAgentStore((s) => s.useHydrateAgentConfig);@@ -77,12 +82,12 @@ export const TopicChatDrawerBody = memo<TopicChatDrawerBodyProps>(const replaceMessages = useChatStore((s) => s.replaceMessages);const operationState = useOperationState(context);- const runningOperation = useTaskStore(+ const drawerRunningOperation = useTaskStore((s) => taskActivitySelectors.activeDrawerTopicActivity(s)?.runningOperation,);// Pass this drawer's agent explicitly β the run drawer also mounts on the// home surface, where the chat store's `activeAgentId` is unset.- useGatewayReconnect(topicId, runningOperation, agentId);+ useGatewayReconnect(topicId, runningOperation ?? drawerRunningOperation, agentId);const itemContent = useCallback((index: number, id: string) => <MessageItem disableEditing id={id} index={index} key={id} />,diff --git a/src/features/Portal/TaskResult/Body.tsx b/src/features/Portal/TaskResult/Body.tsxindex 3563153cc8b..3ff2c70ee09 100644--- a/src/features/Portal/TaskResult/Body.tsx+++ b/src/features/Portal/TaskResult/Body.tsx@@ -8,15 +8,20 @@ import TaskAcceptance from '@/features/AgentTasks/AgentTaskDetail/TaskAcceptanceimport 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 TopicChatDrawer, {+ TopicChatDrawerBody,+} from '@/features/AgentTasks/AgentTaskDetail/TopicChatDrawer';import { useActiveTaskResult } from '@/features/AgentTasks/AgentTaskDetail/useActiveTaskResult';import { useChatStore } from '@/store/chat';import { chatPortalSelectors } from '@/store/chat/selectors';+import { useLiveRun } from './useLiveRun';+const Body = memo(() => {const { t } = useTranslation('chat');const taskId = useChatStore(chatPortalSelectors.taskResultId);const { error, isInitialLoading, isNotFound, onRetry } = useActiveTaskResult(taskId);+ const liveRun = useLiveRun();if (!taskId) return null;if (error)@@ -32,6 +37,21 @@ const Body = memo(() => {</Flexbox>);+ // While the run is in flight there is no report yet β the thing to read is+ // the run itself. Stream its conversation in place; the task detail polls+ // while the run is live, so the panel turns into the report once it settles.+ if (!isInitialLoading && liveRun)+ return (+ <Flexbox flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>+ <TopicChatDrawerBody+ agentId={liveRun.agentId}+ key={liveRun.topicId}+ runningOperation={liveRun.activity.runningOperation}+ topicId={liveRun.topicId}+ />+ </Flexbox>+ );+return (<Flexboxflex={1}diff --git a/src/features/Portal/TaskResult/Title.tsx b/src/features/Portal/TaskResult/Title.tsxindex 5e45c857116..285320c9a7d 100644--- a/src/features/Portal/TaskResult/Title.tsx+++ b/src/features/Portal/TaskResult/Title.tsx@@ -4,15 +4,40 @@ import { cssVar } from 'antd-style';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import AssigneeAvatar from '@/features/AgentTasks/features/AssigneeAvatar';+import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';import { useChatStore } from '@/store/chat';import { chatPortalSelectors } from '@/store/chat/selectors';import { useTaskStore } from '@/store/task';import { oneLineEllipsis } from '@/styles';+import { useLiveRun } from './useLiveRun';+const Title = memo(() => {const { t } = useTranslation('chat');const taskId = useChatStore(chatPortalSelectors.taskResultId);const detail = useTaskStore((state) => (taskId ? state.taskDetailMap[taskId] : undefined));+ const liveRun = useLiveRun();+ const agentMeta = useAgentDisplayMeta(liveRun?.agentId);++ // A live run is a conversation, so it is headed like one: who is working,+ // then what this run is about.+ if (liveRun)+ return (+ <Flexbox horizontal align={'center'} flex={1} gap={8} style={{ minWidth: 0 }}>+ <AssigneeAvatar agentId={liveRun.agentId} size={20} />+ <Text fontSize={14} style={{ flexShrink: 0 }} weight={500}>+ {agentMeta?.title ?? liveRun.activity.author?.name}+ </Text>+ <Text+ className={oneLineEllipsis}+ fontSize={13}+ style={{ color: cssVar.colorTextSecondary, flex: 1, minWidth: 0 }}+ >+ {liveRun.activity.title}+ </Text>+ </Flexbox>+ );return (<Flexbox horizontal align={'center'} flex={1} gap={8} style={{ minWidth: 0 }}>diff --git a/src/features/Portal/TaskResult/useLiveRun.test.ts b/src/features/Portal/TaskResult/useLiveRun.test.tsnew file mode 100644index 00000000000..b73e4c30c3f--- /dev/null+++ b/src/features/Portal/TaskResult/useLiveRun.test.ts@@ -0,0 +1,38 @@+import type { TaskDetailActivity } from '@lobechat/types';+import { describe, expect, it } from 'vitest';++import { resolveLiveRun } from './useLiveRun';++const run = (overrides: Partial<TaskDetailActivity>): TaskDetailActivity =>+ ({ id: 'tpc_1', status: 'running', type: 'topic', ...overrides }) as TaskDetailActivity;++describe('resolveLiveRun', () => {+ it('streams a running run by its agent author', () => {+ expect(+ resolveLiveRun(+ run({ author: { id: 'agt_1', type: 'agent' } as TaskDetailActivity['author'] }),+ ),+ ).toMatchObject({ agentId: 'agt_1', topicId: 'tpc_1' });+ });++ it('falls back to the run agent when a person started it', () => {+ expect(+ resolveLiveRun(+ run({+ agentId: 'agt_2',+ author: { id: 'usr_1', type: 'user' } as TaskDetailActivity['author'],+ }),+ ),+ ).toMatchObject({ agentId: 'agt_2' });+ });++ it('reads the report once the run settled', () => {+ expect(resolveLiveRun(run({ agentId: 'agt_1', status: 'completed' }))).toBeUndefined();+ });++ it('has nothing to stream without a run or an agent', () => {+ expect(resolveLiveRun(undefined)).toBeUndefined();+ expect(resolveLiveRun(run({ agentId: undefined }))).toBeUndefined();+ expect(resolveLiveRun(run({ agentId: 'agt_1', id: undefined }))).toBeUndefined();+ });+});diff --git a/src/features/Portal/TaskResult/useLiveRun.ts b/src/features/Portal/TaskResult/useLiveRun.tsnew file mode 100644index 00000000000..aa5ee897cfb--- /dev/null+++ b/src/features/Portal/TaskResult/useLiveRun.ts@@ -0,0 +1,26 @@+import type { TaskDetailActivity } from '@lobechat/types';++import { useTaskStore } from '@/store/task';+import { taskActivitySelectors } from '@/store/task/selectors';++export interface LiveRun {+ activity: TaskDetailActivity;+ agentId: string;+ topicId: string;+}++/**+ * The run to stream in the result panel: the task's newest run, while it is+ * still running and has a conversation to open. Once it settles this returns+ * nothing and the panel falls back to reading the report.+ */+export const resolveLiveRun = (activity?: TaskDetailActivity): LiveRun | undefined => {+ if (activity?.status !== 'running' || !activity.id) return;+ const agentId =+ activity.author?.type === 'agent' ? activity.author.id : activity.agentId || undefined;+ if (!agentId) return;+ return { activity, agentId, topicId: activity.id };+};++export const useLiveRun = (): LiveRun | undefined =>+ resolveLiveRun(useTaskStore(taskActivitySelectors.activeTaskLatestTopic));diff --git a/src/store/task/selectors/activitySelectors.ts b/src/store/task/selectors/activitySelectors.tsindex 6b0fdce0e94..4201aadb43d 100644--- a/src/store/task/selectors/activitySelectors.ts+++ b/src/store/task/selectors/activitySelectors.ts@@ -20,6 +20,10 @@ const activeTaskBriefs = (s: TaskStoreState): TaskDetailActivity[] =>const activeTaskTopics = (s: TaskStoreState): TaskDetailActivity[] =>activeTaskActivities(s).filter((a) => a.type === 'topic');+/** The newest run of the active task β the one a result panel is about. */+const activeTaskLatestTopic = (s: TaskStoreState): TaskDetailActivity | undefined =>+ activeTaskTopics(s).at(-1);+const activeTaskComments = (s: TaskStoreState): TaskDetailActivity[] =>activeTaskActivities(s).filter((a) => a.type === 'comment');@@ -39,6 +43,7 @@ export const taskActivitySelectors = {activeTaskActivities,activeTaskBriefs,activeTaskComments,+ activeTaskLatestTopic,activeTaskTopics,hasUnresolvedBriefs,unresolvedBriefCount,