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(channel): stack header avatars and add a group settings page (#22583)

Arvin Xu736791d7133c
diff --git a/locales/en-US/channel.json b/locales/en-US/channel.json
index 791957df298..b10200b8cb6 100644
--- a/locales/en-US/channel.json
+++ b/locales/en-US/channel.json
@@ -166,6 +166,46 @@
"searchAgents": "Search Agents",
"send": "Send",
"sendFailed": "Message was not sent. Your draft is preserved; try again.",
+ "settings.back": "Back to channel",
+ "settings.danger.archiveHint": "Replies in progress stop and the channel stops taking messages. History stays readable.",
+ "settings.danger.trashHint": "You can restore the channel and its history from the trash.",
+ "settings.danger.unarchiveHint": "Members can send messages in this channel again.",
+ "settings.general.name": "Channel name",
+ "settings.general.nameDescription": "Shown in the channel list and at the top of the channel.",
+ "settings.general.nameLimit": "Up to {{count}} characters.",
+ "settings.members.description": "Agents and people who can read and reply in this channel.",
+ "settings.reply.duties": "What Agents handle",
+ "settings.reply.dutiesHint": "In your own words, one duty per line. Agents may step in when a message falls within them. Leave empty to turn this off.",
+ "settings.reply.dutiesPlaceholder": "When someone describes a feature request, assess it.",
+ "settings.reply.enabled": "Join without being mentioned",
+ "settings.reply.enabledHint": "When off, Agents only answer when someone @mentions them.",
+ "settings.reply.instructions": "Custom instructions",
+ "settings.reply.instructionsContent": "Instructions",
+ "settings.reply.instructionsHint": "Tell Agents who to answer and what to leave alone. It guides them and is not a hard rule.",
+ "settings.reply.instructionsLimit": "Up to {{count}} characters.",
+ "settings.reply.instructionsPlaceholder": "Tell Agents who to answer and what to leave alone.",
+ "settings.reply.intro": "How Agents in this channel respond to messages that do not @mention them.",
+ "settings.reply.pace.active": "Active",
+ "settings.reply.pace.balanced": "Balanced",
+ "settings.reply.pace.calm": "Calm",
+ "settings.reply.pace.custom": "Custom",
+ "settings.reply.paceHint.active": "Follows up for 10 minutes after replying, even while you are active.",
+ "settings.reply.paceHint.balanced": "Follows up for 5 minutes after replying, and stays quiet for 2 minutes after you speak.",
+ "settings.reply.paceHint.calm": "Rarely joins, and stays quiet while you are active.",
+ "settings.reply.paceHint.custom": "Uses values that were tuned by hand. Choose a pace to replace them.",
+ "settings.reply.saveFailed": "Could not save the replies settings. Try again.",
+ "settings.reply.section.judgement": "Duties",
+ "settings.reply.section.judgementDesc": "What Agents are responsible for, so they can step in without being called, and the instructions they follow.",
+ "settings.reply.section.pace": "Pace",
+ "settings.reply.section.paceDesc": "How soon, and how often, Agents speak up on their own.",
+ "settings.reply.section.switch": "Proactive participation",
+ "settings.save": "Save",
+ "settings.saved": "Saved",
+ "settings.tab.advanced": "Advanced",
+ "settings.tab.general": "General",
+ "settings.tab.members": "Members",
+ "settings.tab.reply": "Replies",
+ "settings.title": "Channel settings",
"startThread": "Start thread",
"status.cancelled": "Stopped",
"status.completed": "Replied",
@@ -176,6 +216,7 @@
"status.running": "Replying…",
"status.silent": "Stayed quiet",
"status.stopping": "Stopping · waiting for execution to end",
+ "status.working": "Working…",
"stopReply": "Stop reply",
"submit": "Create",
"thread": "Thread",
diff --git a/locales/zh-CN/channel.json b/locales/zh-CN/channel.json
index 244a95071fd..ff397703e33 100644
--- a/locales/zh-CN/channel.json
+++ b/locales/zh-CN/channel.json
@@ -166,6 +166,46 @@
"searchAgents": "搜索 Agent",
"send": "发送",
"sendFailed": "发送失败,草稿已保留,请重试。",
+ "settings.back": "返回频道",
+ "settings.danger.archiveHint": "进行中的回复会停止,频道不再接收新消息,历史消息仍可查看。",
+ "settings.danger.trashHint": "你可以在回收站恢复频道和历史消息。",
+ "settings.danger.unarchiveHint": "成员可以重新在这个频道发消息。",
+ "settings.general.name": "频道名称",
+ "settings.general.nameDescription": "显示在频道列表和频道顶部。",
+ "settings.general.nameLimit": "最多 {{count}} 个字符。",
+ "settings.members.description": "可以在这个频道里查看和回复的 Agent 与成员。",
+ "settings.reply.duties": "负责的事",
+ "settings.reply.dutiesHint": "用你自己的话写下 Agent 在频道里负责什么,一行一条。消息落在这些职责内时,Agent 可以主动接手。留空即关闭。",
+ "settings.reply.dutiesPlaceholder": "有人描述需求时,评估一下。",
+ "settings.reply.enabled": "未被 @ 时也可以回复",
+ "settings.reply.enabledHint": "关闭后,Agent 只在被 @ 时回复。",
+ "settings.reply.instructions": "自定义说明",
+ "settings.reply.instructionsContent": "说明内容",
+ "settings.reply.instructionsHint": "告诉 Agent 该回应谁、别碰什么。它用来指导判断,不是硬规则。",
+ "settings.reply.instructionsLimit": "最多 {{count}} 个字符。",
+ "settings.reply.instructionsPlaceholder": "告诉 Agent 该回应谁、别碰什么。",
+ "settings.reply.intro": "设置频道里的 Agent 如何对待没有 @ 它们的消息。",
+ "settings.reply.pace.active": "积极",
+ "settings.reply.pace.balanced": "平衡",
+ "settings.reply.pace.calm": "克制",
+ "settings.reply.pace.custom": "自定义",
+ "settings.reply.paceHint.active": "发言后 10 分钟内持续跟进,你在场时也会接话。",
+ "settings.reply.paceHint.balanced": "发言后 5 分钟内跟进,你发言后 2 分钟内保持安静。",
+ "settings.reply.paceHint.calm": "很少插话,你在场时保持安静。",
+ "settings.reply.paceHint.custom": "正在使用手动调整过的数值,选择其他频率后会替换。",
+ "settings.reply.saveFailed": "回复策略保存失败,请重试。",
+ "settings.reply.section.judgement": "职责边界",
+ "settings.reply.section.judgementDesc": "Agent 负责什么,好让它不等人叫就接手,以及它遵循的说明。",
+ "settings.reply.section.pace": "节奏",
+ "settings.reply.section.paceDesc": "Agent 多快、多频繁地主动插话。",
+ "settings.reply.section.switch": "主动参与",
+ "settings.save": "保存",
+ "settings.saved": "已保存",
+ "settings.tab.advanced": "高级设置",
+ "settings.tab.general": "常规",
+ "settings.tab.members": "成员",
+ "settings.tab.reply": "回复策略",
+ "settings.title": "频道设置",
"startThread": "发起线程",
"status.cancelled": "已停止",
"status.completed": "已回复",
@@ -176,6 +216,7 @@
"status.running": "正在回复…",
"status.silent": "选择不发言",
"status.stopping": "正在停止,等待执行结束",
+ "status.working": "正在工作中…",
"stopReply": "停止回复",
"submit": "创建",
"thread": "线程",
diff --git a/packages/database/src/repositories/channel/__tests__/viewMemberDescription.test.ts b/packages/database/src/repositories/channel/__tests__/viewMemberDescription.test.ts
new file mode 100644
index 00000000000..a0655bd853b
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/viewMemberDescription.test.ts
@@ -0,0 +1,34 @@
+// @vitest-environment node
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { agents, channelMembers } from '../../../schemas';
+import { createChannelFixture } from './testUtils';
+
+const db = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-view-description');
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+describe('Channel member descriptions', () => {
+ it('falls back to the Agent description and prefers a Channel-specific one', async () => {
+ const { asOwner, channel } = await fixture.createTeamChannel();
+ await fixture.addAgent(channel.id, 'Coder');
+ const member = (await asOwner.detail(channel.id)).members.find((item) => item.agentId)!;
+ await db
+ .update(agents)
+ .set({ description: 'Owns parsers' })
+ .where(eq(agents.id, member.agentId!));
+
+ const fallback = (await asOwner.detail(channel.id)).members.find((m) => m.id === member.id);
+ expect(fallback?.description).toBe('Owns parsers');
+
+ await db
+ .update(channelMembers)
+ .set({ description: 'Reviews this release' })
+ .where(eq(channelMembers.id, member.id));
+ const own = (await asOwner.detail(channel.id)).members.find((m) => m.id === member.id);
+ expect(own?.description).toBe('Reviews this release');
+ });
+});
diff --git a/packages/database/src/repositories/channel/view.ts b/packages/database/src/repositories/channel/view.ts
index d306e08512d..f8bad59a4bc 100644
--- a/packages/database/src/repositories/channel/view.ts
+++ b/packages/database/src/repositories/channel/view.ts
@@ -99,7 +99,10 @@ export const readChannelView = async (
actorType: channelMembers.actorType,
agentId: channelMembers.agentId,
avatar: agents.avatar,
- description: channelMembers.description,
+ // The same fallback routing uses: a Channel-specific description, else the Agent's own.
+ description: sql<
+ string | null
+ >`coalesce(nullif(${channelMembers.description}, ''), ${agents.description})`,
id: channelMembers.id,
name: channelMembers.name,
role: channelMembers.role,
diff --git a/packages/locales/src/default/channel.ts b/packages/locales/src/default/channel.ts
index 1d6507c8210..037f5abee81 100644
--- a/packages/locales/src/default/channel.ts
+++ b/packages/locales/src/default/channel.ts
@@ -139,6 +139,7 @@ export default {
'status.stopping': 'Stopping · waiting for execution to end',
'status.preparing': 'Preparing…',
'status.running': 'Replying…',
+ 'status.working': 'Working…',
'status.completed': 'Replied',
'status.failed': 'Reply failed',
'status.cancelled': 'Stopped',
@@ -220,4 +221,52 @@ export default {
'reply.attachment': 'Attachment',
'reply.viewOriginal': 'View original message',
'reply.unavailable': 'Original message unavailable',
+ 'settings.title': 'Channel settings',
+ 'settings.back': 'Back to channel',
+ 'settings.save': 'Save',
+ 'settings.saved': 'Saved',
+ 'settings.general.name': 'Channel name',
+ 'settings.reply.enabled': 'Join without being mentioned',
+ 'settings.reply.enabledHint': 'When off, Agents only answer when someone @mentions them.',
+ 'settings.reply.pace.calm': 'Calm',
+ 'settings.reply.pace.balanced': 'Balanced',
+ 'settings.reply.pace.active': 'Active',
+ 'settings.reply.pace.custom': 'Custom',
+ 'settings.reply.paceHint.calm': 'Rarely joins, and stays quiet while you are active.',
+ 'settings.reply.paceHint.balanced':
+ 'Follows up for 5 minutes after replying, and stays quiet for 2 minutes after you speak.',
+ 'settings.reply.paceHint.active':
+ 'Follows up for 10 minutes after replying, even while you are active.',
+ 'settings.reply.paceHint.custom':
+ 'Uses values that were tuned by hand. Choose a pace to replace them.',
+ 'settings.reply.instructions': 'Custom instructions',
+ 'settings.reply.instructionsPlaceholder': 'Tell Agents who to answer and what to leave alone.',
+ 'settings.reply.saveFailed': 'Could not save the replies settings. Try again.',
+ 'settings.danger.archiveHint':
+ 'Replies in progress stop and the channel stops taking messages. History stays readable.',
+ 'settings.danger.unarchiveHint': 'Members can send messages in this channel again.',
+ 'settings.danger.trashHint': 'You can restore the channel and its history from the trash.',
+ 'settings.tab.general': 'General',
+ 'settings.tab.members': 'Members',
+ 'settings.tab.reply': 'Replies',
+ 'settings.general.nameDescription': 'Shown in the channel list and at the top of the channel.',
+ 'settings.general.nameLimit': 'Up to {{count}} characters.',
+ 'settings.members.description': 'Agents and people who can read and reply in this channel.',
+ 'settings.reply.instructionsLimit': 'Up to {{count}} characters.',
+ 'settings.tab.advanced': 'Advanced',
+ 'settings.reply.intro':
+ 'How Agents in this channel respond to messages that do not @mention them.',
+ 'settings.reply.section.switch': 'Proactive participation',
+ 'settings.reply.section.pace': 'Pace',
+ 'settings.reply.section.paceDesc': 'How soon, and how often, Agents speak up on their own.',
+ 'settings.reply.section.judgement': 'Duties',
+ 'settings.reply.section.judgementDesc':
+ 'What Agents are responsible for, so they can step in without being called, and the instructions they follow.',
+ 'settings.reply.duties': 'What Agents handle',
+ 'settings.reply.dutiesHint':
+ 'In your own words, one duty per line. Agents may step in when a message falls within them. Leave empty to turn this off.',
+ 'settings.reply.dutiesPlaceholder': 'When someone describes a feature request, assess it.',
+ 'settings.reply.instructionsHint':
+ 'Tell Agents who to answer and what to leave alone. It guides them and is not a hard rule.',
+ 'settings.reply.instructionsContent': 'Instructions',
};
diff --git a/src/features/Channels/ChannelStatus.tsx b/src/features/Channels/ChannelStatus.tsx
index 096daef6b3c..83350078d73 100644
--- a/src/features/Channels/ChannelStatus.tsx
+++ b/src/features/Channels/ChannelStatus.tsx
@@ -4,13 +4,24 @@ import { Check } from 'lucide-react';
import type { ChannelStatusTone } from './jobStatus';
import { statusStyles, toneStyles } from './styles';
-/** A status line led by a tone dot, or by a check once the reply landed. */
-export function ChannelStatus({ label, tone }: { label: string; tone: ChannelStatusTone }) {
+/**
+ * A status line led by a tone dot, or by a check once the reply landed. `hideDot` is for a line
+ * beside an avatar that already wears the same dot.
+ */
+export function ChannelStatus({
+ hideDot,
+ label,
+ tone,
+}: {
+ hideDot?: boolean;
+ label: string;
+ tone: ChannelStatusTone;
+}) {
return (
<span data-tone={tone} {...stylex.props(statusStyles.state, toneStyles[tone])}>
{tone === 'done' ? (
<Check size={12} />
- ) : (
+ ) : hideDot ? null : (
<span aria-hidden {...stylex.props(statusStyles.dot)} />
)}
{label}
diff --git a/src/features/Channels/MemberList.tsx b/src/features/Channels/MemberList.tsx
index d8b8272bf29..5a0a447e894 100644
--- a/src/features/Channels/MemberList.tsx
+++ b/src/features/Channels/MemberList.tsx
@@ -1,5 +1,5 @@
import type { ChannelDetail, ChannelPublicMember } from '@lobechat/types';
-import { ActionIcon, Flexbox, Text } from '@lobehub/ui';
+import { ActionIcon, Flexbox, Spin, Text } from '@lobehub/ui';
import * as stylex from '@stylexjs/stylex';
import { ExternalLink, FolderCog } from 'lucide-react';
import { useTranslation } from 'react-i18next';
@@ -9,7 +9,7 @@ import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwar
import { openChannelAgentEnvironment } from './AgentEnvironment';
import { ChannelStatus } from './ChannelStatus';
import type { ChannelStatusTone } from './jobStatus';
-import { channelJobStatus, channelJobTone, memberCurrentJob } from './jobStatus';
+import { channelJobTone, memberCurrentJob, memberJobStatus } from './jobStatus';
import { MemberAvatar } from './MemberAvatar';
import { memberName } from './memberName';
import { statusStyles, styles, toneStyles } from './styles';
@@ -28,7 +28,11 @@ export const StatusAvatar = ({ entry, size }: { entry: MemberEntry; size: number
{entry.member.actorType === 'agent' && (
<span
aria-hidden
- {...stylex.props(statusStyles.state, statusStyles.memberDot, toneStyles[entry.tone])}
+ {...stylex.props(
+ statusStyles.state,
+ statusStyles.memberDot,
+ entry.tone === 'working' ? statusStyles.memberWorking : toneStyles[entry.tone],
+ )}
>
<span {...stylex.props(statusStyles.dot)} />
</span>
@@ -43,7 +47,7 @@ export function useMemberEntries(detail: ChannelDetail) {
(member) => {
const job = member.actorType === 'agent' ? memberCurrentJob(jobs, member.id) : undefined;
return {
- label: member.actorType === 'agent' ? t(job ? channelJobStatus(job) : 'status.idle') : '',
+ label: member.actorType === 'agent' ? t(job ? memberJobStatus(job) : 'status.idle') : '',
member,
name: memberName(member, t('deletedMember')),
tone: job ? channelJobTone(job) : 'quiet',
@@ -53,8 +57,28 @@ export function useMemberEntries(detail: ChannelDetail) {
return entries;
}
+/** A working member spins amber, like a running Agent in the sidebar. */
+const MemberState = ({ entry }: { entry: MemberEntry }) =>
+ entry.tone === 'working' ? (
+ <span {...stylex.props(statusStyles.state, statusStyles.memberWorking)}>
+ <Spin size={12} style={{ color: 'inherit' }} />
+ {entry.label}
+ </span>
+ ) : (
+ <ChannelStatus hideDot label={entry.label} tone={entry.tone} />
+ );
+
/** The same roster and member actions in the personal popover and workspace sidebar. */
-export function MemberList({ detail, onAction }: { detail: ChannelDetail; onAction?: () => void }) {
+export function MemberList({
+ detail,
+ onAction,
+ showDescription,
+}: {
+ detail: ChannelDetail;
+ onAction?: () => void;
+ /** Roomy layouts: who each member is under the name, with the status moved to the row's end. */
+ showDescription?: boolean;
+}) {
const { t } = useTranslation('channel');
const navigate = useWorkspaceAwareNavigate();
const entries = useMemberEntries(detail);
@@ -69,12 +93,19 @@ export function MemberList({ detail, onAction }: { detail: ChannelDetail; onActi
<Text ellipsis title={entry.name} weight={500}>
{entry.name}
</Text>
- {entry.member.actorType === 'agent' ? (
- <ChannelStatus label={entry.label} tone={entry.tone} />
+ {showDescription && entry.member.actorType === 'agent' ? (
+ entry.member.description && (
+ <Text ellipsis fontSize={12} title={entry.member.description} type="secondary">
+ {entry.member.description}
+ </Text>
+ )
+ ) : entry.member.actorType === 'agent' ? (
+ <MemberState entry={entry} />
) : (
<span {...stylex.props(styles.muted)}>{t('person')}</span>
)}
</Flexbox>
+ {showDescription && entry.member.actorType === 'agent' && <MemberState entry={entry} />}
{entry.member.agentId && entry.member.status === 'active' && manageable && (
<ActionIcon
aria-label={t('environment.editNamed', { name: entry.name })}
diff --git a/src/features/Channels/MemberStatus.test.tsx b/src/features/Channels/MemberStatus.test.tsx
index 9b9b2bc2d3d..29eb96c69cf 100644
--- a/src/features/Channels/MemberStatus.test.tsx
+++ b/src/features/Channels/MemberStatus.test.tsx
@@ -71,7 +71,7 @@ describe('MemberStatus in a direct conversation', () => {
it('keeps the Agent environment setup in the menu', () => {
render(createElement(MemberStatus, { detail: detail() }));
- expect(menuKeys()).toEqual(['openAgent', 'environment', 'copyId', 'archive', 'delete']);
+ expect(menuKeys()).toEqual(['openAgent', 'environment', 'copyId']);
fireEvent.click(screen.getByText('environment'));
expect(openEnvironment).toHaveBeenCalledWith('chn_cook', expect.objectContaining(cook));
});
@@ -88,3 +88,17 @@ describe('MemberStatus in a direct conversation', () => {
expect(menuKeys()).not.toContain('environment');
});
});
+
+describe('MemberStatus in a group Channel', () => {
+ it('sends management to the settings page instead of offering delete', () => {
+ render(createElement(MemberStatus, { detail: detail({ agentId: null }) }));
+
+ expect(menuKeys()).toEqual(['copyId', 'settings']);
+ });
+
+ it('offers no settings to a member who cannot manage the Channel', () => {
+ render(createElement(MemberStatus, { detail: detail({ agentId: null, canDelete: false }) }));
+
+ expect(menuKeys()).toEqual(['copyId']);
+ });
+});
diff --git a/src/features/Channels/MemberStatus.tsx b/src/features/Channels/MemberStatus.tsx
index c45d053fd81..c8858b5e97f 100644
--- a/src/features/Channels/MemberStatus.tsx
+++ b/src/features/Channels/MemberStatus.tsx
@@ -2,12 +2,13 @@ import { CHANNEL_URL } from '@lobechat/const';
import type { ChannelDetail } from '@lobechat/types';
import { ActionIcon, Button, DropdownMenu, Flexbox, Popover, Text } from '@lobehub/ui';
import * as stylex from '@stylexjs/stylex';
-import { Bot, FolderCog, MoreHorizontal, UserPlus, Users } from 'lucide-react';
+import { Bot, FolderCog, MoreHorizontal, Settings, UserPlus, Users } from 'lucide-react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useCloseOnNavigate } from '@/hooks/useCloseOnNavigate';
+import { sx } from '@/styles/sx';
import { openChannelAgentEnvironment } from './AgentEnvironment';
import { canInviteMembers } from './channelAccess';
@@ -20,8 +21,11 @@ import { useChannelMenu } from './useChannelMenu';
/** Header avatars before the rest fold into a count; the list shows everyone. */
const MAX_VISIBLE = 5;
-/** Channel actions a direct conversation keeps; renaming would drift from the Agent's name. */
-const DIRECT_MENU_KEYS = new Set(['copyId', 'archive', 'unarchive', 'delete']);
+/**
+ * Channel actions a direct conversation keeps. It is the chat with one Agent, so it cannot be
+ * renamed, archived or trashed; `unarchive` only frees one that was archived earlier.
+ */
+const DIRECT_MENU_KEYS = new Set(['copyId', 'unarchive']);
/**
* Members as avatars with live status dots. One click lists everyone by name, because
@@ -74,11 +78,28 @@ export function MemberStatus({
{ type: 'divider' as const },
]
: []),
+ // Keyed items only: the menu's own dividers separate actions a direct conversation does not have.
...channelMenu(channel).filter(
- (item) => !('key' in item) || DIRECT_MENU_KEYS.has(String(item.key)),
+ (item) => 'key' in item && DIRECT_MENU_KEYS.has(String(item.key)),
),
];
+ // Managing a group lives on its settings page; deleting it is not one click from the header.
+ const groupMenu = () => [
+ ...channelMenu(channel).filter((item) => 'key' in item && item.key === 'copyId'),
+ ...(channel.canDelete
+ ? [
+ { type: 'divider' as const },
+ {
+ icon: Settings,
+ key: 'settings',
+ label: t('settings.title'),
+ onClick: () => navigate(`${CHANNEL_URL(channel.id, null, channel.projectId)}/settings`),
+ },
+ ]
+ : []),
+ ];
+
return (
<Flexbox horizontal align="center" gap={4}>
<FailureIndicator detail={detail} />
@@ -115,9 +136,17 @@ export function MemberStatus({
type="text"
{...stylex.props(statusStyles.memberButton)}
>
- {entries.slice(0, MAX_VISIBLE).map((entry) => (
- <StatusAvatar entry={entry} key={entry.member.id} size={24} />
- ))}
+ <span {...stylex.props(statusStyles.memberStack)}>
+ {entries.slice(0, MAX_VISIBLE).map((entry, index) => (
+ // Earlier avatars sit on top, or each one would cover the previous status dot.
+ <span
+ key={entry.member.id}
+ {...sx(statusStyles.memberStackItem, { zIndex: MAX_VISIBLE - index })}
+ >
+ <StatusAvatar entry={entry} size={20} />
+ </span>
+ ))}
+ </span>
{overflow > 0 && <span {...stylex.props(styles.muted)}>+{overflow}</span>}
</Button>
</Popover>
@@ -144,16 +173,14 @@ export function MemberStatus({
}
/>
)}
- {direct && (
- <DropdownMenu items={directMenu()}>
- <ActionIcon
- aria-label={t('more', { ns: 'common' })}
- icon={MoreHorizontal}
- size="small"
- title={t('more', { ns: 'common' })}
- />
- </DropdownMenu>
- )}
+ <DropdownMenu items={direct ? directMenu() : groupMenu()}>
+ <ActionIcon
+ aria-label={t('more', { ns: 'common' })}
+ icon={MoreHorizontal}
+ size="small"
+ title={t('more', { ns: 'common' })}
+ />
+ </DropdownMenu>
</Flexbox>
);
}
diff --git a/src/features/Channels/Settings/DangerSection.tsx b/src/features/Channels/Settings/DangerSection.tsx
new file mode 100644
index 00000000000..a79c1bc74e2
--- /dev/null
+++ b/src/features/Channels/Settings/DangerSection.tsx
@@ -0,0 +1,38 @@
+import type { ChannelListItem } from '@lobechat/types';
+import { Button } from '@lobehub/ui';
+import { useTranslation } from 'react-i18next';
+
+import { useChannelArchive } from '../useChannelArchive';
+import { useRemoveChannel } from '../useRemoveChannel';
+import { FormCard } from './FormCard';
+
+export function DangerSection({ channel }: { channel: ChannelListItem }) {
+ const { t } = useTranslation('channel');
+ const { archive, unarchive } = useChannelArchive();
+ const remove = useRemoveChannel();
+ const archived = channel.status === 'archived';
+
+ return (
+ <>
+ <FormCard
+ description={t(archived ? 'settings.danger.unarchiveHint' : 'settings.danger.archiveHint')}
+ title={t(archived ? 'unarchive' : 'archive')}
+ action={
+ <Button onClick={() => (archived ? void unarchive(channel.id) : archive(channel))}>
+ {t(archived ? 'unarchive' : 'archive')}
+ </Button>
+ }
+ />
+ <FormCard
+ danger
+ description={t('settings.danger.trashHint')}
+ title={t('moveToTrash')}
+ action={
+ <Button danger type="primary" onClick={() => remove(channel)}>
+ {t('moveToTrash')}
+ </Button>
+ }
+ />
+ </>
+ );
+}
diff --git a/src/features/Channels/Settings/FormCard.tsx b/src/features/Channels/Settings/FormCard.tsx
new file mode 100644
index 00000000000..a9c9c4e2109
--- /dev/null
+++ b/src/features/Channels/Settings/FormCard.tsx
@@ -0,0 +1,57 @@
+import { Flexbox, Text } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
+import type { ReactNode } from 'react';
+
+import { settingsStyles as styles } from './styles';
+
+interface FormCardProps {
+ action?: ReactNode;
+ children?: ReactNode;
+ danger?: boolean;
+ description?: string;
+ /** Beside the title, for an action on the card's whole content rather than a commit. */
+ headerAction?: ReactNode;
+ hint?: ReactNode;
+ /** No frame, for content that is already a list of its own rows. */
+ plain?: boolean;
+ title: string;
+}
+
+/** One setting: what it is and its control above, its hint and commit button in a footer bar. */
+export function FormCard({
+ action,
+ children,
+ danger,
+ description,
+ headerAction,
+ hint,
+ plain,
+ title,
+}: FormCardProps) {
+ return (
+ <section {...stylex.props(styles.card, danger && styles.dangerCard, plain && styles.plainCard)}>
+ <div {...stylex.props(styles.body, plain && styles.plainBody)}>
+ <Flexbox horizontal align="flex-start" gap={16} justify="space-between">
+ <div>
+ <Text as="h3" fontSize={18} style={{ margin: 0 }} weight={600}>
+ {title}
+ </Text>
+ {description && <Text type="secondary">{description}</Text>}
+ </div>
+ {headerAction}
+ </Flexbox>
+ {children}
+ </div>
+ {(hint || action) && (
+ <div {...stylex.props(styles.footer, danger && styles.dangerFooter)}>
+ {hint && (
+ <Text fontSize={13} type="secondary">
+ {hint}
+ </Text>
+ )}
+ {action && <div {...stylex.props(styles.action)}>{action}</div>}
+ </div>
+ )}
+ </section>
+ );
+}
diff --git a/src/features/Channels/Settings/GeneralSection.tsx b/src/features/Channels/Settings/GeneralSection.tsx
new file mode 100644
index 00000000000..dd0dd88e8ca
--- /dev/null
+++ b/src/features/Channels/Settings/GeneralSection.tsx
@@ -0,0 +1,61 @@
+import type { ChannelListItem } from '@lobechat/types';
+import { CHANNEL_LIMITS } from '@lobechat/types';
+import { Button, Input, toast } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { channelActions } from '@/store/channel';
+import { isTrpcErrorCode } from '@/utils/trpcError';
+
+import { FormCard } from './FormCard';
+import { settingsStyles } from './styles';
+
+export function GeneralSection({ channel }: { channel: ChannelListItem }) {
+ const { t } = useTranslation('channel');
+ const [title, setTitle] = useState(channel.title);
+ const [saving, setSaving] = useState(false);
+ const archived = channel.status === 'archived';
+ const next = title.trim();
+
+ const save = async () => {
+ setSaving(true);
+ try {
+ await channelActions.rename(channel.id, next);
+ toast.success(t('settings.saved'));
+ } catch (error) {
+ console.error('Failed to rename Channel', error);
+ toast.error(t(isTrpcErrorCode(error, 'FORBIDDEN') ? 'renameForbidden' : 'renameFailed'));
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ return (
+ <FormCard
+ description={t('settings.general.nameDescription')}
+ hint={t('settings.general.nameLimit', { count: CHANNEL_LIMITS.titleLength })}
+ title={t('settings.general.name')}
+ action={
+ <Button
+ disabled={archived || !next || next === channel.title}
+ loading={saving}
+ type="primary"
+ onClick={save}
+ >
+ {t('settings.save')}
+ </Button>
+ }
+ >
+ <div {...stylex.props(settingsStyles.field)}>
+ <Input
+ aria-label={t('settings.general.name')}
+ disabled={archived}
+ maxLength={CHANNEL_LIMITS.titleLength}
+ value={title}
+ onChange={(event) => setTitle(event.target.value)}
+ />
+ </div>
+ </FormCard>
+ );
+}
diff --git a/src/features/Channels/Settings/MembersSection.tsx b/src/features/Channels/Settings/MembersSection.tsx
new file mode 100644
index 00000000000..a73042ad2e6
--- /dev/null
+++ b/src/features/Channels/Settings/MembersSection.tsx
@@ -0,0 +1,43 @@
+import type { ChannelDetail } from '@lobechat/types';
+import { Button } from '@lobehub/ui';
+import { UserPlus } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+import { canInviteMembers } from '../channelAccess';
+import { openInviteMembers } from '../CreateChannel';
+import { MemberList, useMemberEntries } from '../MemberList';
+import { FormCard } from './FormCard';
+
+export function MembersSection({ detail }: { detail: ChannelDetail }) {
+ const { t } = useTranslation('channel');
+ const { channel, members } = detail;
+ const entries = useMemberEntries(detail);
+
+ return (
+ <FormCard
+ plain
+ description={t('settings.members.description')}
+ title={t('membersCount', { count: entries.length })}
+ headerAction={
+ canInviteMembers(channel) && (
+ <Button
+ icon={UserPlus}
+ onClick={() =>
+ openInviteMembers({
+ agentIds: members.flatMap((member) =>
+ member.status === 'active' && member.agentId ? [member.agentId] : [],
+ ),
+ id: channel.id,
+ workspaceId: channel.workspaceId,
+ })
+ }
+ >
+ {t('invite.title')}
+ </Button>
+ )
+ }
+ >
+ <MemberList showDescription detail={detail} />
+ </FormCard>
+ );
+}
diff --git a/src/features/Channels/Settings/ReplySection.tsx b/src/features/Channels/Settings/ReplySection.tsx
new file mode 100644
index 00000000000..21c061a9c90
--- /dev/null
+++ b/src/features/Channels/Settings/ReplySection.tsx
@@ -0,0 +1,229 @@
+import { Flexbox, Switch, Text, TextArea, toast } from '@lobehub/ui';
+import { Form } from '@lobehub/ui/form';
+import type { ReactNode } from 'react';
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import AsyncBoundary from '@/components/AsyncBoundary';
+import { ChoiceList } from '@/features/AgentChannel/PlatformDetail/ChoiceList';
+import { ModuleSaveBar } from '@/features/AgentChannel/PlatformDetail/ModuleSaveBar';
+import type { ChannelWakeConfig } from '@/services/channel';
+import { channelActions } from '@/store/channel';
+
+import { applyWakeForm, toWakeForm, WAKE_TEXT_MAX_LENGTH, type WakeFormValues } from './wakeForm';
+
+/** The blocks with a Save of their own, as on an IM bot's reply settings. */
+const MODULES = {
+ judgement: ['duties', 'customInstructionsEnabled', 'customInstructions'],
+ pace: ['pace'],
+} satisfies Record<string, (keyof WakeFormValues)[]>;
+type ModuleId = keyof typeof MODULES;
+
+const Field = ({
+ children,
+ desc,
+ horizontal,
+ label,
+}: {
+ children: ReactNode;
+ desc?: string;
+ horizontal?: boolean;
+ label: string;
+}) => (
+ <Flexbox
+ align={horizontal ? 'center' : undefined}
+ gap={horizontal ? 16 : 8}
+ horizontal={horizontal}
+ justify={horizontal ? 'space-between' : undefined}
+ paddingBlock={12}
+ >
+ <Flexbox gap={2}>
+ <Text weight={500}>{label}</Text>
+ {desc && (
+ <Text fontSize={12} type="secondary">
+ {desc}
+ </Text>
+ )}
+ </Flexbox>
+ {children}
+ </Flexbox>
+);
+
+function ReplyForm({ channelId, stored }: { channelId: string; stored: ChannelWakeConfig | null }) {
+ const { t } = useTranslation(['channel', 'agent']);
+ const saved = toWakeForm(stored);
+ const [form, setForm] = useState(saved);
+ const [saving, setSaving] = useState<ModuleId | null>(null);
+ const update = (patch: Partial<WakeFormValues>) => setForm((prev) => ({ ...prev, ...patch }));
+
+ const write = (values: WakeFormValues) =>
+ channelActions.updateWakeConfig(channelId, applyWakeForm(stored, values));
+ const reportFailure = (error: unknown) => {
+ console.error('Failed to save the Channel reply strategy', error);
+ toast.error(t('settings.reply.saveFailed'));
+ };
+
+ /** The switch saves as it changes; every other block is committed by its own Save. */
+ const toggle = async (enabled: boolean) => {
+ update({ enabled });
+ try {
+ await write({ ...saved, enabled });
+ } catch (error) {
+ update({ enabled: saved.enabled });
+ reportFailure(error);
+ }
+ };
+
+ const pick = (id: ModuleId, source: WakeFormValues) =>
+ Object.fromEntries(MODULES[id].map((key) => [key, source[key]])) as Partial<WakeFormValues>;
+ const saveBar = (id: ModuleId) => (
+ <ModuleSaveBar
+ dirty={MODULES[id].some((key) => form[key] !== saved[key])}
+ saving={saving === id}
+ onDiscard={() => update(pick(id, saved))}
+ onSave={async () => {
+ setSaving(id);
+ try {
+ await write({ ...saved, ...pick(id, form) });
+ toast.success(t('settings.saved'));
+ } catch (error) {
+ reportFailure(error);
+ } finally {
+ setSaving(null);
+ }
+ }}
+ />
+ );
+
+ const paces = (['calm', 'balanced', 'active'] as const).map((value) => ({
+ desc: t(`settings.reply.paceHint.${value}`),
+ label: t(`settings.reply.pace.${value}`),
+ recommendedLabel:
+ value === 'balanced' ? t('channel.access.recommended', { ns: 'agent' }) : undefined,
+ value,
+ }));
+ // Only a strategy tuned by hand can hold it; its numbers are not edited here.
+ const options =
+ saved.pace === 'custom'
+ ? [
+ ...paces,
+ {
+ desc: t('settings.reply.paceHint.custom'),
+ label: t('settings.reply.pace.custom'),
+ recommendedLabel: undefined,
+ value: 'custom' as const,
+ },
+ ]
+ : paces;
+
+ return (
+ <Flexbox gap={24}>
+ <Text fontSize={12} type="secondary">
+ {t('settings.reply.intro')}
+ </Text>
+ <Form.Group
+ collapsible={false}
+ keyValue="channel-reply-switch"
+ title={t('settings.reply.section.switch')}
+ variant="filled"
+ >
+ <Field
+ horizontal
+ desc={t('settings.reply.enabledHint')}
+ label={t('settings.reply.enabled')}
+ >
+ <Switch
+ aria-label={t('settings.reply.enabled')}
+ checked={form.enabled}
+ onChange={toggle}
+ />
+ </Field>
+ </Form.Group>
+ {form.enabled && (
+ <>
+ <Form.Group
+ collapsible={false}
+ desc={t('settings.reply.section.paceDesc')}
+ extra={saveBar('pace')}
+ keyValue="channel-reply-pace"
+ title={t('settings.reply.section.pace')}
+ variant="filled"
+ >
+ <Flexbox paddingBlock={8}>
+ <ChoiceList
+ aria-label={t('settings.reply.section.pace')}
+ options={options}
+ value={form.pace}
+ onChange={(pace) => update({ pace })}
+ />
+ </Flexbox>
+ </Form.Group>
+ <Form.Group
+ collapsible={false}
+ desc={t('settings.reply.section.judgementDesc')}
+ extra={saveBar('judgement')}
+ keyValue="channel-reply-judgement"
+ title={t('settings.reply.section.judgement')}
+ variant="filled"
+ >
+ <Field desc={t('settings.reply.dutiesHint')} label={t('settings.reply.duties')}>
+ <TextArea
+ aria-label={t('settings.reply.duties')}
+ autoSize={{ maxRows: 10, minRows: 4 }}
+ maxLength={WAKE_TEXT_MAX_LENGTH}
+ placeholder={t('settings.reply.dutiesPlaceholder')}
+ value={form.duties}
+ onChange={(event) => update({ duties: event.target.value })}
+ />
+ </Field>
+ <Field
+ horizontal
+ desc={t('settings.reply.instructionsHint')}
+ label={t('settings.reply.instructions')}
+ >
+ <Switch
+ aria-label={t('settings.reply.instructions')}
+ checked={form.customInstructionsEnabled}
+ onChange={(customInstructionsEnabled) => update({ customInstructionsEnabled })}
+ />
+ </Field>
+ {form.customInstructionsEnabled && (
+ <Field
+ desc={t('settings.reply.instructionsLimit', { count: WAKE_TEXT_MAX_LENGTH })}
+ label={t('settings.reply.instructionsContent')}
+ >
+ <TextArea
+ aria-label={t('settings.reply.instructionsContent')}
+ autoSize={{ maxRows: 10, minRows: 4 }}
+ maxLength={WAKE_TEXT_MAX_LENGTH}
+ placeholder={t('settings.reply.instructionsPlaceholder')}
+ value={form.customInstructions}
+ onChange={(event) => update({ customInstructions: event.target.value })}
+ />
+ </Field>
+ )}
+ </Form.Group>
+ </>
+ )}
+ </Flexbox>
+ );
+}
+
+export function ReplySection({ channelId }: { channelId: string }) {
+ const { data, error, isLoading, mutate } = channelActions.useFetchWakeConfig(channelId);
+
+ return (
+ <AsyncBoundary
+ data={data}
+ error={error}
+ isLoading={isLoading}
+ onRetry={() => {
+ void mutate();
+ }}
+ >
+ {data && (
+ <ReplyForm channelId={channelId} stored={data.channel as ChannelWakeConfig | null} />
+ )}
+ </AsyncBoundary>
+ );
+}
diff --git a/src/features/Channels/Settings/index.tsx b/src/features/Channels/Settings/index.tsx
new file mode 100644
index 00000000000..e3749f44112
--- /dev/null
+++ b/src/features/Channels/Settings/index.tsx
@@ -0,0 +1,108 @@
+import { ActionIcon, Flexbox, Tabs, Text } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
+import { ArrowLeft } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+import { Navigate, useNavigate, useParams, useSearchParams } from 'react-router';
+
+import NotFound from '@/components/404';
+import AsyncBoundary from '@/components/AsyncBoundary';
+import { RouteLoading } from '@/components/Skeleton/RouteSegment';
+import NavHeader from '@/features/NavHeader';
+import { channelActions, channelSelectors, useChannelStore } from '@/store/channel';
+import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
+
+import { visibleChannelDetail } from '../channelAccess';
+import { styles } from '../styles';
+import { DangerSection } from './DangerSection';
+import { GeneralSection } from './GeneralSection';
+import { MembersSection } from './MembersSection';
+import { ReplySection } from './ReplySection';
+import { settingsStyles } from './styles';
+import { channelSettingsTabs, resolveChannelSettingsTab } from './tabs';
+
+/** Everything an admin manages about a group Channel: its conversation stays uncluttered. */
+function EnabledChannelSettings() {
+ const { t } = useTranslation('channel');
+ const { channelId } = useParams<{ channelId: string }>();
+ const navigate = useNavigate();
+ const [searchParams, setSearchParams] = useSearchParams();
+ const view = { channelId: channelId ?? '', threadId: null };
+ const sync = channelActions.useFetchDetail(channelId ? view : null);
+ const detail = visibleChannelDetail(useChannelStore(channelSelectors.detail(view)), sync.error);
+ if (!channelId) return null;
+
+ // A direct conversation is titled by its Agent and has no roster to manage.
+ if (detail && (detail.channel.agentId || !detail.channel.canDelete))
+ return <Navigate replace relative="path" to=".." />;
+
+ const channel = detail?.channel;
+ const tabs = channelSettingsTabs(channel?.status === 'archived');
+ const tab = resolveChannelSettingsTab(searchParams.get('tab'), tabs);
+
+ return (
+ <Flexbox {...stylex.props(styles.layout)}>
+ <NavHeader
+ {...stylex.props(styles.threadHeader)}
+ left={
+ <Flexbox horizontal align="center" gap={8}>
+ <ActionIcon
+ aria-label={t('settings.back')}
+ icon={ArrowLeft}
+ size="small"
+ title={t('settings.back')}
+ onClick={() => navigate('..', { relative: 'path' })}
+ />
+ <Text ellipsis weight={500}>
+ {t('settings.title')}
+ </Text>
+ </Flexbox>
+ }
+ />
+ <div {...stylex.props(settingsStyles.scroll)}>
+ <AsyncBoundary
+ data={detail}
+ error={sync.error}
+ isLoading={!detail && !sync.error}
+ onRetry={() => {
+ void sync.revalidate();
+ }}
+ >
+ {detail && channel && (
+ <Flexbox gap={24} {...stylex.props(settingsStyles.content)}>
+ <Tabs
+ activeKey={tab}
+ items={tabs.map((key) => ({ key, label: t(`settings.tab.${key}`) }))}
+ variant="square"
+ onChange={(key) => setSearchParams({ tab: key }, { replace: true })}
+ />
+ {/* Kept mounted so switching tabs does not discard a draft. */}
+ <div hidden={tab !== 'general'} key={`general:${channel.id}`}>
+ <GeneralSection channel={channel} />
+ </div>
+ <div hidden={tab !== 'members'}>
+ <MembersSection detail={detail} />
+ </div>
+ {tabs.includes('reply') && (
+ <div hidden={tab !== 'reply'} key={`reply:${channel.id}`}>
+ <ReplySection channelId={channel.id} />
+ </div>
+ )}
+ <div hidden={tab !== 'advanced'}>
+ <Flexbox gap={24}>
+ <DangerSection channel={channel} />
+ </Flexbox>
+ </div>
+ </Flexbox>
+ )}
+ </AsyncBoundary>
+ </div>
+ </Flexbox>
+ );
+}
+
+export default function ChannelSettingsPage() {
+ const ready = useServerConfigStore((s) => s.serverConfigInit);
+ const enabled = useServerConfigStore(serverConfigSelectors.enableChannels);
+ if (!ready) return <RouteLoading />;
+ return enabled ? <EnabledChannelSettings /> : <NotFound />;
+}
diff --git a/src/features/Channels/Settings/styles.ts b/src/features/Channels/Settings/styles.ts
new file mode 100644
index 00000000000..aac1b2c5d9f
--- /dev/null
+++ b/src/features/Channels/Settings/styles.ts
@@ -0,0 +1,67 @@
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+
+export const settingsStyles = stylex.create({
+ scroll: {
+ overflowY: 'auto',
+ flex: '1',
+ minHeight: 0,
+ },
+ content: {
+ width: '100%',
+ maxWidth: 800,
+ marginInline: 'auto',
+ paddingBlock: 24,
+ paddingInline: 24,
+ },
+ card: {
+ overflow: 'hidden',
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: 12,
+ backgroundColor: cssVar.colorBgContainer,
+ },
+ plainCard: {
+ overflow: 'visible',
+ borderWidth: 0,
+ borderRadius: 0,
+ backgroundColor: 'transparent',
+ },
+ plainBody: {
+ padding: 0,
+ },
+ dangerCard: {
+ borderColor: cssVar.colorErrorBorder,
+ },
+ body: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: 12,
+ padding: 24,
+ },
+ footer: {
+ display: 'flex',
+ gap: 16,
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ minHeight: 56,
+ paddingBlock: 12,
+ paddingInline: 24,
+ borderBlockStartWidth: 1,
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ backgroundColor: cssVar.colorFillQuaternary,
+ },
+ dangerFooter: {
+ borderBlockStartColor: cssVar.colorErrorBorder,
+ backgroundColor: cssVar.colorErrorBg,
+ },
+ action: {
+ flex: 'none',
+ marginInlineStart: 'auto',
+ },
+ field: {
+ maxWidth: 320,
+ },
+});
diff --git a/src/features/Channels/Settings/tabs.test.ts b/src/features/Channels/Settings/tabs.test.ts
new file mode 100644
index 00000000000..83291a1432c
--- /dev/null
+++ b/src/features/Channels/Settings/tabs.test.ts
@@ -0,0 +1,24 @@
+import { describe, expect, it } from 'vitest';
+
+import { channelSettingsTabs, resolveChannelSettingsTab } from './tabs';
+
+describe('channelSettingsTabs', () => {
+ it('drops replies for an archived Channel', () => {
+ expect(channelSettingsTabs(false)).toEqual(['general', 'members', 'reply', 'advanced']);
+ expect(channelSettingsTabs(true)).toEqual(['general', 'members', 'advanced']);
+ });
+});
+
+describe('resolveChannelSettingsTab', () => {
+ it('opens the requested tab', () => {
+ expect(resolveChannelSettingsTab('reply', channelSettingsTabs(false))).toBe('reply');
+ });
+
+ it.each([null, 'unknown'])('falls back to general for %s', (requested) => {
+ expect(resolveChannelSettingsTab(requested, channelSettingsTabs(false))).toBe('general');
+ });
+
+ it('falls back when the requested tab is unavailable', () => {
+ expect(resolveChannelSettingsTab('reply', channelSettingsTabs(true))).toBe('general');
+ });
+});
diff --git a/src/features/Channels/Settings/tabs.ts b/src/features/Channels/Settings/tabs.ts
new file mode 100644
index 00000000000..4da948db0e4
--- /dev/null
+++ b/src/features/Channels/Settings/tabs.ts
@@ -0,0 +1,11 @@
+export type ChannelSettingsTab = 'advanced' | 'general' | 'members' | 'reply';
+
+/** An archived Channel takes no writes until it is reopened, so its replies cannot be edited. */
+export const channelSettingsTabs = (archived: boolean): ChannelSettingsTab[] =>
+ archived ? ['general', 'members', 'advanced'] : ['general', 'members', 'reply', 'advanced'];
+
+/** The `?tab=` of a shared link, or the first tab when it is missing or not available here. */
+export const resolveChannelSettingsTab = (
+ requested: string | null,
+ tabs: ChannelSettingsTab[],
+): ChannelSettingsTab => tabs.find((tab) => tab === requested) ?? tabs[0];
diff --git a/src/features/Channels/Settings/wakeForm.test.ts b/src/features/Channels/Settings/wakeForm.test.ts
new file mode 100644
index 00000000000..d0e196ed038
--- /dev/null
+++ b/src/features/Channels/Settings/wakeForm.test.ts
@@ -0,0 +1,47 @@
+import { describe, expect, it } from 'vitest';
+
+import { applyWakeForm, toWakeForm } from './wakeForm';
+
+describe('toWakeForm', () => {
+ it('reads a Channel with no strategy as the defaults', () => {
+ expect(toWakeForm(null)).toEqual({
+ customInstructions: '',
+ customInstructionsEnabled: false,
+ duties: '',
+ enabled: true,
+ pace: 'balanced',
+ });
+ });
+
+ it('reads a strategy without a pace as custom', () => {
+ expect(toWakeForm({ enabled: false }).pace).toBe('custom');
+ });
+
+ it('treats instructions saved without the switch as on', () => {
+ expect(toWakeForm({ customInstructions: 'old' }).customInstructionsEnabled).toBe(true);
+ });
+
+ it('keeps the text of instructions that are switched off', () => {
+ const form = toWakeForm({ customInstructions: 'old', customInstructionsEnabled: false });
+ expect(form).toMatchObject({ customInstructions: 'old', customInstructionsEnabled: false });
+ });
+});
+
+describe('applyWakeForm', () => {
+ it('keeps the fields the form does not edit', () => {
+ const stored = {
+ duties: { text: 'bills', threshold: 0.5 },
+ pace: 'calm' as const,
+ rules: { scope: 'none' },
+ };
+ expect(applyWakeForm(stored, { ...toWakeForm(stored), duties: ' refunds ' })).toMatchObject({
+ duties: { text: 'refunds', threshold: 0.5 },
+ pace: 'calm',
+ rules: { scope: 'none' },
+ });
+ });
+
+ it('adds no duties block to a Channel that never had duties', () => {
+ expect(applyWakeForm(null, toWakeForm(null))).not.toHaveProperty('duties');
+ });
+});
diff --git a/src/features/Channels/Settings/wakeForm.ts b/src/features/Channels/Settings/wakeForm.ts
new file mode 100644
index 00000000000..389269a6113
--- /dev/null
+++ b/src/features/Channels/Settings/wakeForm.ts
@@ -0,0 +1,41 @@
+import type { ChannelWakeConfig } from '@/services/channel';
+
+export const WAKE_TEXT_MAX_LENGTH = 4000;
+
+export interface WakeFormValues {
+ customInstructions: string;
+ customInstructionsEnabled: boolean;
+ duties: string;
+ enabled: boolean;
+ pace: NonNullable<ChannelWakeConfig['pace']>;
+}
+
+/**
+ * A Channel with no stored strategy uses the defaults, which are the balanced pace. One stored
+ * without a pace reads as custom, so numbers somebody tuned by hand are not overridden.
+ */
+export const toWakeForm = (stored: ChannelWakeConfig | null): WakeFormValues => ({
+ customInstructions: stored?.customInstructions ?? '',
+ // Older strategies hold the text without the switch: having text meant it was on.
+ customInstructionsEnabled: stored?.customInstructionsEnabled ?? !!stored?.customInstructions,
+ duties: stored?.duties?.text ?? '',
+ enabled: stored?.enabled !== false,
+ pace: stored ? (stored.pace ?? 'custom') : 'balanced',
+});
+
+/** The API replaces the whole strategy, so everything this form does not edit is carried over. */
+export const applyWakeForm = (
+ stored: ChannelWakeConfig | null,
+ form: WakeFormValues,
+): ChannelWakeConfig => {
+ const duties = form.duties.trim();
+ return {
+ ...stored,
+ customInstructions: form.customInstructions.trim(),
+ customInstructionsEnabled: form.customInstructionsEnabled,
+ enabled: form.enabled,
+ pace: form.pace,
+ // Other duty settings stay; a Channel that never had duties does not gain an empty block.
+ ...(duties || stored?.duties ? { duties: { ...stored?.duties, text: duties } } : {}),
+ };
+};
diff --git a/src/features/Channels/jobStatus.test.ts b/src/features/Channels/jobStatus.test.ts
index d53616c5ee3..061b2b8b505 100644
--- a/src/features/Channels/jobStatus.test.ts
+++ b/src/features/Channels/jobStatus.test.ts
@@ -7,11 +7,19 @@ import {
directAvatarState,
directReplyStatus,
memberCurrentJob,
+ memberJobStatus,
replyActivityJobs,
replyAvatarState,
unresolvedFailures,
} from './jobStatus';
+describe('memberJobStatus', () => {
+ it('words a running reply as work and leaves other statuses alone', () => {
+ expect(memberJobStatus({ status: 'running' } as never)).toBe('status.working');
+ expect(memberJobStatus({ status: 'queued' } as never)).toBe('status.preparing');
+ });
+});
+
describe('Channel task status', () => {
const job = (patch: Partial<ChannelPublicJob>) =>
({
diff --git a/src/features/Channels/jobStatus.ts b/src/features/Channels/jobStatus.ts
index 9b7a82c6dde..82e9bf96237 100644
--- a/src/features/Channels/jobStatus.ts
+++ b/src/features/Channels/jobStatus.ts
@@ -10,6 +10,12 @@ export const channelJobStatus = (job: ChannelReplyJob) =>
: 'status.preparing'
: (`status.${job.status}` as const);
+/** On a member's own row, a running reply is described by what the Agent is doing. */
+export const memberJobStatus = (job: ChannelReplyJob) => {
+ const status = channelJobStatus(job);
+ return status === 'status.running' ? ('status.working' as const) : status;
+};
+
/** Colour family of a status: working blue, attention amber, error red, settled grey. */
export type ChannelStatusTone = 'attention' | 'done' | 'error' | 'quiet' | 'working';
diff --git a/src/features/Channels/paths.test.ts b/src/features/Channels/paths.test.ts
index 4b6dd814041..17534d19529 100644
--- a/src/features/Channels/paths.test.ts
+++ b/src/features/Channels/paths.test.ts
@@ -9,6 +9,8 @@ describe('matchChannel', () => {
['/acme/channels/chn_1', 'chn_1'],
['/project/pro_1/channels/chn_1', 'chn_1'],
['/acme/project/pro_1/channels/chn_1/', 'chn_1'],
+ ['/channels/chn_1/settings', 'chn_1'],
+ ['/acme/project/pro_1/channels/chn_1/settings/', 'chn_1'],
])('reads %s as an open Channel', (pathname, expected) => {
expect(matchChannel(pathname)).toBe(expected);
});
diff --git a/src/features/Channels/paths.ts b/src/features/Channels/paths.ts
index 17970d181df..885fe5325a3 100644
--- a/src/features/Channels/paths.ts
+++ b/src/features/Channels/paths.ts
@@ -1,5 +1,5 @@
// An optional leading segment is the workspace slug, then an optional project scope.
-const CHANNEL_PATH = /^(?:\/[^/]+)?(?:\/project\/[^/]+)?\/channels\/([^/]+)\/?$/;
+const CHANNEL_PATH = /^(?:\/[^/]+)?(?:\/project\/[^/]+)?\/channels\/([^/]+)(?:\/settings)?\/?$/;
/** Which Channel a (possibly workspace-prefixed or project-scoped) pathname opens, if any. */
export const matchChannel = (pathname: string): string | undefined =>
diff --git a/src/features/Channels/routeMeta.ts b/src/features/Channels/routeMeta.ts
index e45b899a1a2..82906dca9a7 100644
--- a/src/features/Channels/routeMeta.ts
+++ b/src/features/Channels/routeMeta.ts
@@ -1,7 +1,8 @@
-import { Hash } from 'lucide-react';
+import { Hash, Settings } from 'lucide-react';
import { lazy } from 'react';
import ChannelLayoutSkeleton from '@/components/Skeleton/Channel';
+import { createSurfaceSkeleton } from '@/components/Skeleton/Surface';
import { routeMeta } from '@/spa/router/routeMeta';
// Route metas load with the router on first paint; keep the Channel store out of that graph.
@@ -13,3 +14,9 @@ export const channelRouteMeta = routeMeta({
Skeleton: ChannelLayoutSkeleton,
titleKey: 'channel:title',
});
+
+export const channelSettingsRouteMeta = routeMeta({
+ icon: Settings,
+ Skeleton: createSurfaceSkeleton('form'),
+ titleKey: 'channel:settings.title',
+});
diff --git a/src/features/Channels/styles.ts b/src/features/Channels/styles.ts
index a28f6d2a631..5c365a11a82 100644
--- a/src/features/Channels/styles.ts
+++ b/src/features/Channels/styles.ts
@@ -282,10 +282,29 @@ export const statusStyles = stylex.create({
memberButton: {
flex: 'none',
gap: 4,
- height: 32,
+ height: 28,
paddingBlock: 4,
paddingInline: 4,
},
+ memberStack: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ },
+ memberStackItem: {
+ position: 'relative',
+ display: 'inline-flex',
+ flex: 'none',
+ marginInlineStart: { 'default': -6, ':first-child': 0 },
+ borderRadius: '50%',
+ outlineWidth: 2,
+ outlineStyle: 'solid',
+ outlineColor: cssVar.colorBgContainer,
+ // Emoji avatars are transparent; without a fill the neighbour shows through.
+ backgroundColor: cssVar.colorBgContainer,
+ },
+ memberWorking: {
+ color: cssVar.colorWarning,
+ },
memberAvatar: {
position: 'relative',
display: 'inline-flex',
diff --git a/src/features/MessageList/AgentConversation.test.tsx b/src/features/MessageList/AgentConversation.test.tsx
index 292b8c8125f..e2c0da8b60c 100644
--- a/src/features/MessageList/AgentConversation.test.tsx
+++ b/src/features/MessageList/AgentConversation.test.tsx
@@ -92,8 +92,8 @@ describe('AgentConversation avatar', () => {
expect(screen.getByTestId('agent-avatar')).toHaveTextContent('agt_cook:🍳');
});
- // A row that opens a direct Channel is that conversation, so its archive / trash live here.
- it('offers the direct Channel archive and trash actions beside the Agent menu', () => {
+ // A direct conversation is the chat with one Agent: it cannot be archived or trashed.
+ it('offers no archive or trash for an open direct Channel', () => {
render(
createElement(AgentConversation, {
active: false,
@@ -101,9 +101,7 @@ describe('AgentConversation avatar', () => {
}),
);
- expect(screen.getByTestId('menu')).toHaveTextContent(
- 'delete,divider,channel-archive,channel-delete',
- );
+ expect(screen.getByTestId('menu').textContent).toBe('delete');
});
it('offers unarchive instead for an archived direct Channel', () => {
diff --git a/src/features/MessageList/AgentConversation.tsx b/src/features/MessageList/AgentConversation.tsx
index a0f6981a264..4606a11072e 100644
--- a/src/features/MessageList/AgentConversation.tsx
+++ b/src/features/MessageList/AgentConversation.tsx
@@ -21,14 +21,13 @@ import { type Conversation } from './conversations';
import { AVATAR_SIZE } from './style';
import { useAgentConversationLink } from './useAgentConversationLink';
-/** The direct Channel's own conversation actions, next to the Agent's own menu. */
-const CONVERSATION_ACTION_KEYS = new Set(['archive', 'unarchive', 'delete']);
+/** The direct Channel's own conversation action, next to the Agent's own menu. */
+const CONVERSATION_ACTION_KEYS = new Set(['unarchive']);
/**
- * A row that opens a direct Channel *is* that conversation, so the Channel's archive and
- * trash actions belong on the row: without them, archiving or trashing the conversation
- * means opening it first, and the Agent's Delete removes the Agent instead. Keys are
- * prefixed so they cannot collide with the Agent's own `delete`.
+ * A direct Channel is the chat with one Agent, so it cannot be archived or trashed. The row only
+ * frees one that was archived earlier. Keys are prefixed so they cannot collide with the Agent's
+ * own menu.
*/
const conversationActions = (menu: DropdownItem[]): DropdownItem[] =>
menu.flatMap((item) => {
diff --git a/src/libs/swr/keys.ts b/src/libs/swr/keys.ts
index 431766e9db7..25fc4745c75 100644
--- a/src/libs/swr/keys.ts
+++ b/src/libs/swr/keys.ts
@@ -47,6 +47,10 @@ export const channelKeys = {
(channelId: string, memberId: string) =>
['channel:agentEnvironment', channelId, memberId] as const,
),
+ wakeConfig: def(
+ 'channel:wakeConfig',
+ (channelId: string) => ['channel:wakeConfig', channelId] as const,
+ ),
userCandidates: def(
'channel:userCandidates',
(channelId: string | undefined, search: string) =>
diff --git a/src/routes/(main)/channels/[channelId]/settings/index.tsx b/src/routes/(main)/channels/[channelId]/settings/index.tsx
new file mode 100644
index 00000000000..264cba2883f
--- /dev/null
+++ b/src/routes/(main)/channels/[channelId]/settings/index.tsx
@@ -0,0 +1 @@
+export { default } from '@/features/Channels/Settings';
diff --git a/src/routes/(main)/project/[projectId]/channels/[channelId]/settings/index.tsx b/src/routes/(main)/project/[projectId]/channels/[channelId]/settings/index.tsx
new file mode 100644
index 00000000000..264cba2883f
--- /dev/null
+++ b/src/routes/(main)/project/[projectId]/channels/[channelId]/settings/index.tsx
@@ -0,0 +1 @@
+export { default } from '@/features/Channels/Settings';
diff --git a/src/services/channel.ts b/src/services/channel.ts
index 84fac460811..6c862180444 100644
--- a/src/services/channel.ts
+++ b/src/services/channel.ts
@@ -10,6 +10,15 @@ export interface ChannelAgentSelection {
workingDirectory?: string;
}
+/** The fields of a stored reply strategy this client edits; any others are written back as read. */
+export type ChannelWakeConfig = Record<string, unknown> & {
+ customInstructions?: string;
+ customInstructionsEnabled?: boolean;
+ duties?: Record<string, unknown> & { text?: string };
+ enabled?: boolean;
+ pace?: 'active' | 'balanced' | 'calm' | 'custom';
+};
+
export interface ChannelViewParams {
before?: number;
channelId: string;
@@ -30,6 +39,11 @@ class ChannelService {
memberId: string,
environment: Pick<ChannelAgentSelection, 'deviceId' | 'workingDirectory'>,
) => lambdaClient.channel.updateAgentEnvironment.mutate({ channelId, environment, memberId });
+ wakeConfig = async (channelId: string) =>
+ (await lambdaClient.channel.wakeConfig.query({ channelId })).data;
+ /** Replaces the Channel's whole reply strategy; `null` returns it to the defaults. */
+ updateWakeConfig = (channelId: string, wake: ChannelWakeConfig | null) =>
+ lambdaClient.channel.updateWakeConfig.mutate({ channelId, wake });
rename = (channelId: string, title: string) =>
lambdaClient.channel.rename.mutate({ channelId, title });
addUser = (channelId: string, userId: string) =>
diff --git a/src/spa/router/collaborationRoutes.tsx b/src/spa/router/collaborationRoutes.tsx
index 7ee72102b27..7fe26905e13 100644
--- a/src/spa/router/collaborationRoutes.tsx
+++ b/src/spa/router/collaborationRoutes.tsx
@@ -1,7 +1,7 @@
import type { RouteObject } from 'react-router';
import { agentsRouteMeta } from '@/features/AgentViewAll/routeMeta';
-import { channelRouteMeta } from '@/features/Channels/routeMeta';
+import { channelRouteMeta, channelSettingsRouteMeta } from '@/features/Channels/routeMeta';
import { dashboardRouteMeta, dashboardsRouteMeta } from '@/features/Dashboard/routeMeta';
import { projectsRouteMeta } from '@/features/Projects/routeMeta';
import { dynamicElement, dynamicLayout, ErrorBoundary, redirectElement } from '@/utils/router';
@@ -84,6 +84,15 @@ export const collaborationRoutes: RouteObject[] = [
handle: { meta: channelRouteMeta },
path: ':channelId',
},
+ {
+ element: dynamicElement(
+ () => import('@/routes/(main)/channels/[channelId]/settings'),
+ 'Desktop > Channel Settings',
+ { preloadId: 'channels' },
+ ),
+ handle: { meta: channelSettingsRouteMeta },
+ path: ':channelId/settings',
+ },
],
errorElement: <ErrorBoundary resetPath=".." />,
path: 'channels',
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index 2ea705c05a8..9eecfb03f39 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -216,6 +216,7 @@ describe('desktop router shared definition', () => {
'topic/:topicId?',
'conversation/:topicId?',
'channels/:channelId',
+ 'channels/:channelId/settings',
'tasks',
'settings/:section?',
'goals',
diff --git a/src/spa/router/mobileWorkspaceRoutes.tsx b/src/spa/router/mobileWorkspaceRoutes.tsx
index f1aee433016..e0da1a727b3 100644
--- a/src/spa/router/mobileWorkspaceRoutes.tsx
+++ b/src/spa/router/mobileWorkspaceRoutes.tsx
@@ -88,6 +88,11 @@ const projectRoutes: RouteObject[] = [
element: redirectElement('..'),
handle: undefined,
}),
+ 'channels/:channelId/settings': (route) => ({
+ ...route,
+ element: redirectElement('../..'),
+ handle: undefined,
+ }),
'index': withHandle({
mobileShellHeader: true,
mobileShellTitle: ProjectMobileShellTitle,
diff --git a/src/spa/router/projectWorkspaceRoutes.tsx b/src/spa/router/projectWorkspaceRoutes.tsx
index 1ba6ed2578a..71affd96676 100644
--- a/src/spa/router/projectWorkspaceRoutes.tsx
+++ b/src/spa/router/projectWorkspaceRoutes.tsx
@@ -2,7 +2,7 @@ import { Navigate, type RouteObject, useLocation, useParams } from 'react-router
import { goalsRouteMeta } from '@/features/AgentGoals/routeMeta';
import { tasksRouteMeta } from '@/features/AgentTasks/routeMeta';
-import { channelRouteMeta } from '@/features/Channels/routeMeta';
+import { channelRouteMeta, channelSettingsRouteMeta } from '@/features/Channels/routeMeta';
import { dashboardRouteMeta, dashboardsRouteMeta } from '@/features/Dashboard/routeMeta';
import {
projectConversationRouteMeta,
@@ -57,6 +57,15 @@ export const projectWorkspaceRoute: RouteObject = {
handle: { meta: channelRouteMeta },
path: 'channels/:channelId',
},
+ {
+ element: dynamicElement(
+ () => import('@/routes/(main)/project/[projectId]/channels/[channelId]/settings'),
+ 'Desktop > Project Channel Settings',
+ { preloadId: 'channels' },
+ ),
+ handle: { meta: channelSettingsRouteMeta },
+ path: 'channels/:channelId/settings',
+ },
{
element: dynamicElement(
() => import('@/routes/(main)/project/[projectId]/tasks'),
diff --git a/src/store/channel/action.ts b/src/store/channel/action.ts
index 4f3268a1a98..e2a48eaefe6 100644
--- a/src/store/channel/action.ts
+++ b/src/store/channel/action.ts
@@ -8,6 +8,7 @@ import {
type ChannelAgentSelection,
channelService,
type ChannelViewParams,
+ type ChannelWakeConfig,
} from '@/services/channel';
import { getElectronStoreState } from '@/store/electron';
@@ -190,6 +191,14 @@ class ChannelActionImpl {
useClientDataSWR(channelKeys.agentEnvironment(channelId, memberId), () =>
channelService.agentEnvironment(channelId, memberId),
);
+ useFetchWakeConfig = (channelId: string | null) =>
+ useClientDataSWR(channelId ? channelKeys.wakeConfig(channelId) : null, () =>
+ channelService.wakeConfig(channelId!),
+ );
+ updateWakeConfig = async (channelId: string, wake: ChannelWakeConfig) => {
+ await channelService.updateWakeConfig(channelId, wake);
+ await this.#refreshAfterWrite(() => mutate(channelKeys.wakeConfig(channelId)));
+ };
updateAgentEnvironment = async (
channelId: string,
memberId: string,