Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(channels/mentions): boost agent in mentions (#3729)

teod5d6f568e2fc
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
index da81945f56..88de9c9eb3 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/MentionsMenuItem.tsx
@@ -5,8 +5,9 @@ import ClockIcon from '@phosphor/clock.svg';
import EmailIcon from '@phosphor/envelope.svg';
import UsersIcon from '@phosphor/users.svg';
import { cn } from '@ui';
-import { createEffect } from 'solid-js';
+import { createEffect, Show } from 'solid-js';
import type { MentionItem } from '../../../../utils/mentionsUtils';
+import { isBotMentionItem } from '../utils/botMention';
import {
getBlockNameFromEntity,
getMentionItemName,
@@ -87,12 +88,19 @@ export function MentionsMenuItem(props: {
})}
>
<div class="mr-2 flex items-center">{icon()}</div>
- <span
- class="ph-no-capture text-ink text-xs sm:text-sm font-medium grow overflow-hidden text-nowrap"
- style={{ 'text-overflow': 'ellipsis' }}
- >
- {name()}
- </span>
+ <div class="flex min-w-0 grow items-center gap-2">
+ <span
+ class="ph-no-capture min-w-0 max-w-full overflow-hidden text-nowrap text-ink text-xs sm:text-sm font-medium"
+ style={{ 'text-overflow': 'ellipsis' }}
+ >
+ {name()}
+ </span>
+ <Show when={isBotMentionItem(props.item)}>
+ <span class="inline-flex shrink-0 items-center rounded-sm bg-hover px-1.5 py-0.5 text-[10px] font-medium leading-none text-ink-muted">
+ Agent
+ </span>
+ </Show>
+ </div>
</div>
);
}
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useUsersMention.ts b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useUsersMention.ts
index d886206278..94dbd49ad5 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useUsersMention.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/hooks/useUsersMention.ts
@@ -5,6 +5,7 @@ import { createFreshSearch, FreshSearchPresets } from '@core/util/freshSort';
import { createLazyMemo } from '@solid-primitives/memo';
import type { Accessor } from 'solid-js';
import type { GroupMentionItem } from '../../../../utils/mentionsUtils';
+import { isBotMentionUser } from '../utils/botMention';
type UseUsersMentionOptions = {
/** Custom users list if necessary */
@@ -29,6 +30,8 @@ const GROUPS = [
},
] as const;
+const BOT_MENTION_BOOST = 10;
+
/**
* Hook for managing user mentions in the mentions menu.
* Handles user list retrieval, search, filtering, and special groups.
@@ -67,22 +70,30 @@ export function useUsersMention(
return quickAccess.useList('person');
});
- const userSearch = () =>
- createFreshSearch<UserItem>({
- config: FreshSearchPresets.baseUserSearch<UserItem>(
- currentUserDomain,
- (item) => item.data.email
- ),
+ const userSearch = () => {
+ const baseConfig = FreshSearchPresets.baseUserSearch<UserItem>(
+ currentUserDomain,
+ (item) => item.data.email
+ );
+
+ return createFreshSearch<UserItem>({
+ config: {
+ ...baseConfig,
+ boostFn: (item) =>
+ (baseConfig.boostFn?.(item) ?? 0) +
+ (isBotMentionUser(item) ? BOT_MENTION_BOOST : 0),
+ },
getName: (item) => item.searchText,
getTimestamp: (item) => ({
lastInteraction: item.timestamps.lastInteraction,
}),
});
+ };
const users = createLazyMemo(() => {
const term = searchTerm();
- if (!term) return usersList()();
- return userSearch()(usersList()(), term).map(({ item }) => item);
+ const list = usersList()();
+ return userSearch()(list, term).map(({ item }) => item);
});
/**
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/botMention.ts b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/botMention.ts
new file mode 100644
index 0000000000..026846a31f
--- /dev/null
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu/utils/botMention.ts
@@ -0,0 +1,15 @@
+import { isMacroAgentId } from '@core/constant/macroAgent';
+import type { UserItem } from '@core/context/quickAccess';
+import type { MentionItem } from '../../../../utils/mentionsUtils';
+
+export function isBotMentionId(id: string | undefined): boolean {
+ return id?.startsWith('bot|') === true || isMacroAgentId(id);
+}
+
+export function isBotMentionUser(item: UserItem): boolean {
+ return isBotMentionId(item.id);
+}
+
+export function isBotMentionItem(item: MentionItem): boolean {
+ return item.kind === 'user' && isBotMentionUser(item);
+}