Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): keep attachment-only teammate DM bubbles in share images

zqchrisee95d622af1a
diff --git a/apps/desktop/src/renderer/__tests__/HookTaskCard.test.tsx b/apps/desktop/src/renderer/__tests__/HookTaskCard.test.tsx
index e3770ef07a..d59d3a8f45 100644
--- a/apps/desktop/src/renderer/__tests__/HookTaskCard.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/HookTaskCard.test.tsx
@@ -363,3 +363,33 @@ describe('HookTaskCard attached context', () => {
expect(screen.getByRole('button', { name: i18n.t('chat.userMessage.editCancel') })).toBeTruthy();
});
});
+
+describe('teammate DM attachment-only bubbles in share images', () => {
+ // Value: real UserMessage -> production stripMessageSources, the share-image path.
+ // Regression: #6624 moved teammate DM attachments into the bubble, which was still
+ // marked as a removable source label when it had no text, so sharing dropped the attachment.
+ // Coverage gap: the existing share test only covers IM source headers, not DM attachments.
+ // Minimal unit input: a teammate DM user message with one image or one file and no text.
+ // Standalone file: 3.00s Vitest, including the existing HookTaskCard cases.
+ it.each([
+ ['image', { images: [{ base64: 'iVBORw0KGgo=', mimeType: 'image/png', originalName: 'shot.png' }] }],
+ ['file', { files: [{ name: 'report.pdf', path: '/fixture/report.pdf' }] }],
+ ])('keeps an %s-only message when the share image strips source labels', async (_kind, attachments) => {
+ let container!: HTMLElement;
+ await act(async () => {
+ ({ container } = render(
+ <MemoryRouter>
+ <ConfirmDialogProvider>
+ <Tooltip.Provider>
+ <UserMessage content="" workingDir="" simplifiedBotConversation {...attachments} />
+ </Tooltip.Provider>
+ </ConfirmDialogProvider>
+ </MemoryRouter>,
+ ));
+ });
+ const clone = container.cloneNode(true) as HTMLElement;
+ stripMessageSources(clone);
+ if ('images' in attachments) expect(clone.querySelector('img[alt="shot.png"]')).toBeTruthy();
+ else expect(clone.textContent).toContain('report.pdf');
+ });
+});
diff --git a/apps/desktop/src/renderer/components/chat/UserMessage.tsx b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
index 993989fd6a..b81d466c36 100644
--- a/apps/desktop/src/renderer/components/chat/UserMessage.tsx
+++ b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
@@ -1516,7 +1516,8 @@ export function UserMessage({
{(inlineQuoteCount > 0 || displayBubbleBody.trim() || ghostChipDisplay || attachmentsInBubble) && (
<div
// 只剩插件标注行的气泡:分享图会剥掉标注,整泡一起去掉,不留空壳。
- {...(inlineQuoteCount === 0 && !displayBubbleBody.trim()
+ // 伙伴私聊里附件也在气泡内,有附件就不是空壳。
+ {...(inlineQuoteCount === 0 && !displayBubbleBody.trim() && !attachmentsInBubble
? { [SHARE_SOURCE_ATTR]: '' }
: {})}
className={cn(