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: unify tasks and goals in agent and personal navigation (#23561)

AmAzing-579099b1849c
diff --git a/apps/server/src/services/goal/SWARM.md b/apps/server/src/services/goal/SWARM.md
index a6e43c72fad..bcb2b6a4565 100644
--- a/apps/server/src/services/goal/SWARM.md
+++ b/apps/server/src/services/goal/SWARM.md
@@ -5,20 +5,20 @@ Status: design, not built. Builds on Goal marks (`marks.ts`, commit 0f5d9bb672a)
## Why
A Goal today plans a task graph and verifies each Task. That fits building and migrating;
-it fits badly when the work is *optimising one score against an evaluator* — tune a model,
+it fits badly when the work is _optimising one score against an evaluator_ — tune a model,
raise a benchmark, cut a latency — where progress is "submit, read the score, change,
submit again".
We measured it on EdgeBench (`k12_math_recommendation`, Kimi Code, 2 h wall clock; harness
and raw data in `~/CodeProjects/edgebench-eval`, see its `RESULTS.md`):
-| Shape | runs | score @2h (mean) | @30m | output tokens |
-|---|---|---|---|---|
-| Single Kimi session | 7 | 33.6 (sd 4.5) | — | 133k |
-| Today's Goal (planner splits into serial tasks) | 1 | 21.8 | 16.2 | 219k |
-| 3 independent sessions, keep the best | 2 | 37.0 | 34.2 | 607k |
-| 3 lanes + marks (no coordination) | 1 | 34.7 | 34.2 | 374k |
-| 3 lanes + marks + coordinator | 3 | 37.4 | 26.5 | 409k |
+| Shape | runs | score @2h (mean) | @30m | output tokens |
+| ----------------------------------------------- | ---- | ---------------- | ---- | ------------- |
+| Single Kimi session | 7 | 33.6 (sd 4.5) | — | 133k |
+| Today's Goal (planner splits into serial tasks) | 1 | 21.8 | 16.2 | 219k |
+| 3 independent sessions, keep the best | 2 | 37.0 | 34.2 | 607k |
+| 3 lanes + marks (no coordination) | 1 | 34.7 | 34.2 | 374k |
+| 3 lanes + marks + coordinator | 3 | 37.4 | 26.5 | 409k |
What this says:
@@ -47,19 +47,19 @@ A Swarm Goal is an optimisation Goal:
- **N lanes**: parallel copies of the workspace, one long-running Task each.
It is not a replacement for planned Goals. Builds, migrations and anything without a
-scoring command keep today's planner. A planner may *propose* swarm mode when the
+scoring command keep today's planner. A planner may _propose_ swarm mode when the
requirement names a metric and an evaluator.
## Concepts
-| Concept | What it is | Built on |
-|---|---|---|
-| Lane | An independent copy of the workspace, plus the time-boxed Task that works in it | `experiment` container node; per-topic working directory |
-| Evaluator | A command run inside a lane that prints a score (plain number, `TOTAL_SCORE n`, or JSON `{score, valid, summary, metrics}`) | new `lh goal evaluate` |
-| Objective series | One metric series per Goal; each evaluation is a point tagged with lane, run and code fingerprint | metric series and observations (`metric` router, north-star criteria) |
-| Leaderboard | Each lane's best and latest valid score, the leader, time since the last new best | derived from the objective series |
-| Directive | A coordinator instruction addressed to one lane | new mark kind `directive` |
-| Champion | The best-scoring lane state when the run ends; promoted back to the root workspace | — |
+| Concept | What it is | Built on |
+| ---------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
+| Lane | An independent copy of the workspace, plus the time-boxed Task that works in it | `experiment` container node; per-topic working directory |
+| Evaluator | A command run inside a lane that prints a score (plain number, `TOTAL_SCORE n`, or JSON `{score, valid, summary, metrics}`) | new `lh goal evaluate` |
+| Objective series | One metric series per Goal; each evaluation is a point tagged with lane, run and code fingerprint | metric series and observations (`metric` router, north-star criteria) |
+| Leaderboard | Each lane's best and latest valid score, the leader, time since the last new best | derived from the objective series |
+| Directive | A coordinator instruction addressed to one lane | new mark kind `directive` |
+| Champion | The best-scoring lane state when the run ends; promoted back to the root workspace | — |
## User flow
@@ -154,13 +154,13 @@ The policy is a pure function over the leaderboard, the lane fingerprints and th
It runs in the goal tick every 10 minutes, or on each new point, rate-limited. It was
prototyped as `harness/coordinator.py` in `~/CodeProjects/edgebench-eval`.
-| Signal | Condition (defaults) | Action |
-|---|---|---|
-| Leaderboard | every tick | refresh the single leaderboard mark, which is pinned in prompts |
-| Converged | two lanes share a fingerprint | keep one, give the others new directions |
-| Stagnant | no new global best for 25 min (scaled to the timebox) | new directions for every lane |
-| Lagging | a lane is more than 3 points or 10% behind the leader after 30% of the timebox | adopt the leader, then a direction |
-| Warm-up | before the first valid score in any lane | none: lanes start free to get a runnable version fast |
+| Signal | Condition (defaults) | Action |
+| ----------- | ------------------------------------------------------------------------------ | --------------------------------------------------------------- |
+| Leaderboard | every tick | refresh the single leaderboard mark, which is pinned in prompts |
+| Converged | two lanes share a fingerprint | keep one, give the others new directions |
+| Stagnant | no new global best for 25 min (scaled to the timebox) | new directions for every lane |
+| Lagging | a lane is more than 3 points or 10% behind the leader after 30% of the timebox | adopt the leader, then a direction |
+| Warm-up | before the first valid score in any lane | none: lanes start free to get a runnable version fast |
Directions come from one system-model call per decision. Its inputs are the task
requirement, the leaderboard, recent marks and the lanes that need a direction, and it
@@ -197,16 +197,13 @@ The `signature` column planned for pain detection stays a separate change.
## Delivery plan
-All of it sits behind the Agent Lab gate (`useAgentLabGate`) until the benchmark target
-below holds.
-
-| PR | Content | Depends on |
-|---|---|---|
-| 1 | Goal marks (done, 0f5d9bb672a) | — |
-| 2 | `config.objective`, `lh goal set-objective` / `evaluate` / `objective`, objective series with lane metadata, operation-token write path, leaderboard read model, `<goal_objective>` prompt section, per-machine evaluation lock (built) | 1 |
-| 3 | `config.swarm`, lane containers, per-lane directory (device) / per-lane sandbox, graded-archive upload and `lane adopt`, timeboxed lane Tasks, deadline wrap-up and champion | 2 |
-| 4 | Coordinator policy in tick, `directive` marks, prompt pinning | 3 |
-| 5 | Goal page leaderboard and champion promote (web) | 2 (reads), 4 |
+| PR | Content | Depends on |
+| --- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
+| 1 | Goal marks (done, 0f5d9bb672a) | — |
+| 2 | `config.objective`, `lh goal set-objective` / `evaluate` / `objective`, objective series with lane metadata, operation-token write path, leaderboard read model, `<goal_objective>` prompt section, per-machine evaluation lock (built) | 1 |
+| 3 | `config.swarm`, lane containers, per-lane directory (device) / per-lane sandbox, graded-archive upload and `lane adopt`, timeboxed lane Tasks, deadline wrap-up and champion | 2 |
+| 4 | Coordinator policy in tick, `directive` marks, prompt pinning | 3 |
+| 5 | Goal page leaderboard and champion promote (web) | 2 (reads), 4 |
Each PR's acceptance includes the EdgeBench harness on `k12_math_recommendation`
(3 lanes, 2 h, Kimi Code). The bar for removing the Lab gate is:
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index cf416844c20..97a1978d039 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -387,6 +387,7 @@
"createTask.expandToInline": "Dock to page",
"createTask.instructionPlaceholder": "Add task instruction...",
"createTask.member": "Assignee",
+ "createTask.removeSchedule": "Remove schedule",
"createTask.submit": "Create task",
"createTask.submitScheduled": "Create scheduled task",
"createTask.titlePlaceholder": "Task title",
@@ -2515,6 +2516,7 @@
"tab.context": "Context",
"tab.engine": "Engine",
"tab.environment": "Environment",
+ "tab.goalsAndTasks": "Tasks and goals",
"tab.group.identity": "Identity",
"tab.group.setup": "Configure",
"tab.group.shape": "Shape",
diff --git a/locales/en-US/labs.json b/locales/en-US/labs.json
index 2bb93b43c20..db4c2dcba6c 100644
--- a/locales/en-US/labs.json
+++ b/locales/en-US/labs.json
@@ -22,8 +22,6 @@
"features.deviceTunnel.title": "Remote Port Links",
"features.evalCapture.desc": "Adds a message action that captures a conversation turn — its prior context, input and the answer it produced — as an evaluation test case.",
"features.evalCapture.title": "Save a turn as an eval case",
- "features.goals.desc": "Hand the agent a goal: it breaks the goal into tasks, tracks progress, and delivers the result for you to review.",
- "features.goals.title": "Goals",
"features.groupChat.desc": "Enable multi-agent group chat coordination.",
"features.groupChat.title": "Group Chat (Multi-Agent)",
"features.heteroSessionImport.desc": "Add an \"Import Local Agent Sessions\" entry to the topic list menu: scan local Claude Code / Codex CLI transcripts and import them as topics, with incremental sync on re-import.",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 8b2437c972b..fa5e5d21e9a 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -387,6 +387,7 @@
"createTask.expandToInline": "固定到页面",
"createTask.instructionPlaceholder": "添加描述…",
"createTask.member": "负责人",
+ "createTask.removeSchedule": "移除定时",
"createTask.submit": "创建任务",
"createTask.submitScheduled": "创建定时任务",
"createTask.titlePlaceholder": "任务标题",
@@ -2515,6 +2516,7 @@
"tab.context": "上下文",
"tab.engine": "引擎",
"tab.environment": "执行环境",
+ "tab.goalsAndTasks": "任务与目标",
"tab.group.identity": "身份",
"tab.group.setup": "配置",
"tab.group.shape": "塑造",
diff --git a/locales/zh-CN/labs.json b/locales/zh-CN/labs.json
index 8c6a2108009..94f5d402939 100644
--- a/locales/zh-CN/labs.json
+++ b/locales/zh-CN/labs.json
@@ -22,8 +22,6 @@
"features.deviceTunnel.title": "远程端口链接",
"features.evalCapture.desc": "在消息动作里增加一项,把一轮对话(前置上下文、本轮输入与它产生的回答)捕获成评测用例。",
"features.evalCapture.title": "把对话保存为评测用例",
- "features.goals.desc": "把目标交给助手:它会拆解任务、跟进进度,并交付结果供你验收。",
- "features.goals.title": "目标",
"features.groupChat.desc": "启用多代理协同群聊功能。",
"features.groupChat.title": "群聊(多代理)",
"features.heteroSessionImport.desc": "在话题列表菜单中新增「导入本地 Agent 会话」入口:扫描本地 Claude Code / Codex CLI 的会话记录并导入为话题,重复导入时增量同步新消息。",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 4512e281060..8005b903575 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -2154,6 +2154,7 @@ export default {
'tab.profileBasic': 'Profile',
'tab.skills': 'Skills',
'tab.search': 'Search',
+ 'tab.goalsAndTasks': 'Tasks and goals',
'tab.tasks': 'Tasks',
'task.activity.calling': 'Calling Skill...',
'task.activity.clientExecuting': 'Executing locally...',
@@ -2551,6 +2552,7 @@ export default {
'createTask.expandToInline': 'Dock to page',
'createTask.instructionPlaceholder': 'Add task instruction...',
'createTask.submit': 'Create task',
+ 'createTask.removeSchedule': 'Remove schedule',
'createTask.submitScheduled': 'Create scheduled task',
'createTask.titlePlaceholder': 'Task title',
'createTask.visibility.changeFailed': 'Failed to change task visibility',
diff --git a/packages/locales/src/default/labs.ts b/packages/locales/src/default/labs.ts
index f49622a8c40..898f020d6e7 100644
--- a/packages/locales/src/default/labs.ts
+++ b/packages/locales/src/default/labs.ts
@@ -37,9 +37,6 @@ export default {
'Give a port on the working device a link, so a dev server running there can be opened from here. The link only works for people who can reach that device.',
'features.deviceTunnel.title': 'Remote Port Links',
'features.heteroSessionImport.title': 'Local Agent Session Import',
- 'features.goals.desc':
- 'Hand the agent a goal: it breaks the goal into tasks, tracks progress, and delivers the result for you to review.',
- 'features.goals.title': 'Goals',
'features.imessage.desc':
'Connect agents to iMessage through the local LobeHub Desktop BlueBubbles bridge.',
'features.imessage.title': 'iMessage Channel',
diff --git a/packages/types/src/user/preference.ts b/packages/types/src/user/preference.ts
index ae834c2deff..0f1c3a47bab 100644
--- a/packages/types/src/user/preference.ts
+++ b/packages/types/src/user/preference.ts
@@ -275,15 +275,9 @@ export const UserLabSchema = z.object({
* (its ids and the client environment) to the support team
*/
enableTopicBugReport: z.boolean().optional(),
- /**
- * enable Goals: hand the agent a goal it plans into tasks, tracks and delivers
- */
+ /** @deprecated Legacy client preference. Goals are available to everyone. */
enableGoals: z.boolean().optional(),
- /**
- * @deprecated Renamed to `enableGoals`. Written alongside it, and read first,
- * while older clients that only know this key are still around: their writes
- * touch only this key, so it carries the latest choice.
- */
+ /** @deprecated Legacy alias for the Goals lab preference. */
enableTopicAcceptance: z.boolean().optional(),
/**
* expose a port on the working device through a tunnel link, so a dev server
diff --git a/src/features/AgentGoals/AgentGoalsPage.tsx b/src/features/AgentGoals/AgentGoalsPage.tsx
index ca19a78aea6..23cc3102d4f 100644
--- a/src/features/AgentGoals/AgentGoalsPage.tsx
+++ b/src/features/AgentGoals/AgentGoalsPage.tsx
@@ -17,8 +17,9 @@ import { LayoutGridIcon, ListIcon, PlusIcon, RefreshCwIcon, SearchXIcon } from '
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
import GoalSkeleton, { GoalListRowsSkeleton } from '@/components/Skeleton/Goal';
-import AgentBreadcrumb from '@/features/AgentBreadcrumb';
+import { AgentGoalsAndTasksTabs } from '@/features/AgentTasks/AgentGoalsAndTasksTabs';
import NavHeader from '@/features/NavHeader';
import WideScreenContainer from '@/features/WideScreenContainer';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
@@ -121,6 +122,7 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
const { pageTitleFontSize } = useDensityTokens();
const navigate = useWorkspaceAwareNavigate();
const cacheScope = useCacheScope();
+ const activeWorkspaceId = useActiveWorkspaceId();
const isGlobal = !agentId && !projectId;
const agentFilter = useGoalStore((s) => s.goalListAgentFilter);
const setAgentFilter = useGoalStore((s) => s.setGoalListAgentFilter);
@@ -223,6 +225,7 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
!isArchivedProbePending &&
archivedView !== undefined &&
archivedView.goals.length === 0;
+ const isListPending = isLoading || isArchivedProbePending;
const summary = useMemo(() => {
const total = listView?.total ?? goals.length;
// An aggregate that has not answered is unknown, not zero. Falling back to
@@ -294,16 +297,19 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
<Flexbox flex={1} height={'100%'}>
<NavHeader
left={
- agentId ? (
- <AgentBreadcrumb agentId={agentId} title={t('goalList.title')} />
+ agentId || (isGlobal && !activeWorkspaceId) ? (
+ <AgentGoalsAndTasksTabs agentId={agentId} view={'goals'} />
) : (
<Text weight={600}>{t('goalList.title')}</Text>
)
}
right={
- <Button icon={PlusIcon} size={'small'} type={'fill'} onClick={() => openCreateGoal()}>
- {t('goalPage.create')}
- </Button>
+ !isListPending &&
+ !hasNoGoals && (
+ <Button icon={PlusIcon} size={'small'} type={'fill'} onClick={() => openCreateGoal()}>
+ {t('goalPage.create')}
+ </Button>
+ )
}
/>
<WideScreenContainer
@@ -314,7 +320,7 @@ const AgentGoalsPage = memo<AgentGoalsPageProps>(({ agentId, projectId }) => {
paddingInline={16}
wrapperStyle={{ flex: 1, overflowY: 'auto' }}
>
- {isLoading || isArchivedProbePending ? (
+ {isListPending ? (
<GoalSkeleton chrome={'body'} />
) : error && listView === undefined ? (
// Only a read that left nothing to show becomes the page: a failed
diff --git a/src/features/AgentGoals/GoalDetailPage.test.tsx b/src/features/AgentGoals/GoalDetailPage.test.tsx
index 4a5b9c38651..3c533596310 100644
--- a/src/features/AgentGoals/GoalDetailPage.test.tsx
+++ b/src/features/AgentGoals/GoalDetailPage.test.tsx
@@ -3,6 +3,7 @@
*/
import { fireEvent, render, screen } from '@testing-library/react';
import type { ReactNode } from 'react';
+import { MemoryRouter } from 'react-router';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { WorkspaceSidePanelProvider } from '@/features/RightPanel/WorkspaceSidePanel';
@@ -208,10 +209,16 @@ describe('GoalDetailPage', () => {
mocks.showPortal = false;
});
+ it('links back to the goals list from the agent-less route', () => {
+ render(<GoalDetailPage goalId={'goal_1'} />, { wrapper: MemoryRouter });
+
+ expect(screen.getByRole('link', { name: 'goalList.title' })).toHaveAttribute('href', '/goals');
+ });
+
// The measured numbers are what executing the requirement has observed, so
// they read below it as its outcome.
it('renders the north-star metrics below the requirement', () => {
- render(<GoalDetailPage goalId={'goal_1'} />);
+ render(<GoalDetailPage goalId={'goal_1'} />, { wrapper: MemoryRouter });
expect(
screen
@@ -246,6 +253,7 @@ describe('GoalDetailPage', () => {
<WorkspaceSidePanelProvider>
<GoalDetailPage goalId={'goal_1'} />
</WorkspaceSidePanelProvider>,
+ { wrapper: MemoryRouter },
);
expect(screen.getByTestId('goal-supervisor-toggle')).toHaveTextContent(
@@ -262,7 +270,7 @@ describe('GoalDetailPage', () => {
// agent is the only thing that can say whose conversation this is.
it('falls back to the goal agent’s conversation without a route agent or a record', () => {
mocks.hasSupervision = false;
- render(<GoalDetailPage goalId={'goal_1'} />);
+ render(<GoalDetailPage goalId={'goal_1'} />, { wrapper: MemoryRouter });
expect(screen.getByTestId('goal-supervisor-toggle')).toHaveTextContent('goalChat.title');
fireEvent.click(screen.getByTestId('goal-supervisor-toggle'));
@@ -322,6 +330,7 @@ describe('GoalDetailPage', () => {
<WorkspaceSidePanelProvider>
<GoalDetailPage goalId={'goal_1'} />
</WorkspaceSidePanelProvider>,
+ { wrapper: MemoryRouter },
);
expect(screen.queryByTestId('goal-portal-content')).not.toBeInTheDocument();
@@ -342,7 +351,7 @@ describe('GoalDetailPage', () => {
mocks.graphError = { data: { code: 'NOT_FOUND', httpStatus: 404 } };
mocks.recovery = { pending: true };
- render(<GoalDetailPage goalId={'goal_1'} />);
+ render(<GoalDetailPage goalId={'goal_1'} />, { wrapper: MemoryRouter });
expect(screen.getByTestId('goal-detail-skeleton')).toBeTruthy();
});
diff --git a/src/features/AgentGoals/GoalWorkspaceBreadcrumb.tsx b/src/features/AgentGoals/GoalWorkspaceBreadcrumb.tsx
index 03fdd4183a6..f81fa39e7a0 100644
--- a/src/features/AgentGoals/GoalWorkspaceBreadcrumb.tsx
+++ b/src/features/AgentGoals/GoalWorkspaceBreadcrumb.tsx
@@ -7,8 +7,6 @@ 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;
@@ -16,12 +14,10 @@ interface GoalWorkspaceBreadcrumbProps {
/**
* 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.
+ * a bare task detail leads back to `/tasks`.
*/
const GoalWorkspaceBreadcrumb = memo<GoalWorkspaceBreadcrumbProps>(({ title }) => {
const { t } = useTranslation('chat');
- const goalsEnabled = useUserStore(labPreferSelectors.enableGoals);
const titleCrumb = {
key: 'goal',
@@ -37,23 +33,19 @@ const GoalWorkspaceBreadcrumb = memo<GoalWorkspaceBreadcrumbProps>(({ title }) =
<Breadcrumb
className={styles.breadcrumb}
separator={<Icon icon={ChevronRight} />}
- items={
- goalsEnabled
- ? [
- {
- key: 'goals',
- title: (
- <WorkspaceLink to={'/goals'}>
- <Text color={'inherit'} style={{ whiteSpace: 'nowrap' }} weight={500}>
- {t('goalList.title')}
- </Text>
- </WorkspaceLink>
- ),
- },
- titleCrumb,
- ]
- : [titleCrumb]
- }
+ items={[
+ {
+ key: 'goals',
+ title: (
+ <WorkspaceLink to={'/goals'}>
+ <Text color={'inherit'} style={{ whiteSpace: 'nowrap' }} weight={500}>
+ {t('goalList.title')}
+ </Text>
+ </WorkspaceLink>
+ ),
+ },
+ titleCrumb,
+ ]}
/>
);
});
diff --git a/src/features/AgentGoals/useAgentLabGate.test.ts b/src/features/AgentGoals/useAgentLabGate.test.ts
deleted file mode 100644
index 4fa3469a338..00000000000
--- a/src/features/AgentGoals/useAgentLabGate.test.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import { renderHook } from '@testing-library/react';
-import { beforeEach, describe, expect, it, vi } from 'vitest';
-
-import { useAgentLabGate } from './useAgentLabGate';
-
-/**
- * The lab gate reads `preference.lab.enableGoals`, which is `false`
- * until `useInitUserState` resolves. Before the gate split "still loading"
- * from "settled off" via `isPreferenceInit`, the initial `false` rendered
- * `null` (a white flash inside the agent layout) and the redirect effect
- * kicked cold-boot visitors back to chat before their preference ever arrived.
- */
-const userStateMock: {
- initError?: unknown;
- isUserStateInit?: boolean;
- preference: { lab?: { enableGoals?: boolean } };
-} = { preference: {} };
-
-vi.mock('@/store/user', () => ({
- useUserStore: (selector: (state: Record<string, unknown>) => unknown) =>
- selector({
- isUserStateInit: userStateMock.isUserStateInit,
- isUserStateInitError: userStateMock.initError,
- preference: userStateMock.preference,
- }),
-}));
-
-beforeEach(() => {
- userStateMock.initError = undefined;
- userStateMock.isUserStateInit = true;
- userStateMock.preference = {};
-});
-
-describe('useAgentLabGate', () => {
- it('reports the gate as unjudged while preference is still initializing', () => {
- userStateMock.isUserStateInit = false;
-
- const { result } = renderHook(() => useAgentLabGate());
-
- expect(result.current.isPreferenceInit).toBe(false);
- expect(result.current.shouldRedirect).toBe(false);
- });
-
- it('opens the gate once preference settles with the lab enabled', () => {
- userStateMock.preference = { lab: { enableGoals: true } };
-
- const { result } = renderHook(() => useAgentLabGate());
-
- expect(result.current).toEqual({
- enabled: true,
- initFailed: false,
- isPreferenceInit: true,
- shouldRedirect: false,
- });
- });
-
- it('redirects only after preference confirms the lab is off', () => {
- userStateMock.preference = { lab: { enableGoals: false } };
-
- const { result } = renderHook(() => useAgentLabGate());
-
- expect(result.current.shouldRedirect).toBe(true);
- });
-
- it('redirects even when user state failed to initialize, so the page is not a dead end', () => {
- userStateMock.initError = new Error('offline');
- userStateMock.isUserStateInit = false;
-
- const { result } = renderHook(() => useAgentLabGate());
-
- // The gate itself stays unjudged — the route reads `isUserStateInitError`
- // separately, skips the skeleton, and this redirect is what actually gets
- // the visitor off the page instead of an empty pane with no exit.
- expect(result.current).toMatchObject({
- initFailed: true,
- isPreferenceInit: false,
- shouldRedirect: true,
- });
- });
-
- it('treats a falsy init error as no failure', () => {
- userStateMock.initError = null;
- userStateMock.isUserStateInit = false;
-
- const { result } = renderHook(() => useAgentLabGate());
-
- expect(result.current).toMatchObject({ initFailed: false, shouldRedirect: false });
- });
-});
diff --git a/src/features/AgentGoals/useAgentLabGate.ts b/src/features/AgentGoals/useAgentLabGate.ts
deleted file mode 100644
index f7a63139305..00000000000
--- a/src/features/AgentGoals/useAgentLabGate.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-'use client';
-
-import { useMemo } from 'react';
-
-import { useUserStore } from '@/store/user';
-import { labPreferSelectors, preferenceSelectors } from '@/store/user/selectors';
-
-/**
- * The lab gate every `/agent/:aid/goal*` route sits behind.
- *
- * `enableGoals` reads `preference.lab`, which is `false` until
- * `useInitUserState` resolves. Judging the gate before that settles renders a
- * white flash (`null` for the whole pane) and the redirect effect kicks
- * cold-boot visitors back to chat before their preference ever arrived.
- * `isPreferenceInit` splits "still loading" from "settled off", and a failed
- * user-state init keeps the legacy escape instead of an endless skeleton.
- */
-export const useAgentLabGate = () => {
- const initError = useUserStore((s) => s.isUserStateInitError);
- const isPreferenceInit = useUserStore(preferenceSelectors.isPreferenceInit);
- const enabled = useUserStore(labPreferSelectors.enableGoals);
-
- const initFailed = !!initError;
-
- return useMemo(
- () => ({
- enabled,
- // A failed user-state init keeps the legacy escape: the route falls
- // through to its redirect instead of an endless skeleton.
- initFailed,
- isPreferenceInit,
- // A failed init never settles the preference, so the gate stays
- // unjudgeable forever. `shouldRedirect` is what actually gets the
- // visitor out, so it must fire here too — without it the route skips the
- // skeleton and then renders `null`, leaving an empty pane with no exit.
- shouldRedirect: (isPreferenceInit || initFailed) && !enabled,
- }),
- [enabled, initFailed, isPreferenceInit],
- );
-};
diff --git a/src/features/AgentSidebar/Header/Nav.test.tsx b/src/features/AgentSidebar/Header/Nav.test.tsx
index 587d9a0dc16..a02c70d0e40 100644
--- a/src/features/AgentSidebar/Header/Nav.test.tsx
+++ b/src/features/AgentSidebar/Header/Nav.test.tsx
@@ -172,8 +172,6 @@ vi.mock('@/store/user/selectors', () => ({
labPreferSelectors: {
enableSelfLearning: (state: { preference: { lab?: { enableSelfLearning?: boolean } } }) =>
state.preference.lab?.enableSelfLearning ?? false,
- enableGoals: (state: { preference: { lab?: { enableGoals?: boolean } } }) =>
- state.preference.lab?.enableGoals ?? false,
},
}));
@@ -342,40 +340,33 @@ describe('Agent sidebar header nav', () => {
expect(screen.getByRole('button', { name: 'title' })).toBeInTheDocument();
});
- it('navigates to the agent goals page', () => {
+ it('opens the combined entry even when a previous Goals preference is false', () => {
+ labMock.enableGoals = false;
usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
render(<Nav />);
- fireEvent.click(screen.getByRole('button', { name: 'goalList.title' }));
+ fireEvent.click(screen.getByRole('button', { name: 'tab.goalsAndTasks' }));
expect(switchTopicMock).toHaveBeenCalledWith(null, { skipRefreshMessage: true });
- expect(pushMock).toHaveBeenCalledWith('/agent/agt_eH4zL98zBx5u/goals');
+ expect(pushMock).toHaveBeenCalledWith('/agent/agt_eH4zL98zBx5u/tasks');
});
- it('navigates to the agent tasks page', () => {
- usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
+ it.each([
+ '/agent/agt_eH4zL98zBx5u/goals',
+ '/agent/agt_eH4zL98zBx5u/goal/example',
+ '/agent/agt_eH4zL98zBx5u/tasks',
+ '/agent/agt_eH4zL98zBx5u/task/task_2FCHvjS7d4CA',
+ ])('keeps the tasks entry active on %s', (pathname) => {
+ usePathnameMock.mockReturnValue(pathname);
render(<Nav />);
- fireEvent.click(screen.getByRole('button', { name: 'tab.tasks' }));
- expect(switchTopicMock).toHaveBeenCalledWith(null, { skipRefreshMessage: true });
- expect(pushMock).toHaveBeenCalledWith('/agent/agt_eH4zL98zBx5u/tasks');
+ expect(screen.getByRole('button', { name: 'tab.goalsAndTasks' })).toHaveAttribute(
+ 'data-active',
+ 'true',
+ );
});
- it.each(['/agent/agt_eH4zL98zBx5u/tasks', '/agent/agt_eH4zL98zBx5u/task/task_2FCHvjS7d4CA'])(
- 'keeps the tasks entry active on %s',
- (pathname) => {
- usePathnameMock.mockReturnValue(pathname);
-
- render(<Nav />);
-
- expect(screen.getByRole('button', { name: 'tab.tasks' })).toHaveAttribute(
- 'data-active',
- 'true',
- );
- },
- );
-
it('moves self-evolving into the profile group for members who can open it', () => {
usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
@@ -429,7 +420,7 @@ describe('Agent sidebar header nav', () => {
});
});
- it('places goals above tasks, with profile settings in the header', () => {
+ it('opens tasks from the combined entry, with profile settings in the header', () => {
usePathnameMock.mockReturnValue('/agent/agt_eH4zL98zBx5u');
render(<Nav />);
@@ -439,7 +430,10 @@ describe('Agent sidebar header nav', () => {
expect(screen.getByRole('banner')).toContainElement(
screen.getByRole('button', { name: 'tab.profile' }),
);
- expect(labels.indexOf('goalList.title')).toBeLessThan(labels.indexOf('tab.tasks'));
+ expect(labels).not.toContain('goalList.title');
+ expect(labels).not.toContain('tab.tasks');
+ fireEvent.click(screen.getByRole('button', { name: 'tab.goalsAndTasks' }));
+ expect(pushMock).toHaveBeenCalledWith('/agent/agt_eH4zL98zBx5u/tasks');
});
// The full topic page is reached from the Topics section header arrow, not a
diff --git a/src/features/AgentSidebar/Header/Nav.tsx b/src/features/AgentSidebar/Header/Nav.tsx
index 8ca91e9a796..3871b0eeac8 100644
--- a/src/features/AgentSidebar/Header/Nav.tsx
+++ b/src/features/AgentSidebar/Header/Nav.tsx
@@ -2,7 +2,7 @@
import { Flexbox } from '@lobehub/ui';
import { BotPromptIcon } from '@lobehub/ui/icons';
-import { DnaIcon, ListTodoIcon, MessageSquarePlusIcon, SearchIcon, TargetIcon } from 'lucide-react';
+import { DnaIcon, ListTodoIcon, MessageSquarePlusIcon, SearchIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';
@@ -18,8 +18,6 @@ import { topicActionKeys } from '@/libs/swr/keys';
import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/selectors';
import { useGlobalStore } from '@/store/global';
-import { useUserStore } from '@/store/user';
-import { labPreferSelectors } from '@/store/user/selectors';
import { isMobileSurface } from '@/utils/mobileSurface';
import { isAgentProfileRoute } from './isAgentProfileRoute';
@@ -42,7 +40,7 @@ const Nav = ({ onOpenProfile, showProfile }: NavProps) => {
// 下钻页 /self-evolving/:domainId 也算在这个入口下,否则点进去侧边栏就失焦了
const isSelfLearningActive = pathname.includes('/self-evolving');
const isProfileActive = isAgentProfileRoute(pathname) && !isSelfLearningActive;
- const isGoalsActive = pathname.endsWith('/goals');
+ const isGoalsActive = pathname.endsWith('/goals') || pathname.includes('/goal/');
const isTasksActive = pathname.endsWith('/tasks') || pathname.includes('/task/');
const router = useQueryRoute();
const { allowed: canCreateTopic } = usePermission('create_content');
@@ -50,7 +48,6 @@ const Nav = ({ onOpenProfile, showProfile }: NavProps) => {
const switchTopic = useChatStore((s) => s.switchTopic);
const [openNewTopicOrSaveTopic] = useChatStore((s) => [s.openNewTopicOrSaveTopic]);
const isNewTopicSendInFlight = useChatStore(topicSelectors.isNewTopicSendInFlight);
- const enableGoals = useUserStore(labPreferSelectors.enableGoals);
const { enabled: enableSelfLearning } = useSelfLearningSurface();
// Self-evolving lives in the profile group; it stays here only where that group
// cannot reach it: members with no profile entry, and the mobile Segmented.
@@ -103,21 +100,10 @@ const Nav = ({ onOpenProfile, showProfile }: NavProps) => {
}}
/>
)}
- {enableGoals && (
- <NavItem
- active={isGoalsActive}
- icon={TargetIcon}
- title={t('goalList.title')}
- onClick={() => {
- switchTopic(null, { skipRefreshMessage: true });
- router.push(urlJoin('/agent', agentId!, 'goals'));
- }}
- />
- )}
<NavItem
- active={isTasksActive}
+ active={isTasksActive || isGoalsActive}
icon={ListTodoIcon}
- title={t('tab.tasks')}
+ title={t('tab.goalsAndTasks')}
onClick={() => {
switchTopic(null, { skipRefreshMessage: true });
router.push(urlJoin('/agent', agentId!, 'tasks'));
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
index 4c1ec0087b9..ada663bef41 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.test.tsx
@@ -20,7 +20,6 @@ const runningStartTimeMock = vi.hoisted(() => ({ value: undefined as number | un
const topicUnreadCompletedMock = vi.hoisted(() => ({ value: false }));
const onlyMineMock = vi.hoisted(() => ({ value: false }));
const currentUserIdMock = vi.hoisted(() => ({ value: 'user-1' as string | undefined }));
-const goalsEnabledMock = vi.hoisted(() => ({ value: true }));
const hasDraftMock = vi.hoisted(() => ({ value: false }));
const isDesktopMock = vi.hoisted(() => ({ value: false }));
const electronTabMocks = vi.hoisted(() => ({
@@ -150,7 +149,6 @@ vi.mock('@/store/user', () => ({
vi.mock('@/store/user/selectors', () => ({
labPreferSelectors: {
enableBetterCodingExperience: () => false,
- enableGoals: () => goalsEnabledMock.value,
},
userProfileSelectors: { userId: () => currentUserIdMock.value },
}));
@@ -251,7 +249,6 @@ describe('TopicItem active state', () => {
topicMetaCardMock.value = undefined;
onlyMineMock.value = false;
currentUserIdMock.value = 'user-1';
- goalsEnabledMock.value = true;
hasDraftMock.value = false;
vi.useRealTimers();
});
@@ -614,14 +611,6 @@ describe('TopicItem active state', () => {
expect(screen.queryByLabelText('metaCard.goal')).not.toBeInTheDocument();
});
-
- it('hides the goal marker while the goals lab is off', () => {
- goalsEnabledMock.value = false;
-
- render(<TopicItem hasGoal id="tpc_test" title="Topic" />);
-
- expect(screen.queryByLabelText('metaCard.goal')).not.toBeInTheDocument();
- });
});
it('adds the CI status to the pull request marker', () => {
diff --git a/src/features/AgentSidebar/Topic/List/Item/index.tsx b/src/features/AgentSidebar/Topic/List/Item/index.tsx
index 488a6d786a0..488f217a0a9 100644
--- a/src/features/AgentSidebar/Topic/List/Item/index.tsx
+++ b/src/features/AgentSidebar/Topic/List/Item/index.tsx
@@ -274,7 +274,6 @@ const TopicItemRow = memo<TopicItemRowProps>(
const inboxId = useAgentStore(builtinAgentSelectors.inboxAgentId);
const { t } = useTranslation('topic');
const { isDarkMode } = useTheme();
- const goalsEnabled = useUserStore(labPreferSelectors.enableGoals);
// Rows render by the dozen, so agent-level reads share ONE subscription.
// Only workspace-shared (`public`) agents get the creator avatar — a
// workspace-private agent's topics all belong to the viewer.
@@ -526,7 +525,7 @@ const TopicItemRow = memo<TopicItemRowProps>(
// The conversation a goal was planned in says more about the row than
// the PR it produced, so it outranks the PR marker (which stays in the
// meta hover card).
- if (hasGoal && goalsEnabled) {
+ if (hasGoal) {
return (
<Tooltip title={t('metaCard.goal')}>
<span aria-label={t('metaCard.goal')} className={styles.markerIcon}>
diff --git a/src/features/AgentTasks/AgentGoalsAndTasksTabs.tsx b/src/features/AgentTasks/AgentGoalsAndTasksTabs.tsx
new file mode 100644
index 00000000000..fa5d06ed237
--- /dev/null
+++ b/src/features/AgentTasks/AgentGoalsAndTasksTabs.tsx
@@ -0,0 +1,30 @@
+import { TabsIndicator, TabsList, TabsRoot, TabsTab } from '@lobehub/ui';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+
+interface AgentGoalsAndTasksTabsProps {
+ agentId?: string;
+ view: 'goals' | 'tasks';
+}
+
+export const AgentGoalsAndTasksTabs = memo<AgentGoalsAndTasksTabsProps>(({ agentId, view }) => {
+ const { t } = useTranslation('chat');
+ const navigate = useWorkspaceAwareNavigate();
+
+ return (
+ <TabsRoot
+ size={'small'}
+ value={view}
+ variant={'square'}
+ onValueChange={(value) => navigate(agentId ? `/agent/${agentId}/${value}` : `/${value}`)}
+ >
+ <TabsList aria-label={t('tab.goalsAndTasks')}>
+ <TabsIndicator />
+ <TabsTab value={'tasks'}>{t('tab.tasks')}</TabsTab>
+ <TabsTab value={'goals'}>{t('goalList.title')}</TabsTab>
+ </TabsList>
+ </TabsRoot>
+ );
+});
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskGoalBar.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskGoalBar.tsx
index 1da6032e6f1..a2575135605 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskGoalBar.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskGoalBar.tsx
@@ -26,7 +26,7 @@ const TaskGoalBar = memo(() => {
style={{ maxWidth: '100%', minWidth: 0 }}
type={'text'}
// The agent-less route: the goal's supervising agent may be private to its
- // creator or gated by Agent Lab, while the goal itself stays readable.
+ // creator, while the goal itself stays readable.
onClick={() => navigate(`/goal/${goal.id}`)}
>
<Text ellipsis style={{ minWidth: 0 }} weight={500}>
diff --git a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
index 62b2630f5f3..7afb1bae054 100644
--- a/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
+++ b/src/features/AgentTasks/AgentTaskList/AgentTasksPage.tsx
@@ -8,7 +8,7 @@ import {
TabsRoot,
TabsTab,
} from '@lobehub/ui';
-import { Plus } from 'lucide-react';
+import { ClockIcon, Plus } from 'lucide-react';
import { memo, type ReactNode, useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation, useSearchParams } from 'react-router';
@@ -29,6 +29,7 @@ import { TASK_COLLECTION_PAGE_SIZE } from '@/store/task/slices/list/action';
import { useHeaderActionSize } from '@/styles/density';
import { isMobileSurface } from '@/utils/mobileSurface';
+import { AgentGoalsAndTasksTabs } from '../AgentGoalsAndTasksTabs';
import { createTaskModal } from '../CreateTaskModal';
import { useTaskProjectList } from '../features/useTaskProjectList';
import Breadcrumb from '../shared/Breadcrumb';
@@ -572,7 +573,10 @@ const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId, headerActions, proj
// "Content contains" for the same condition.
const showFind = !isMobile && (headerVisibility.showViewOptions || hasFilter);
- const headerLeft = (
+ const showGoalsAndTasksTabs = !!agentId || (!projectId && !activeWorkspaceId);
+ const headerLeft = showGoalsAndTasksTabs ? (
+ <AgentGoalsAndTasksTabs agentId={agentId} view={'tasks'} />
+ ) : (
<Flexbox horizontal align={'center'} gap={8}>
{headerVisibility.showBreadcrumb && <Breadcrumb />}
<TabsRoot size={'small'} value={collection} onValueChange={handleCollectionChange}>
@@ -604,8 +608,24 @@ const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId, headerActions, proj
<Flexbox flex={1} height={'100%'}>
<NavHeader
left={headerLeft}
+ styles={showGoalsAndTasksTabs ? undefined : { left: { gap: 8, paddingLeft: 4 } }}
right={
<Flexbox horizontal align={'center'} gap={4}>
+ {showGoalsAndTasksTabs && (
+ <Button
+ aria-label={t('taskList.scheduled.title')}
+ aria-pressed={isScheduledCollection}
+ icon={ClockIcon}
+ size={'small'}
+ title={t('taskList.scheduled.title')}
+ type={isScheduledCollection ? 'fill' : 'text'}
+ onClick={() =>
+ handleCollectionChange(isScheduledCollection ? 'tasks' : 'scheduled')
+ }
+ >
+ {isMobile ? undefined : t('taskList.scheduled.title')}
+ </Button>
+ )}
{showFind && <TaskListFind content={filter?.content} onChange={handleFindChange} />}
{(headerVisibility.showViewOptions || hasFilter) && (
<TaskFilterButton fields={filterFields} filter={filter} setFilter={setFilter} />
@@ -657,12 +677,6 @@ const AgentTasksPage = memo<AgentTasksPageProps>(({ agentId, headerActions, proj
)}
</Flexbox>
}
- styles={{
- left: {
- paddingLeft: 4,
- gap: 8,
- },
- }}
/>
<TaskFilterBar
fields={filterFields}
diff --git a/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.project.test.tsx b/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.project.test.tsx
index fa6564a1299..d38a7763dbc 100644
--- a/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.project.test.tsx
+++ b/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.project.test.tsx
@@ -80,7 +80,7 @@ vi.mock('@/store/user', () => ({
useUserStore: (selector: (s: unknown) => unknown) => selector({}),
}));
vi.mock('@/store/user/selectors', () => ({
- labPreferSelectors: { enableGoals: () => false, enableProjects: () => true },
+ labPreferSelectors: { enableProjects: () => true },
userProfileSelectors: { userId: () => 'u1' },
}));
vi.mock('@/styles', () => ({ shinyTextStyles: {} }));
diff --git a/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.test.tsx b/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.test.tsx
index c4dda2025c6..357a6f4ab5b 100644
--- a/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.test.tsx
+++ b/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.test.tsx
@@ -171,13 +171,9 @@ vi.mock('@/store/global', () => ({
}),
}));
-const userStateMock = vi.hoisted(() => ({
- lab: {} as Record<string, boolean>,
-}));
-
vi.mock('@/store/user', () => ({
useUserStore: (selector: (state: Record<string, unknown>) => unknown) =>
- selector({ preference: { lab: userStateMock.lab }, user: { id: 'self-user' } }),
+ selector({ preference: { lab: {} }, user: { id: 'self-user' } }),
}));
// The label picker reads the label registry; its own behavior is covered by
@@ -296,11 +292,6 @@ vi.mock('../shared/useAgentVisibility', () => ({
useAgentVisibility: (agentId?: string) => (agentId === 'agent-private' ? 'private' : undefined),
}));
-/** Flips the Labs toggles the composer still reads. */
-const setLabs = (lab: { enableGoals?: boolean }) => {
- userStateMock.lab = lab as Record<string, boolean>;
-};
-
const clearReading = {
clarifications: [],
confidence: 'high' as const,
@@ -313,7 +304,6 @@ const clearReading = {
describe('CreateTaskInlineEntry', () => {
beforeEach(() => {
permissionMock.allowed = true;
- setLabs({});
analyzeIntentMock.mockReset();
synthesizeInstructionMock.mockReset();
// The second reading is the normal path: it rewrites the brief with the
@@ -741,7 +731,6 @@ describe('CreateTaskInlineEntry', () => {
describe('intent recognition', () => {
beforeEach(() => {
- setLabs({ enableGoals: true });
editorMarkdownMock.value = 'Write a project plan';
});
diff --git a/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.tsx b/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.tsx
index 606a08aa3e8..915739bc55b 100644
--- a/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.tsx
+++ b/src/features/AgentTasks/AgentTaskList/CreateTaskInlineEntry.tsx
@@ -15,7 +15,7 @@ import {
toast,
} from '@lobehub/ui';
import { $getRoot } from 'lexical';
-import { ChevronDown, ChevronUp, Paperclip, TagIcon } from 'lucide-react';
+import { ChevronDown, ChevronUp, ClockIcon, Paperclip, TagIcon, XIcon } from 'lucide-react';
import { type KeyboardEvent, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -37,9 +37,15 @@ import { useGlobalStore } from '@/store/global';
import { getTaskStoreState, useTaskStore } from '@/store/task';
import { taskLabelSelectors } from '@/store/task/selectors';
import { useUserStore } from '@/store/user';
-import { labPreferSelectors, userProfileSelectors } from '@/store/user/selectors';
+import { userProfileSelectors } from '@/store/user/selectors';
import { shinyTextStyles } from '@/styles';
+import ScheduleChip from '../CreateTaskModal/ScheduleChip';
+import {
+ createDefaultScheduleDraft,
+ type ScheduleDraft,
+ toScheduledCreateParams,
+} from '../CreateTaskModal/scheduleDraft';
import AssigneeAgentSelector from '../features/AssigneeAgentSelector';
import AssigneeAvatar from '../features/AssigneeAvatar';
import AssigneeMemberSelector from '../features/AssigneeMemberSelector';
@@ -126,6 +132,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
useDefaultMemberAssignee();
const navigate = useWorkspaceAwareNavigate();
const taskListOriginState = useTaskListOriginState();
+ const [schedule, setSchedule] = useState<ScheduleDraft>();
const [priority, setPriority] = useState(0);
const [labels, setLabels] = useState<TaskLabelRef[]>([]);
const isLabelsInit = useTaskStore(taskLabelSelectors.isLabelsInit);
@@ -156,7 +163,6 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
// Reading the draft is what submit does now. It only stops for confirmation
// when it found something the user alone can settle, so the escape hatch is
// the dropdown's "create directly" rather than a setting nobody would find.
- const canCreateGoal = useUserStore(labPreferSelectors.enableGoals);
const [analysis, setAnalysis] = useState<TaskIntentAnalysis | null>(null);
const [intentTitle, setIntentTitle] = useState('');
const [intentAnswers, setIntentAnswers] = useState<ClarificationAnswers>({});
@@ -272,6 +278,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
// hydration only — it must not keep the previous scope's selection).
editor.cleanDocument?.();
setPriority(0);
+ setSchedule(undefined);
// Labels belong to a workspace: one picked in the previous scope would be a
// foreign id here and fail the create.
setLabels([]);
@@ -286,6 +293,9 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
if (!draft) return;
try {
if (draft.markdown) editor.setDocument?.('markdown', draft.markdown);
+ if (agentId && !parentTaskId && draft.schedule?.pattern && draft.schedule.timezone) {
+ setSchedule(draft.schedule);
+ }
if (typeof draft.priority === 'number') setPriority(draft.priority);
if (!lockAssignee && draft.assigneeAgentId) setAssigneeAgentId(draft.assigneeAgentId);
// Re-validated rather than trusted: the draft is a browser string that a
@@ -328,6 +338,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
editor,
isMembersLoading,
lockAssignee,
+ parentTaskId,
projectId,
setProjectChoice,
]);
@@ -366,6 +377,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
markdown,
priority,
projectId: projectChoice,
+ schedule,
visibility,
},
draftHasTextRef.current,
@@ -382,6 +394,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
memberChoice,
priority,
projectChoice,
+ schedule,
visibility,
]);
@@ -409,6 +422,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
const resetComposer = useCallback(() => {
setPriority(0);
+ setSchedule(undefined);
setLabels([]);
// A restore still waiting for the registry belongs to the draft just sent.
pendingDraftLabelIdsRef.current = undefined;
@@ -472,13 +486,15 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
// handle the composer's own failure here so it isn't silent, keeping the
// draft intact (the reset only runs on success).
try {
+ const config = execution ? { execution: toTaskExecutionConfigPatch(execution) } : undefined;
const result = await createTask({
assigneeAgentId,
assigneeUserId,
// Only present when the user pinned a run location / directory. Left
// out otherwise so the task inherits the assignee agent entirely,
// which is what tasks did before they could carry a selection.
- ...(execution ? { config: { execution: toTaskExecutionConfigPatch(execution) } } : {}),
+ ...(config && { config }),
+ ...(schedule && toScheduledCreateParams(schedule, config)),
editorData: draft.editorJson,
instruction: draft.instruction,
...pickedLabelIds(labels, pendingDraftLabelIdsRef.current),
@@ -563,6 +579,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
priority,
taskListOriginState,
resetComposer,
+ schedule,
visibility,
],
);
@@ -572,6 +589,10 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
const draft = readDraft();
if (!draft) return;
+ if (schedule) {
+ await submitDraft(draft);
+ return;
+ }
setIsAnalyzing(true);
try {
const result = await taskService.analyzeIntent({
@@ -596,7 +617,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
} finally {
setIsAnalyzing(false);
}
- }, [assigneeMeta?.title, canCreateTask, isMemberPending, readDraft, submitDraft]);
+ }, [assigneeMeta?.title, canCreateTask, isMemberPending, readDraft, schedule, submitDraft]);
/**
* The escape hatch, one click away in the submit dropdown: create the task
@@ -767,7 +788,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
onBack={() => setAnalysis(null)}
onConfirm={handleConfirmIntent}
onSkip={handleSkipIntent}
- onSwitchToGoal={canCreateGoal ? handleSwitchToGoal : undefined}
+ onSwitchToGoal={handleSwitchToGoal}
onTitleChange={setIntentTitle}
/>
)}
@@ -944,6 +965,26 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
onChange={setExecution}
/>
+ {agentId &&
+ !parentTaskId &&
+ (schedule ? (
+ <Flexbox horizontal align={'center'}>
+ <ScheduleChip value={schedule} onChange={setSchedule} />
+ <ActionIcon
+ icon={XIcon}
+ size={'small'}
+ title={t('createTask.removeSchedule')}
+ onClick={() => setSchedule(undefined)}
+ />
+ </Flexbox>
+ ) : (
+ <ActionIcon
+ icon={ClockIcon}
+ size={'small'}
+ title={t('taskSchedule.title')}
+ onClick={() => setSchedule(createDefaultScheduleDraft())}
+ />
+ ))}
<ActionIcon
icon={Paperclip}
size={'small'}
@@ -1000,7 +1041,7 @@ const CreateTaskInlineEntry = memo<CreateTaskInlineEntryProps>((props) => {
// than as the button having gone inert.
<span className={shinyTextStyles.shinyText}>{t('taskIntent.analyzing')}</span>
) : (
- t('createTask.submit')
+ t(schedule ? 'createTask.submitScheduled' : 'createTask.submit')
)}
</Button>
{/* The escape hatch sits on the button it bypasses, so a user who
diff --git a/src/features/AgentTasks/AgentTaskList/taskCreateDraft.ts b/src/features/AgentTasks/AgentTaskList/taskCreateDraft.ts
index 6034d0194c0..7910a3c2cbf 100644
--- a/src/features/AgentTasks/AgentTaskList/taskCreateDraft.ts
+++ b/src/features/AgentTasks/AgentTaskList/taskCreateDraft.ts
@@ -1,3 +1,5 @@
+import type { ScheduleDraft } from '../CreateTaskModal/scheduleDraft';
+
/**
* The composer's in-progress draft as stored in the browser. Every field is
* optional because the value is a browser string that a previous release (or
@@ -13,6 +15,7 @@ export interface TaskCreateDraft {
priority?: number;
/** `null` is an explicit "no project"; a missing key follows the scope's default. */
projectId?: string | null;
+ schedule?: ScheduleDraft;
visibility?: 'private' | 'public';
}
diff --git a/src/features/ChatInput/ActionBar/Plus/index.tsx b/src/features/ChatInput/ActionBar/Plus/index.tsx
index 630e88b21f7..15043c81af0 100644
--- a/src/features/ChatInput/ActionBar/Plus/index.tsx
+++ b/src/features/ChatInput/ActionBar/Plus/index.tsx
@@ -26,8 +26,6 @@ import { agentSelectors } from '@/store/agent/selectors';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
-import { useUserStore } from '@/store/user';
-import { labPreferSelectors } from '@/store/user/selectors';
import { useDensityTokens } from '@/styles/density';
import { densityTokens } from '@/styles/density.stylex';
@@ -187,9 +185,6 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI
const agentId = useAgentId();
const { canConfigureResource } = useChatInputResourceAccess();
- // Goal creation is lab-gated while the product surface is being rolled out.
- const enableGoals = useUserStore(labPreferSelectors.enableGoals);
-
const upload = useChatInputUpload();
const { enableKnowledgeBase } = useServerConfigStore(featureFlagsSelectors);
@@ -396,27 +391,25 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI
// Goal creation has one canonical entry: drop the goal chip at the head of
// the composer. The agent then plans and calls builtin-goal.createGoal,
// regardless of whether this conversation already has a topic.
- const acceptanceItems: ActionDropdownMenuItems = enableGoals
- ? [
- {
- icon: TargetIcon,
- key: 'set-topic-goal',
- // Same string as the chip it inserts: one label for the affordance,
- // so the menu row and the chip can never drift apart.
- label: tEditor('slash.goal'),
- onClick: () => {
- insertGoalTag(editor, tEditor('slash.goal'));
- },
- },
- ]
- : [];
+ const goalItems: ActionDropdownMenuItems = [
+ {
+ icon: TargetIcon,
+ key: 'set-topic-goal',
+ // Same string as the chip it inserts: one label for the affordance,
+ // so the menu row and the chip can never drift apart.
+ label: tEditor('slash.goal'),
+ onClick: () => {
+ insertGoalTag(editor, tEditor('slash.goal'));
+ },
+ },
+ ];
// Grouped with a single divider only between non-empty groups:
// [attachments] | [tools · skills] | [set goal] | [formatting · params]
const menuGroups: ActionDropdownMenuItems[] = [
attachmentsItems,
coreItems,
- acceptanceItems,
+ goalItems,
formatItems,
];
return menuGroups
@@ -425,7 +418,6 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI
}, [
agentId,
canConfigureResource,
- enableGoals,
canUploadImage,
canUploadVideo,
canUploadAudio,
diff --git a/src/features/CommandMenu/useCommandMenu.ts b/src/features/CommandMenu/useCommandMenu.ts
index 91c73cbf34a..2eb390fadd6 100644
--- a/src/features/CommandMenu/useCommandMenu.ts
+++ b/src/features/CommandMenu/useCommandMenu.ts
@@ -1,6 +1,6 @@
import { useDebounce } from 'ahooks';
import { useTheme as useNextThemesTheme } from 'next-themes';
-import { useCallback, useEffect, useMemo } from 'react';
+import { useCallback, useEffect } from 'react';
import useSWR from 'swr';
import type { FtsSearchResult } from '@/database/repositories/ftsSearch';
@@ -19,13 +19,10 @@ import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/selectors';
import { useGlobalStore } from '@/store/global';
import { globalHelpers } from '@/store/global/helpers';
-import { useUserStore } from '@/store/user';
-import { labPreferSelectors } from '@/store/user/selectors';
import { openTrustedExternalUrl } from '@/utils/openTrustedExternalUrl';
import { useCommandMenuContext } from './CommandMenuContext';
import { type ThemeMode } from './types';
-import { withoutGatedGoals } from './utils/goalResults';
/**
* Shared methods for CommandMenu
@@ -63,16 +60,14 @@ export const useCommandMenu = () => {
// Search functionality
const hasSearch = debouncedSearch.trim().length > 0;
const searchQuery = debouncedSearch.trim();
- // Goals sit behind a lab: with it off the menu neither asks for them nor shows any.
- const goalsEnabled = useUserStore(labPreferSelectors.enableGoals);
const {
- data: rawSearchResults,
+ data: searchResults,
error: searchError,
isLoading: isSearching,
isValidating: isSearchValidating,
} = useSWR<FtsSearchResult[]>(
- hasSearch ? ['search', searchQuery, agentId, typeFilter, goalsEnabled] : null,
+ hasSearch ? ['search', searchQuery, agentId, typeFilter] : null,
async () => {
const locale = globalHelpers.getCurrentLanguage();
return lambdaClient.search.query.query({
@@ -83,7 +78,7 @@ export const useCommandMenu = () => {
includeMarketplace: false,
// Goals are not in the full-text index; the server looks them up by
// title/requirement only when asked, and the menu renders them.
- includeGoals: goalsEnabled,
+ includeGoals: true,
limitPerType: typeFilter ? 50 : 5, // Show more results when filtering by type
locale,
query: searchQuery,
@@ -95,10 +90,6 @@ export const useCommandMenu = () => {
revalidateOnReconnect: false,
},
);
- const searchResults = useMemo(
- () => withoutGatedGoals(rawSearchResults, goalsEnabled),
- [goalsEnabled, rawSearchResults],
- );
// Close on Escape key and prevent body scroll
useEffect(() => {
diff --git a/src/features/CommandMenu/utils/goalResults.test.ts b/src/features/CommandMenu/utils/goalResults.test.ts
index dff444d9f53..6d0131cff7b 100644
--- a/src/features/CommandMenu/utils/goalResults.test.ts
+++ b/src/features/CommandMenu/utils/goalResults.test.ts
@@ -1,25 +1,6 @@
import { describe, expect, it } from 'vitest';
-import { goalResultStatusKey, withoutGatedGoals } from './goalResults';
-
-const results = [
- { id: 'agt_1', title: 'Agent', type: 'agent' },
- { id: 'goal_1', status: 'running', title: 'Goal', type: 'goal' },
-] as any[];
-
-describe('withoutGatedGoals', () => {
- it('keeps goal results while the Goals lab is on', () => {
- expect(withoutGatedGoals(results, true)).toBe(results);
- });
-
- it('drops goal results while the Goals lab is off', () => {
- expect(withoutGatedGoals(results, false)?.map((r) => r.type)).toEqual(['agent']);
- });
-
- it('passes a missing response through', () => {
- expect(withoutGatedGoals(undefined, false)).toBeUndefined();
- });
-});
+import { goalResultStatusKey } from './goalResults';
describe('goalResultStatusKey', () => {
it('maps failed goals to the localized needs-attention label', () => {
diff --git a/src/features/CommandMenu/utils/goalResults.ts b/src/features/CommandMenu/utils/goalResults.ts
index 28ec2cfd1da..5ff4b553f15 100644
--- a/src/features/CommandMenu/utils/goalResults.ts
+++ b/src/features/CommandMenu/utils/goalResults.ts
@@ -1,19 +1,8 @@
import type { GoalStatus } from '@lobechat/const/goal';
import { goalStatuses } from '@lobechat/const/goal';
-import type { FtsSearchResult } from '@/database/repositories/ftsSearch';
import { goalStatusKey } from '@/features/AgentGoals/goalPresentation';
-/**
- * Goals sit behind a lab: with it off their routes redirect away, so the menu
- * shows none — an explicit `type:goal` search included.
- */
-export const withoutGatedGoals = (
- results: FtsSearchResult[] | undefined,
- goalsEnabled: boolean,
-): FtsSearchResult[] | undefined =>
- goalsEnabled || !results ? results : results.filter((result) => result.type !== 'goal');
-
/**
* The goal list's status label key for a search hit (`failed` reads as "Needs
* attention"), or `undefined` for a status this client does not know.
diff --git a/src/features/Conversation/ChatInput/LinkedGoalTray/index.tsx b/src/features/Conversation/ChatInput/LinkedGoalTray/index.tsx
index 24343359181..f1d8c25cf89 100644
--- a/src/features/Conversation/ChatInput/LinkedGoalTray/index.tsx
+++ b/src/features/Conversation/ChatInput/LinkedGoalTray/index.tsx
@@ -12,8 +12,6 @@ import GoalStatusGlyph from '@/features/AgentGoals/GoalStatusGlyph';
import type { GoalListItem } from '@/services/goal';
import { useChatStore } from '@/store/chat';
import { goalSelectors, useGoalStore } from '@/store/goal';
-import { useUserStore } from '@/store/user';
-import { labPreferSelectors } from '@/store/user/selectors';
import { densityTokens } from '@/styles/density.stylex';
import { dataSelectors, messageStateSelectors, useConversationStore } from '../../store';
@@ -135,12 +133,11 @@ interface LinkedGoalTrayProps {
/**
* The goals this conversation planned, floating above the composer with their
- * live status (behind the `enableGoals` lab). The conversation is the
+ * live status. The conversation is the
* goal's planning conversation, so its progress belongs here — clicking a row
* opens the whole goal in the Portal, beside the chat that shaped it.
*/
const LinkedGoalTray = memo<LinkedGoalTrayProps>(({ topAttached }) => {
- const enabled = useUserStore(labPreferSelectors.enableGoals);
const topicId = useConversationStore((s) => s.context.topicId);
const displayMessages = useConversationStore(dataSelectors.displayMessages);
const useFetchTopicGoals = useGoalStore((s) => s.useFetchTopicGoals);
@@ -152,27 +149,21 @@ const LinkedGoalTray = memo<LinkedGoalTrayProps>(({ topAttached }) => {
messageStateSelectors.isAIGenerating(s),
),
);
- const { error, revalidate } = useFetchTopicGoals(
- enabled ? topicId : undefined,
- goalRequestGenerating,
- );
+ const { error, revalidate } = useFetchTopicGoals(topicId, goalRequestGenerating);
const topicGoals = useGoalStore(goalSelectors.topicGoals(topicId));
const confirmed = useGoalStore(goalSelectors.topicGoalsConfirmed(topicId));
const confirmState = linkedGoalConfirmState(confirmed, error);
const retry = useCallback(() => void revalidate(), [revalidate]);
// Server-confirmed rows only, in both directions: a goal still pending in a
// tool result may not exist yet, and a cached empty list proves nothing.
- useMarkSidebarTopicGoal(
- enabled ? topicId : undefined,
- confirmed ? !!topicGoals?.length : undefined,
- );
+ useMarkSidebarTopicGoal(topicId, confirmed ? !!topicGoals?.length : undefined);
const goals = useMemo(
() => selectLinkedGoals(topicGoals, displayMessages),
[topicGoals, displayMessages],
);
- if (!enabled || !topicId || goals.length === 0) return null;
+ if (!topicId || goals.length === 0) return null;
return (
<Flexbox {...stylex.props(styles.container, topAttached && styles.containerTopAttached)}>
diff --git a/src/features/GlobalApprovalNotification/index.tsx b/src/features/GlobalApprovalNotification/index.tsx
index 7ba6c9466fb..6c6edd90f17 100644
--- a/src/features/GlobalApprovalNotification/index.tsx
+++ b/src/features/GlobalApprovalNotification/index.tsx
@@ -10,8 +10,6 @@ import { useTranslation } from 'react-i18next';
import { isDesktop } from '@/const/version';
import { usePermission } from '@/hooks/usePermission';
-import { useUserStore } from '@/store/user';
-import { labPreferSelectors } from '@/store/user/selectors';
import ApprovalCard from './ApprovalCard';
import GoalClarificationCard from './GoalClarificationCard';
@@ -48,9 +46,8 @@ const GlobalApprovalNotification = memo(() => {
// Goal asks the user waved off leave the island but stay in the Home inbox,
// so they are never lost — a run approval has no such fallback and stays.
// The server leaves dismissed asks out of both lists, on every client.
- const enableGoals = useUserStore(labPreferSelectors.enableGoals);
const { allowed: canAnswerGoals } = usePermission('create_content');
- const dismissKey = useIslandDismissals(enableGoals && canAnswerGoals);
+ const dismissKey = useIslandDismissals(canAnswerGoals);
// Confirm only once the server kept it; on failure the card comes back.
const dismiss = async (key: string) => {
try {
diff --git a/src/features/GlobalApprovalNotification/usePendingGoalClarifications.ts b/src/features/GlobalApprovalNotification/usePendingGoalClarifications.ts
index 6232195fd01..ca01ac327f3 100644
--- a/src/features/GlobalApprovalNotification/usePendingGoalClarifications.ts
+++ b/src/features/GlobalApprovalNotification/usePendingGoalClarifications.ts
@@ -6,8 +6,6 @@ import { usePermission } from '@/hooks/usePermission';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
import { useGoalStore } from '@/store/goal';
-import { useUserStore } from '@/store/user';
-import { labPreferSelectors } from '@/store/user/selectors';
export interface GoalClarificationGroup {
agentId: string | null;
@@ -47,11 +45,10 @@ export const selectIslandGoalClarifications = (
/** Goal clarification rounds the island should ask, oldest first. */
export const usePendingGoalClarifications = (): GoalClarificationGroup[] => {
- const enabled = useUserStore(labPreferSelectors.enableGoals);
// The same gate the goal page puts on its answer controls.
const { allowed: canAnswer } = usePermission('create_content');
const useFetchPendingClarifications = useGoalStore((s) => s.useFetchPendingClarifications);
- const { data } = useFetchPendingClarifications(enabled && canAnswer);
+ const { data } = useFetchPendingClarifications(canAnswer);
const { pathname } = useLocation();
const portalGoalId = useChatStore(chatPortalSelectors.goalPortalId);
diff --git a/src/features/GlobalApprovalNotification/usePendingGoalDecisions.ts b/src/features/GlobalApprovalNotification/usePendingGoalDecisions.ts
index 2756e00d590..306ef5a4a0f 100644
--- a/src/features/GlobalApprovalNotification/usePendingGoalDecisions.ts
+++ b/src/features/GlobalApprovalNotification/usePendingGoalDecisions.ts
@@ -7,8 +7,6 @@ import { usePermission } from '@/hooks/usePermission';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
import { useGoalStore } from '@/store/goal';
-import { useUserStore } from '@/store/user';
-import { labPreferSelectors } from '@/store/user/selectors';
import { goalIdFromPath } from './usePendingGoalClarifications';
@@ -75,10 +73,9 @@ export const selectIslandGoalItems = (
/** Goal gates and sign-offs the island should ask, oldest first. */
export const usePendingGoalDecisions = (): IslandGoalItem[] => {
- const enabled = useUserStore(labPreferSelectors.enableGoals);
const { allowed: canAnswer } = usePermission('create_content');
const useFetchPendingForIsland = useGoalStore((s) => s.useFetchPendingForIsland);
- const { data } = useFetchPendingForIsland(enabled && canAnswer);
+ const { data } = useFetchPendingForIsland(canAnswer);
const { pathname } = useLocation();
const portalGoalId = useChatStore(chatPortalSelectors.goalPortalId);
diff --git a/src/features/HomeInbox/index.tsx b/src/features/HomeInbox/index.tsx
index ff535d5fd1e..46de7018bba 100644
--- a/src/features/HomeInbox/index.tsx
+++ b/src/features/HomeInbox/index.tsx
@@ -24,7 +24,6 @@ import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useGoalStore } from '@/store/goal';
import { useUserStore } from '@/store/user';
-import { labPreferSelectors } from '@/store/user/selectors';
import { authSelectors, userProfileSelectors } from '@/store/user/slices/auth/selectors';
import { useDensityTokens } from '@/styles/density';
@@ -189,10 +188,8 @@ const HomeInbox = memo<HomeInboxProps>((props) => {
const shownNewsOffset = newsData ? resolveShownNewsOffset(newsData.day) : 0;
// Goals are the one home feed that is not about today: they run for days, so
- // the dashboard is where you check on them. Behind the same lab toggle as the
- // goal pages themselves — without it a row would navigate to a redirect.
- const goalsEnabled = useUserStore(labPreferSelectors.enableGoals);
- const showGoals = isLogin === true && goalsEnabled && showRailSections;
+ // the dashboard is where you check on them.
+ const showGoals = isLogin === true && showRailSections;
const useFetchHomeGoals = useGoalStore((s) => s.useFetchHomeGoals);
const goalsSWR = useFetchHomeGoals(showGoals, cacheScope);
// Read the replica view, not the hook: the persisted roll-up paints the rail
diff --git a/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts b/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts
index 0d25934d99c..5d7487e61f0 100644
--- a/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts
+++ b/src/features/HomeSidebar/Body/CustomizeSidebarModal.test.ts
@@ -42,11 +42,13 @@ describe('CustomizeSidebarModal', () => {
);
});
- 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);
- });
+ it.each([false, true])(
+ 'shows the separate Goals option only in workspace mode (%s)',
+ (workspace) => {
+ expect(getSortableSidebarItemIds(workspace).has('goals')).toBe(workspace);
+ expect(getSortableSidebarItemIds(workspace).has('tasks')).toBe(true);
+ },
+ );
it('offers Channels, hideable, only while Channels are enabled', () => {
expect(getSortableSidebarItemIds(false).has('channels')).toBe(false);
diff --git a/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx b/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx
index dbebcc947ba..1cfeb1413cb 100644
--- a/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx
+++ b/src/features/HomeSidebar/Body/CustomizeSidebarModal.tsx
@@ -49,12 +49,11 @@ import { systemStatusSelectors } from '@/store/global/selectors';
import {
DEFAULT_SIDEBAR_ITEMS,
getDefaultHiddenSections,
+ setSidebarSectionHidden,
SIDEBAR_ACCORDION_KEYS,
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';
import { densityTokens } from '@/styles/density.stylex';
// ---------------------------------------------------------------------------
@@ -90,24 +89,16 @@ const ALL_SIDEBAR_ITEMS: SidebarItemConfig[] = [
interface SidebarItemAvailability {
channelsEnabled?: boolean;
dashboardEnabled?: boolean;
- goalsEnabled?: boolean;
}
-// Dashboards also stay out until the `dashboard` feature flag is on for the
-// user, Channels until Channels are enabled, and Goals until the user turns on
-// its lab; a dropped id is restored by `withAllKnownKeys` once it is.
export const getAvailableSidebarItems = (
isWorkspaceMode: boolean,
- {
- channelsEnabled = false,
- dashboardEnabled = false,
- goalsEnabled = false,
- }: SidebarItemAvailability = {},
+ { channelsEnabled = false, dashboardEnabled = false }: SidebarItemAvailability = {},
): SidebarItemConfig[] =>
ALL_SIDEBAR_ITEMS.filter((item) => {
if (item.id === 'channels' && !channelsEnabled) return false;
+ if (!isWorkspaceMode && item.id === 'goals') return false;
if (item.id === 'dashboard' && !dashboardEnabled) return false;
- if (item.id === 'goals' && !goalsEnabled) return false;
if (isWorkspaceMode && (item.id === 'memory' || item.id === 'dashboard')) return false;
return true;
});
@@ -191,10 +182,11 @@ const styles = stylex.create({
const SortableItem = memo<{
hiddenSections: string[];
+ personal: boolean;
id: string;
onToggle: (key: string) => void;
-}>(({ id, hiddenSections, onToggle }) => {
- const { t } = useTranslation(['common', 'channel']);
+}>(({ id, hiddenSections, onToggle, personal }) => {
+ const { t } = useTranslation(['common', 'channel', 'chat']);
const item = ITEM_MAP.get(id);
const labelKey = item?.labelKey;
const {
@@ -240,7 +232,11 @@ const SortableItem = memo<{
<Icon icon={GripVertical} size={14} style={{ color: cssVar.colorTextQuaternary }} />
</Flexbox>
{route?.icon && <Icon icon={route.icon} size={18} />}
- <Text>{t(labelKey as any, { ns: item.labelNs ?? 'common' })}</Text>
+ <Text>
+ {personal && id === 'tasks'
+ ? t('tab.goalsAndTasks', { ns: 'chat' })
+ : t(labelKey as any, { ns: item.labelNs ?? 'common' })}
+ </Text>
</Flexbox>
{item.alwaysVisible ? (
<Tooltip title={t('navPanel.pinned' as any)}>
@@ -348,8 +344,8 @@ const AccordionGroup = memo<{ children: React.ReactNode }>(({ children }) => {
// Drag overlay item (static, no sortable hooks)
// ---------------------------------------------------------------------------
-const OverlayItem = memo<{ id: string }>(({ id }) => {
- const { t } = useTranslation(['common', 'channel']);
+const OverlayItem = memo<{ id: string; personal: boolean }>(({ id, personal }) => {
+ const { t } = useTranslation(['common', 'channel', 'chat']);
const agentLabelKey = 'navPanel.agent';
// Accordion group overlay: render a compact representation
@@ -395,7 +391,11 @@ const OverlayItem = memo<{ id: string }>(({ id }) => {
<Flexbox horizontal align={'center'} className={stylex.props(styles.overlay).className} gap={8}>
<Icon icon={GripVertical} size={14} style={{ color: cssVar.colorTextQuaternary }} />
{route?.icon && <Icon icon={route.icon} size={18} />}
- <Text>{t(labelKey as any, { ns: labelNs })}</Text>
+ <Text>
+ {personal && id === 'tasks'
+ ? t('tab.goalsAndTasks', { ns: 'chat' })
+ : t(labelKey as any, { ns: labelNs })}
+ </Text>
</Flexbox>
);
});
@@ -423,16 +423,14 @@ const CustomizeSidebarContent = memo(() => {
const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
const isWorkspaceMode = !!useActiveWorkspaceSlug();
const dashboardEnabled = useServerConfigStore(serverConfigSelectors.enableDashboard);
- const goalsEnabled = useUserStore(labPreferSelectors.enableGoals);
const channelsEnabled = useChannelsEnabled();
const sortableItemIds = useMemo(
() =>
getSortableSidebarItemIds(isWorkspaceMode, {
channelsEnabled,
dashboardEnabled,
- goalsEnabled,
}),
- [isWorkspaceMode, channelsEnabled, dashboardEnabled, goalsEnabled],
+ [isWorkspaceMode, channelsEnabled, dashboardEnabled],
);
const filteredStoreItems = useMemo(
() => storeItems.filter((id) => sortableItemIds.has(id)),
@@ -478,12 +476,10 @@ const CustomizeSidebarContent = memo(() => {
const toggleSection = useCallback(
(key: string) => {
const isHidden = hiddenSections.includes(key);
- const newHidden = isHidden
- ? hiddenSections.filter((k) => k !== key)
- : [...hiddenSections, key];
+ const newHidden = setSidebarSectionHidden(hiddenSections, key, !isHidden, isWorkspaceMode);
setHiddenSections(newHidden);
},
- [hiddenSections],
+ [hiddenSections, isWorkspaceMode],
);
const handleResetDefault = useCallback(() => {
@@ -579,7 +575,13 @@ const CustomizeSidebarContent = memo(() => {
isSpacer(id) ? (
<SpacerSortableItem key={id} />
) : (
- <SortableItem hiddenSections={hiddenSections} id={id} key={id} onToggle={toggleSection} />
+ <SortableItem
+ hiddenSections={hiddenSections}
+ id={id}
+ key={id}
+ personal={!isWorkspaceMode}
+ onToggle={toggleSection}
+ />
);
return (
@@ -610,7 +612,7 @@ const CustomizeSidebarContent = memo(() => {
{createPortal(
<DragOverlay dropAnimation={{ sideEffects: defaultDropAnimationSideEffects({}) }}>
- {activeId ? <OverlayItem id={activeId} /> : null}
+ {activeId ? <OverlayItem id={activeId} personal={!isWorkspaceMode} /> : null}
</DragOverlay>,
document.body,
)}
diff --git a/src/features/HomeSidebar/Body/index.tsx b/src/features/HomeSidebar/Body/index.tsx
index 0d9be357dd3..c16709976d7 100644
--- a/src/features/HomeSidebar/Body/index.tsx
+++ b/src/features/HomeSidebar/Body/index.tsx
@@ -19,7 +19,7 @@ import { useNavLayout } from '@/hooks/useNavLayout';
import type { NativeContextMenuItem } from '@/libs/contextMenu/types';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
-import { SIDEBAR_SPACER_ID } from '@/store/global/selectors/systemStatus';
+import { setSidebarSectionHidden, SIDEBAR_SPACER_ID } from '@/store/global/selectors/systemStatus';
import { useUserStore } from '@/store/user';
import { isModifierClick } from '@/utils/navigation';
@@ -97,9 +97,16 @@ const Body = memo(() => {
const hideSection = useCallback(
(key: string) => {
- updateSystemStatus({ hiddenSidebarSections: [...hiddenSections, key] });
+ updateSystemStatus({
+ hiddenSidebarSections: setSidebarSectionHidden(
+ hiddenSections,
+ key,
+ true,
+ !!activeWorkspaceId,
+ ),
+ });
},
- [hiddenSections, updateSystemStatus],
+ [activeWorkspaceId, hiddenSections, updateSystemStatus],
);
const getContextMenuItems = useCallback(
@@ -162,7 +169,6 @@ const Body = memo(() => {
}}
>
<NavItem
- active={tab === (navItem.activeTab ?? key)}
contextMenuItems={getContextMenuItems(key)}
icon={navItem.icon}
title={navItem.title}
@@ -171,6 +177,9 @@ const Body = memo(() => {
<ActionIcon icon={MoreHorizontalIcon} size={'small'} style={{ flex: 'none' }} />
</DropdownMenu>
}
+ active={
+ tab === (navItem.activeTab ?? key) || navItem.additionalActiveTabs?.includes(tab)
+ }
/>
</WorkspaceLink>
);
diff --git a/src/features/MobileHome/useFeatureNavItems.test.ts b/src/features/MobileHome/useFeatureNavItems.test.ts
index 5468f253063..a9fcd576928 100644
--- a/src/features/MobileHome/useFeatureNavItems.test.ts
+++ b/src/features/MobileHome/useFeatureNavItems.test.ts
@@ -19,6 +19,9 @@ vi.mock('@/hooks/useNavLayout', () => ({
{ icon: SearchIcon, key: 'search', onClick: vi.fn(), title: 'Search' },
{ icon: HomeIcon, key: 'home', title: 'Home', url: '/' },
{ icon: ListTodo, key: 'tasks', title: 'Tasks', url: '/tasks' },
+ ...(mocks.workspaceSlug
+ ? [{ icon: Target, key: 'goals', title: 'Goals', url: '/goals' }]
+ : []),
// `useNavLayout` hides projects while the lab is off.
{
hidden: !mocks.enableProjects,
@@ -27,8 +30,6 @@ vi.mock('@/hooks/useNavLayout', () => ({
title: 'Projects',
url: '/projects',
},
- // `useNavLayout` hides goals while the lab is off.
- { hidden: true, icon: Target, key: 'goals', title: 'Goals', url: '/goals' },
],
}),
}));
@@ -60,7 +61,7 @@ describe('useFeatureNavItems', () => {
it('adds the workspace settings entry inside a workspace', () => {
mocks.workspaceSlug = 'acme';
- expect(keysOf()).toEqual(['tasks', 'pages', 'settings']);
+ expect(keysOf()).toEqual(['tasks', 'goals', 'pages', 'settings']);
});
it('gives every item a destination the shortcut can navigate to', () => {
diff --git a/src/features/Settings/labs/features.test.ts b/src/features/Settings/labs/features.test.ts
index 52bbb5b5a22..69f57e88c32 100644
--- a/src/features/Settings/labs/features.test.ts
+++ b/src/features/Settings/labs/features.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest';
import { filterAvailableLabFeatures, type LabFeatureItem } from './features';
const features: LabFeatureItem[] = [
- { flag: 'enableGoals', i18nKey: 'goals', searchKeywords: [], stage: 'beta' },
+ { flag: 'enableEvalCapture', i18nKey: 'evalCapture', searchKeywords: [], stage: 'beta' },
{
businessOnly: true,
flag: 'enableTopicBugReport',
@@ -16,13 +16,13 @@ const features: LabFeatureItem[] = [
describe('filterAvailableLabFeatures', () => {
it('hides business-only experiments when business features are off', () => {
expect(filterAvailableLabFeatures(features, false).map(({ flag }) => flag)).toEqual([
- 'enableGoals',
+ 'enableEvalCapture',
]);
});
it('offers business-only experiments when business features are on', () => {
expect(filterAvailableLabFeatures(features, true).map(({ flag }) => flag)).toEqual([
- 'enableGoals',
+ 'enableEvalCapture',
'enableTopicBugReport',
]);
});
diff --git a/src/features/Settings/labs/features.ts b/src/features/Settings/labs/features.ts
index 2a04db8326a..1492ad6996c 100644
--- a/src/features/Settings/labs/features.ts
+++ b/src/features/Settings/labs/features.ts
@@ -23,7 +23,6 @@ type LabFeatureI18nKey =
| 'desktopSplitView'
| 'deviceTunnel'
| 'evalCapture'
- | 'goals'
| 'heteroSessionImport'
| 'imessage'
| 'messageTextSelectionActions'
@@ -107,12 +106,6 @@ const ALL_LAB_FEATURES: LabFeatureItem[] = [
searchKeywords: ['bug', 'report', 'feedback', 'issue', 'support'],
stage: 'alpha',
},
- {
- flag: 'enableGoals',
- i18nKey: 'goals',
- searchKeywords: ['goal', 'goals', 'objective'],
- stage: 'beta',
- },
{
flag: 'enableDeviceTunnel',
i18nKey: 'deviceTunnel',
diff --git a/src/features/Settings/labs/index.test.tsx b/src/features/Settings/labs/index.test.tsx
index b093a67f50a..79118850576 100644
--- a/src/features/Settings/labs/index.test.tsx
+++ b/src/features/Settings/labs/index.test.tsx
@@ -173,8 +173,8 @@ describe('Labs settings page', () => {
const claudeCodeSdk = screen.getByText('features.claudeCodeSdk.title');
expect(within(claudeCodeSdk).getByText('stage.alpha.label')).toBeDefined();
- const goals = screen.getByText('features.goals.title');
- expect(within(goals).getByText('stage.beta.label')).toBeDefined();
+ const oauthApps = screen.getByText('features.oauthApps.title');
+ expect(within(oauthApps).getByText('stage.beta.label')).toBeDefined();
});
it('explains what each stage means via the tag tooltip', () => {
diff --git a/src/hooks/useNavLayout.test.tsx b/src/hooks/useNavLayout.test.tsx
index 1538ff4e606..cee2ba958e7 100644
--- a/src/hooks/useNavLayout.test.tsx
+++ b/src/hooks/useNavLayout.test.tsx
@@ -8,7 +8,6 @@ interface GlobalStateMock {
const mocks = vi.hoisted(() => ({
activeWorkspaceSlug: null as string | null,
enableDashboard: false,
- enableGoals: false,
showMarket: true,
}));
@@ -33,13 +32,12 @@ 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),
+ useUserStore: () => false,
}));
vi.mock('@/store/user/selectors', () => ({
- labPreferSelectors: { enableGoals: ENABLE_GOALS },
+ labPreferSelectors: { enableProjects: vi.fn() },
}));
vi.mock('@/business/client/hooks/useActiveWorkspaceSlug', () => ({
@@ -51,7 +49,6 @@ describe('useNavLayout', () => {
mocks.activeWorkspaceSlug = null;
mocks.showMarket = true;
mocks.enableDashboard = false;
- mocks.enableGoals = false;
});
const dashboardItem = async () => {
@@ -78,14 +75,11 @@ describe('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;
+ it('merges Goals into Tasks in personal mode and keeps both workspace destinations', async () => {
+ expect(await goalsItem()).toBeUndefined();
+ mocks.activeWorkspaceSlug = 'acme';
const item = await goalsItem();
- expect(item?.hidden).toBe(false);
+ expect(item?.hidden).not.toBe(true);
expect(item?.url).toBe('/goals');
const { useNavLayout } = await import('./useNavLayout');
diff --git a/src/hooks/useNavLayout.ts b/src/hooks/useNavLayout.ts
index 889cfd663a7..bc8d5987230 100644
--- a/src/hooks/useNavLayout.ts
+++ b/src/hooks/useNavLayout.ts
@@ -18,6 +18,7 @@ import { labPreferSelectors } from '@/store/user/selectors';
export interface NavItem {
/** First path segment that marks this item active, when it differs from `key`. */
activeTab?: string;
+ additionalActiveTabs?: string[];
hidden?: boolean;
icon: any;
isNew?: boolean;
@@ -43,12 +44,11 @@ export interface NavLayout {
}
export const useNavLayout = (): NavLayout => {
- const { t } = useTranslation('common');
+ const { t } = useTranslation(['common', 'chat']);
const toggleCommandMenu = useGlobalStore((s) => s.toggleCommandMenu);
const { showMarket, hideGitHub } = useServerConfigStore(featureFlagsSelectors);
const activeWorkspaceSlug = useActiveWorkspaceSlug();
const enableDashboard = useServerConfigStore(serverConfigSelectors.enableDashboard);
- const enableGoals = useUserStore(labPreferSelectors.enableGoals);
const enableProjects = useUserStore(labPreferSelectors.enableProjects);
const topNavItems = useMemo(
@@ -68,18 +68,21 @@ export const useNavLayout = (): NavLayout => {
},
{
icon: getRouteById('tasks')!.icon,
+ additionalActiveTabs: activeWorkspaceSlug ? undefined : ['goals', 'goal', 'task'],
key: SidebarTabKey.Tasks,
- title: t('tab.tasks'),
+ title: activeWorkspaceSlug ? t('tab.tasks') : t('tab.goalsAndTasks', { ns: 'chat' }),
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',
- },
+ ...(activeWorkspaceSlug
+ ? [
+ {
+ icon: getRouteById('goals')!.icon,
+ key: SidebarTabKey.Goals,
+ title: t('tab.goals'),
+ url: '/goals',
+ },
+ ]
+ : []),
{
// Keyed `project` to match the sidebar layout id; the page is `/projects`.
activeTab: 'projects',
@@ -105,7 +108,7 @@ export const useNavLayout = (): NavLayout => {
url: '/resource',
},
] as NavItem[],
- [t, toggleCommandMenu, activeWorkspaceSlug, enableDashboard, enableGoals, enableProjects],
+ [t, toggleCommandMenu, activeWorkspaceSlug, enableDashboard, enableProjects],
);
const bottomMenuItems = useMemo(
diff --git a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx
index e6702d3a58f..4a33775111e 100644
--- a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx
+++ b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx
@@ -13,8 +13,6 @@ import SubmenuChevron from '@/features/ChatInput/ActionBar/components/SubmenuChe
import { insertGoalTag } from '@/features/ChatInput/InputEditor/ActionTag/goalTag';
import { useChatInputStore } from '@/features/ChatInput/store';
import { useConversationStore } from '@/features/Conversation';
-import { useUserStore } from '@/store/user';
-import { labPreferSelectors } from '@/store/user/selectors';
import { OFFSETS_IN_HOURS, resolveScheduleTime } from './scheduleTime';
import { useHeteroUpload } from './useHeteroUpload';
@@ -64,7 +62,6 @@ const HeteroPlus = memo<HeteroPlusProps>(({ providerType }) => {
const scheduledSendAt = useConversationStore((s) => s.scheduledSendAt);
const setScheduledSendAt = useConversationStore((s) => s.setScheduledSendAt);
- const enableGoals = useUserStore(labPreferSelectors.enableGoals);
const closeMenu = useCallback(() => setOpen(false), []);
const { beforeUpload, onFiles } = useHeteroUpload(providerType, closeMenu);
@@ -130,21 +127,17 @@ const HeteroPlus = memo<HeteroPlusProps>(({ providerType }) => {
type: 'switch',
},
// Goal creation shares the standard input's goal chip.
- ...(enableGoals
- ? ([
- { type: 'divider' },
- {
- icon: TargetIcon,
- key: 'set-topic-goal',
- // Same string as the chip it inserts — see the agent composer's Plus.
- label: tEditor('slash.goal'),
- onClick: () => {
- setOpen(false);
- insertGoalTag(editor, tEditor('slash.goal'));
- },
- },
- ] as ActionDropdownMenuItems)
- : []),
+ { type: 'divider' },
+ {
+ icon: TargetIcon,
+ key: 'set-topic-goal',
+ // Same string as the chip it inserts — see the agent composer's Plus.
+ label: tEditor('slash.goal'),
+ onClick: () => {
+ setOpen(false);
+ insertGoalTag(editor, tEditor('slash.goal'));
+ },
+ },
];
}, [
t,
@@ -153,7 +146,6 @@ const HeteroPlus = memo<HeteroPlusProps>(({ providerType }) => {
setShowTypoBar,
armSchedule,
scheduledSendAt,
- enableGoals,
editor,
beforeUpload,
onFiles,
diff --git a/src/routes/(main)/agent/goal/[goalId]/index.tsx b/src/routes/(main)/agent/goal/[goalId]/index.tsx
index 83db47b869c..8023718cdff 100644
--- a/src/routes/(main)/agent/goal/[goalId]/index.tsx
+++ b/src/routes/(main)/agent/goal/[goalId]/index.tsx
@@ -1,29 +1,13 @@
'use client';
-import { memo, useEffect } from 'react';
+import { memo } from 'react';
import { useParams } from 'react-router';
-import GoalDetailSkeleton from '@/components/Skeleton/GoalDetail';
import { GoalDetailPage } from '@/features/AgentGoals';
-import { useAgentLabGate } from '@/features/AgentGoals/useAgentLabGate';
-import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
const GoalDetailRoute = memo(() => {
const { aid, goalId } = useParams<{ aid?: string; goalId?: string }>();
- const navigate = useWorkspaceAwareNavigate();
- const { enabled, initFailed, isPreferenceInit, shouldRedirect } = useAgentLabGate();
-
- useEffect(() => {
- if (aid && shouldRedirect) navigate(`/agent/${aid}`, { replace: true });
- }, [aid, navigate, shouldRedirect]);
-
if (!aid || !goalId) return null;
- // Preference still loading: the gate cannot be judged yet, so hold the page
- // skeleton instead of painting nothing (the white flash) or redirecting.
- // A failed user-state init keeps the legacy escape: fall through to the
- // redirect below rather than an endless skeleton.
- if (!isPreferenceInit && !initFailed) return <GoalDetailSkeleton />;
- if (!enabled) return null;
return <GoalDetailPage agentId={aid} goalId={goalId} />;
});
diff --git a/src/routes/(main)/agent/goals/index.tsx b/src/routes/(main)/agent/goals/index.tsx
index 65467977bbb..e92bc757e82 100644
--- a/src/routes/(main)/agent/goals/index.tsx
+++ b/src/routes/(main)/agent/goals/index.tsx
@@ -1,29 +1,13 @@
'use client';
-import { memo, useEffect } from 'react';
+import { memo } from 'react';
import { useParams } from 'react-router';
-import GoalSkeleton from '@/components/Skeleton/Goal';
import { AgentGoalsPage } from '@/features/AgentGoals';
-import { useAgentLabGate } from '@/features/AgentGoals/useAgentLabGate';
-import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
const AgentGoalsRoute = memo(() => {
const { aid } = useParams<{ aid?: string }>();
- const navigate = useWorkspaceAwareNavigate();
- const { enabled, initFailed, isPreferenceInit, shouldRedirect } = useAgentLabGate();
-
- useEffect(() => {
- if (aid && shouldRedirect) navigate(`/agent/${aid}`, { replace: true });
- }, [aid, navigate, shouldRedirect]);
-
if (!aid) return null;
- // Preference still loading: the gate cannot be judged yet, so hold the page
- // skeleton instead of painting nothing (the white flash) or redirecting.
- // A failed user-state init keeps the legacy escape: fall through to the
- // redirect below rather than an endless skeleton.
- if (!isPreferenceInit && !initFailed) return <GoalSkeleton />;
- if (!enabled) return null;
return <AgentGoalsPage agentId={aid} />;
});
diff --git a/src/routes/(main)/goals/index.tsx b/src/routes/(main)/goals/index.tsx
index 765363e56b1..f989f10cff2 100644
--- a/src/routes/(main)/goals/index.tsx
+++ b/src/routes/(main)/goals/index.tsx
@@ -1,27 +1,3 @@
'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;
+export { AgentGoalsPage as default } from '@/features/AgentGoals';
diff --git a/src/store/global/selectors/systemStatus.test.ts b/src/store/global/selectors/systemStatus.test.ts
index ee89efa5d6a..899ef8ee7e0 100644
--- a/src/store/global/selectors/systemStatus.test.ts
+++ b/src/store/global/selectors/systemStatus.test.ts
@@ -14,6 +14,7 @@ import {
readOverridableField,
reorderSidebarItems,
routeOverlayWrites,
+ setSidebarSectionHidden,
SIDEBAR_SPACER_ID,
systemStatusSelectors,
} from './systemStatus';
@@ -733,6 +734,21 @@ describe('systemStatusSelectors', () => {
]);
});
+ it('keeps the merged personal entry visible if either old entry was visible', () => {
+ const personalHidden = (keys: string[]) =>
+ systemStatusSelectors.hiddenSidebarSections(null)(
+ merge(initialState, {
+ status: { hiddenSidebarSections: keys },
+ }),
+ );
+ expect(personalHidden(['tasks'])).not.toContain('tasks');
+ expect(personalHidden(['goals'])).not.toContain('tasks');
+ const hidden = setSidebarSectionHidden(['recents'], 'tasks', true, false);
+ expect(personalHidden(hidden)).toContain('tasks');
+ expect(setSidebarSectionHidden(hidden, 'tasks', false, false)).toEqual(['recents']);
+ expect(setSidebarSectionHidden([], 'tasks', true, true)).toEqual(['tasks']);
+ });
+
it('hiddenSidebarSections prefers overlay in workspace mode', () => {
expect(systemStatusSelectors.hiddenSidebarSections('ws-1')(stateWithOverlay)).toEqual([
'recents',
diff --git a/src/store/global/selectors/systemStatus.ts b/src/store/global/selectors/systemStatus.ts
index bcffb6ef529..81f42e0d7c0 100644
--- a/src/store/global/selectors/systemStatus.ts
+++ b/src/store/global/selectors/systemStatus.ts
@@ -199,6 +199,18 @@ export const WORKSPACE_DEFAULT_HIDDEN_SECTIONS: string[] = ['recents'];
export const getDefaultHiddenSections = (isWorkspaceMode: boolean): string[] =>
isWorkspaceMode ? [...WORKSPACE_DEFAULT_HIDDEN_SECTIONS] : DEFAULT_HIDDEN_SECTIONS;
+/** A personal sidebar has one control for the two previously independent entries. */
+export const setSidebarSectionHidden = (
+ hidden: string[],
+ key: string,
+ hide: boolean,
+ workspace: boolean,
+): string[] => {
+ const keys = !workspace && key === 'tasks' ? ['tasks', 'goals'] : [key];
+ const remaining = hidden.filter((item) => !keys.includes(item));
+ return hide ? [...remaining, ...keys] : remaining;
+};
+
const hiddenSidebarSections =
(workspaceId: string | null) =>
(s: GlobalState): string[] => {
@@ -216,7 +228,13 @@ const hiddenSidebarSections =
}
return merged;
}
- return normalizeLegacyHiddenSections(s.status.hiddenSidebarSections ?? DEFAULT_HIDDEN_SECTIONS);
+ const hidden = normalizeLegacyHiddenSections(
+ s.status.hiddenSidebarSections ?? DEFAULT_HIDDEN_SECTIONS,
+ );
+ // Keep the combined entry reachable if either destination was visible before the merge.
+ return hidden.includes('tasks') && !hidden.includes('goals')
+ ? hidden.filter((key) => key !== 'tasks')
+ : hidden;
};
const sidebarExpandedKeys =
diff --git a/src/store/user/slices/preference/action.test.ts b/src/store/user/slices/preference/action.test.ts
index 148a3b31ddb..5247c083399 100644
--- a/src/store/user/slices/preference/action.test.ts
+++ b/src/store/user/slices/preference/action.test.ts
@@ -32,7 +32,7 @@ describe('createPreferenceSlice', () => {
});
describe('updateLab', () => {
- it('mirrors enableGoals into the legacy enableTopicAcceptance key for older clients', async () => {
+ it('preserves other saved preferences when updating a lab', async () => {
const updatePreferenceSpy = vi
.spyOn(userService, 'updatePreference')
.mockResolvedValue(undefined as any);
@@ -47,16 +47,16 @@ describe('createPreferenceSlice', () => {
});
await act(async () => {
- await useUserStore.getState().updateLab({ enableGoals: false });
+ await useUserStore.getState().updateLab({ enableProjects: false });
});
expect(useUserStore.getState().preference.lab).toMatchObject({
- enableGoals: false,
- enableTopicAcceptance: false,
+ enableProjects: false,
+ enableTopicAcceptance: true,
});
expect(updatePreferenceSpy).toHaveBeenCalledWith(
expect.objectContaining({
- lab: expect.objectContaining({ enableGoals: false, enableTopicAcceptance: false }),
+ lab: expect.objectContaining({ enableProjects: false, enableTopicAcceptance: true }),
}),
);
});
diff --git a/src/store/user/slices/preference/action.ts b/src/store/user/slices/preference/action.ts
index 618a31c10da..6206c9b653d 100644
--- a/src/store/user/slices/preference/action.ts
+++ b/src/store/user/slices/preference/action.ts
@@ -31,11 +31,7 @@ export class PreferenceActionImpl {
updateLab = async (lab: Partial<UserLab>, action?: any): Promise<void> => {
const { updatePreference } = this.#get();
- // Older clients still read the pre-rename `enableTopicAcceptance` key, so keep
- // it in step with `enableGoals` until they age out.
- const patch =
- lab.enableGoals === undefined ? lab : { ...lab, enableTopicAcceptance: lab.enableGoals };
- const nextLab = merge(this.#get().preference.lab, patch);
+ const nextLab = merge(this.#get().preference.lab, lab);
await updatePreference({ lab: nextLab }, action || n('updateLab'));
};
diff --git a/src/store/user/slices/preference/selectors/labPrefer.test.ts b/src/store/user/slices/preference/selectors/labPrefer.test.ts
deleted file mode 100644
index 16dccbaaead..00000000000
--- a/src/store/user/slices/preference/selectors/labPrefer.test.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import { type UserState } from '@/store/user/initialState';
-
-import { labPreferSelectors } from './labPrefer';
-
-const stateWithLab = (lab: Record<string, boolean>) => ({ preference: { lab } }) as UserState;
-
-describe('labPreferSelectors.enableGoals', () => {
- it('is off by default', () => {
- expect(labPreferSelectors.enableGoals(stateWithLab({}))).toBe(false);
- });
-
- it('keeps users who opted in under the legacy enableTopicAcceptance key', () => {
- expect(labPreferSelectors.enableGoals(stateWithLab({ enableTopicAcceptance: true }))).toBe(
- true,
- );
- });
-
- // This client writes both keys, while older clients write only the legacy
- // one — so when they disagree, the legacy key holds the latest choice.
- it('honours an older client turning Goals off through the legacy key', () => {
- expect(
- labPreferSelectors.enableGoals(
- stateWithLab({ enableGoals: true, enableTopicAcceptance: false }),
- ),
- ).toBe(false);
- });
-
- it('reads the new key when the legacy one was never written', () => {
- expect(labPreferSelectors.enableGoals(stateWithLab({ enableGoals: true }))).toBe(true);
- });
-});
diff --git a/src/store/user/slices/preference/selectors/labPrefer.ts b/src/store/user/slices/preference/selectors/labPrefer.ts
index 7df71cc7a17..da1b76b97c6 100644
--- a/src/store/user/slices/preference/selectors/labPrefer.ts
+++ b/src/store/user/slices/preference/selectors/labPrefer.ts
@@ -29,10 +29,6 @@ export const labPreferSelectors = {
enableOAuthApps: (s: UserState): boolean => s.preference.lab?.enableOAuthApps ?? false,
enableSelfLearning: (s: UserState): boolean => s.preference.lab?.enableSelfLearning ?? false,
enableProjects: (s: UserState): boolean => s.preference.lab?.enableProjects ?? false,
- // `updateLab` writes both keys, but older clients only write the legacy
- // `enableTopicAcceptance` — so while both exist it holds the latest choice.
- enableGoals: (s: UserState): boolean =>
- s.preference.lab?.enableTopicAcceptance ?? s.preference.lab?.enableGoals ?? false,
enableTaskVerify: (s: UserState): boolean => s.preference.lab?.enableTaskVerify ?? false,
enableTopicBugReport: (s: UserState): boolean => s.preference.lab?.enableTopicBugReport ?? false,
};