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.

fix(mentions): an agent's hover card offers no direct message (#6485)

Wolf Mermelstein4b780a64fe34
diff --git a/apps/web/src/lib/core/component/UserTooltip.test.tsx b/apps/web/src/lib/core/component/UserTooltip.test.tsx
index ae082b8578..219b88bcd0 100644
--- a/apps/web/src/lib/core/component/UserTooltip.test.tsx
+++ b/apps/web/src/lib/core/component/UserTooltip.test.tsx
@@ -83,6 +83,35 @@ beforeEach(() => {
mocks.onClose.mockReset();
});
+describe('UserTooltip direct message action', () => {
+ it('offers a DM for another person', () => {
+ render(() => (
+ <UserTooltip
+ displayName="Jane Doe"
+ id="macro|[email protected]"
+ />
+ ));
+
+ expect(screen.getByRole('button', { name: 'DM' })).toBeTruthy();
+ });
+
+ it('offers no DM for an agent, which is mentioned rather than messaged', () => {
+ render(() => (
+ <UserTooltip
+ displayName="Cursor"
+ email="Cursor"
+ id="bot|00000000-0000-0000-0000-00000000c5c5"
+ />
+ ));
+
+ expect(screen.queryByRole('button', { name: 'DM' })).toBeNull();
+ // The rest of the card is untouched: an agent still hovers like a person.
+ expect(screen.getByText('Cursor')).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'Assign task' })).toBeTruthy();
+ });
+});
+
describe('UserTooltip CRM contact action', () => {
it('opens the CRM contact resolved for the hovered email', async () => {
const user = userEvent.setup({ skipHover: true });
diff --git a/apps/web/src/lib/core/component/UserTooltip.tsx b/apps/web/src/lib/core/component/UserTooltip.tsx
index 8c2ffbc27b..b30fecdd1b 100644
--- a/apps/web/src/lib/core/component/UserTooltip.tsx
+++ b/apps/web/src/lib/core/component/UserTooltip.tsx
@@ -2,6 +2,7 @@ import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { useSplitLayout } from '@components/app/split-layout/layout';
import { toast } from '@core/component/Toast/Toast';
import { enableCrm } from '@core/constant/featureFlags';
+import { isBotPrincipalId } from '@core/constant/macroAgent';
import { useUserId } from '@core/context/user';
import { useIsConnectedSecondaryInbox } from '@core/user';
import WideChat from '@icon/wide-chat.svg';
@@ -46,6 +47,12 @@ export function UserTooltip(props: UserTooltipProps) {
const isConnectedSecondaryInbox = useIsConnectedSecondaryInbox();
const canTreatAsUser = () =>
!!props.id && !props.isDeleted && !isConnectedSecondaryInbox(props.id);
+ // An agent is mentioned like a person and hovers like one, but there is
+ // nobody on the other end of a direct message to it: an agent answers where
+ // it was mentioned, and a DM channel it never reads would look like a
+ // conversation that is simply being ignored.
+ const canDirectMessage = () =>
+ canTreatAsUser() && !isBotPrincipalId(props.id);
const { openWithSplit, popoverSplit } = useSplitLayout();
const crmFlag = useFeatureFlag(enableCrm);
const getOrCreateDmMutation = useGetOrCreateDirectMessageMutation({
@@ -148,7 +155,7 @@ export function UserTooltip(props: UserTooltipProps) {
</Suspense>
)}
</Show>
- <Show when={canTreatAsUser() && props.id !== currentUserId()}>
+ <Show when={canDirectMessage() && props.id !== currentUserId()}>
<ActionItem onClick={openDM}>
<WideChat class="size-3.5" />
DM