Skip to content

Commit c1d6f3f

Browse files
authored
Keep wave huddles pending for placeholder profiles (#1349)
1 parent e3fc0e0 commit c1d6f3f

6 files changed

Lines changed: 205 additions & 133 deletions

File tree

‎desktop/src/features/channels/ui/ChannelPane.tsx‎

Lines changed: 4 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
MessageTimeline,
1212
type MessageTimelineHandle,
1313
} from "@/features/messages/ui/MessageTimeline";
14-
import type { ImetaMedia } from "@/features/messages/lib/imetaMediaMarkdown";
1514
import { buildDirectMessageIntro } from "@/features/channels/lib/dmParticipantDisplay";
1615
import {
1716
getDmHuddleMemberPubkeys,
@@ -23,20 +22,12 @@ import {
2322
} from "@/features/messages/lib/videoReviewContext";
2423
import { useComposerHeightPadding } from "@/features/messages/ui/useComposerHeightPadding";
2524
import { TypingIndicatorRow } from "@/features/messages/ui/TypingIndicatorRow";
26-
import type { TypingIndicatorEntry } from "@/features/messages/useChannelTyping";
27-
import {
28-
type ProfilePanelTab,
29-
type ProfilePanelView,
30-
UserProfilePanel,
31-
} from "@/features/profile/ui/UserProfilePanel";
25+
import { UserProfilePanel } from "@/features/profile/ui/UserProfilePanel";
3226
import { ChannelFindBar } from "@/features/search/ui/ChannelFindBar";
3327
import { AgentSessionThreadPanel } from "@/features/channels/ui/AgentSessionThreadPanel";
3428
import { ChannelManagementAuxiliaryPanel } from "@/features/channels/ui/ChannelManagementAuxiliaryPanel";
3529
import { RightAuxiliaryPane } from "@/features/channels/ui/RightAuxiliaryPane";
36-
import {
37-
BotActivityComposerAction,
38-
type BotActivityAgent,
39-
} from "@/features/channels/ui/BotActivityBar";
30+
import { BotActivityComposerAction } from "@/features/channels/ui/BotActivityBar";
4031
import {
4132
containsWelcomePersonaMention,
4233
WelcomeComposerBanner,
@@ -52,136 +43,17 @@ import {
5243
isWelcomeSetupSystemMessage,
5344
mentionsKnownAgent,
5445
} from "@/features/channels/ui/ChannelPane.helpers";
46+
import type { ChannelPaneProps } from "@/features/channels/ui/ChannelPane.types";
5547
import * as agentSessionSelection from "@/features/channels/ui/agentSessionSelection";
56-
import type { ChannelAgentSessionAgent } from "@/features/channels/ui/useChannelAgentSessions";
5748
import { Button } from "@/shared/ui/button";
58-
import type { useChannelFind } from "@/features/search/useChannelFind";
59-
import {
60-
buildMainTimelineEntries,
61-
type MainTimelineEntry,
62-
} from "@/features/messages/lib/threadPanel";
49+
import { buildMainTimelineEntries } from "@/features/messages/lib/threadPanel";
6350
import { useRenderScopedReactionHydration } from "@/features/messages/lib/useRenderScopedReactionHydration";
6451
import type { TimelineMessage } from "@/features/messages/types";
65-
import type { UserProfileLookup } from "@/features/profile/lib/identity";
6652
import { isWelcomeChannel } from "@/features/onboarding/welcome";
6753
import { KIND_SYSTEM_MESSAGE } from "@/shared/constants/kinds";
68-
import type { Channel } from "@/shared/api/types";
6954
import { useIsThreadPanelOverlay } from "@/shared/hooks/use-mobile";
7055
import { channelChrome } from "@/shared/layout/chromeLayout";
7156
import { cn } from "@/shared/lib/cn";
72-
type ChannelPaneProps = {
73-
activeChannel: Channel | null;
74-
activityAgents?: BotActivityAgent[];
75-
agentPubkeys?: ReadonlySet<string>;
76-
agentPubkeysPending?: boolean;
77-
agentSessionAgents: ChannelAgentSessionAgent[];
78-
botTypingEntries: TypingIndicatorEntry[];
79-
channelFind: ReturnType<typeof useChannelFind>;
80-
channelManagementOpen?: boolean;
81-
currentPubkey?: string;
82-
editTarget?: {
83-
author: string;
84-
body: string;
85-
id: string;
86-
imetaMedia?: ImetaMedia[];
87-
} | null;
88-
fetchOlder?: () => Promise<void>;
89-
header?: React.ReactNode;
90-
hasOlderMessages?: boolean;
91-
isFetchingOlder?: boolean;
92-
isJoining?: boolean;
93-
isSinglePanelView?: boolean;
94-
isSending: boolean;
95-
isTimelineLoading: boolean;
96-
messages: TimelineMessage[];
97-
firstUnreadMessageId?: string | null;
98-
unreadCount?: number;
99-
canResetThreadPanelWidth: boolean;
100-
onCancelEdit?: () => void;
101-
onCancelThreadReply: () => void;
102-
onCloseAgentSession: () => void;
103-
onCloseChannelManagement?: () => void;
104-
onChannelManagementDeleted?: () => void;
105-
onCloseProfilePanel: () => void;
106-
onAddAgent?: () => void;
107-
onCreateChannel?: () => void;
108-
onCloseThread: () => void;
109-
onDelete?: (message: TimelineMessage) => void;
110-
onEdit?: (message: TimelineMessage) => void;
111-
onEditSave?: (content: string, mediaTags?: string[][]) => Promise<void>;
112-
onMarkUnread?: (message: TimelineMessage) => void;
113-
onMarkRead?: (message: TimelineMessage) => void;
114-
onExpandThreadReplies: (message: TimelineMessage) => void;
115-
onJoinChannel?: () => Promise<void>;
116-
onOpenAgentSession: (pubkey: string) => void;
117-
onOpenDm?: (pubkeys: string[]) => Promise<void> | void;
118-
onOpenMembers?: () => void;
119-
onOpenProfilePanel: (pubkey: string) => void;
120-
onOpenThread: (message: TimelineMessage) => void;
121-
onResetThreadPanelWidth: () => void;
122-
onSelectThreadReplyTarget: (message: TimelineMessage) => void;
123-
onSendMessage: (
124-
content: string,
125-
mentionPubkeys: string[],
126-
mediaTags?: string[][],
127-
) => Promise<void>;
128-
onSendVideoReviewComment?: (
129-
message: TimelineMessage,
130-
content: string,
131-
mentionPubkeys: string[],
132-
mediaTags?: string[][],
133-
parentEventId?: string,
134-
) => Promise<void>;
135-
onSendThreadReply: (
136-
content: string,
137-
mentionPubkeys: string[],
138-
mediaTags?: string[][],
139-
) => Promise<void>;
140-
onTargetReached?: (messageId: string) => void;
141-
onToggleReaction?: (
142-
message: TimelineMessage,
143-
emoji: string,
144-
remove: boolean,
145-
) => Promise<void>;
146-
onThreadScrollTargetResolved: () => void;
147-
onThreadPanelResizeStart: (
148-
event: React.PointerEvent<HTMLButtonElement>,
149-
) => void;
150-
personaLookup?: Map<string, string>;
151-
profiles?: UserProfileLookup;
152-
openThreadHeadId: string | null;
153-
shouldShowThreadSkeleton: boolean;
154-
openAgentSessionPubkey: string | null;
155-
onProfilePanelViewChange: (
156-
view: ProfilePanelView,
157-
options?: { replace?: boolean },
158-
) => void;
159-
onProfilePanelTabChange: (
160-
tab: ProfilePanelTab,
161-
options?: { replace?: boolean },
162-
) => void;
163-
profilePanelPubkey?: string | null;
164-
profilePanelTab: ProfilePanelTab;
165-
profilePanelView: ProfilePanelView;
166-
threadHeadMessage: TimelineMessage | null;
167-
threadMessages: MainTimelineEntry[];
168-
threadPanelWidthPx: number;
169-
threadTypingPubkeys: string[];
170-
threadReplyTargetMessage: TimelineMessage | null;
171-
threadScrollTargetId: string | null;
172-
threadUnreadCounts?: ReadonlyMap<string, number>;
173-
threadReplyUnreadCounts?: ReadonlyMap<string, number>;
174-
threadFirstUnreadReplyId?: string | null;
175-
targetMessageId: string | null;
176-
typingPubkeys: string[];
177-
isFollowingThread?: boolean;
178-
onFollowThread?: () => void;
179-
onUnfollowThread?: () => void;
180-
followThreadById?: (rootId: string) => void;
181-
unfollowThreadById?: (rootId: string) => void;
182-
isFollowingThreadById?: (rootId: string) => boolean;
183-
isMessageUnreadById?: (messageId: string) => boolean;
184-
};
18557
export const ChannelPane = React.memo(function ChannelPane({
18658
activeChannel,
18759
agentPubkeys,
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import type * as React from "react";
2+
import type { useChannelFind } from "@/features/search/useChannelFind";
3+
import type {
4+
ProfilePanelTab,
5+
ProfilePanelView,
6+
} from "@/features/profile/ui/UserProfilePanel";
7+
import type { BotActivityAgent } from "@/features/channels/ui/BotActivityBar";
8+
import type { ChannelAgentSessionAgent } from "@/features/channels/ui/useChannelAgentSessions";
9+
import type { ImetaMedia } from "@/features/messages/lib/imetaMediaMarkdown";
10+
import type { MainTimelineEntry } from "@/features/messages/lib/threadPanel";
11+
import type { TimelineMessage } from "@/features/messages/types";
12+
import type { TypingIndicatorEntry } from "@/features/messages/useChannelTyping";
13+
import type { UserProfileLookup } from "@/features/profile/lib/identity";
14+
import type { Channel } from "@/shared/api/types";
15+
16+
export type ChannelPaneProps = {
17+
activeChannel: Channel | null;
18+
activityAgents?: BotActivityAgent[];
19+
agentPubkeys?: ReadonlySet<string>;
20+
agentPubkeysPending?: boolean;
21+
agentSessionAgents: ChannelAgentSessionAgent[];
22+
botTypingEntries: TypingIndicatorEntry[];
23+
channelFind: ReturnType<typeof useChannelFind>;
24+
channelManagementOpen?: boolean;
25+
currentPubkey?: string;
26+
editTarget?: {
27+
author: string;
28+
body: string;
29+
id: string;
30+
imetaMedia?: ImetaMedia[];
31+
} | null;
32+
fetchOlder?: () => Promise<void>;
33+
header?: React.ReactNode;
34+
hasOlderMessages?: boolean;
35+
isFetchingOlder?: boolean;
36+
isJoining?: boolean;
37+
isSinglePanelView?: boolean;
38+
isSending: boolean;
39+
isTimelineLoading: boolean;
40+
messages: TimelineMessage[];
41+
firstUnreadMessageId?: string | null;
42+
unreadCount?: number;
43+
canResetThreadPanelWidth: boolean;
44+
onCancelEdit?: () => void;
45+
onCancelThreadReply: () => void;
46+
onCloseAgentSession: () => void;
47+
onCloseChannelManagement?: () => void;
48+
onChannelManagementDeleted?: () => void;
49+
onCloseProfilePanel: () => void;
50+
onAddAgent?: () => void;
51+
onCreateChannel?: () => void;
52+
onCloseThread: () => void;
53+
onDelete?: (message: TimelineMessage) => void;
54+
onEdit?: (message: TimelineMessage) => void;
55+
onEditSave?: (content: string, mediaTags?: string[][]) => Promise<void>;
56+
onMarkUnread?: (message: TimelineMessage) => void;
57+
onMarkRead?: (message: TimelineMessage) => void;
58+
onExpandThreadReplies: (message: TimelineMessage) => void;
59+
onJoinChannel?: () => Promise<void>;
60+
onOpenAgentSession: (pubkey: string) => void;
61+
onOpenDm?: (pubkeys: string[]) => Promise<void> | void;
62+
onOpenMembers?: () => void;
63+
onOpenProfilePanel: (pubkey: string) => void;
64+
onOpenThread: (message: TimelineMessage) => void;
65+
onResetThreadPanelWidth: () => void;
66+
onSelectThreadReplyTarget: (message: TimelineMessage) => void;
67+
onSendMessage: (
68+
content: string,
69+
mentionPubkeys: string[],
70+
mediaTags?: string[][],
71+
) => Promise<void>;
72+
onSendVideoReviewComment?: (
73+
message: TimelineMessage,
74+
content: string,
75+
mentionPubkeys: string[],
76+
mediaTags?: string[][],
77+
parentEventId?: string,
78+
) => Promise<void>;
79+
onSendThreadReply: (
80+
content: string,
81+
mentionPubkeys: string[],
82+
mediaTags?: string[][],
83+
) => Promise<void>;
84+
onTargetReached?: (messageId: string) => void;
85+
onToggleReaction?: (
86+
message: TimelineMessage,
87+
emoji: string,
88+
remove: boolean,
89+
) => Promise<void>;
90+
onThreadScrollTargetResolved: () => void;
91+
onThreadPanelResizeStart: (
92+
event: React.PointerEvent<HTMLButtonElement>,
93+
) => void;
94+
personaLookup?: Map<string, string>;
95+
profiles?: UserProfileLookup;
96+
openThreadHeadId: string | null;
97+
shouldShowThreadSkeleton: boolean;
98+
openAgentSessionPubkey: string | null;
99+
onProfilePanelViewChange: (
100+
view: ProfilePanelView,
101+
options?: { replace?: boolean },
102+
) => void;
103+
onProfilePanelTabChange: (
104+
tab: ProfilePanelTab,
105+
options?: { replace?: boolean },
106+
) => void;
107+
profilePanelPubkey?: string | null;
108+
profilePanelTab: ProfilePanelTab;
109+
profilePanelView: ProfilePanelView;
110+
threadHeadMessage: TimelineMessage | null;
111+
threadMessages: MainTimelineEntry[];
112+
threadPanelWidthPx: number;
113+
threadTypingPubkeys: string[];
114+
threadReplyTargetMessage: TimelineMessage | null;
115+
threadScrollTargetId: string | null;
116+
threadUnreadCounts?: ReadonlyMap<string, number>;
117+
threadReplyUnreadCounts?: ReadonlyMap<string, number>;
118+
threadFirstUnreadReplyId?: string | null;
119+
targetMessageId: string | null;
120+
typingPubkeys: string[];
121+
isFollowingThread?: boolean;
122+
onFollowThread?: () => void;
123+
onUnfollowThread?: () => void;
124+
followThreadById?: (rootId: string) => void;
125+
unfollowThreadById?: (rootId: string) => void;
126+
isFollowingThreadById?: (rootId: string) => boolean;
127+
isMessageUnreadById?: (messageId: string) => boolean;
128+
};

‎desktop/src/features/channels/ui/ChannelScreen.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ export function ChannelScreen({
325325
(channelMembersQuery.isPending ||
326326
managedAgentsQuery.isPending ||
327327
relayAgentsQuery.isPending ||
328-
(messageProfilePubkeys.length > 0 && messageProfilesQuery.isPending));
328+
(messageProfilePubkeys.length > 0 &&
329+
(messageProfilesQuery.isPending ||
330+
messageProfilesQuery.isPlaceholderData)));
329331
const {
330332
agentSessionCandidates,
331333
botTypingEntries,

‎desktop/src/testing/e2eBridge.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type E2eConfig = {
8888
canvasReadError?: string;
8989
openDmDelayMs?: number;
9090
sendMessageDelayMs?: number;
91+
usersBatchDelayMs?: number;
9192
/** Delay (ms) applied to older-history (`history-` subId) fetches so e2e
9293
* tests can observe the in-flight prepend window. 0/undefined = instant. */
9394
historyDelayMs?: number;
@@ -3373,6 +3374,13 @@ async function handleGetUsersBatch(
33733374
},
33743375
config: E2eConfig | undefined,
33753376
) {
3377+
const usersBatchDelayMs = config?.mock?.usersBatchDelayMs ?? 0;
3378+
if (usersBatchDelayMs > 0) {
3379+
await new Promise<void>((resolve) => {
3380+
window.setTimeout(resolve, usersBatchDelayMs);
3381+
});
3382+
}
3383+
33763384
const identity = getIdentity(config);
33773385
if (!identity) {
33783386
const profiles: RawUsersBatchResponse["profiles"] = {};

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,67 @@ test("wave attachment huddle passes the bot DM pubkey", async ({ page }) => {
14601460
.toEqual(expect.arrayContaining([TEST_IDENTITIES.charlie.pubkey]));
14611461
});
14621462

1463+
test("wave attachment huddle waits for placeholder profile-only bot data", async ({
1464+
page,
1465+
}) => {
1466+
await installMockBridge(page, { usersBatchDelayMs: 2_000 });
1467+
1468+
await page.goto("/");
1469+
await page.getByTestId("channel-general").click();
1470+
await expect(page.getByTestId("chat-title")).toHaveText("general");
1471+
await waitForMockLiveSubscription(page, "general", SYSTEM_MESSAGE_KIND);
1472+
1473+
await page.evaluate(
1474+
({ kind, targetPubkey }) => {
1475+
window.__BUZZ_E2E_EMIT_MOCK_MESSAGE__?.({
1476+
channelName: "general",
1477+
content: JSON.stringify({
1478+
type: "member_joined",
1479+
actor: targetPubkey,
1480+
target: targetPubkey,
1481+
}),
1482+
kind,
1483+
});
1484+
},
1485+
{
1486+
kind: SYSTEM_MESSAGE_KIND,
1487+
targetPubkey: PROFILE_ONLY_AGENT_PUBKEY,
1488+
},
1489+
);
1490+
await waitForTimelineSettled(page);
1491+
1492+
const joinedRow = page
1493+
.getByTestId("system-message-row")
1494+
.filter({ hasText: "joined the channel" });
1495+
const agentChip = joinedRow.locator(
1496+
"[data-mention].agent-mention-highlight",
1497+
{
1498+
hasText: "mira",
1499+
},
1500+
);
1501+
await expect(agentChip).toBeVisible({ timeout: 5_000 });
1502+
await agentChip.hover();
1503+
1504+
const profilePopover = page.locator(
1505+
'[data-testid="user-profile-popover"][data-state="open"]',
1506+
);
1507+
await expect(profilePopover).toBeVisible();
1508+
await profilePopover
1509+
.getByTestId(`user-profile-popover-wave-${PROFILE_ONLY_AGENT_PUBKEY}`)
1510+
.click();
1511+
1512+
const startHuddleButton = page
1513+
.getByTestId("message-wave-attachment")
1514+
.getByRole("button", { name: "Start huddle" });
1515+
await expect(startHuddleButton).toBeDisabled();
1516+
await expect(startHuddleButton).toBeEnabled({ timeout: 5_000 });
1517+
await startHuddleButton.click();
1518+
1519+
await expect
1520+
.poll(() => readStartHuddleMemberPubkeys(page))
1521+
.toEqual(expect.arrayContaining([PROFILE_ONLY_AGENT_PUBKEY]));
1522+
});
1523+
14631524
test("wave attachment huddle waits for delayed bot DM pubkey", async ({
14641525
page,
14651526
}) => {

0 commit comments

Comments
 (0)