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.

🐛 fix(channel): simplify personal mentions and failure hints (#22017)

AmAzing-fc3a929bdb35
diff --git a/src/features/Channels/Composer.tsx b/src/features/Channels/Composer.tsx
index a570c901e21..1c37e1aee7f 100644
--- a/src/features/Channels/Composer.tsx
+++ b/src/features/Channels/Composer.tsx
@@ -1,4 +1,5 @@
import type { ChannelPublicMember } from '@lobechat/types';
+import type { ISlashOption } from '@lobehub/editor';
import {
INSERT_MENTION_COMMAND,
ReactCodePlugin,
@@ -15,6 +16,7 @@ import type { ReactNode } from 'react';
import { useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { useActiveWorkspaceId } from '@/business/client/hooks/useActiveWorkspaceId';
import { useLocalDragUpload } from '@/components/DragUploadZone/useLocalDragUpload';
import { usePasteFile } from '@/components/DragUploadZone/usePasteFile';
import DraftFile from '@/features/ChatInput/Mobile/FilePreview/FileItem/File';
@@ -60,6 +62,7 @@ export function Composer({
) => Promise<void>;
}) {
const { t } = useTranslation('channel');
+ const workspaceId = useActiveWorkspaceId();
const editor = useEditor();
const draft = useComposerDraft(editor, draftKey);
const shouldSendOnEnter = useEnterToSend();
@@ -183,17 +186,25 @@ export function Composer({
mentionable,
search?.matchingString || '',
t('deletedMember'),
- ).map((group) => ({
- type: 'section',
- key: group.actorType,
- label: t(group.actorType === 'user' ? 'membersTitle' : 'agents'),
- items: group.members.map((member) => ({
+ !!workspaceId,
+ ).flatMap<ISlashOption>((group) => {
+ const items = group.members.map((member) => ({
icon: <MemberAvatar member={member} size={24} />,
key: member.id,
label: memberName(member, t('deletedMember')),
metadata: { type: 'channel-member', id: member.id },
- })),
- })),
+ }));
+ return group.actorType
+ ? [
+ {
+ type: 'section' as const,
+ key: group.actorType,
+ label: t(group.actorType === 'user' ? 'membersTitle' : 'agents'),
+ items,
+ },
+ ]
+ : items;
+ }),
markdownWriter: (node) => `@${node.label}`,
onSelect: (instance, option) => {
instance.dispatchCommand(INSERT_MENTION_COMMAND, {
diff --git a/src/features/Channels/MessageReceipts.tsx b/src/features/Channels/MessageReceipts.tsx
index 347a6d654c4..5aea60107cc 100644
--- a/src/features/Channels/MessageReceipts.tsx
+++ b/src/features/Channels/MessageReceipts.tsx
@@ -105,7 +105,6 @@ export function ReplyDetail({
<Text style={{ overflowWrap: 'anywhere', whiteSpace: 'pre-wrap' }}>
{job.errorMessage?.trim() || t('receipt.errorUnavailable')}
</Text>
- <span {...stylex.props(styles.muted)}>{t('receipt.failedHint')}</span>
</Flexbox>
)}
{job.canStop && isChannelJobActive(job) && (
diff --git a/src/features/Channels/mentionGroups.test.ts b/src/features/Channels/mentionGroups.test.ts
index 638881afc49..4b72dda53a4 100644
--- a/src/features/Channels/mentionGroups.test.ts
+++ b/src/features/Channels/mentionGroups.test.ts
@@ -29,6 +29,19 @@ const otherUser = member('other-user', 'user', 'Lin');
const otherAgent = member('other-agent', 'agent', 'Code helper');
describe('Channel mention groups', () => {
+ it('returns personal-space matches without actor section headings', () => {
+ expect(getMentionGroups([agent, otherAgent], '', 'Former member', false)).toEqual([
+ { actorType: undefined, members: [agent, otherAgent] },
+ ]);
+ expect(getMentionGroups([agent], 'zzzzzzz', 'Former member', false)).toEqual([]);
+ });
+
+ it('retains the Agent section in team spaces even without matching people', () => {
+ expect(getMentionGroups([agent], '', 'Former member', true)).toEqual([
+ { actorType: 'agent', members: [agent] },
+ ]);
+ });
+
it('puts members before Agents and preserves the original order within each group', () => {
expect(getMentionGroups([agent, user, otherAgent, otherUser], '', 'Former member')).toEqual([
{ actorType: 'user', members: [user, otherUser] },
diff --git a/src/features/Channels/mentionGroups.ts b/src/features/Channels/mentionGroups.ts
index 0490c117bf0..e4eafe61f57 100644
--- a/src/features/Channels/mentionGroups.ts
+++ b/src/features/Channels/mentionGroups.ts
@@ -8,6 +8,7 @@ export function getMentionGroups(
members: ChannelPublicMember[],
query: string,
fallbackName: string,
+ grouped = true,
) {
const matches = query
? new Fuse(
@@ -18,6 +19,8 @@ export function getMentionGroups(
.map(({ item }) => item.member)
: members;
+ if (!grouped) return matches.length ? [{ actorType: undefined, members: matches }] : [];
+
return (['user', 'agent'] as const)
.map((actorType) => ({
actorType,