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.

πŸ’„ style(goal): goal portal header β€” more menu on the left, expand on the right (#19963)

Arvin Xu5a803fdfe53f
diff --git a/src/features/AgentGoals/GoalDetailActions.tsx b/src/features/AgentGoals/GoalDetailActions.tsx
index 3eb3d322f3e..a7d18f84c94 100644
--- a/src/features/AgentGoals/GoalDetailActions.tsx
+++ b/src/features/AgentGoals/GoalDetailActions.tsx
@@ -19,82 +19,90 @@ interface GoalDetailActionsProps {
/** Absent for a goal with no responsible agent β€” e.g. one created from a project. */
agentId?: string;
goalId: string;
+ /** Replaces the default redirect to the goal list, for hosts that are not the goal page. */
+ onDeleted?: () => void;
projectId?: string | null;
}
-const GoalDetailActions = memo<GoalDetailActionsProps>(({ agentId, goalId, projectId }) => {
- const { t } = useTranslation(['chat', 'common']);
- const navigate = useWorkspaceAwareNavigate();
- const { allowed: canEditTask } = usePermission('create_content');
- const deleteGoal = useGoalStore((s) => s.deleteGoal);
- // Not `window.location.href`: on desktop that is the `app://renderer` shell
- // origin (and the shell location does not track the active tab) β€” build the
- // shareable web URL from the app origin and the goal route explicitly.
- const appOrigin = useAppOrigin();
- const shareUrl = appOrigin
- ? `${appOrigin}${agentId ? `/agent/${agentId}/goal/${goalId}` : `/goal/${goalId}`}`
- : undefined;
+const GoalDetailActions = memo<GoalDetailActionsProps>(
+ ({ agentId, goalId, onDeleted, projectId }) => {
+ const { t } = useTranslation(['chat', 'common']);
+ const navigate = useWorkspaceAwareNavigate();
+ const { allowed: canEditTask } = usePermission('create_content');
+ const deleteGoal = useGoalStore((s) => s.deleteGoal);
+ // Not `window.location.href`: on desktop that is the `app://renderer` shell
+ // origin (and the shell location does not track the active tab) β€” build the
+ // shareable web URL from the app origin and the goal route explicitly.
+ const appOrigin = useAppOrigin();
+ const shareUrl = appOrigin
+ ? `${appOrigin}${agentId ? `/agent/${agentId}/goal/${goalId}` : `/goal/${goalId}`}`
+ : undefined;
- const items = useMemo<DropdownItem[]>(
- () => [
- {
- icon: <Icon icon={CopyIcon} />,
- key: 'copyId',
- label: t('taskList.contextMenu.copyId'),
- onClick: async () => {
- await copyToClipboard(goalId);
- toast.success(t('taskList.contextMenu.copyIdSuccess'));
+ const items = useMemo<DropdownItem[]>(
+ () => [
+ {
+ icon: <Icon icon={CopyIcon} />,
+ key: 'copyId',
+ label: t('taskList.contextMenu.copyId'),
+ onClick: async () => {
+ await copyToClipboard(goalId);
+ toast.success(t('taskList.contextMenu.copyIdSuccess'));
+ },
},
- },
- {
- disabled: !shareUrl,
- icon: <Icon icon={LinkIcon} />,
- key: 'copyLink',
- label: t('taskList.contextMenu.copyLink'),
- onClick: async () => {
- if (!shareUrl) return;
- await copyToClipboard(shareUrl);
- toast.success(t('taskList.contextMenu.copyLinkSuccess'));
+ {
+ disabled: !shareUrl,
+ icon: <Icon icon={LinkIcon} />,
+ key: 'copyLink',
+ label: t('taskList.contextMenu.copyLink'),
+ onClick: async () => {
+ if (!shareUrl) return;
+ await copyToClipboard(shareUrl);
+ toast.success(t('taskList.contextMenu.copyLinkSuccess'));
+ },
},
- },
- { type: 'divider' },
- {
- danger: true,
- disabled: !canEditTask,
- icon: <Icon icon={TrashIcon} />,
- key: 'delete',
- label: t('delete', { ns: 'common' }),
- onClick: () => {
- confirmModal({
- content: t('goalDetail.deleteConfirm.content'),
- okButtonProps: { danger: true },
- okText: t('goalDetail.deleteConfirm.ok'),
- onOk: async () => {
- // Mirrors the list scope the goal was rendered under, so the page
- // the user lands on is the one whose cache was just refreshed.
- await deleteGoal(agentId, goalId, projectId ? `project:${projectId}` : undefined);
- navigate(
- agentId
- ? `/agent/${agentId}/goals`
- : projectId
- ? `/project/${projectId}/goals`
- : '/',
- );
- },
- title: t('goalDetail.deleteConfirm.title'),
- });
+ { type: 'divider' },
+ {
+ danger: true,
+ disabled: !canEditTask,
+ icon: <Icon icon={TrashIcon} />,
+ key: 'delete',
+ label: t('delete', { ns: 'common' }),
+ onClick: () => {
+ confirmModal({
+ content: t('goalDetail.deleteConfirm.content'),
+ okButtonProps: { danger: true },
+ okText: t('goalDetail.deleteConfirm.ok'),
+ onOk: async () => {
+ // Mirrors the list scope the goal was rendered under, so the page
+ // the user lands on is the one whose cache was just refreshed.
+ await deleteGoal(agentId, goalId, projectId ? `project:${projectId}` : undefined);
+ if (onDeleted) {
+ onDeleted();
+ return;
+ }
+ navigate(
+ agentId
+ ? `/agent/${agentId}/goals`
+ : projectId
+ ? `/project/${projectId}/goals`
+ : '/',
+ );
+ },
+ title: t('goalDetail.deleteConfirm.title'),
+ });
+ },
},
- },
- ],
- [agentId, canEditTask, deleteGoal, goalId, navigate, projectId, shareUrl, t],
- );
+ ],
+ [agentId, canEditTask, deleteGoal, goalId, navigate, onDeleted, projectId, shareUrl, t],
+ );
- return (
- <DropdownMenu items={items} placement={'bottomRight'}>
- <ActionIcon icon={MoreHorizontalIcon} size={'small'} title={t('goalDetail.moreActions')} />
- </DropdownMenu>
- );
-});
+ return (
+ <DropdownMenu items={items} placement={'bottomRight'}>
+ <ActionIcon icon={MoreHorizontalIcon} size={'small'} title={t('goalDetail.moreActions')} />
+ </DropdownMenu>
+ );
+ },
+);
GoalDetailActions.displayName = 'GoalDetailActions';
diff --git a/src/features/Portal/Goal/Header.tsx b/src/features/Portal/Goal/Header.tsx
new file mode 100644
index 00000000000..b41608ef362
--- /dev/null
+++ b/src/features/Portal/Goal/Header.tsx
@@ -0,0 +1,40 @@
+import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@lobechat/const';
+import { ActionIcon } from '@lobehub/ui/base-ui';
+import { Maximize2Icon } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useChatStore } from '@/store/chat';
+import { chatPortalSelectors } from '@/store/chat/selectors';
+
+import PortalHeader from '../components/Header';
+import Title from './Title';
+import { useOpenGoalPage } from './useOpenGoalPage';
+
+const Header = memo<{ onClose?: () => void }>(({ onClose }) => {
+ const { t } = useTranslation('chat');
+ const goalId = useChatStore(chatPortalSelectors.goalPortalId);
+ const openGoalPage = useOpenGoalPage(goalId);
+
+ return (
+ <PortalHeader
+ title={<Title />}
+ rightExtra={
+ openGoalPage && (
+ <ActionIcon
+ aria-label={t('goalProcess.portal.openPage')}
+ icon={Maximize2Icon}
+ size={DESKTOP_HEADER_ICON_SMALL_SIZE}
+ title={t('goalProcess.portal.openPage')}
+ onClick={openGoalPage}
+ />
+ )
+ }
+ onClose={onClose}
+ />
+ );
+});
+
+Header.displayName = 'GoalPortalHeader';
+
+export default Header;
diff --git a/src/features/Portal/Goal/Title.tsx b/src/features/Portal/Goal/Title.tsx
index 3c3a8715eda..e4796e848d0 100644
--- a/src/features/Portal/Goal/Title.tsx
+++ b/src/features/Portal/Goal/Title.tsx
@@ -1,22 +1,20 @@
import { Flexbox } from '@lobehub/ui';
-import { ActionIcon, Text } from '@lobehub/ui/base-ui';
-import { SquareArrowOutUpRight } from 'lucide-react';
+import { Text } from '@lobehub/ui/base-ui';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import GoalDetailActions from '@/features/AgentGoals/GoalDetailActions';
import GoalStatusGlyph from '@/features/AgentGoals/GoalStatusGlyph';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
import { goalSelectors, useGoalStore } from '@/store/goal';
import { oneLineEllipsis } from '@/styles';
-import { useOpenGoalPage } from './useOpenGoalPage';
-
const Title = memo(() => {
const { t } = useTranslation('chat');
const goalId = useChatStore(chatPortalSelectors.goalPortalId);
const goal = useGoalStore((s) => goalSelectors.goalGraph(goalId)(s)?.goal);
- const openGoalPage = useOpenGoalPage(goalId);
+ const clearPortalStack = useChatStore((s) => s.clearPortalStack);
return (
<Flexbox horizontal align={'center'} flex={1} gap={8} style={{ minWidth: 0 }}>
@@ -24,14 +22,14 @@ const Title = memo(() => {
<Text className={oneLineEllipsis} style={{ flex: '0 1 auto', fontSize: 14, minWidth: 0 }}>
{goal?.title ?? t('goalProcess.portal.title')}
</Text>
- {openGoalPage && (
- <ActionIcon
- aria-label={t('goalProcess.portal.openPage')}
- icon={SquareArrowOutUpRight}
- size={'small'}
- style={{ flexShrink: 0 }}
- title={t('goalProcess.portal.openPage')}
- onClick={openGoalPage}
+ {goal && (
+ // Deleting from the side panel keeps the user in their conversation β€”
+ // only the panel showing the now-gone goal closes.
+ <GoalDetailActions
+ agentId={goal.agentId ?? undefined}
+ goalId={goal.id}
+ projectId={goal.projectId}
+ onDeleted={clearPortalStack}
/>
)}
</Flexbox>
diff --git a/src/features/Portal/Goal/index.ts b/src/features/Portal/Goal/index.ts
index 03af5f2f56d..4444650c351 100644
--- a/src/features/Portal/Goal/index.ts
+++ b/src/features/Portal/Goal/index.ts
@@ -1,5 +1,6 @@
import { type PortalImpl } from '../type';
import Body from './Body';
+import Header from './Header';
import Title from './Title';
-export const Goal: PortalImpl = { Body, Title };
+export const Goal: PortalImpl = { Body, Header, Title };
diff --git a/src/features/Portal/router.tsx b/src/features/Portal/router.tsx
index 2384c1425db..41a8cde689b 100644
--- a/src/features/Portal/router.tsx
+++ b/src/features/Portal/router.tsx
@@ -89,7 +89,7 @@ export const PortalContent = memo<PortalContentProps>(
const Title = ViewImpl?.Title || HomeTitle;
const headerContent = CustomHeader ? (
- <CustomHeader />
+ <CustomHeader onClose={onClose} />
) : (
<Header title={<Title />} onClose={onClose} />
);
diff --git a/src/features/Portal/type.ts b/src/features/Portal/type.ts
index 7751e5ac1ae..72ef99c4928 100644
--- a/src/features/Portal/type.ts
+++ b/src/features/Portal/type.ts
@@ -2,7 +2,7 @@ import { type FC, type PropsWithChildren } from 'react';
export interface PortalImpl {
Body: FC;
- Header?: FC;
+ Header?: FC<{ onClose?: () => void }>;
Title: FC;
Wrapper?: FC<PropsWithChildren>;
}