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 a cross-agent goals page (#21221)

Arvin Xub5252e579987
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index e9c766936a0..5f9656c8aba 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -722,6 +722,8 @@
"goalList.taskProgress": "{{done}}/{{total}} tasks done",
"goalList.title": "Goals",
"goalPage.activeGoals": "Open goals",
+ "goalPage.agentFilter.all": "All agents",
+ "goalPage.agentFilter.title": "Filter by agent",
"goalPage.allGoals": "All goals",
"goalPage.create": "Create goal",
"goalPage.description": "Track what this agent is pursuing and how close each goal is to acceptance.",
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index a4382c5285e..e443acd1329 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -472,6 +472,7 @@
"tab.eval": "Eval Lab",
"tab.files": "Files",
"tab.generation": "Generation",
+ "tab.goals": "Goals",
"tab.home": "Home",
"tab.image": "Image",
"tab.knowledgeBase": "Library",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index f1e4097c6e7..f02f8e2e7df 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -722,6 +722,8 @@
"goalList.taskProgress": "{{done}}/{{total}} 项任务完成",
"goalList.title": "目标",
"goalPage.activeGoals": "待处理目标",
+ "goalPage.agentFilter.all": "全部 Agent",
+ "goalPage.agentFilter.title": "按 Agent 筛选",
"goalPage.allGoals": "全部目标",
"goalPage.create": "创建目标",
"goalPage.description": "掌握 Agent 正在追逐什么,以及每个目标距离验收还有多远。",
diff --git a/locales/zh-CN/common.json b/locales/zh-CN/common.json
index 6cf0456ad99..7f3cb3b9f26 100644
--- a/locales/zh-CN/common.json
+++ b/locales/zh-CN/common.json
@@ -472,6 +472,7 @@
"tab.eval": "评测实验室",
"tab.files": "文件",
"tab.generation": "生成",
+ "tab.goals": "目标",
"tab.home": "首页",
"tab.image": "图片",
"tab.knowledgeBase": "资源库",
diff --git a/packages/app-config/src/routes/index.ts b/packages/app-config/src/routes/index.ts
index be6339a5aae..ee080609ca7 100644
--- a/packages/app-config/src/routes/index.ts
+++ b/packages/app-config/src/routes/index.ts
@@ -8,6 +8,7 @@ import {
ListTodoIcon,
Settings,
ShapesIcon,
+ TargetIcon,
Video,
} from 'lucide-react';
@@ -108,6 +109,15 @@ export const NAVIGATION_ROUTES: NavigationRoute[] = [
path: '/tasks',
pathPrefix: '/tasks',
},
+ {
+ cmdkKey: 'tab.goals',
+ electronKey: 'navigation.goals',
+ icon: TargetIcon,
+ id: 'goals',
+ keywords: ['goals', 'objective', 'target', 'agent'],
+ path: '/goals',
+ pathPrefix: '/goals',
+ },
{
cmdkKey: 'tab.dashboard',
electronKey: 'navigation.dashboard',
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 318411a39c7..d301addec18 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -2880,6 +2880,8 @@ export default {
'goalProcess.start': 'Start',
'goalPage.allGoals': 'All goals',
'goalPage.activeGoals': 'Open goals',
+ 'goalPage.agentFilter.all': 'All agents',
+ 'goalPage.agentFilter.title': 'Filter by agent',
'goalPage.description':
'Track what this agent is pursuing and how close each goal is to acceptance.',
'goalPage.create': 'Create goal',
diff --git a/packages/locales/src/default/common.ts b/packages/locales/src/default/common.ts
index f83109d3669..59b9dacc696 100644
--- a/packages/locales/src/default/common.ts
+++ b/packages/locales/src/default/common.ts
@@ -598,6 +598,7 @@ export default {
'tab.eval': 'Eval Lab',
'tab.files': 'Files',
'tab.generation': 'Generation',
+ 'tab.goals': 'Goals',
'tab.home': 'Home',
'tab.knowledgeBase': 'Library',
'tab.marketplace': 'Marketplace',
diff --git a/src/features/AgentGoals/AgentGoalsPage.tsx b/src/features/AgentGoals/AgentGoalsPage.tsx
index 706140363e2..2cee7dfd695 100644
--- a/src/features/AgentGoals/AgentGoalsPage.tsx
+++ b/src/features/AgentGoals/AgentGoalsPage.tsx
@@ -20,11 +20,14 @@ import AgentBreadcrumb from '@/features/AgentBreadcrumb';
import NavHeader from '@/features/NavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { useCacheScope } from '@/libs/swr/useCacheScope';
import type { GoalListFilter } from '@/store/goal';
import { goalSelectors, useGoalStore } from '@/store/goal';
-import { goalListKey } from '@/store/goal/projection';
+import { globalGoalListScopeId, goalListKey, goalListScopeId } from '@/store/goal/projection';
import { createGoalModal } from './CreateGoalModal';
+import GoalAgentFilter from './GoalAgentFilter';
+import { goalAgentFilterOptions } from './goalAgentFilterOptions';
import { GoalCardItem } from './GoalCardItem';
import GoalEmptyState from './GoalEmptyState';
import type { GoalExampleSeed } from './goalExamples';
@@ -99,6 +102,7 @@ const GoalLoadError = ({ onRetry }: { onRetry: () => void }) => {
};
interface AgentGoalsPageProps {
+ /** Neither id: the cross-agent page, listing every agent's goals. */
agentId?: string;
projectId?: string;
}
@@ -106,7 +110,16 @@ interface AgentGoalsPageProps {
const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
const { t } = useTranslation('chat');
const navigate = useWorkspaceAwareNavigate();
- const scopeId = projectId ? `project:${projectId}` : agentId!;
+ const cacheScope = useCacheScope();
+ const isGlobal = !agentId && !projectId;
+ const agentFilter = useGoalStore((s) => s.goalListAgentFilter);
+ const setAgentFilter = useGoalStore((s) => s.setGoalListAgentFilter);
+ // The cross-agent page narrowed to one agent reads that agent's own list —
+ // the same server query and cache entry as the agent's Goals page.
+ const queryAgentId = isGlobal ? agentFilter : agentId;
+ const globalScope = isGlobal && !queryAgentId ? cacheScope : undefined;
+ const scopeId = goalListScopeId({ agentId: queryAgentId, globalScope, projectId });
+ const allGoalsScopeId = isGlobal ? globalGoalListScopeId(cacheScope) : scopeId;
const useFetchGoals = useGoalStore((s) => s.useFetchGoals);
const refreshGoals = useGoalStore((s) => s.refreshGoals);
const filter = useGoalStore((s) => s.goalListFilter);
@@ -118,27 +131,45 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
// The rows live in the replica view; the hook only orchestrates the fetch, so
// a revisit paints the persisted projection on the first frame instead of an
// empty-state frame while the sync lands.
- const { error, isLoading } = useFetchGoals(agentId, projectId);
+ const { error, isLoading } = useFetchGoals(queryAgentId, projectId, 'all', globalScope);
// The active tab reads its own statuses from the server. `all` shares the
// window read's entry, so the page only pays for an extra request once the
// user opens a narrow tab.
- const tabSync = useFetchGoals(agentId, projectId, filter);
- // `delivered` is a whole-set count, not a count of the page the list happens
- // to hold: read the review set's own total so the header can never disagree
- // with what the Needs-review tab shows once a goal sits past the list's page.
- // The read has to run whichever tab is active, since the header shows it
- // regardless — the rows themselves come from the view below.
- useFetchGoals(agentId, projectId, 'review');
+ const tabSync = useFetchGoals(queryAgentId, projectId, filter, globalScope);
+ // An agent's or project's page: `delivered` is a whole-set count, not a count
+ // of the page the list happens to hold — read the review set's own total so
+ // the overview can never disagree with what the Needs-review tab shows once a
+ // goal sits past the list's page. The read has to run whichever tab is
+ // active, since the overview shows it regardless.
+ // The cross-agent page has no overview; it reads every agent's goals instead,
+ // which the agent filter lists its options from even while narrowed.
+ useFetchGoals(
+ isGlobal ? undefined : agentId,
+ projectId,
+ isGlobal ? 'all' : 'review',
+ isGlobal ? cacheScope : undefined,
+ );
const listView = useGoalStore(goalSelectors.goalListView(scopeId));
+ const allGoalsView = useGoalStore(goalSelectors.goalListView(allGoalsScopeId));
const tabView = useGoalStore(
goalSelectors.goalListView(
- filter === 'all' ? scopeId : goalListKey({ agentId, filter, projectId }),
+ filter === 'all'
+ ? scopeId
+ : goalListKey({ agentId: queryAgentId, filter, globalScope, projectId }),
),
);
const reviewView = useGoalStore(
goalSelectors.goalListView(goalListKey({ agentId, filter: 'review', projectId })),
);
const goals = useMemo(() => listView?.goals ?? [], [listView]);
+ const agentFilterOptions = useMemo(
+ () => (isGlobal ? goalAgentFilterOptions(allGoalsView?.goals ?? []) : []),
+ [allGoalsView, isGlobal],
+ );
+ // Whether the scope has any goal at all — on the cross-agent page that is
+ // every agent's list, so narrowing to one agent shows the filtered-empty
+ // state rather than the first-goal onboarding.
+ const hasNoGoals = (isGlobal ? (allGoalsView?.goals.length ?? 0) : goals.length) === 0;
const summary = useMemo(() => {
const total = listView?.total ?? goals.length;
// An aggregate that has not answered is unknown, not zero. Falling back to
@@ -185,7 +216,10 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
// instead of the modal blocking on it.
onCreated: (goal) => {
void refreshGoals(scopeId);
- const ownerId = goal.agentId ?? agentId;
+ if (allGoalsScopeId !== scopeId) void refreshGoals(allGoalsScopeId);
+ // The cross-agent page keeps the user in the workspace, like a task
+ // opened from the global task list.
+ const ownerId = isGlobal ? undefined : (goal.agentId ?? agentId);
navigate(ownerId ? `/agent/${ownerId}/goal/${goal.goalId}` : `/goal/${goal.goalId}`);
},
});
@@ -223,46 +257,56 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
// home rail, the goal portal and the detail page use), so a network
// blip no longer hides goals the user already has locally.
<GoalLoadError onRetry={() => void refreshGoals(scopeId)} />
- ) : goals.length === 0 ? (
+ ) : hasNoGoals ? (
<GoalEmptyState onCreate={openCreateGoal} />
) : (
<>
- <Flexbox className={styles.overview}>
- <Flexbox horizontal align={'center'} gap={20} justify={'space-between'} wrap={'wrap'}>
- <Flexbox gap={3}>
- <Text fontSize={20} weight={600}>
- {t('goalPage.title')}
- </Text>
- <Text type={'secondary'}>{t('goalPage.description')}</Text>
- </Flexbox>
- <Flexbox horizontal gap={20}>
- <Flexbox className={styles.metric} gap={2}>
- <Text fontSize={20} weight={600}>
- {summary.total}
- </Text>
- <Text fontSize={12} type={'secondary'}>
- {t('goalPage.metrics.total')}
- </Text>
- </Flexbox>
- <Flexbox className={styles.metric} gap={2}>
+ {/* The overview sizes up one agent's or project's goals; across
+ every agent the list and its tabs already carry that. */}
+ {!isGlobal && (
+ <Flexbox className={styles.overview}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={20}
+ justify={'space-between'}
+ wrap={'wrap'}
+ >
+ <Flexbox gap={3}>
<Text fontSize={20} weight={600}>
- {summary.pursuing ?? '—'}
- </Text>
- <Text fontSize={12} type={'secondary'}>
- {t('goalPage.metrics.pursuing')}
+ {t('goalPage.title')}
</Text>
+ <Text type={'secondary'}>{t('goalPage.description')}</Text>
</Flexbox>
- <Flexbox className={styles.metric} gap={2}>
- <Text fontSize={20} weight={600}>
- {summary.delivered ?? '—'}
- </Text>
- <Text fontSize={12} type={'secondary'}>
- {t('goalPage.metrics.delivered')}
- </Text>
+ <Flexbox horizontal gap={20}>
+ <Flexbox className={styles.metric} gap={2}>
+ <Text fontSize={20} weight={600}>
+ {summary.total}
+ </Text>
+ <Text fontSize={12} type={'secondary'}>
+ {t('goalPage.metrics.total')}
+ </Text>
+ </Flexbox>
+ <Flexbox className={styles.metric} gap={2}>
+ <Text fontSize={20} weight={600}>
+ {summary.pursuing ?? '—'}
+ </Text>
+ <Text fontSize={12} type={'secondary'}>
+ {t('goalPage.metrics.pursuing')}
+ </Text>
+ </Flexbox>
+ <Flexbox className={styles.metric} gap={2}>
+ <Text fontSize={20} weight={600}>
+ {summary.delivered ?? '—'}
+ </Text>
+ <Text fontSize={12} type={'secondary'}>
+ {t('goalPage.metrics.delivered')}
+ </Text>
+ </Flexbox>
</Flexbox>
</Flexbox>
</Flexbox>
- </Flexbox>
+ )}
<Flexbox gap={10}>
<Flexbox horizontal align={'center'} justify={'space-between'}>
<Flexbox horizontal align={'center'} gap={8}>
@@ -272,6 +316,13 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
<span className={styles.countBadge}>{visibleGoalCount}</span>
</Flexbox>
<Flexbox horizontal align={'center'} gap={8}>
+ {isGlobal && (
+ <GoalAgentFilter
+ options={agentFilterOptions}
+ value={agentFilter}
+ onChange={setAgentFilter}
+ />
+ )}
<Segmented
size={'small'}
value={filter}
@@ -329,7 +380,12 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
filteredGoals
.slice(0, visibleLimit)
.map((item) => (
- <GoalItem goal={item} key={item.goal.id} projectId={projectId} />
+ <GoalItem
+ globalScopeId={isGlobal ? scopeId : undefined}
+ goal={item}
+ key={item.goal.id}
+ projectId={projectId}
+ />
))
)}
</div>
diff --git a/src/features/AgentGoals/GoalAgentFilter.tsx b/src/features/AgentGoals/GoalAgentFilter.tsx
new file mode 100644
index 00000000000..cbe66848dcf
--- /dev/null
+++ b/src/features/AgentGoals/GoalAgentFilter.tsx
@@ -0,0 +1,233 @@
+'use client';
+
+import { agentDisplayName } from '@lobechat/types';
+import {
+ Block,
+ Button,
+ createStaticStyles,
+ cssVar,
+ Flexbox,
+ Icon,
+ Input,
+ Popover,
+ Text,
+} from '@lobehub/ui';
+import isEqual from 'fast-deep-equal';
+import { CheckIcon, ChevronDownIcon, UsersIcon } from 'lucide-react';
+import type { KeyboardEvent } from 'react';
+import { memo, useMemo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import AssigneeAvatar from '@/features/AgentTasks/features/AssigneeAvatar';
+import { isInboxAgentId } from '@/features/AgentTasks/shared/isInboxAgent';
+import { useAgentStore } from '@/store/agent';
+import { agentSelectors, builtinAgentSelectors } from '@/store/agent/selectors';
+import { useHomeStore } from '@/store/home';
+import { homeAgentListSelectors } from '@/store/home/selectors';
+
+import type { GoalAgentFilterOption } from './goalAgentFilterOptions';
+import { matchGoalAgentFilterOptions } from './goalAgentFilterOptions';
+
+const styles = createStaticStyles(({ css }) => ({
+ search: css`
+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};
+ `,
+}));
+
+/**
+ * Display names of the filter's agents, resolved the way the rest of the goal
+ * UI names them: the visited agent's own meta, else the sidebar's copy — the
+ * search has to match what each row reads.
+ */
+const useAgentTitles = (agentIds: string[]): Record<string, string> => {
+ const { t } = useTranslation(['chat', 'common']);
+ const inboxAgentId = useAgentStore(builtinAgentSelectors.inboxAgentId);
+ const metaTitles = useAgentStore(
+ (s) => agentIds.map((id) => agentDisplayName(agentSelectors.getAgentMetaById(id)(s))),
+ isEqual,
+ );
+ const sidebarTitles = useHomeStore(
+ (s) => agentIds.map((id) => agentDisplayName(homeAgentListSelectors.getAgentById(id)(s))),
+ isEqual,
+ );
+
+ return useMemo(
+ () =>
+ Object.fromEntries(
+ agentIds.map((id, index) => [
+ id,
+ metaTitles[index] ||
+ sidebarTitles[index] ||
+ (isInboxAgentId(id, inboxAgentId)
+ ? t('inbox.title', { ns: 'chat' })
+ : t('defaultSession', { ns: 'common' })),
+ ]),
+ ),
+ [agentIds, inboxAgentId, metaTitles, sidebarTitles, t],
+ );
+};
+
+interface FilterRowProps {
+ active: boolean;
+ count?: number;
+ icon: React.ReactNode;
+ onSelect: () => void;
+ selected: boolean;
+ title: string;
+}
+
+const FilterRow = ({ active, count, icon, onSelect, selected, title }: FilterRowProps) => (
+ <Block
+ clickable
+ horizontal
+ align={'center'}
+ gap={8}
+ paddingBlock={6}
+ paddingInline={8}
+ variant={active ? 'filled' : 'borderless'}
+ onClick={onSelect}
+ >
+ {icon}
+ <Text ellipsis style={{ flex: 1 }}>
+ {title}
+ </Text>
+ {selected ? (
+ <Icon color={cssVar.colorTextSecondary} icon={CheckIcon} size={14} />
+ ) : (
+ count !== undefined && (
+ <Text fontSize={12} type={'secondary'}>
+ {count}
+ </Text>
+ )
+ )}
+ </Block>
+);
+
+interface GoalAgentFilterProps {
+ onChange: (agentId?: string) => void;
+ options: GoalAgentFilterOption[];
+ value?: string;
+}
+
+/**
+ * Narrows the cross-agent goals page to one agent's goals, the way an agent's
+ * own Goals page would show them, without leaving the workspace. Searchable,
+ * since a workspace can hold far more agents than a menu can scan.
+ */
+const GoalAgentFilter = memo<GoalAgentFilterProps>(({ onChange, options, value }) => {
+ const { t } = useTranslation('chat');
+ const [open, setOpen] = useState(false);
+ const [search, setSearch] = useState('');
+ const [activeIndex, setActiveIndex] = useState(0);
+ const agentIds = useMemo(
+ () => [...new Set([...options.map((option) => option.agentId), ...(value ? [value] : [])])],
+ [options, value],
+ );
+ const titles = useAgentTitles(agentIds);
+ const query = search.trim();
+ const matches = useMemo(
+ () => matchGoalAgentFilterOptions(options, titles, query),
+ [options, query, titles],
+ );
+ // The "all agents" row is the way back from a narrowed list; while searching
+ // for a specific agent it is noise, so it only leads the unfiltered menu.
+ const rows: Array<GoalAgentFilterOption | undefined> = query ? matches : [undefined, ...matches];
+
+ const select = (agentId?: string) => {
+ onChange(agentId);
+ setOpen(false);
+ setSearch('');
+ };
+
+ const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
+ if (rows.length === 0) return;
+ if (event.key === 'ArrowDown') {
+ event.preventDefault();
+ setActiveIndex((index) => (index + 1) % rows.length);
+ } else if (event.key === 'ArrowUp') {
+ event.preventDefault();
+ setActiveIndex((index) => (index - 1 + rows.length) % rows.length);
+ } else if (event.key === 'Enter') {
+ event.preventDefault();
+ select(rows[Math.min(activeIndex, rows.length - 1)]?.agentId);
+ }
+ };
+
+ return (
+ <Popover
+ open={open}
+ placement={'bottomRight'}
+ styles={{ content: { padding: 0, width: 260 } }}
+ trigger={'click'}
+ content={
+ <Flexbox>
+ <Input
+ autoFocus
+ className={styles.search}
+ placeholder={t('taskList.assigneeSearch.agentPlaceholder')}
+ value={search}
+ variant={'borderless'}
+ onKeyDown={handleKeyDown}
+ onChange={(event) => {
+ setSearch(event.target.value);
+ setActiveIndex(0);
+ }}
+ />
+ {rows.length === 0 ? (
+ <Flexbox align={'center'} justify={'center'} padding={16}>
+ <Text fontSize={12} type={'secondary'}>
+ {t('taskList.assigneeSearch.agentEmpty')}
+ </Text>
+ </Flexbox>
+ ) : (
+ <Flexbox gap={2} padding={6} style={{ maxHeight: '50vh', overflowY: 'auto' }}>
+ {rows.map((option, index) =>
+ option ? (
+ <FilterRow
+ active={index === activeIndex}
+ count={option.count}
+ icon={<AssigneeAvatar agentId={option.agentId} size={20} />}
+ key={option.agentId}
+ selected={option.agentId === value}
+ title={titles[option.agentId]}
+ onSelect={() => select(option.agentId)}
+ />
+ ) : (
+ <FilterRow
+ active={index === activeIndex}
+ icon={<Icon color={cssVar.colorTextSecondary} icon={UsersIcon} size={18} />}
+ key={'all'}
+ selected={!value}
+ title={t('goalPage.agentFilter.all')}
+ onSelect={() => select(undefined)}
+ />
+ ),
+ )}
+ </Flexbox>
+ )}
+ </Flexbox>
+ }
+ onOpenChange={(next) => {
+ setOpen(next);
+ if (!next) setSearch('');
+ setActiveIndex(0);
+ }}
+ >
+ <Button
+ icon={value ? <AssigneeAvatar agentId={value} size={16} /> : <Icon icon={UsersIcon} />}
+ size={'small'}
+ // Stretch to the toolbar row, so it stands as tall as the status
+ // Segmented beside it instead of a size step shorter.
+ style={{ alignSelf: 'stretch', height: 'auto' }}
+ title={t('goalPage.agentFilter.title')}
+ >
+ {value ? titles[value] : t('goalPage.agentFilter.all')}
+ <Icon icon={ChevronDownIcon} size={14} />
+ </Button>
+ </Popover>
+ );
+});
+
+GoalAgentFilter.displayName = 'GoalAgentFilter';
+
+export default GoalAgentFilter;
diff --git a/src/features/AgentGoals/GoalAgentLabel.tsx b/src/features/AgentGoals/GoalAgentLabel.tsx
new file mode 100644
index 00000000000..ac222e02f86
--- /dev/null
+++ b/src/features/AgentGoals/GoalAgentLabel.tsx
@@ -0,0 +1,45 @@
+'use client';
+
+import { createStaticStyles, Flexbox, Text } from '@lobehub/ui';
+import { memo } from 'react';
+
+import AssigneeAvatar from '@/features/AgentTasks/features/AssigneeAvatar';
+import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';
+
+const styles = createStaticStyles(({ css }) => ({
+ label: css`
+ flex: none;
+ width: 140px;
+ min-width: 0;
+ `,
+}));
+
+interface GoalAgentLabelProps {
+ agentId?: string | null;
+}
+
+/**
+ * Whose goal a row is, on the cross-agent list. A fixed width keeps the
+ * progress columns aligned row to row; a goal with no responsible agent (one
+ * created from a project page) keeps the slot empty rather than inventing one.
+ */
+const GoalAgentLabel = memo<GoalAgentLabelProps>(({ agentId }) => {
+ const meta = useAgentDisplayMeta(agentId);
+
+ return (
+ <Flexbox horizontal align={'center'} className={styles.label} gap={6}>
+ {agentId && meta && (
+ <>
+ <AssigneeAvatar agentId={agentId} size={18} />
+ <Text ellipsis fontSize={13} type={'secondary'}>
+ {meta.title}
+ </Text>
+ </>
+ )}
+ </Flexbox>
+ );
+});
+
+GoalAgentLabel.displayName = 'GoalAgentLabel';
+
+export default GoalAgentLabel;
diff --git a/src/features/AgentGoals/GoalCardItem.tsx b/src/features/AgentGoals/GoalCardItem.tsx
index 6ea528030bb..fc7442247fd 100644
--- a/src/features/AgentGoals/GoalCardItem.tsx
+++ b/src/features/AgentGoals/GoalCardItem.tsx
@@ -7,7 +7,9 @@ import { memo } from 'react';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
+import GoalAgentLabel from './GoalAgentLabel';
import GoalItemMoreButton from './GoalItemMoreButton';
+import { goalItemPath } from './goalItemPath';
import { GoalProgress } from './GoalProgress';
import GoalStatusGlyph from './GoalStatusGlyph';
import type { GoalItemProps } from './types';
@@ -30,7 +32,7 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
-export const GoalCardItem = memo<GoalItemProps>(({ goal: item, projectId }) => {
+export const GoalCardItem = memo<GoalItemProps>(({ globalScopeId, goal: item, projectId }) => {
const navigate = useWorkspaceAwareNavigate();
const { aid } = useActiveRouteParams<{ aid?: string }>();
const { goal } = item;
@@ -39,9 +41,15 @@ export const GoalCardItem = memo<GoalItemProps>(({ goal: item, projectId }) => {
// to the bare detail route. Without this every card there is a dead link.
const agentId = aid ?? goal.agentId;
const handleClick = () => {
- navigate(agentId ? `/agent/${agentId}/goal/${goal.id}` : `/goal/${goal.id}`);
+ navigate(goalItemPath({ agentId, crossAgent: !!globalScopeId, goalId: goal.id }));
};
- const menuItems = useGoalItemMenu({ agentId, goal, projectId, routeAgentId: aid });
+ const menuItems = useGoalItemMenu({
+ agentId,
+ globalScopeId,
+ goal,
+ projectId,
+ routeAgentId: aid,
+ });
const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
if (event.key !== 'Enter' && event.key !== ' ') return;
event.preventDefault();
@@ -77,8 +85,10 @@ export const GoalCardItem = memo<GoalItemProps>(({ goal: item, projectId }) => {
</Flexbox>
<GoalItemMoreButton items={menuItems} />
</Flexbox>
+ {/* Its own line: a card is too narrow to hold the label beside the
+ progress grid without pushing the grid past the card's edge. */}
+ {globalScopeId && <GoalAgentLabel agentId={goal.agentId} />}
<GoalProgress
- findingCount={item.findingCount}
pendingDecisions={item.pendingDecisions}
taskDone={item.taskDone}
taskTotal={item.taskTotal}
diff --git a/src/features/AgentGoals/GoalDetailPage.tsx b/src/features/AgentGoals/GoalDetailPage.tsx
index f7658cde996..25f5d32389f 100644
--- a/src/features/AgentGoals/GoalDetailPage.tsx
+++ b/src/features/AgentGoals/GoalDetailPage.tsx
@@ -35,6 +35,7 @@ import { goalManagerConversation } from './goalPresentation';
import GoalRequirement from './GoalRequirement';
import { GoalSupervision } from './GoalSupervision';
import GoalSupervisorToggle from './GoalSupervisorToggle';
+import GoalWorkspaceBreadcrumb from './GoalWorkspaceBreadcrumb';
import NorthStarMetrics from './NorthStarMetrics';
import ProcessControl from './ProcessControl';
import { useGoalChatPanel } from './useGoalChatPanel';
@@ -249,9 +250,7 @@ const GoalDetailPage = memo<GoalDetailPageProps>(({ agentId, goalId }) => {
title={<Link to={buildAgentPath('goals')}>{t('goalList.title')}</Link>}
/>
) : (
- <Text fontSize={14} weight={500}>
- {goal.title}
- </Text>
+ <GoalWorkspaceBreadcrumb title={goal.title} />
)}
{/* Not nested under the breadcrumb: an agent-less goal still has to
be deletable, and this menu is the only place that can do it. */}
diff --git a/src/features/AgentGoals/GoalListItem.tsx b/src/features/AgentGoals/GoalListItem.tsx
index fad8474e230..73dd3c0f435 100644
--- a/src/features/AgentGoals/GoalListItem.tsx
+++ b/src/features/AgentGoals/GoalListItem.tsx
@@ -7,7 +7,9 @@ import { memo } from 'react';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useActiveRouteParams } from '@/hooks/useActiveRouteParams';
+import GoalAgentLabel from './GoalAgentLabel';
import GoalItemMoreButton from './GoalItemMoreButton';
+import { goalItemPath } from './goalItemPath';
import { GoalProgress } from './GoalProgress';
import GoalStatusGlyph from './GoalStatusGlyph';
import type { GoalItemProps } from './types';
@@ -29,7 +31,7 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
-export const GoalListItem = memo<GoalItemProps>(({ goal: item, projectId }) => {
+export const GoalListItem = memo<GoalItemProps>(({ globalScopeId, goal: item, projectId }) => {
const navigate = useWorkspaceAwareNavigate();
const { aid } = useActiveRouteParams<{ aid?: string }>();
const { goal } = item;
@@ -38,9 +40,15 @@ export const GoalListItem = memo<GoalItemProps>(({ goal: item, projectId }) => {
// to the bare detail route. Without this every card there is a dead link.
const agentId = aid ?? goal.agentId;
const handleClick = () => {
- navigate(agentId ? `/agent/${agentId}/goal/${goal.id}` : `/goal/${goal.id}`);
+ navigate(goalItemPath({ agentId, crossAgent: !!globalScopeId, goalId: goal.id }));
};
- const menuItems = useGoalItemMenu({ agentId, goal, projectId, routeAgentId: aid });
+ const menuItems = useGoalItemMenu({
+ agentId,
+ globalScopeId,
+ goal,
+ projectId,
+ routeAgentId: aid,
+ });
const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
if (event.key !== 'Enter' && event.key !== ' ') return;
event.preventDefault();
@@ -77,8 +85,8 @@ export const GoalListItem = memo<GoalItemProps>(({ goal: item, projectId }) => {
</Text>
)}
</Flexbox>
+ {globalScopeId && <GoalAgentLabel agentId={goal.agentId} />}
<GoalProgress
- findingCount={item.findingCount}
pendingDecisions={item.pendingDecisions}
taskDone={item.taskDone}
taskTotal={item.taskTotal}
diff --git a/src/features/AgentGoals/GoalProgress.tsx b/src/features/AgentGoals/GoalProgress.tsx
index 154af3bdcdd..fd184c9bf84 100644
--- a/src/features/AgentGoals/GoalProgress.tsx
+++ b/src/features/AgentGoals/GoalProgress.tsx
@@ -24,7 +24,7 @@ const styles = createStaticStyles(({ css }) => ({
`,
metrics: css`
display: grid;
- grid-template-columns: minmax(178px, 1fr) 72px 48px 64px;
+ grid-template-columns: minmax(0, 1fr) 48px 64px;
column-gap: 12px;
align-items: center;
@@ -32,12 +32,13 @@ const styles = createStaticStyles(({ css }) => ({
min-width: 390px;
`,
needsYou: css`
- justify-self: end;
+ flex: none;
color: ${cssVar.colorWarning};
white-space: nowrap;
`,
progress: css`
overflow: hidden;
+ flex: none;
width: 64px;
height: 4px;
@@ -54,7 +55,6 @@ const styles = createStaticStyles(({ css }) => ({
}));
export interface GoalProgressProps {
- findingCount: number;
pendingDecisions: number;
taskDone: number;
taskTotal: number;
@@ -63,45 +63,47 @@ export interface GoalProgressProps {
}
/**
- * The list row's roll-up: how far the graph got, what it produced, what it
- * cost — and, taking priority over the findings count, whether anything is
- * blocked on the user right now.
+ * The list row's roll-up: how far the graph got, whether anything is blocked
+ * on the user right now, and how long it ran and what it cost.
*/
export const GoalProgress = memo<GoalProgressProps>(
- ({ findingCount, pendingDecisions, totalRunCost, totalRunDuration, taskDone, taskTotal }) => {
+ ({ pendingDecisions, totalRunCost, totalRunDuration, taskDone, taskTotal }) => {
const { t } = useTranslation('chat');
const progress = taskTotal > 0 ? Math.round((taskDone / taskTotal) * 100) : 0;
return (
<div className={styles.metrics}>
- {taskTotal > 0 ? (
- <Flexbox horizontal align={'center'} className={styles.acceptance} gap={6}>
- <div aria-hidden className={styles.progress}>
- <div className={styles.progressValue} style={{ width: `${progress}%` }} />
- </div>
+ {/* Progress and anything blocked on the user read as one cell, so
+ duration and cost sit in fixed columns at the row's end and line up
+ whether or not a goal needs you. */}
+ <Flexbox horizontal align={'center'} className={styles.acceptance} gap={8}>
+ {taskTotal > 0 ? (
+ <Flexbox horizontal align={'center'} gap={6} style={{ minWidth: 0 }}>
+ <div aria-hidden className={styles.progress}>
+ <div className={styles.progressValue} style={{ width: `${progress}%` }} />
+ </div>
+ <Text ellipsis color={cssVar.colorTextTertiary} fontSize={12}>
+ {t('goalList.taskProgress', { done: taskDone, total: taskTotal })}
+ </Text>
+ </Flexbox>
+ ) : (
<Text ellipsis color={cssVar.colorTextTertiary} fontSize={12}>
- {t('goalList.taskProgress', { done: taskDone, total: taskTotal })}
+ {t('goalList.noTasks')}
+ </Text>
+ )}
+ {pendingDecisions > 0 && (
+ <Text className={styles.needsYou} fontSize={12}>
+ {t('goalList.needsYou', { count: pendingDecisions })}
</Text>
- </Flexbox>
- ) : (
- <Text ellipsis color={cssVar.colorTextTertiary} fontSize={12}>
- {t('goalList.noTasks')}
- </Text>
- )}
- {pendingDecisions > 0 ? (
- <Text className={styles.needsYou} fontSize={12}>
- {t('goalList.needsYou', { count: pendingDecisions })}
- </Text>
- ) : (
- <Text className={styles.metric} color={cssVar.colorTextTertiary} fontSize={12}>
- {t('goalList.findings', { count: findingCount })}
- </Text>
- )}
+ )}
+ </Flexbox>
+ {/* A goal that has not run yet leaves these cells empty: a column of
+ lone dashes reads as stray marks rather than as "nothing yet". */}
<Text className={styles.metric} color={cssVar.colorTextTertiary} fontSize={12}>
- {formatGoalDuration(totalRunDuration)}
+ {totalRunDuration > 0 ? formatGoalDuration(totalRunDuration) : null}
</Text>
<Text className={styles.metric} color={cssVar.colorTextTertiary} fontSize={12}>
- {formatGoalCost(totalRunCost)}
+ {totalRunCost > 0 ? formatGoalCost(totalRunCost) : null}
</Text>
</div>
);
diff --git a/src/features/AgentGoals/GoalWorkspaceBreadcrumb.tsx b/src/features/AgentGoals/GoalWorkspaceBreadcrumb.tsx
new file mode 100644
index 00000000000..14257b087f6
--- /dev/null
+++ b/src/features/AgentGoals/GoalWorkspaceBreadcrumb.tsx
@@ -0,0 +1,62 @@
+'use client';
+
+import { Breadcrumb, Icon, Text } from '@lobehub/ui';
+import { ChevronRight } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { styles } from '@/features/AgentTasks/shared/style';
+import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
+import { useUserStore } from '@/store/user';
+import { labPreferSelectors } from '@/store/user/selectors';
+
+interface GoalWorkspaceBreadcrumbProps {
+ title: string;
+}
+
+/**
+ * The bare `/goal/:goalId` page's way back: the cross-agent goal list, the way
+ * a bare task detail leads back to `/tasks`. The list sits behind the goals
+ * lab, so with it off the crumb is only the goal's title.
+ */
+const GoalWorkspaceBreadcrumb = memo<GoalWorkspaceBreadcrumbProps>(({ title }) => {
+ const { t } = useTranslation('chat');
+ const goalsEnabled = useUserStore(labPreferSelectors.enableGoals);
+
+ const titleCrumb = {
+ key: 'goal',
+ title: (
+ <Text ellipsis color={'inherit'} style={{ maxWidth: 320 }} weight={500}>
+ {title}
+ </Text>
+ ),
+ };
+
+ return (
+ <Breadcrumb
+ className={styles.breadcrumb}
+ separator={<Icon icon={ChevronRight} />}
+ items={
+ goalsEnabled
+ ? [
+ {
+ key: 'goals',
+ title: (
+ <WorkspaceLink to={'/goals'}>
+ <Text color={'inherit'} weight={500}>
+ {t('goalList.title')}
+ </Text>
+ </WorkspaceLink>
+ ),
+ },
+ titleCrumb,
+ ]
+ : [titleCrumb]
+ }
+ />
+ );
+});
+
+GoalWorkspaceBreadcrumb.displayName = 'GoalWorkspaceBreadcrumb';
+
+export default GoalWorkspaceBreadcrumb;
diff --git a/src/features/AgentGoals/goalAgentFilterOptions.test.ts b/src/features/AgentGoals/goalAgentFilterOptions.test.ts
new file mode 100644
index 00000000000..1d02bc0bb65
--- /dev/null
+++ b/src/features/AgentGoals/goalAgentFilterOptions.test.ts
@@ -0,0 +1,43 @@
+import { describe, expect, it } from 'vitest';
+
+import { goalAgentFilterOptions, matchGoalAgentFilterOptions } from './goalAgentFilterOptions';
+
+describe('goalAgentFilterOptions', () => {
+ it('lists each agent once, in first-appearance order, with its goal count', () => {
+ const goals = [
+ { goal: { agentId: 'agt-b' } },
+ { goal: { agentId: 'agt-a' } },
+ { goal: { agentId: 'agt-b' } },
+ ];
+
+ expect(goalAgentFilterOptions(goals)).toEqual([
+ { agentId: 'agt-b', count: 2 },
+ { agentId: 'agt-a', count: 1 },
+ ]);
+ });
+
+ it('leaves out goals with no agent', () => {
+ expect(goalAgentFilterOptions([{ goal: { agentId: null } }, { goal: {} }])).toEqual([]);
+ });
+});
+
+describe('matchGoalAgentFilterOptions', () => {
+ const options = [
+ { agentId: 'agt-a', count: 2 },
+ { agentId: 'agt-b', count: 1 },
+ ];
+ const titles = { 'agt-a': '目标验收助手', 'agt-b': 'Lobe AI' };
+
+ it('keeps every option for an empty search', () => {
+ expect(matchGoalAgentFilterOptions(options, titles, ' ')).toEqual(options);
+ });
+
+ it('matches the agent name case-insensitively', () => {
+ expect(matchGoalAgentFilterOptions(options, titles, 'lobe')).toEqual([options[1]]);
+ expect(matchGoalAgentFilterOptions(options, titles, '验收')).toEqual([options[0]]);
+ });
+
+ it('returns nothing when no name matches', () => {
+ expect(matchGoalAgentFilterOptions(options, titles, 'zzz')).toEqual([]);
+ });
+});
diff --git a/src/features/AgentGoals/goalAgentFilterOptions.ts b/src/features/AgentGoals/goalAgentFilterOptions.ts
new file mode 100644
index 00000000000..ea9e06d2f12
--- /dev/null
+++ b/src/features/AgentGoals/goalAgentFilterOptions.ts
@@ -0,0 +1,37 @@
+interface GoalWithAgent {
+ goal: { agentId?: string | null };
+}
+
+export interface GoalAgentFilterOption {
+ agentId: string;
+ count: number;
+}
+
+/**
+ * The agents the cross-agent goals page can be narrowed to: every agent that
+ * owns a goal in the loaded list, in the order they first appear (newest goal
+ * first), with how many goals each owns there. Goals with no agent (created
+ * from a project page) have nothing to filter by and are left out.
+ */
+export const goalAgentFilterOptions = (goals: GoalWithAgent[]): GoalAgentFilterOption[] => {
+ const counts = new Map<string, number>();
+ for (const { goal } of goals) {
+ if (!goal.agentId) continue;
+ counts.set(goal.agentId, (counts.get(goal.agentId) ?? 0) + 1);
+ }
+ return [...counts].map(([agentId, count]) => ({ agentId, count }));
+};
+
+/**
+ * The options whose agent name contains the search text, case-insensitively.
+ * An empty search keeps every option.
+ */
+export const matchGoalAgentFilterOptions = (
+ options: GoalAgentFilterOption[],
+ titles: Record<string, string>,
+ search: string,
+): GoalAgentFilterOption[] => {
+ const query = search.trim().toLowerCase();
+ if (!query) return options;
+ return options.filter(({ agentId }) => (titles[agentId] ?? '').toLowerCase().includes(query));
+};
diff --git a/src/features/AgentGoals/goalItemPath.test.ts b/src/features/AgentGoals/goalItemPath.test.ts
new file mode 100644
index 00000000000..0355031e672
--- /dev/null
+++ b/src/features/AgentGoals/goalItemPath.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from 'vitest';
+
+import { goalItemPath } from './goalItemPath';
+
+describe('goalItemPath', () => {
+ it('opens the bare route from the cross-agent list, even for an agent’s goal', () => {
+ expect(goalItemPath({ agentId: 'agt-1', crossAgent: true, goalId: 'goal-1' })).toBe(
+ '/goal/goal-1',
+ );
+ });
+
+ it('opens a goal under its agent on an agent or project page', () => {
+ expect(goalItemPath({ agentId: 'agt-1', goalId: 'goal-1' })).toBe('/agent/agt-1/goal/goal-1');
+ });
+
+ it('falls back to the bare route for a goal with no agent', () => {
+ expect(goalItemPath({ agentId: null, goalId: 'goal-1' })).toBe('/goal/goal-1');
+ });
+});
diff --git a/src/features/AgentGoals/goalItemPath.ts b/src/features/AgentGoals/goalItemPath.ts
new file mode 100644
index 00000000000..265bcdd3805
--- /dev/null
+++ b/src/features/AgentGoals/goalItemPath.ts
@@ -0,0 +1,16 @@
+interface GoalItemPathOptions {
+ /** The row's agent: the route's agent first, then the goal's own. */
+ agentId?: string | null;
+ /** The row sits on the cross-agent list. */
+ crossAgent?: boolean;
+ goalId: string;
+}
+
+/**
+ * Where a goal-list row opens. The cross-agent list keeps the user in the
+ * workspace on the bare route, the way the global task list does; elsewhere a
+ * goal with an agent opens under that agent, and an agent-less one (created
+ * from a project page) falls back to the bare route.
+ */
+export const goalItemPath = ({ agentId, crossAgent, goalId }: GoalItemPathOptions): string =>
+ agentId && !crossAgent ? `/agent/${agentId}/goal/${goalId}` : `/goal/${goalId}`;
diff --git a/src/features/AgentGoals/types.ts b/src/features/AgentGoals/types.ts
index a94d7451327..22b711cce00 100644
--- a/src/features/AgentGoals/types.ts
+++ b/src/features/AgentGoals/types.ts
@@ -1,6 +1,11 @@
import type { GoalListItem } from '@/store/goal/initialState';
export interface GoalItemProps {
+ /**
+ * Set on the cross-agent page: the row names its agent, opens on the bare
+ * `/goal/:goalId` route, and refreshes this list scope after a status change.
+ */
+ globalScopeId?: string;
goal: GoalListItem;
projectId?: string;
}
diff --git a/src/features/AgentGoals/useGoalActions.ts b/src/features/AgentGoals/useGoalActions.ts
index e14c3a94848..f57d66d3a43 100644
--- a/src/features/AgentGoals/useGoalActions.ts
+++ b/src/features/AgentGoals/useGoalActions.ts
@@ -59,7 +59,11 @@ export const useConfirmDeleteGoal = ({
return;
}
navigate(
- agentId ? `/agent/${agentId}/goals` : projectId ? `/project/${projectId}/goals` : '/',
+ agentId
+ ? `/agent/${agentId}/goals`
+ : projectId
+ ? `/project/${projectId}/goals`
+ : '/goals',
);
},
title: t('goalDetail.deleteConfirm.title'),
diff --git a/src/features/AgentGoals/useGoalMenuItems.tsx b/src/features/AgentGoals/useGoalMenuItems.tsx
index 0d9ad8426e8..da98f7ec114 100644
--- a/src/features/AgentGoals/useGoalMenuItems.tsx
+++ b/src/features/AgentGoals/useGoalMenuItems.tsx
@@ -135,6 +135,8 @@ export const useGoalMenuItems = ({
interface UseGoalItemMenuOptions {
/** The goal's agent, resolved by the host: the route's agent first, then the goal's own. */
agentId?: string | null;
+ /** The cross-agent list rendering the row, refreshed in place of an agent's or project's. */
+ globalScopeId?: string;
goal: { agentId?: string | null; id: string; status: string; userId?: string | null };
/** The project whose goal page renders the row; absent on an agent's page. */
projectId?: string;
@@ -145,6 +147,7 @@ interface UseGoalItemMenuOptions {
/** The action menu of a goal-list row (list or card view). */
export const useGoalItemMenu = ({
agentId,
+ globalScopeId,
goal,
projectId,
routeAgentId,
@@ -152,7 +155,7 @@ export const useGoalItemMenu = ({
// The row reads its status from the list, not the goal graph the store
// actions refresh, so a status change refetches the list it was rendered in.
const refreshGoals = useGoalStore((s) => s.refreshGoals);
- const scopeId = projectId ? `project:${projectId}` : routeAgentId;
+ const scopeId = globalScopeId ?? (projectId ? `project:${projectId}` : routeAgentId);
const handleStatusChanged = useCallback(() => {
if (scopeId) void refreshGoals(scopeId);
}, [refreshGoals, scopeId]);
diff --git a/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts b/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts
index 6170f75567a..b8c16af83a7 100644
--- a/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts
+++ b/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts
@@ -41,4 +41,10 @@ describe('CustomizeSidebarModal', () => {
false,
);
});
+
+ it('offers Goals only while the goals lab is on', () => {
+ expect(getSortableSidebarItemIds(false).has('goals')).toBe(false);
+ expect(getSortableSidebarItemIds(false, { goalsEnabled: true }).has('goals')).toBe(true);
+ expect(getSortableSidebarItemIds(true, { goalsEnabled: true }).has('goals')).toBe(true);
+ });
});
diff --git a/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx b/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx
index dda660392a2..e1a36c2dc7c 100644
--- a/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx
+++ b/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx
@@ -48,6 +48,8 @@ import {
SIDEBAR_SPACER_ID,
} from '@/store/global/selectors/systemStatus';
import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
+import { useUserStore } from '@/store/user';
+import { labPreferSelectors } from '@/store/user/selectors';
// ---------------------------------------------------------------------------
// Types & constants
@@ -64,6 +66,7 @@ export interface SidebarItemConfig {
const ALL_SIDEBAR_ITEMS: SidebarItemConfig[] = [
{ id: 'tasks', labelKey: 'tab.tasks', routeId: 'tasks' },
+ { id: 'goals', labelKey: 'tab.goals', routeId: 'goals' },
{ id: 'dashboard', labelKey: 'tab.dashboard', routeId: 'dashboard' },
{ id: 'pages', labelKey: 'tab.pages', routeId: 'page' },
{ id: 'recents', labelKey: 'recents' },
@@ -80,13 +83,18 @@ const ALL_SIDEBAR_ITEMS: SidebarItemConfig[] = [
// owner-private, so hide it from the customizer where toggling it on
// would render an empty accordion no user can populate.
// Dashboards also stay out until the `dashboard` feature flag is on for the
-// user; a dropped id is restored by `withAllKnownKeys` once it is.
+// user, and Goals until the user turns on its lab; a dropped id is restored by
+// `withAllKnownKeys` once it is.
export const getAvailableSidebarItems = (
isWorkspaceMode: boolean,
- { dashboardEnabled = false }: { dashboardEnabled?: boolean } = {},
+ {
+ dashboardEnabled = false,
+ goalsEnabled = false,
+ }: { dashboardEnabled?: boolean; goalsEnabled?: boolean } = {},
): SidebarItemConfig[] =>
ALL_SIDEBAR_ITEMS.filter((item) => {
if (item.id === 'dashboard' && !dashboardEnabled) return false;
+ if (item.id === 'goals' && !goalsEnabled) return false;
if (isWorkspaceMode && (item.id === 'memory' || item.id === 'dashboard')) return false;
if (!isWorkspaceMode && item.id === 'private') return false;
return true;
@@ -94,7 +102,7 @@ export const getAvailableSidebarItems = (
export const getSortableSidebarItemIds = (
isWorkspaceMode: boolean,
- options?: { dashboardEnabled?: boolean },
+ options?: { dashboardEnabled?: boolean; goalsEnabled?: boolean },
): Set<string> =>
new Set([
...getAvailableSidebarItems(isWorkspaceMode, options).map((item) => item.id),
@@ -390,9 +398,10 @@ const CustomizeSidebarContent = memo(() => {
const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
const isWorkspaceMode = !!useActiveWorkspaceSlug();
const dashboardEnabled = useServerConfigStore(serverConfigSelectors.enableDashboard);
+ const goalsEnabled = useUserStore(labPreferSelectors.enableGoals);
const sortableItemIds = useMemo(
- () => getSortableSidebarItemIds(isWorkspaceMode, { dashboardEnabled }),
- [isWorkspaceMode, dashboardEnabled],
+ () => getSortableSidebarItemIds(isWorkspaceMode, { dashboardEnabled, goalsEnabled }),
+ [isWorkspaceMode, dashboardEnabled, goalsEnabled],
);
const filteredStoreItems = useMemo(
() => storeItems.filter((id) => sortableItemIds.has(id)),
diff --git a/src/hooks/useNavLayout.test.tsx b/src/hooks/useNavLayout.test.tsx
index 559f8abff65..4f634229a90 100644
--- a/src/hooks/useNavLayout.test.tsx
+++ b/src/hooks/useNavLayout.test.tsx
@@ -8,6 +8,7 @@ interface GlobalStateMock {
const mocks = vi.hoisted(() => ({
activeWorkspaceSlug: null as string | null,
enableDashboard: false,
+ enableGoals: false,
showMarket: true,
}));
@@ -32,6 +33,15 @@ vi.mock('@/store/serverConfig', () => ({
: { hideGitHub: false, showMarket: mocks.showMarket },
}));
+const ENABLE_GOALS = 'enableGoals';
+vi.mock('@/store/user', () => ({
+ useUserStore: (selector: unknown) => (selector === ENABLE_GOALS ? mocks.enableGoals : undefined),
+}));
+
+vi.mock('@/store/user/selectors', () => ({
+ labPreferSelectors: { enableGoals: ENABLE_GOALS },
+}));
+
vi.mock('@/business/client/hooks/useActiveWorkspaceSlug', () => ({
useActiveWorkspaceSlug: () => mocks.activeWorkspaceSlug,
}));
@@ -41,6 +51,7 @@ describe('useNavLayout', () => {
mocks.activeWorkspaceSlug = null;
mocks.showMarket = true;
mocks.enableDashboard = false;
+ mocks.enableGoals = false;
});
const dashboardItem = async () => {
@@ -61,6 +72,28 @@ describe('useNavLayout', () => {
expect((await dashboardItem())?.hidden).toBe(true);
});
+ const goalsItem = async () => {
+ const { useNavLayout } = await import('./useNavLayout');
+ const { result } = renderHook(() => useNavLayout());
+ return result.current.topNavItems.find((item) => item.key === 'goals');
+ };
+
+ it('hides Goals while the goals lab is off', async () => {
+ expect((await goalsItem())?.hidden).toBe(true);
+ });
+
+ it('shows Goals next to Tasks once the goals lab is on', async () => {
+ mocks.enableGoals = true;
+ const item = await goalsItem();
+ expect(item?.hidden).toBe(false);
+ expect(item?.url).toBe('/goals');
+
+ const { useNavLayout } = await import('./useNavLayout');
+ const { result } = renderHook(() => useNavLayout());
+ const keys = result.current.topNavItems.map((navItem) => navItem.key);
+ expect(keys.indexOf('goals')).toBe(keys.indexOf('tasks') + 1);
+ });
+
it('keeps Memory visible in personal mode', async () => {
const { useNavLayout } = await import('./useNavLayout');
const { result } = renderHook(() => useNavLayout());
diff --git a/src/hooks/useNavLayout.ts b/src/hooks/useNavLayout.ts
index 6954156fee3..af5a1d4604e 100644
--- a/src/hooks/useNavLayout.ts
+++ b/src/hooks/useNavLayout.ts
@@ -11,6 +11,8 @@ import {
serverConfigSelectors,
useServerConfigStore,
} from '@/store/serverConfig';
+import { useUserStore } from '@/store/user';
+import { labPreferSelectors } from '@/store/user/selectors';
export interface NavItem {
hidden?: boolean;
@@ -43,6 +45,7 @@ export const useNavLayout = (): NavLayout => {
const { showMarket, hideGitHub } = useServerConfigStore(featureFlagsSelectors);
const activeWorkspaceSlug = useActiveWorkspaceSlug();
const enableDashboard = useServerConfigStore(serverConfigSelectors.enableDashboard);
+ const enableGoals = useUserStore(labPreferSelectors.enableGoals);
const topNavItems = useMemo(
() =>
@@ -65,6 +68,14 @@ export const useNavLayout = (): NavLayout => {
title: t('tab.tasks'),
url: '/tasks',
},
+ {
+ // Behind the same lab toggle as the agent-scoped goal pages.
+ hidden: !enableGoals,
+ icon: getRouteById('goals')!.icon,
+ key: SidebarTabKey.Goals,
+ title: t('tab.goals'),
+ url: '/goals',
+ },
{
// Personal boards only for now — workspace-level boards have no UI
// yet — and only while the `dashboard` feature flag is on.
@@ -81,7 +92,7 @@ export const useNavLayout = (): NavLayout => {
url: '/resource',
},
] as NavItem[],
- [t, toggleCommandMenu, activeWorkspaceSlug, enableDashboard],
+ [t, toggleCommandMenu, activeWorkspaceSlug, enableDashboard, enableGoals],
);
const bottomMenuItems = useMemo(
diff --git a/src/layout/GlobalProvider/useUserStateRedirect.ts b/src/layout/GlobalProvider/useUserStateRedirect.ts
index 5a1c29b25fe..b4b6ef4c484 100644
--- a/src/layout/GlobalProvider/useUserStateRedirect.ts
+++ b/src/layout/GlobalProvider/useUserStateRedirect.ts
@@ -19,6 +19,8 @@ const RESERVED_FIRST_SEGMENTS = new Set([
'desktop-onboarding',
'devtools',
'eval',
+ 'goal',
+ 'goals',
'group',
'image',
'me',
diff --git a/src/routes/(main)/goals/index.tsx b/src/routes/(main)/goals/index.tsx
new file mode 100644
index 00000000000..765363e56b1
--- /dev/null
+++ b/src/routes/(main)/goals/index.tsx
@@ -0,0 +1,27 @@
+'use client';
+
+import { memo, useEffect } from 'react';
+
+import GoalSkeleton from '@/components/Skeleton/Goal';
+import { AgentGoalsPage } from '@/features/AgentGoals';
+import { useAgentLabGate } from '@/features/AgentGoals/useAgentLabGate';
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+
+/** Every agent's goals in one list, the goal counterpart of the global `/tasks`. */
+const GoalsRoute = memo(() => {
+ const navigate = useWorkspaceAwareNavigate();
+ const { enabled, initFailed, isPreferenceInit, shouldRedirect } = useAgentLabGate();
+
+ useEffect(() => {
+ if (shouldRedirect) navigate('/', { replace: true });
+ }, [navigate, shouldRedirect]);
+
+ // Same gate as the agent-scoped route: hold the skeleton until the lab
+ // preference settles instead of flashing an empty pane or redirecting early.
+ if (!isPreferenceInit && !initFailed) return <GoalSkeleton />;
+ if (!enabled) return null;
+
+ return <AgentGoalsPage />;
+});
+
+export default GoalsRoute;
diff --git a/src/spa/router/desktopRouter.shared.tsx b/src/spa/router/desktopRouter.shared.tsx
index dcf5d350445..1bd12389682 100644
--- a/src/spa/router/desktopRouter.shared.tsx
+++ b/src/spa/router/desktopRouter.shared.tsx
@@ -89,6 +89,7 @@ import { preferenceListLoader } from '@/spa/router/preferenceListLoader';
import { agentAccessLoader, agentGroupAccessLoader } from '@/spa/router/resourceAccessLoader';
import { NoRouteSkeleton, routeMeta } from '@/spa/router/routeMeta';
import { scheduledTaskListLoader } from '@/spa/router/scheduledTaskListLoader';
+import { taskWorkspaceChildren } from '@/spa/router/taskWorkspaceRoutes';
import { withSegmentFallback } from '@/spa/router/withSegmentFallback';
import { worksLoader } from '@/spa/router/worksLoader';
import { SettingsTabs } from '@/store/global/initialState';
@@ -1173,51 +1174,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
},
{
- children: [
- {
- children: [
- {
- element: dynamicElement(() => import('@/routes/(main)/tasks'), 'Desktop > Tasks', {
- preloadId: 'tasks',
- }),
- handle: { meta: tasksRouteMeta },
- index: true,
- loader: scheduledTaskListLoader,
- },
- ],
- errorElement: <ErrorBoundary resetPath=".." />,
- path: 'tasks',
- },
- {
- children: [
- {
- element: dynamicElement(
- () => import('@/routes/(main)/task/[taskId]'),
- 'Desktop > Task Detail',
- ),
- handle: { meta: taskRouteMeta },
- // Optional readable title tail — see the agent-scoped route above.
- path: ':taskId/:slug?',
- },
- ],
- errorElement: <ErrorBoundary resetPath="../tasks" />,
- path: 'task',
- },
- {
- children: [
- {
- element: dynamicElement(
- () => import('@/routes/(main)/goal/[goalId]'),
- 'Desktop > Goal Detail',
- ),
- handle: { meta: goalDetailRouteMeta },
- path: ':goalId',
- },
- ],
- errorElement: <ErrorBoundary resetPath="../tasks" />,
- path: 'goal',
- },
- ],
+ children: taskWorkspaceChildren,
element: dynamicLayout(
() => import('@/routes/(main)/(task-workspace)/_layout'),
'Desktop > Task Workspace > Layout',
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index 44723093dff..0c03da5a762 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -79,6 +79,7 @@ async function readRouterSources() {
'desktopRouter.shared.tsx',
'desktopRouter.config.tsx',
'desktopRouter.config.desktop.tsx',
+ 'taskWorkspaceRoutes.tsx',
].map((filename) => readFile(path.join(process.cwd(), 'src/spa/router', filename), 'utf8')),
);
}
diff --git a/src/spa/router/taskWorkspaceRoutes.tsx b/src/spa/router/taskWorkspaceRoutes.tsx
new file mode 100644
index 00000000000..329a65f1d98
--- /dev/null
+++ b/src/spa/router/taskWorkspaceRoutes.tsx
@@ -0,0 +1,69 @@
+import type { RouteObject } from 'react-router';
+
+import { goalDetailRouteMeta, goalsRouteMeta } from '@/features/AgentGoals/routeMeta';
+import { taskRouteMeta, tasksRouteMeta } from '@/features/AgentTasks/routeMeta';
+import { scheduledTaskListLoader } from '@/spa/router/scheduledTaskListLoader';
+import { dynamicElement, ErrorBoundary } from '@/utils/router';
+
+/**
+ * The cross-agent task workspace: `/tasks` and `/goals`, and the bare
+ * `/task/:taskId` and `/goal/:goalId` details they open. Mounted under the
+ * workspace layout in `desktopRouter.shared.tsx`.
+ */
+export const taskWorkspaceChildren: RouteObject[] = [
+ {
+ children: [
+ {
+ element: dynamicElement(() => import('@/routes/(main)/tasks'), 'Desktop > Tasks', {
+ preloadId: 'tasks',
+ }),
+ handle: { meta: tasksRouteMeta },
+ index: true,
+ loader: scheduledTaskListLoader,
+ },
+ ],
+ errorElement: <ErrorBoundary resetPath=".." />,
+ path: 'tasks',
+ },
+ {
+ children: [
+ {
+ element: dynamicElement(() => import('@/routes/(main)/goals'), 'Desktop > Goals'),
+ handle: { meta: goalsRouteMeta },
+ index: true,
+ },
+ ],
+ errorElement: <ErrorBoundary resetPath=".." />,
+ path: 'goals',
+ },
+ {
+ children: [
+ {
+ element: dynamicElement(
+ () => import('@/routes/(main)/task/[taskId]'),
+ 'Desktop > Task Detail',
+ ),
+ handle: { meta: taskRouteMeta },
+ // Optional readable title tail — see the agent-scoped `task/:taskId/:slug?`
+ // route in `desktopRouter.shared.tsx`.
+ path: ':taskId/:slug?',
+ },
+ ],
+ errorElement: <ErrorBoundary resetPath="../tasks" />,
+ path: 'task',
+ },
+ {
+ children: [
+ {
+ element: dynamicElement(
+ () => import('@/routes/(main)/goal/[goalId]'),
+ 'Desktop > Goal Detail',
+ ),
+ handle: { meta: goalDetailRouteMeta },
+ path: ':goalId',
+ },
+ ],
+ errorElement: <ErrorBoundary resetPath="../goals" />,
+ path: 'goal',
+ },
+];
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index f0801c4bd45..c50ed053ac9 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -9,6 +9,7 @@ export enum SidebarTabKey {
Chat = 'chat',
Community = 'community',
Dashboard = 'dashboard',
+ Goals = 'goals',
Home = 'home',
Image = 'image',
Knowledge = 'knowledge',
diff --git a/src/store/global/selectors/systemStatus.test.ts b/src/store/global/selectors/systemStatus.test.ts
index 1c640505b64..d59e88f1509 100644
--- a/src/store/global/selectors/systemStatus.test.ts
+++ b/src/store/global/selectors/systemStatus.test.ts
@@ -276,7 +276,9 @@ describe('systemStatusSelectors', () => {
status: { sidebarItems: stored },
});
expect(systemStatusSelectors.sidebarItems(null)(s)).toEqual([
- // Defaults missing from a saved layout (here the newer `dashboard`) are backfilled.
+ // Defaults missing from a saved layout (here the newer `goals` and
+ // `dashboard`) are backfilled.
+ 'goals',
'dashboard',
'private',
'agent',
@@ -295,6 +297,7 @@ describe('systemStatusSelectors', () => {
it('should preserve a canonically-positioned spacer', () => {
const stored = [
'pages',
+ 'goals',
'dashboard',
'project',
'recents',
@@ -334,6 +337,7 @@ describe('systemStatusSelectors', () => {
expect(systemStatusSelectors.sidebarItems(null)(s)).toEqual([
'tasks',
'pages',
+ 'goals',
'dashboard',
'recents',
'project',
@@ -380,6 +384,7 @@ describe('systemStatusSelectors', () => {
// the legacy state was saved) is backfilled at the head of the block.
expect(items).toEqual([
'tasks',
+ 'goals',
'dashboard',
'resource',
'private',
@@ -403,6 +408,7 @@ describe('systemStatusSelectors', () => {
// backfilled at the head of the block; recents/agent keep legacy order.
expect(items).toEqual([
'tasks',
+ 'goals',
'dashboard',
'resource',
'private',
diff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.ts
index 5bf26408b4b..34d3ba795cf 100644
--- a/src/store/global/selectors/systemStatus.ts
+++ b/src/store/global/selectors/systemStatus.ts
@@ -194,6 +194,7 @@ export const SIDEBAR_SPACER_ID = '__spacer__';
export const DEFAULT_SIDEBAR_ITEMS: string[] = [
'tasks',
+ 'goals',
'dashboard',
'resource',
'recents',
diff --git a/src/store/goal/action.test.ts b/src/store/goal/action.test.ts
index 78e2ed929cc..78a3ed23332 100644
--- a/src/store/goal/action.test.ts
+++ b/src/store/goal/action.test.ts
@@ -256,6 +256,19 @@ describe('GoalAction', () => {
);
});
+ it('reads the cross-agent list without an assignee filter, keyed by cache scope', () => {
+ renderHook(() =>
+ useGoalStore.getState().useFetchGoals(undefined, undefined, 'all', 'user-1:workspace-1'),
+ );
+
+ expect(syncKeyFor('goalList')?.[4]).toBe('global:user-1:workspace-1');
+ void syncFetcherFor('goalList')?.();
+ const [query] = vi.mocked(goalService.list).mock.calls[0];
+ expect(query).toMatchObject({ limit: 100 });
+ expect(query?.agentId).toBeUndefined();
+ expect(query?.projectId).toBeUndefined();
+ });
+
it('asks the server for the tab’s own statuses under the tab’s own entry', () => {
// A page of the newest goals cannot answer "what is in review", so the tab
// gets its own server read rather than a client-side filter.
diff --git a/src/store/goal/action.ts b/src/store/goal/action.ts
index bdb0cbe843b..69ab5689ee0 100644
--- a/src/store/goal/action.ts
+++ b/src/store/goal/action.ts
@@ -537,6 +537,14 @@ export class GoalActionImpl {
await this.#homeGoalList.revalidate(scope);
};
+ setGoalListAgentFilter = (agentId?: string): void => {
+ this.#set(
+ { goalListAgentFilter: agentId, goalListVisibleLimit: 10 },
+ false,
+ 'setGoalListAgentFilter',
+ );
+ };
+
setGoalListFilter = (filter: GoalListFilter): void => {
this.#set({ goalListFilter: filter, goalListVisibleLimit: 10 }, false, 'setGoalListFilter');
};
@@ -558,9 +566,15 @@ export class GoalActionImpl {
* network answers, so the page never flashes its empty state over hydrated
* data.
*/
- useFetchGoals = (agentId?: string, projectId?: string, filter: GoalListFilter = 'all') => {
+ useFetchGoals = (
+ agentId?: string,
+ projectId?: string,
+ filter: GoalListFilter = 'all',
+ /** Cache scope of the cross-agent page, read when neither id is given. */
+ globalScope?: string,
+ ) => {
const params: GoalListParams | undefined =
- agentId || projectId ? { agentId, filter, projectId } : undefined;
+ agentId || projectId || globalScope ? { agentId, filter, globalScope, projectId } : undefined;
const key = params ? goalListKey(params) : undefined;
const sync = this.#goalList.useSync(params ?? null, { revalidateOnFocus: true });
diff --git a/src/store/goal/initialState.ts b/src/store/goal/initialState.ts
index 4ae8bf6e3ba..b19a24b779a 100644
--- a/src/store/goal/initialState.ts
+++ b/src/store/goal/initialState.ts
@@ -31,6 +31,11 @@ export interface GoalState {
* (what the project dashboard and the route meta read) and one sibling entry
* per narrow tab (`goalListKey`).
*/
+ /**
+ * The agent the cross-agent goals page is narrowed to; unset lists every
+ * agent's goals. Kept in the store so returning from a goal keeps the filter.
+ */
+ goalListAgentFilter?: string;
goalListByAgentId: Record<string, GoalListValue>;
goalListFilter: GoalListFilter;
/** Local-first bookkeeping for `goalListByAgentId`. */
diff --git a/src/store/goal/projection.test.ts b/src/store/goal/projection.test.ts
new file mode 100644
index 00000000000..5276d13e667
--- /dev/null
+++ b/src/store/goal/projection.test.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from 'vitest';
+
+import {
+ globalGoalListScopeId,
+ goalListKey,
+ goalListScopeId,
+ goalListScopeParams,
+} from './projection';
+
+describe('goal list scopes', () => {
+ it.each([{ agentId: 'agt-1' }, { projectId: 'proj-1' }, { globalScope: 'user-1:workspace-1' }])(
+ 'round-trips the %o scope through its scope id',
+ (scope) => {
+ const scopeId = goalListScopeId(scope);
+
+ expect(goalListScopeParams(scopeId, 'review')).toEqual({ ...scope, filter: 'review' });
+ },
+ );
+
+ it('keys the cross-agent list per cache scope, apart from any agent or project', () => {
+ expect(goalListScopeId({ globalScope: 'user-1:workspace-1' })).toBe(
+ globalGoalListScopeId('user-1:workspace-1'),
+ );
+ expect(goalListKey({ filter: 'all', globalScope: 'user-1:workspace-1' })).toBe(
+ 'global:user-1:workspace-1',
+ );
+ expect(goalListKey({ filter: 'running', globalScope: 'user-1:workspace-2' })).toBe(
+ 'global:user-1:workspace-2:goals-page:running',
+ );
+ });
+});
diff --git a/src/store/goal/projection.ts b/src/store/goal/projection.ts
index 5b0bd14e1f2..a26b97ace6d 100644
--- a/src/store/goal/projection.ts
+++ b/src/store/goal/projection.ts
@@ -29,6 +29,11 @@ export interface GoalListValue {
export interface GoalListParams {
agentId?: string;
filter: GoalListFilter;
+ /**
+ * Cache scope (`userId:workspaceId`) of the cross-agent list, which names
+ * neither an agent nor a project — so a workspace you left cannot answer here.
+ */
+ globalScope?: string;
projectId?: string;
}
@@ -38,21 +43,35 @@ export interface HomeGoalListParams {
scope: string;
}
+const GLOBAL_SCOPE_PREFIX = 'global:';
+const PROJECT_SCOPE_PREFIX = 'project:';
+
+/** Scope id of the cross-agent goals page for one cache scope. */
+export const globalGoalListScopeId = (globalScope: string): string =>
+ `${GLOBAL_SCOPE_PREFIX}${globalScope}`;
+
/**
- * Scope id of a goals page: an agent's page, or a project's. Also the entry key
- * of that scope's `all` list — the key `goalListByAgentId` has always used.
+ * Scope id of a goals page: an agent's page, a project's, or the cross-agent
+ * page. Also the entry key of that scope's `all` list — the key
+ * `goalListByAgentId` has always used.
*/
export const goalListScopeId = ({
agentId,
+ globalScope,
projectId,
-}: Pick<GoalListParams, 'agentId' | 'projectId'>): string =>
- projectId ? `project:${projectId}` : agentId!;
+}: Pick<GoalListParams, 'agentId' | 'globalScope' | 'projectId'>): string =>
+ projectId
+ ? `${PROJECT_SCOPE_PREFIX}${projectId}`
+ : (agentId ?? globalGoalListScopeId(globalScope!));
/** Rebuild the list params of one scope id (the inverse of `goalListScopeId`). */
-export const goalListScopeParams = (scopeId: string, filter: GoalListFilter): GoalListParams =>
- scopeId.startsWith('project:')
- ? { filter, projectId: scopeId.slice('project:'.length) }
- : { agentId: scopeId, filter };
+export const goalListScopeParams = (scopeId: string, filter: GoalListFilter): GoalListParams => {
+ if (scopeId.startsWith(PROJECT_SCOPE_PREFIX))
+ return { filter, projectId: scopeId.slice(PROJECT_SCOPE_PREFIX.length) };
+ if (scopeId.startsWith(GLOBAL_SCOPE_PREFIX))
+ return { filter, globalScope: scopeId.slice(GLOBAL_SCOPE_PREFIX.length) };
+ return { agentId: scopeId, filter };
+};
/**
* Entry key of one tab's list. `all` keys the scope itself; a narrow tab keys a