Skip to content

Commit 8ce9e79

Browse files
wesbillmanPinky
andauthored
fix(desktop): hide message action for inaccessible agents (#1883)
Signed-off-by: Wes <[email protected]> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
1 parent 54f4165 commit 8ce9e79

3 files changed

Lines changed: 93 additions & 39 deletions

File tree

‎desktop/src/features/profile/ui/UserProfilePopover.tsx‎

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ export function UserProfilePopover({
241241
const selfProfileQuery = useProfileQuery(open && showProfileActions);
242242
const isCurrentUserOwner = ownsAuthorAgent(profile, currentPubkey);
243243
const viewerIsOwner = isCurrentUserOwner || isOwner === true;
244+
const showMessageAction =
245+
showProfileActions &&
246+
!isAgentClassificationPending &&
247+
(!isBotProfile || viewerIsOwner);
248+
const showAnyProfileActions = showHumanProfileActions || showMessageAction;
244249
const canViewActivity =
245250
isBotProfile && viewerIsOwner && canOpenAgentActivity(pubkey);
246251
const presenceStatus = presenceQuery.data?.[pubkey.toLowerCase()];
@@ -298,7 +303,7 @@ export function UserProfilePopover({
298303
);
299304

300305
const handleMessage = React.useCallback(async () => {
301-
if (!showProfileActions || pendingAction !== null) return;
306+
if (!showMessageAction || pendingAction !== null) return;
302307

303308
clearHoverTimer();
304309
setPendingAction("message");
@@ -326,7 +331,7 @@ export function UserProfilePopover({
326331
openDmMutation,
327332
pendingAction,
328333
pubkey,
329-
showProfileActions,
334+
showMessageAction,
330335
]);
331336

332337
const handleHuddle = React.useCallback(async () => {
@@ -615,7 +620,7 @@ export function UserProfilePopover({
615620
</button>
616621
) : null}
617622

618-
{hasUserStatus || showProfileActions ? (
623+
{hasUserStatus || showAnyProfileActions ? (
619624
<>
620625
<div
621626
aria-hidden="true"
@@ -634,7 +639,7 @@ export function UserProfilePopover({
634639
) : null}
635640
</StatusLine>
636641
) : null}
637-
{showProfileActions ? (
642+
{showAnyProfileActions ? (
638643
<div className="flex gap-2">
639644
{showHumanProfileActions ? (
640645
<Button
@@ -666,29 +671,31 @@ export function UserProfilePopover({
666671
)}
667672
</Button>
668673
) : null}
669-
<Button
670-
className="min-w-0 flex-1"
671-
data-testid={`user-profile-popover-message-${pubkey}`}
672-
disabled={
673-
pendingAction !== null || openDmMutation.isPending
674-
}
675-
onClick={() => {
676-
void handleMessage();
677-
}}
678-
size="sm"
679-
type="button"
680-
variant="outline"
681-
>
682-
{pendingAction === "message" ? (
683-
<Spinner
684-
aria-hidden="true"
685-
className="h-3.5 w-3.5 border-2"
686-
/>
687-
) : (
688-
<MessageSquare />
689-
)}
690-
Message
691-
</Button>
674+
{showMessageAction ? (
675+
<Button
676+
className="min-w-0 flex-1"
677+
data-testid={`user-profile-popover-message-${pubkey}`}
678+
disabled={
679+
pendingAction !== null || openDmMutation.isPending
680+
}
681+
onClick={() => {
682+
void handleMessage();
683+
}}
684+
size="sm"
685+
type="button"
686+
variant="outline"
687+
>
688+
{pendingAction === "message" ? (
689+
<Spinner
690+
aria-hidden="true"
691+
className="h-3.5 w-3.5 border-2"
692+
/>
693+
) : (
694+
<MessageSquare />
695+
)}
696+
Message
697+
</Button>
698+
) : null}
692699
{showHumanProfileActions ? (
693700
<Button
694701
className="min-w-0 flex-1"

‎desktop/tests/e2e/mentions.spec.ts‎

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,21 @@ async function expectAgentProfileMessageOnly(
168168
).toHaveCount(0);
169169
}
170170

171+
async function expectAgentProfileActionsHidden(
172+
profilePopover: import("@playwright/test").Locator,
173+
pubkey: string,
174+
) {
175+
await expect(
176+
profilePopover.getByTestId(`user-profile-popover-message-${pubkey}`),
177+
).toHaveCount(0);
178+
await expect(
179+
profilePopover.getByTestId(`user-profile-popover-wave-${pubkey}`),
180+
).toHaveCount(0);
181+
await expect(
182+
profilePopover.getByTestId(`user-profile-popover-huddle-${pubkey}`),
183+
).toHaveCount(0);
184+
}
185+
171186
test("@ trigger prioritizes channel members before runnable personas and other agents", async ({
172187
page,
173188
}) => {
@@ -1273,7 +1288,7 @@ test("system agent avatar only exposes message action", async ({ page }) => {
12731288
);
12741289
});
12751290

1276-
test("profile-only agent author popover only exposes message action", async ({
1291+
test("profile-only agent author hides actions without agent access", async ({
12771292
page,
12781293
}) => {
12791294
await installMockBridge(page, {
@@ -1305,7 +1320,7 @@ test("profile-only agent author popover only exposes message action", async ({
13051320
'[data-testid="user-profile-popover"][data-state="open"]',
13061321
);
13071322
await expect(profilePopover).toBeVisible();
1308-
await expectAgentProfileMessageOnly(
1323+
await expectAgentProfileActionsHidden(
13091324
profilePopover,
13101325
PROFILE_ONLY_AGENT_PUBKEY,
13111326
);
@@ -1684,7 +1699,16 @@ test("clicking a mention chip in a forum post opens the profile panel", async ({
16841699
);
16851700
});
16861701

1687-
test("bot profile only exposes message action", async ({ page }) => {
1702+
test("owned bot profile only exposes message action", async ({ page }) => {
1703+
await installMockBridge(page, {
1704+
managedAgents: [
1705+
{
1706+
pubkey: TEST_IDENTITIES.charlie.pubkey,
1707+
name: "charlie",
1708+
status: "online",
1709+
},
1710+
],
1711+
});
16881712
await page.goto("/");
16891713
await page.getByTestId("channel-agents").click();
16901714
await expect(page.getByTestId("chat-title")).toHaveText("agents");
@@ -1699,14 +1723,24 @@ test("bot profile only exposes message action", async ({ page }) => {
16991723
'[data-testid="user-profile-popover"][data-state="open"]',
17001724
);
17011725
await expect(profilePopover).toBeVisible();
1702-
await expect(profilePopover.getByText("Codex")).toBeVisible();
17031726
await expectAgentProfileMessageOnly(
17041727
profilePopover,
17051728
TEST_IDENTITIES.charlie.pubkey,
17061729
);
17071730
});
17081731

1709-
test("agent mention profile only exposes message action", async ({ page }) => {
1732+
test("owned agent mention profile only exposes message action", async ({
1733+
page,
1734+
}) => {
1735+
await installMockBridge(page, {
1736+
managedAgents: [
1737+
{
1738+
pubkey: TEST_IDENTITIES.charlie.pubkey,
1739+
name: "charlie",
1740+
status: "online",
1741+
},
1742+
],
1743+
});
17101744
await page.goto("/");
17111745
await page.getByTestId("channel-general").click();
17121746
await expect(page.getByTestId("chat-title")).toHaveText("general");
@@ -1813,7 +1847,7 @@ test("profile popover wave sends a direct message for a human profile", async ({
18131847
);
18141848
});
18151849

1816-
test("delayed agent profile keeps wave and huddle hidden while classifying", async ({
1850+
test("delayed inaccessible agent profile keeps all actions hidden", async ({
18171851
page,
18181852
}) => {
18191853
await installMockBridge(page, {
@@ -1853,8 +1887,19 @@ test("delayed agent profile keeps wave and huddle hidden while classifying", asy
18531887
'[data-testid="user-profile-popover"][data-state="open"]',
18541888
);
18551889
await expect(profilePopover).toBeVisible();
1856-
await expectAgentProfileMessageOnly(
1857-
profilePopover,
1858-
DELAYED_RELAY_AGENT_PUBKEY,
1859-
);
1890+
await expect(
1891+
profilePopover.getByTestId(
1892+
`user-profile-popover-message-${DELAYED_RELAY_AGENT_PUBKEY}`,
1893+
),
1894+
).toHaveCount(0);
1895+
await expect(
1896+
profilePopover.getByTestId(
1897+
`user-profile-popover-wave-${DELAYED_RELAY_AGENT_PUBKEY}`,
1898+
),
1899+
).toHaveCount(0);
1900+
await expect(
1901+
profilePopover.getByTestId(
1902+
`user-profile-popover-huddle-${DELAYED_RELAY_AGENT_PUBKEY}`,
1903+
),
1904+
).toHaveCount(0);
18601905
});

‎desktop/tests/e2e/smoke.spec.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ test("inbox feed shows channel and agent activity sections", async ({
224224
);
225225
});
226226

227-
test("inbox agent hover only exposes message action", async ({ page }) => {
227+
test("inbox agent hover hides actions without agent access", async ({
228+
page,
229+
}) => {
228230
await page.goto("/");
229231

230232
await selectHomeInboxFilter(page, "Agents");
@@ -242,7 +244,7 @@ test("inbox agent hover only exposes message action", async ({ page }) => {
242244
profilePopover.getByTestId(
243245
`user-profile-popover-message-${DEFAULT_AGENT_ACTIVITY_PUBKEY}`,
244246
),
245-
).toBeVisible();
247+
).toHaveCount(0);
246248
await expect(
247249
profilePopover.getByTestId(
248250
`user-profile-popover-wave-${DEFAULT_AGENT_ACTIVITY_PUBKEY}`,

0 commit comments

Comments
 (0)