Skip to content

Commit 4672ee5

Browse files
authored
Fix pending message feedback (#3543)
## Summary - Keep `Sending…` beside message timestamps, including grouped pending messages. - Match the profile-card hover surface to inactive channel rows. ## Snapshots ### Pending message ![Pending message status](https://raw.githubusercontent.com/block/buzz/655189aec0904677a68651f8aabf0e17d69734cd/pr-3543--pending-message-inline.png) ### Profile hover ![Profile hover](https://raw.githubusercontent.com/block/buzz/655189aec0904677a68651f8aabf0e17d69734cd/pr-3543--profile-hover.png) ## Validation - `pnpm -C desktop typecheck` - `pnpm -C desktop check:file-sizes` - `pnpm -C desktop build:e2e` - `pnpm -C desktop exec playwright test tests/e2e/message-feedback-snapshots.spec.ts --project=smoke` --------- Signed-off-by: kenny lopez <[email protected]>
1 parent c55e421 commit 4672ee5

8 files changed

Lines changed: 181 additions & 7 deletions

File tree

‎desktop/playwright.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default defineConfig({
3434
"**/hosted-communities-settings-screenshots.spec.ts",
3535
"**/invites-settings-screenshots.spec.ts",
3636
"**/messaging.spec.ts",
37+
"**/message-feedback-snapshots.spec.ts",
3738
"**/custom-emoji.spec.ts",
3839
"**/profile-custom-emoji-status.spec.ts",
3940
"**/custom-emoji-ui.spec.ts",

‎desktop/src/features/messages/lib/timelineItems.test.mjs‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,36 @@ test("buildTimelineItems: consecutive same-author messages within the window are
245245
);
246246
});
247247

248+
test("buildTimelineItems: pending messages remain standalone until acknowledged", () => {
249+
const entries = [
250+
entry({ id: "a", pubkey: "author-a", createdAt: dayAt(2026, 6, 14) }),
251+
entry({
252+
id: "b",
253+
pubkey: "author-a",
254+
createdAt: dayAt(2026, 6, 14, 12, 2),
255+
pending: true,
256+
}),
257+
entry({
258+
id: "c",
259+
pubkey: "author-a",
260+
createdAt: dayAt(2026, 6, 14, 12, 3),
261+
}),
262+
];
263+
264+
const messageItems = buildTimelineItems(entries, null).items.filter(
265+
(item) => item.kind === "message",
266+
);
267+
268+
assert.deepEqual(
269+
messageItems.map((item) => item.isContinuation),
270+
[false, false, false],
271+
);
272+
assert.deepEqual(
273+
messageItems.map((item) => item.isFollowedByContinuation),
274+
[false, false, false],
275+
);
276+
});
277+
248278
test("buildTimelineItems: same-author messages past the window start a new group", () => {
249279
const author = "author-a";
250280
const entries = [

‎desktop/src/features/messages/lib/timelineItems.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,13 @@ export function buildTimelineItems(
232232
continue;
233233
}
234234

235+
// Pending rows render with their own header so the send status can sit
236+
// beside the timestamp. Keep the timeline spacing and row estimate in
237+
// that same standalone state until the send acknowledgement arrives.
235238
const isContinuation =
239+
!message.pending &&
236240
previousGroupEntry !== null &&
241+
!previousGroupEntry.message.pending &&
237242
hasSameMessageAuthor(previousGroupEntry.message, message) &&
238243
isWithinGroupingWindow(
239244
previousGroupEntry.message.createdAt,

‎desktop/src/features/messages/ui/MessageRow.tsx‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ export const MessageRow = React.memo(
143143
showDepthGuides?: boolean;
144144
videoReviewContext?: VideoReviewContext;
145145
}) {
146+
// Keep the transient send state with its timestamp rather than collapsing
147+
// it into a grouped message row with no header.
148+
const isDisplayedAsContinuation = isContinuation && !message.pending;
146149
const [expandedDiffId, setExpandedDiffId] = React.useState<string | null>(
147150
null,
148151
);
@@ -443,7 +446,7 @@ export const MessageRow = React.memo(
443446
</div>
444447
);
445448

446-
const avatarGutterNode = isContinuation ? (
449+
const avatarGutterNode = isDisplayedAsContinuation ? (
447450
continuationTimestampGutter
448451
) : message.pubkey ? (
449452
<UserProfilePopover
@@ -515,7 +518,12 @@ export const MessageRow = React.memo(
515518
message.pending || message.edited ? (
516519
<>
517520
{message.pending ? (
518-
<p className="font-medium text-primary/80">Sending</p>
521+
<p
522+
className="font-normal text-muted-foreground/70"
523+
data-testid="message-send-status"
524+
>
525+
Sending…
526+
</p>
519527
) : null}
520528
{message.edited ? (
521529
<Tooltip>
@@ -536,13 +544,13 @@ export const MessageRow = React.memo(
536544
);
537545

538546
const continuationMetadataNode =
539-
isContinuation && statusMetadataNode ? (
547+
isDisplayedAsContinuation && statusMetadataNode ? (
540548
<div className="mt-0.5 flex items-baseline gap-2 text-xs">
541549
{statusMetadataNode}
542550
</div>
543551
) : null;
544552

545-
const headerNode = isContinuation ? null : (
553+
const headerNode = isDisplayedAsContinuation ? null : (
546554
<MessageHeaderRow>
547555
{message.pubkey ? (
548556
<UserProfilePopover
@@ -570,7 +578,9 @@ export const MessageRow = React.memo(
570578
) : null}
571579
</MessageHeaderRow>
572580
);
573-
const bodyContainerClass = isContinuation ? "mt-0" : bodyOffsetClass;
581+
const bodyContainerClass = isDisplayedAsContinuation
582+
? "mt-0"
583+
: bodyOffsetClass;
574584

575585
const messageBodyNode = (
576586
<>
@@ -788,7 +798,7 @@ export const MessageRow = React.memo(
788798
? "mx-1 px-2"
789799
: "px-2",
790800
"flex gap-2.5",
791-
isContinuation ? "items-center" : "items-start",
801+
isDisplayedAsContinuation ? "items-center" : "items-start",
792802
hasActiveReminder ? "bg-blue-500/10" : "",
793803
highlighted
794804
? "-mx-4 rounded-none px-6 before:absolute before:-inset-y-1.5 before:inset-x-0 before:animate-[route-target-highlight-fade_2s_ease-out_forwards] before:bg-primary/10 before:content-[''] motion-reduce:before:animate-none sm:-mx-6 sm:px-8"

‎desktop/src/features/sidebar/ui/SidebarProfileCard.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function SidebarProfileCard({
100100
return (
101101
// biome-ignore lint/a11y/noStaticElementInteractions lint/a11y/useKeyWithClickEvents: child buttons provide keyboard access; wrapper fills pointer gaps between them.
102102
<div
103-
className="group/profile-card cursor-pointer rounded-xl px-2 py-2 transition-colors hover:bg-sidebar-border/35 dark:hover:bg-sidebar-border/30"
103+
className="group/profile-card cursor-pointer rounded-xl px-2 py-2 transition-colors hover:bg-sidebar-border/35"
104104
data-testid="sidebar-profile-card"
105105
onClick={handleCardClick}
106106
ref={profileCardRef}

‎desktop/src/shared/styles/globals/theme.css‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,13 @@
481481
color: var(--buzz-muted-foreground);
482482
}
483483

484+
/* Match the hover treatment used by inactive channel rows. */
485+
:root[data-buzz-sidebar]
486+
[data-testid="app-sidebar"]
487+
[data-testid="sidebar-profile-card"]:hover {
488+
background-color: var(--buzz-hover-surface);
489+
}
490+
484491
/*
485492
* App and settings sidebar section headings plus secondary footer text use the
486493
* same tint. Navigation rows keep their normal foreground in both sidebars.

‎desktop/src/testing/e2eBridge.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,8 @@ declare global {
10181018
mentionPubkeys?: string[];
10191019
extraTags?: string[][];
10201020
createdAt?: number;
1021+
/** Marks this test-only message as locally pending. */
1022+
pending?: boolean;
10211023
/** 64-hex id required for the event to be a valid reaction target. */
10221024
id?: string;
10231025
}) => RelayEvent;
@@ -4014,6 +4016,7 @@ function emitMockChannelMessage(
40144016
mentionPubkeys?: string[],
40154017
extraTags?: string[][],
40164018
createdAt?: number,
4019+
pending?: boolean,
40174020
id?: string,
40184021
) {
40194022
const eventKind = kind ?? 9;
@@ -4032,6 +4035,7 @@ function emitMockChannelMessage(
40324035
createdAt,
40334036
id,
40344037
);
4038+
if (pending) event.pending = true;
40354039
recordMockMessage(channelId, event);
40364040
emitMockLiveEvent(channelId, event);
40374041
return event;
@@ -4064,6 +4068,7 @@ function emitMockChannelMessage(
40644068
createdAt,
40654069
id,
40664070
);
4071+
if (pending) event.pending = true;
40674072
recordMockMessage(channelId, event);
40684073
emitMockLiveEvent(channelId, event);
40694074
return event;
@@ -9416,6 +9421,7 @@ export function maybeInstallE2eTauriMocks() {
94169421
mentionPubkeys,
94179422
extraTags,
94189423
createdAt,
9424+
pending,
94199425
id,
94209426
}) => {
94219427
const channel = mockChannels.find(
@@ -9434,6 +9440,7 @@ export function maybeInstallE2eTauriMocks() {
94349440
mentionPubkeys,
94359441
extraTags,
94369442
createdAt,
9443+
pending,
94379444
id,
94389445
);
94399446
};
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { expect, test } from "@playwright/test";
2+
3+
import { waitForAnimations } from "../helpers/animations";
4+
import { installMockBridge } from "../helpers/bridge";
5+
6+
const SHOTS = "test-results/message-feedback";
7+
8+
async function waitForMockLiveSubscription(
9+
page: import("@playwright/test").Page,
10+
channelName: string,
11+
) {
12+
await expect
13+
.poll(async () => {
14+
return page.evaluate(
15+
({ ch }) =>
16+
(
17+
window as Window & {
18+
__BUZZ_E2E_HAS_MOCK_LIVE_SUBSCRIPTION__?: (input: {
19+
channelName: string;
20+
}) => boolean;
21+
}
22+
).__BUZZ_E2E_HAS_MOCK_LIVE_SUBSCRIPTION__?.({ channelName: ch }) ??
23+
false,
24+
{ ch: channelName },
25+
);
26+
})
27+
.toBe(true);
28+
}
29+
30+
test("pending continuation keeps Sending next to its timestamp", async ({
31+
page,
32+
}) => {
33+
await installMockBridge(page);
34+
await page.goto("/");
35+
await page.getByTestId("channel-general").click();
36+
await expect(page.getByTestId("chat-title")).toHaveText("general");
37+
await waitForMockLiveSubscription(page, "general");
38+
39+
const sentMessage = `Message before pending state ${Date.now()}`;
40+
const pendingMessage = `Pending message status ${Date.now()}`;
41+
const createdAt = Math.floor(Date.now() / 1_000);
42+
await page.evaluate(
43+
({ firstMessage, secondMessage, timestamp }) => {
44+
const emit = (
45+
window as Window & {
46+
__BUZZ_E2E_EMIT_MOCK_MESSAGE__?: (input: {
47+
channelName: string;
48+
content: string;
49+
createdAt: number;
50+
pending?: boolean;
51+
}) => unknown;
52+
}
53+
).__BUZZ_E2E_EMIT_MOCK_MESSAGE__;
54+
emit?.({
55+
channelName: "general",
56+
content: firstMessage,
57+
createdAt: timestamp - 1,
58+
});
59+
emit?.({
60+
channelName: "general",
61+
content: secondMessage,
62+
createdAt: timestamp,
63+
pending: true,
64+
});
65+
},
66+
{
67+
firstMessage: sentMessage,
68+
secondMessage: pendingMessage,
69+
timestamp: createdAt,
70+
},
71+
);
72+
73+
const pendingRow = page
74+
.getByTestId("message-row")
75+
.filter({ hasText: pendingMessage });
76+
const status = pendingRow.getByTestId("message-send-status");
77+
await expect(status).toHaveText("Sending…");
78+
await expect(pendingRow.getByTestId("message-author")).toHaveCount(1);
79+
80+
const timestamp = status.locator("xpath=../p[1]");
81+
const [timestampBox, statusBox] = await Promise.all([
82+
timestamp.boundingBox(),
83+
status.boundingBox(),
84+
]);
85+
expect(timestampBox).not.toBeNull();
86+
expect(statusBox).not.toBeNull();
87+
if (!timestampBox || !statusBox) {
88+
throw new Error("Pending message metadata is missing its inline layout.");
89+
}
90+
expect(statusBox.x).toBeGreaterThan(timestampBox.x);
91+
expect(Math.abs(statusBox.y - timestampBox.y)).toBeLessThanOrEqual(1);
92+
93+
await waitForAnimations(page);
94+
await pendingRow.screenshot({ path: `${SHOTS}/pending-message-inline.png` });
95+
});
96+
97+
test("profile hover uses the channel hover surface", async ({ page }) => {
98+
await installMockBridge(page);
99+
await page.goto("/");
100+
101+
const profile = page.getByTestId("sidebar-profile-card");
102+
const channel = page.getByTestId("channel-random");
103+
await channel.hover();
104+
const channelHoverColor = await channel.evaluate(
105+
(element) => getComputedStyle(element).backgroundColor,
106+
);
107+
await profile.hover();
108+
await expect(profile).toHaveCSS("background-color", channelHoverColor);
109+
110+
await waitForAnimations(page);
111+
await page
112+
.getByTestId("app-sidebar")
113+
.screenshot({ path: `${SHOTS}/profile-hover.png` });
114+
});

0 commit comments

Comments
 (0)