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(bot): show where to reply as a choice list, like who may DM it (#21741)

Arvin Xu5350e26403ce
diff --git a/apps/server/src/services/bot/platforms/const.ts b/apps/server/src/services/bot/platforms/const.ts
index fd8ebbfe1f2..c4e65a4ae5d 100644
--- a/apps/server/src/services/bot/platforms/const.ts
+++ b/apps/server/src/services/bot/platforms/const.ts
@@ -1002,11 +1002,13 @@ export const DEFAULT_BOT_REPLY_PLACEMENT_MODE: BotReplyPlacementMode = 'agent';
export const replyPlacementField: FieldSchema = {
key: 'replyPlacement',
+ choices: true,
default: DEFAULT_BOT_REPLY_PLACEMENT_MODE,
description: 'channel.replyPlacementHint',
enum: [...BOT_REPLY_PLACEMENT_MODES],
enumDescriptions: ['channel.replyPlacementAgentHint', 'channel.replyPlacementThreadHint'],
enumLabels: ['channel.replyPlacementAgent', 'channel.replyPlacementThread'],
+ enumRecommended: DEFAULT_BOT_REPLY_PLACEMENT_MODE,
label: 'channel.replyPlacement',
type: 'string',
};
diff --git a/locales/en-US/agent.json b/locales/en-US/agent.json
index f65a9f5733f..49fe6faf17b 100644
--- a/locales/en-US/agent.json
+++ b/locales/en-US/agent.json
@@ -433,7 +433,7 @@
"channel.replyPlacementAgentHint": "Quick answers stay in the channel; longer work moves into a thread under the message. When the work takes a while, it first posts a short note on what it will do.",
"channel.replyPlacementHint": "Where the bot answers a message sent to it in a channel. Messages already in a thread or a DM are answered where they are.",
"channel.replyPlacementThread": "Always open a thread",
- "channel.replyPlacementThreadHint": "Every message that wakes the bot in a channel gets its own thread",
+ "channel.replyPlacementThreadHint": "Every message that wakes the bot in a channel gets its own thread.",
"channel.resultDetail.hide": "Hide details",
"channel.resultDetail.show": "Show details",
"channel.runtimeDisconnected": "Bot disconnected",
diff --git a/locales/zh-CN/agent.json b/locales/zh-CN/agent.json
index e4e4f05dbea..f1d22db68e0 100644
--- a/locales/zh-CN/agent.json
+++ b/locales/zh-CN/agent.json
@@ -433,7 +433,7 @@
"channel.replyPlacementAgentHint": "简单的问题直接在频道里回复,需要较长时间处理的事情会在这条消息下开一个消息串回复。处理需要一段时间时,会先回一句接下来要做什么。",
"channel.replyPlacementHint": "在频道里叫到 Bot 时,它在哪里回复。已经在消息串或私信里的消息,就在原处回复。",
"channel.replyPlacementThread": "总是开消息串",
- "channel.replyPlacementThreadHint": "在频道里每次叫到 Bot,都会开一个新的消息串回复",
+ "channel.replyPlacementThreadHint": "在频道里每次叫到 Bot,都会开一个新的消息串回复。",
"channel.resultDetail.hide": "收起详情",
"channel.resultDetail.show": "查看详情",
"channel.runtimeDisconnected": "机器人已断开连接",
diff --git a/packages/locales/src/default/agent.ts b/packages/locales/src/default/agent.ts
index d3842ec4413..62031163f39 100644
--- a/packages/locales/src/default/agent.ts
+++ b/packages/locales/src/default/agent.ts
@@ -643,7 +643,7 @@ export default {
'Quick answers stay in the channel; longer work moves into a thread under the message. When the work takes a while, it first posts a short note on what it will do.',
'channel.replyPlacementThread': 'Always open a thread',
'channel.replyPlacementThreadHint':
- 'Every message that wakes the bot in a channel gets its own thread',
+ 'Every message that wakes the bot in a channel gets its own thread.',
'channel.historyLimit': 'History Message Limit',
'channel.historyLimitHint': 'Default number of messages to fetch when reading channel history',
'channel.serverId': 'Default Server ID',
diff --git a/src/features/AgentChannel/PlatformDetail/Body.botWake.test.tsx b/src/features/AgentChannel/PlatformDetail/Body.botWake.test.tsx
index c823cbeac89..b0cf1030dd3 100644
--- a/src/features/AgentChannel/PlatformDetail/Body.botWake.test.tsx
+++ b/src/features/AgentChannel/PlatformDetail/Body.botWake.test.tsx
@@ -396,3 +396,31 @@ describe('channel settings form: bot-wake options', () => {
});
});
});
+
+describe('channel settings form: reply placement', () => {
+ it('lists where to reply as choices that each say what they do, like who may DM it', () => {
+ state.copy = zh;
+ state.featureFlags = { enableBotWake: true };
+
+ render(<Harness activeTab="reply" />);
+
+ const placement = screen.getByRole('radiogroup', { name: zh['channel.replyPlacement'] });
+ // Both consequences are readable without opening a dropdown.
+ expect(placement).toHaveTextContent(zh['channel.replyPlacementAgentHint']);
+ expect(placement).toHaveTextContent(zh['channel.replyPlacementThreadHint']);
+ expect(placement).toHaveTextContent(zh['channel.access.recommended']);
+ expect(screen.queryByRole('combobox', { name: zh['channel.replyPlacement'] })).toBeNull();
+
+ const agent = screen.getByRole('radio', {
+ name: new RegExp(zh['channel.replyPlacementAgent']),
+ });
+ const thread = screen.getByRole('radio', {
+ name: new RegExp(zh['channel.replyPlacementThread']),
+ });
+ expect(agent).toHaveAttribute('aria-checked', 'true');
+
+ fireEvent.click(thread);
+ expect(thread).toHaveAttribute('aria-checked', 'true');
+ expect(agent).toHaveAttribute('aria-checked', 'false');
+ });
+});