fix(desktop): 保持群聊短消息回执前后的气泡宽度

Assisted-by: Cindy (https://cindy.app)
Signed-off-by: nana <823073145@qq.com>
This commit is contained in:
nana
2026-11-05 16:01:35 +08:00
parent 072f791b42
commit 4fbd13913d
3 changed files with 41 additions and 5 deletions

View File

@@ -8,6 +8,10 @@ export default {
name: 'group-review-layout',
entry: '../group-control/group-control-fixture.tsx',
cases: {
...Object.fromEntries([400, 520, 521, 1200].map(width => [`short-${width}`, {
about: 'A one-character server message keeps its bubble and full toolbar dimensions until acknowledged',
viewport: { width, height: 760 }, data: { ...data, bubbles: true, sendStatus: true },
}])),
...Object.fromEntries([400, 520, 521, 1200].map(width => [`send-${width}`, {
about: 'Pending, slow and acknowledged messages retain identical geometry across the narrow-toolbar breakpoint',
viewport: { width, height: 760 }, data: { ...data, messages: 40, sendStatus: true },
@@ -22,6 +26,38 @@ export default {
}])),
},
async check(page, ui) {
if (ui.case.startsWith('short-')) {
const input = page.locator('textarea');
const outbox = page.getByTestId('bot-group-outbox');
const row = page.locator('[data-bot-group-message-id^="pending:"], [data-bot-group-message-id^="sent-"]');
const geometry = () => row.evaluate(el => {
const bounds = target => {
const { x, width, height } = target.getBoundingClientRect();
return { x, width, height };
};
return {
row: bounds(el),
bubble: bounds(el.querySelector('[data-testid="bot-group-self-bubble"]')),
toolbar: bounds(el.querySelector('[data-bot-group-message-actions]')),
};
});
await input.fill('好');
await input.press('Enter');
await outbox.waitFor();
const pending = await geometry();
assert.equal(await outbox.getByRole('button').count(), 0, 'pending actions stay inaccessible');
await ui.capture('pending');
await outbox.getByRole('status').waitFor({ state: 'attached' });
assert.deepEqual(await geometry(), pending, 'slow feedback preserves the short bubble');
await page.evaluate(() => window.dispatchEvent(new CustomEvent('fixture-send-receipt', { detail: 'ok' })));
await outbox.waitFor({ state: 'detached' });
const sent = await geometry();
await ui.capture('sent');
console.log('SHORT_SEND_GEOMETRY', JSON.stringify({ pending, sent }));
assert.deepEqual(sent, pending, 'receipt preserves the short bubble and all toolbar slots');
assert.equal(await row.locator('[data-bot-group-message-actions]').getByRole('button').count(), 4);
return;
}
if (ui.case.startsWith('send-')) return group.check.call(group, page, {
...ui, case: 'send-status',
async capture(label) {

View File

@@ -1393,7 +1393,7 @@ function BotGroupChatContent({ groupId, direct }: { groupId: string; direct: boo
const owned = !isPlanCard && message.authorKind === 'user' && message.isSelf === false
? botGroupOwnedBotNames(member, members).join(separator) : '';
const isOpenPlanCard = isPlanCard && openPlan !== null && openPlan.id === message.planId;
const quotable = canQuote && !message.pending && isBotGroupMessageQuotable(message);
const quotable = canQuote && isBotGroupMessageQuotable(message);
return (
<Fragment key={adoptedKeysRef.current.get(message.id) ?? message.id}>
{rowLayout?.dateDivider != null ? <BotGroupDateDivider timestamp={rowLayout.dateDivider} locale={locale} /> : null}
@@ -1416,7 +1416,7 @@ function BotGroupChatContent({ groupId, direct }: { groupId: string; direct: boo
quoteDisplay={quoteDisplays.get(message.id)?.display}
onLocateQuote={onLocateQuote}
onQuote={quotable ? onQuote : undefined}
onOpenThread={group.serverBacked && !direct && !message.pending ? onOpenThread : undefined}
onOpenThread={group.serverBacked && !direct ? onOpenThread : undefined}
onChanged={onChanged}
highlighted={highlightId === message.id}
focusable={jumpTarget === message.id || highlightId === message.id}

View File

@@ -453,7 +453,7 @@ function BotGroupTimelineItemImpl(props: BotGroupTimelineItemProps) {
/>
) : null;
const share = message.threadShare;
const threadPreview = props.onOpenThread && (message.replyCount ?? 0) > 0 ? (
const threadPreview = !message.pending && props.onOpenThread && (message.replyCount ?? 0) > 0 ? (
<BotGroupThreadPreview message={message} members={members}
onOpen={() => props.onOpenThread!(message.id)} />
) : null;
@@ -462,9 +462,9 @@ function BotGroupTimelineItemImpl(props: BotGroupTimelineItemProps) {
<CornerDownRight size={12} aria-hidden />{sending ? t('bots.groupChat.timeline.sending') : botGroupThreadShareLabel(share, t)}</p>
<BotGroupThreadShareQuote share={share} members={members} inset={!self}
attachments={<BotGroupMessageAttachments attachments={share.attachments} align="start" />}
onOpenThread={props.onOpenThread ? () => props.onOpenThread!(share.threadRootId, share.messageId) : undefined} />
onOpenThread={!message.pending && props.onOpenThread ? () => props.onOpenThread!(share.threadRootId, share.messageId) : undefined} />
</> : null;
// Reserve the toolbar's actual height while awaiting the server message id.
// Keep every action slot while awaiting the server id; inert prevents premature interaction.
const actions = message.kind === 'message' && props.showActions !== false ? (
<div className={cn('contents', message.pending && 'invisible')} inert={message.pending || undefined} aria-hidden={message.pending || undefined}>
<ChatMessageHoverActions