Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 feat(goal): open the goal conversation by default, unfold it from the open-panel icon (#23334)

Lobehub Coder2a58bf85ba2d
diff --git a/src/features/AgentGoals/GoalDetailPage.test.tsx b/src/features/AgentGoals/GoalDetailPage.test.tsx
index ead6105cbc9..4a5b9c38651 100644
--- a/src/features/AgentGoals/GoalDetailPage.test.tsx
+++ b/src/features/AgentGoals/GoalDetailPage.test.tsx
@@ -221,6 +221,23 @@ describe('GoalDetailPage', () => {
).toBeTruthy();
});
+ // The conversation is the way to talk to the goal's agent, so it is on screen
+ // from the start rather than behind a header entry.
+ it('opens the goal conversation by default', () => {
+ render(<GoalDetailPage agentId={'agt_manager'} goalId={'goal_1'} />);
+
+ expect(screen.getByTestId('goal-right-panel')).toHaveAttribute('data-expand', 'true');
+ expect(screen.getByTestId('goal-supervision')).toHaveTextContent('tpc_manager');
+ });
+
+ it('opens the side conversation by default when the goal has no record', () => {
+ mocks.hasSupervision = false;
+ render(<GoalDetailPage agentId={'agt_manager'} goalId={'goal_1'} />);
+
+ expect(screen.getByTestId('goal-right-panel')).toHaveAttribute('data-expand', 'true');
+ expect(screen.getByTestId('goal-chat')).toHaveAttribute('data-agent-id', 'agt_manager');
+ });
+
// On the agent-less route the task workspace owns the portal host, but the
// supervision record has no other home: the supervising agent's avatar must
// still open it, and must name it as the supervision record to open.
diff --git a/src/features/AgentGoals/GoalSupervisorToggle.tsx b/src/features/AgentGoals/GoalSupervisorToggle.tsx
index 17b877e5781..c3558dc7b37 100644
--- a/src/features/AgentGoals/GoalSupervisorToggle.tsx
+++ b/src/features/AgentGoals/GoalSupervisorToggle.tsx
@@ -1,16 +1,13 @@
'use client';
import { ActionIcon } from '@lobehub/ui';
+import { PanelRightOpenIcon } from 'lucide-react';
import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
-import AssigneeAvatar from '@/features/AgentTasks/features/AssigneeAvatar';
import { useAgentDisplayMeta } from '@/features/AgentTasks/shared/useAgentDisplayMeta';
-/** Fits the 28px header control without crowding it. */
-const AVATAR_SIZE = 20;
-
interface GoalSupervisorToggleProps {
- /** The agent that supervises the goal; its avatar is the panel's entry. */
+ /** The agent that supervises the goal; its name goes into the tooltip. */
agentId: string;
/** Whether the panel is open — drives the pressed state. */
expand: boolean;
@@ -21,12 +18,14 @@ interface GoalSupervisorToggleProps {
}
/**
- * The supervising agent's avatar as the goal panel's entry.
+ * The goal panel's single header entry once the panel is folded.
*
- * The header used to carry two entries for one destination — a panel toggle and a
- * separate "view supervision progress" button. The avatar replaces both, so who
- * is watching and where to see it read as one affordance, and the entry names a
- * person instead of a generic panel glyph.
+ * The panel opens by default, so this only shows after someone folds it. It is
+ * the same open-panel glyph the task detail page and the document editor use,
+ * and the mirror of the panel's own fold button, so folding and unfolding read
+ * as one control. It used to be the supervising agent's avatar, which people
+ * did not read as a way back into the conversation; the tooltip still names
+ * the agent and what the panel holds.
*/
const GoalSupervisorToggle = ({
agentId,
@@ -39,9 +38,7 @@ const GoalSupervisorToggle = ({
if (hideWhenExpanded && expand) return null;
- // The avatar carries the identity; the tooltip has to carry the action too,
- // because an avatar alone does not tell a screen reader (or a hovering user)
- // that pressing it opens something.
+ // The icon carries the action; the tooltip says whose conversation it reopens.
const title = meta?.title ? `${meta.title} · ${label}` : label;
return (
@@ -49,7 +46,7 @@ const GoalSupervisorToggle = ({
active={expand}
aria-label={title}
data-testid={'goal-supervisor-toggle'}
- icon={<AssigneeAvatar agentId={agentId} size={AVATAR_SIZE} />}
+ icon={PanelRightOpenIcon}
size={DESKTOP_HEADER_ICON_SMALL_SIZE}
title={title}
onClick={onToggle}
diff --git a/src/features/AgentGoals/useGoalChatPanel.test.ts b/src/features/AgentGoals/useGoalChatPanel.test.ts
index 1a7e3fd2851..a296f3d7a8f 100644
--- a/src/features/AgentGoals/useGoalChatPanel.test.ts
+++ b/src/features/AgentGoals/useGoalChatPanel.test.ts
@@ -6,10 +6,12 @@ import { useGoalChatPanel } from './useGoalChatPanel';
const manager = { agentId: 'creator', topicId: 'persistent-supervision' };
describe('useGoalChatPanel', () => {
- it('starts collapsed and replaces the responsible conversation with supervision', () => {
+ it('starts open and replaces the responsible conversation with supervision', () => {
const { result } = renderHook(() => useGoalChatPanel('goal-a', 'worker'));
- expect(result.current.open).toBe(false);
+ expect(result.current.open).toBe(true);
expect(result.current.agentId).toBe('worker');
+ act(() => result.current.setOpen(false));
+ expect(result.current.open).toBe(false);
act(() => result.current.setOpen(true));
expect(result.current.open).toBe(true);
act(() => result.current.openConversation(manager));
@@ -65,16 +67,20 @@ describe('useGoalChatPanel', () => {
expect(result.current).toMatchObject({ agentId: 'worker', open: true, request });
});
- it('never carries another goal’s open panel or creator into the next goal', () => {
+ // Every goal starts on its own conversation, open: a panel folded on one goal
+ // stays folded only there.
+ it('never carries another goal’s panel state or creator into the next goal', () => {
const { result, rerender } = renderHook(({ id, agent }) => useGoalChatPanel(id, agent), {
initialProps: { id: 'goal-a', agent: 'worker-a' },
});
act(() => result.current.openConversation(manager));
rerender({ id: 'goal-b', agent: 'worker-b' });
- expect(result.current).toMatchObject({ open: false, agentId: 'worker-b' });
+ expect(result.current).toMatchObject({ open: true, agentId: 'worker-b' });
expect(result.current.topicId).toBeUndefined();
+ act(() => result.current.setOpen(false));
rerender({ id: 'goal-a', agent: 'worker-a' });
- expect(result.current.open).toBe(false);
+ expect(result.current.open).toBe(true);
+ expect(result.current.topicId).toBeUndefined();
rerender({ id: 'goal-b', agent: 'worker-b' });
act(() => result.current.setOpen(true));
expect(result.current).toMatchObject({ open: true, agentId: 'worker-b' });
diff --git a/src/features/AgentGoals/useGoalChatPanel.ts b/src/features/AgentGoals/useGoalChatPanel.ts
index 1a2b08b81e5..247168bc9d8 100644
--- a/src/features/AgentGoals/useGoalChatPanel.ts
+++ b/src/features/AgentGoals/useGoalChatPanel.ts
@@ -20,15 +20,20 @@ interface PanelState {
target?: ConversationTarget;
}
-/** Keep the selected conversation within this goal's inspection session. */
+/**
+ * Keep the selected conversation within this goal's inspection session.
+ *
+ * The panel starts open on every goal: the conversation is how people talk to
+ * the goal's agent, and a folded panel left them without a visible entry.
+ */
export const useGoalChatPanel = (
goalId: string,
responsibleAgentId?: string,
/** The goal's supervision record, once its main Agent has one. */
record?: ConversationTarget,
) => {
- const [state, setState] = useState<PanelState>({ goalId, open: false, request: 0 });
- let current: PanelState = state.goalId === goalId ? state : { goalId, open: false, request: 0 };
+ const [state, setState] = useState<PanelState>({ goalId, open: true, request: 0 });
+ let current: PanelState = state.goalId === goalId ? state : { goalId, open: true, request: 0 };
// The awaited record landed: the panel follows it, unless it is already there.
if (current.awaitingRecord && record) {