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。

feat(mobile): 云端对话显示消息附件(主人附件与伙伴回复产物)

nanabcdf84d9f0a6
diff --git a/apps/mobile/src/__tests__/CloudCompanionScreenAttachments.test.tsx b/apps/mobile/src/__tests__/CloudCompanionScreenAttachments.test.tsx
new file mode 100644
index 0000000000..b301c42745
--- /dev/null
+++ b/apps/mobile/src/__tests__/CloudCompanionScreenAttachments.test.tsx
@@ -0,0 +1,94 @@
+// @vitest-environment jsdom
+import { act, createElement } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+
+const h = vi.hoisted(() => ({
+ stub: (_name: string) => () => null,
+ room: { status: 'ready', messages: [] as unknown[], before: null, loadingOlder: false, reload: vi.fn(), loadOlder: vi.fn(), media: vi.fn() },
+ strips: [] as Array<{ messageId: string; align: string; names: string[]; resolve: unknown }>,
+}));
+vi.mock('react-native', async () => {
+ const { createElement: el } = await import('react');
+ const view = ({ children, testID }: any) => el('div', { 'data-testid': testID }, children);
+ return { View: view, ScrollView: view, ActivityIndicator: view, StyleSheet: { create: (s: any) => s, hairlineWidth: 1 } };
+});
+vi.mock('expo-router', () => ({ Stack: { Screen: () => null }, useRouter: () => ({}) }));
+vi.mock('react-native-safe-area-context', async () => ({ SafeAreaView: (await import('react-native')).View }));
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+vi.mock('@/auth/AuthContext', () => ({ useAuth: () => ({ user: { id: 'u' } }) }));
+vi.mock('@/components/AppText', async () => ({ Text: (await import('react-native')).View }));
+vi.mock('@/components/RemoteCompanionAvatar', () => ({ RemoteCompanionAvatar: h.stub('avatar') }));
+vi.mock('@/chat/useCloudCompanion', () => ({ useCloudCompanionHome: () => ({ actors: [{ id: 'actor', name: 'Mia', avatar: null, homeDeviceId: 'mac' }], setHome: vi.fn(), refresh: vi.fn() }) }));
+vi.mock('@/chat/useCloudCompanionRoom', () => ({ useCloudCompanionRoom: () => h.room }));
+vi.mock('@/device-link/DeviceLinkContext', () => ({ useDeviceLink: () => ({ readDeviceList: vi.fn() }) }));
+vi.mock('@/device-link/devices', () => ({ toDeviceListItems: () => [] }));
+vi.mock('@/device-link/remoteResourceCache', () => ({ cachedBotItem: () => null }));
+vi.mock('@/device-link/revokedDevicesStore', () => ({ useRevokedDevices: () => new Set() }));
+vi.mock('@/theme', async () => {
+ const colors = new Proxy({}, { get: () => '#777777' });
+ return { useTheme: () => ({ colors }), useThemedStyles: (make: any) => make(colors) };
+});
+vi.mock('@/theme/userBubblePreference', () => ({ useUserBubbleAppearance: () => ({ colors: null }) }));
+vi.mock('@/utils/backGuard', () => ({ goBackGuarded: vi.fn() }));
+vi.mock('@/platform/AdaptiveWindowContext', () => ({ useAdaptiveWindow: () => ({ width: 402 }) }));
+vi.mock('@/session/BotGroupAvatars', () => ({ BOT_GROUP_MESSAGE_AVATAR_SIZE: 28 }));
+vi.mock('@/session/BotGroupMessageText', async () => {
+ const { createElement: el } = await import('react');
+ return { BotGroupUserText: ({ content }: any) => el('p', { 'data-kind': 'user-text' }, content),
+ BotGroupMarkdownText: ({ content }: any) => el('p', { 'data-kind': 'reply-text' }, content) };
+});
+vi.mock('@/session/MessageRenderer', () => ({ MarkdownBody: h.stub('markdown') }));
+vi.mock('@/session/messageContentLayout', () => ({ buildMessageContentLayout: () => ({}) }));
+vi.mock('@/session/ChatIdentityHeader', () => ({ CHAT_HEADER_MARK_SIZE: 32, ChatIdentityHeader: h.stub('header'), ChatIdentitySubtitle: h.stub('subtitle') }));
+vi.mock('@/session/CompanionCardButton', () => ({ CompanionCardActions: h.stub('actions'), CompanionCardButton: h.stub('button') }));
+vi.mock('@/session/CompanionSettingsRow', () => ({ CompanionSettingsRow: h.stub('row') }));
+vi.mock('@/session/CompanionSheet', () => ({ CompanionSheet: h.stub('sheet') }));
+vi.mock('@/session/useTeammateNavigation', () => ({ useTeammateNavigation: () => ({ openTeammate: vi.fn() }) }));
+vi.mock('@/session/useTeammateRoster', () => ({ TEAMMATE_COLLECTION_ID: 'teammates', useTeammateRoster: () => ({ items: [], refresh: vi.fn(), isOnline: () => false }) }));
+vi.mock('@/session/BotGroupMessageAttachments', async () => {
+ const { createElement: el } = await import('react');
+ return { BotGroupMessageAttachments: (props: any) => {
+ h.strips.push({ messageId: props.messageId, align: props.align, names: props.attachments.map((a: any) => a.name), resolve: props.resolveServerMedia });
+ return el('div', { 'data-kind': 'strip', 'data-message': props.messageId });
+ } };
+});
+import { CloudCompanionScreen } from '@/session/CloudCompanionScreen';
+
+Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
+const id = (n: number) => `00000000-0000-4000-8000-${String(n).padStart(12, '0')}`;
+const message = (n: number, authorId: string, content: unknown[]) => ({ id: id(n), seq: String(n), authorId, author: { kind: 'x', name: '' },
+ createdAt: `2026-10-13T00:00:0${n}Z`, deleted: false, threadRootId: null, content });
+let root: Root;
+let container: HTMLElement;
+beforeEach(() => {
+ h.strips.length = 0; h.room.status = 'ready';
+ container = document.createElement('div'); root = createRoot(container);
+});
+afterEach(() => act(() => root.unmount()));
+const render = () => act(async () => root.render(createElement(CloudCompanionScreen, { actorId: id(1), botId: 'mia', deviceId: 'mac', deviceName: 'Mac', title: 'Mia' })));
+
+// Tier: behavior. The offline cloud conversation drew only message.text, so an owner's file or a
+// companion's deliverable (media blocks of the room message) never appeared; an attachment-only message vanished.
+it('shows the owner\'s and the companion\'s attachments under their messages, including messages without text', async () => {
+ h.room.messages = [
+ message(2, id(9), [{ type: 'text', text: 'please summarise' }, { type: 'media', mediaId: id(20), caption: 'notes.pdf' }]),
+ message(3, id(1), [{ type: 'text', text: 'done' }, { type: 'media', mediaId: id(21), caption: 'chart.png' }, { type: 'media', mediaId: id(22), caption: 'report.docx' }]),
+ message(4, id(1), [{ type: 'media', mediaId: id(23), caption: 'extra.zip' }]),
+ message(5, id(9), [{ type: 'media', mediaId: id(24), caption: 'photo.jpg' }]),
+ message(6, id(1), [{ type: 'text', text: 'plain' }]),
+ ];
+ await render();
+ expect(h.strips.map(({ messageId, align, names }) => ({ messageId, align, names }))).toEqual([
+ { messageId: id(2), align: 'right', names: ['notes.pdf'] },
+ { messageId: id(3), align: 'left', names: ['chart.png', 'report.docx'] },
+ { messageId: id(4), align: 'left', names: ['extra.zip'] },
+ { messageId: id(5), align: 'right', names: ['photo.jpg'] },
+ ]);
+ // Each strip fetches its addresses from the room hook.
+ expect(h.strips.every(strip => strip.resolve === h.room.media)).toBe(true);
+ expect(container.querySelectorAll('[data-testid="cloudCompanion.message.user"]')).toHaveLength(2);
+ expect(container.querySelectorAll('[data-testid="cloudCompanion.message.companion"]')).toHaveLength(3);
+ // Captions are the attachments' names, not text repeated beside them; an attachment-only message has no empty bubble.
+ expect([...container.querySelectorAll('p')].map(node => node.textContent)).toEqual(['please summarise', 'done', 'plain']);
+});
diff --git a/apps/mobile/src/__tests__/cloudCompanion.test.ts b/apps/mobile/src/__tests__/cloudCompanion.test.ts
index 5c4cf1d088..1885c80013 100644
--- a/apps/mobile/src/__tests__/cloudCompanion.test.ts
+++ b/apps/mobile/src/__tests__/cloudCompanion.test.ts
@@ -59,6 +59,20 @@ describe('cloud companion rows', () => {
], id(1));
expect(view.map(item => [item.text, item.fromCompanion])).toEqual([['hello', false], ['reply', true]]);
});
+ it('keeps attachments beside the text: attachment-only messages stay, captions are not repeated as text, unknown blocks stay out', () => {
+ const base = { authorId: id(1), author: { kind: 'bot', name: '' }, createdAt: '2026-10-13T00:00:00Z', deleted: false, threadRootId: null };
+ const view = cloudCompanionMessages([
+ { ...base, id: id(10), seq: '10', content: [{ type: 'media', mediaId: id(40), caption: 'report.docx' }] },
+ { ...base, id: id(11), seq: '11', authorId: id(9), content: [{ type: 'text', text: '〔来自飞书〕\nlook' }, { type: 'media', mediaId: id(41), caption: 'a.png' },
+ { type: 'media', mediaId: id(42) }, { type: 'media', caption: 'no-id.png' }, { type: 'widget' }] },
+ { ...base, id: id(12), seq: '12', content: [{ type: 'widget' }] },
+ { ...base, id: id(13), seq: '13', deleted: true, content: [{ type: 'media', mediaId: id(43), caption: 'gone.png' }] },
+ ], id(1));
+ expect(view.map(item => ({ id: item.id, text: item.text, names: item.attachments.map(attachment => [attachment.id, attachment.name]) }))).toEqual([
+ { id: id(10), text: '', names: [[id(40), 'report.docx']] },
+ { id: id(11), text: '〔来自飞书〕\nlook', names: [[id(41), 'a.png'], [id(42), expect.any(String)]] },
+ ]);
+ });
it('orders by message time, so older history uploaded later still appears first', () => {
const at = (n: number, time: string): ChatMessage => ({ id: id(n), seq: String(n), authorId: id(9), author: { kind: 'human', name: '' },
createdAt: time, deleted: false, threadRootId: null, content: [{ type: 'text', text: `m${n}` }] });
diff --git a/apps/mobile/src/__tests__/useCloudCompanionRoom.test.tsx b/apps/mobile/src/__tests__/useCloudCompanionRoom.test.tsx
new file mode 100644
index 0000000000..0cfe2846be
--- /dev/null
+++ b/apps/mobile/src/__tests__/useCloudCompanionRoom.test.tsx
@@ -0,0 +1,55 @@
+// @vitest-environment jsdom
+import { act, createElement } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+
+const h = vi.hoisted(() => ({ owner: 'owner:1:global', current: true, companionRoom: vi.fn(), history: vi.fn(), media: vi.fn() }));
+vi.mock('react-native', () => ({ AppState: { addEventListener: () => ({ remove() {} }) } }));
+vi.mock('expo-crypto', () => ({ digestStringAsync: vi.fn(async () => 'hash'), CryptoDigestAlgorithm: { SHA256: 'SHA-256' }, CryptoEncoding: { HEX: 'hex' } }));
+vi.mock('expo-router', async () => {
+ const { useEffect } = await import('react');
+ return { useFocusEffect: (effect: () => void | (() => void)) => useEffect(effect, [effect]) };
+});
+vi.mock('@/chat/useChatServer', async () => {
+ const { useMemo } = await import('react');
+ return { useChatClient: () => useMemo(() => ({ owner: h.owner, enabled: true, current: () => h.current,
+ client: { companionRoom: h.companionRoom, history: h.history, media: h.media } }), [h.owner]) };
+});
+import { useCloudCompanionRoom } from '@/chat/useCloudCompanionRoom';
+
+Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
+const ROOM = '00000000-0000-4000-8000-0000000000aa';
+const MEDIA = '00000000-0000-4000-8000-0000000000bb';
+let root: Root;
+let result: ReturnType<typeof useCloudCompanionRoom>;
+function Probe() { result = useCloudCompanionRoom('actor', 'Writer', true); return null; }
+const render = () => act(async () => root.render(createElement(Probe)));
+beforeEach(() => {
+ vi.resetAllMocks(); h.owner = 'owner:1:global'; h.current = true;
+ h.companionRoom.mockResolvedValue(ROOM); h.history.mockResolvedValue({ messages: [], before: null });
+ root = createRoot(document.createElement('div'));
+});
+afterEach(() => act(() => root.unmount()));
+
+// Tier: behavior. An attachment address is signed per room, so it must be asked of the room this
+// hook resolved, and an answer that arrives after the account changed must not be shown.
+it('fetches an attachment address from the 1:1 room and drops it when the account changed meanwhile', async () => {
+ const file = { id: MEDIA, name: 'report.docx', mimeType: 'application/msword', size: 3, category: 'file', url: 'https://files.example/r', path: null };
+ h.media.mockResolvedValue(file);
+ await render();
+ await expect(result.media(MEDIA)).resolves.toBe(file);
+ expect(h.media).toHaveBeenCalledWith(ROOM, MEDIA);
+ let complete!: (value: unknown) => void;
+ h.media.mockImplementationOnce(() => new Promise(resolve => { complete = resolve; }));
+ const late = result.media(MEDIA);
+ h.current = false;
+ complete(file);
+ await expect(late).rejects.toThrow('OWNER_CHANGED');
+});
+
+it('has no address to fetch before the room is known', async () => {
+ h.companionRoom.mockReturnValue(new Promise(() => {}));
+ await render();
+ await expect(result.media(MEDIA)).rejects.toThrow('OWNER_CHANGED');
+ expect(h.media).not.toHaveBeenCalled();
+});
diff --git a/apps/mobile/src/chat/chatServerClient.ts b/apps/mobile/src/chat/chatServerClient.ts
index fed3a29ef1..826dd10d7e 100644
--- a/apps/mobile/src/chat/chatServerClient.ts
+++ b/apps/mobile/src/chat/chatServerClient.ts
@@ -70,12 +70,16 @@ const bodyBlocks = (message: ChatMessage) => message.deleted || readImportedBotG
// Media blocks are the message's attachments; only the list preview falls back to their names.
const contentText = (message: ChatMessage) => bodyBlocks(message)
.flatMap(block => block.type === 'media' ? [] : [block.text ?? block.fallback ?? '']).join('\n');
-// The cloud companion transcript has no attachment strip, so it keeps captions inline.
-export const chatMessageText = (message: ChatMessage) => bodyBlocks(message)
- .map(block => block.text ?? block.fallback ?? (block.type === 'media' ? block.caption ?? '' : '')).join('\n');
+// The cloud companion transcript draws the same attachment strip as the group chat, so its text leaves media out too.
+export const chatMessageText = contentText;
// The server makes a caption optional; an unnamed attachment still needs a visible name.
const attachmentName = (block: ChatMessage['content'][number]) => block.caption?.trim()
|| (i18next.isInitialized ? i18next.t('groupChat.files.untitled') : '') || 'Attachment';
+/** The message's media blocks as attachments; the address is fetched when one is opened (`media`). */
+export const chatMessageAttachments = (message: ChatMessage): BotGroupAttachment[] => message.deleted ? [] : message.content.flatMap(block => {
+ if (block.type !== 'media' || !block.mediaId) return [];
+ return [{ id: block.mediaId, name: attachmentName(block), category: 'file' as const, mimeType: '', size: 0, url: null, path: null }];
+});
const mediaNames = (message: ChatMessage) => message.deleted ? '' : message.content
.flatMap(block => block.type === 'media' ? [attachmentName(block)] : []).join(', ');
@@ -173,11 +177,7 @@ export function chatGroupView(page: ChatPage, selfId: string, actors: readonly C
isSelf: message.authorId === selfId, content: contentText(message), mentions: { all: false, botIds: [] },
...(quote ? { quote: deletedIds.has(quote.messageId) ? { ...quote, originalDeleted: true } : quote } : {}),
noticeCode: joined ? 'member-joined' : null, planId: null, files: [],
- attachments: message.deleted ? [] : message.content.flatMap(block => {
- if (block.type !== 'media' || !block.mediaId) return [];
- return [{ id: block.mediaId, name: attachmentName(block), category: 'file' as const,
- mimeType: '', size: 0, url: null, path: null }];
- }), createdAt: Date.parse(message.createdAt) };
+ attachments: chatMessageAttachments(message), createdAt: Date.parse(message.createdAt) };
});
const last = messages.at(-1);
const failures = (page.failures ?? []).flatMap(row => {
diff --git a/apps/mobile/src/chat/cloudCompanion.ts b/apps/mobile/src/chat/cloudCompanion.ts
index 144c1b33ec..178d3896e2 100644
--- a/apps/mobile/src/chat/cloudCompanion.ts
+++ b/apps/mobile/src/chat/cloudCompanion.ts
@@ -6,7 +6,8 @@
import { isMobilePlatform } from '@cindy/maker-shared/device-list';
import type { RemoteResourceAvatar } from '@cindy/device-link';
import type { HostedRemoteCollectionItem } from '@/device-link/remoteResources';
-import { chatCursor, chatMessageText, type ChatActor, type ChatMessage, type ChatSetHomeResult } from './chatServerClient';
+import type { BotGroupAttachment } from '@cindy/maker-shared/botGroupChat';
+import { chatCursor, chatMessageAttachments, chatMessageText, type ChatActor, type ChatMessage, type ChatSetHomeResult } from './chatServerClient';
/** How long the phone waits for the new main computer to list the companion. */
export const CLOUD_SWITCH_TIMEOUT_MS = 90_000;
@@ -72,9 +73,12 @@ export function cloudHomeTargets<T extends { deviceId: string; online: boolean }
return targets.filter(target => target.online && target.deviceId !== home && target.deviceId !== self);
}
-export interface CloudMessage { id: string; fromCompanion: boolean; text: string; createdAt: number }
+export interface CloudMessage { id: string; fromCompanion: boolean; text: string; attachments: BotGroupAttachment[]; createdAt: number }
-/** Oldest first, deduplicated; the companion's actor wrote its replies, everyone else is the owner. */
+/**
+ * Oldest first, deduplicated; the companion's actor wrote its replies, everyone else is the owner.
+ * A message with only attachments stays; one with neither text nor attachments is dropped.
+ */
export function cloudCompanionMessages(messages: readonly ChatMessage[], actorId: string): CloudMessage[] {
const unique = [...new Map(messages.map(message => [message.id, message])).values()]
.filter(message => !message.deleted && !message.threadRootId && message.origin !== 'system');
@@ -87,7 +91,9 @@ export function cloudCompanionMessages(messages: readonly ChatMessage[], actorId
});
return unique.flatMap(message => {
const text = chatMessageText(message).trim();
- return text ? [{ id: message.id, fromCompanion: message.authorId === actorId, text, createdAt: Date.parse(message.createdAt) }] : [];
+ const attachments = chatMessageAttachments(message);
+ return text || attachments.length
+ ? [{ id: message.id, fromCompanion: message.authorId === actorId, text, attachments, createdAt: Date.parse(message.createdAt) }] : [];
});
}
diff --git a/apps/mobile/src/chat/useCloudCompanionRoom.ts b/apps/mobile/src/chat/useCloudCompanionRoom.ts
index 95fadfc35f..bdc61235b0 100644
--- a/apps/mobile/src/chat/useCloudCompanionRoom.ts
+++ b/apps/mobile/src/chat/useCloudCompanionRoom.ts
@@ -2,6 +2,7 @@ import { useCallback, useRef, useState } from 'react';
import { AppState } from 'react-native';
import { useFocusEffect } from 'expo-router';
import * as Crypto from 'expo-crypto';
+import type { BotGroupAttachment } from '@cindy/maker-shared/botGroupChat';
import { chatAccessLost, type ChatMessage } from './chatServerClient';
import { useChatClient } from './useChatServer';
@@ -63,6 +64,14 @@ export function useCloudCompanionRoom(actorId: string, name: string, enabled: bo
if (valid()) setState(old => ({ ...old, loadingOlder: false }));
} finally { olderPending.current = false; }
}, [api, identity]);
+ /** The signed address of one attachment, fetched when it is opened (a stale address is simply fetched again). */
+ const media = useCallback(async (mediaId: string): Promise<BotGroupAttachment> => {
+ const current = latest.current;
+ if (current.identity !== identity || !current.roomId) throw new Error('OWNER_CHANGED');
+ const attachment = await api.client.media(current.roomId, mediaId);
+ if (!valid()) throw new Error('OWNER_CHANGED');
+ return attachment;
+ }, [api, identity]);
const own = state.identity === identity ? state : initial();
- return { ...own, reload, loadOlder };
+ return { ...own, reload, loadOlder, media };
}
diff --git a/apps/mobile/src/session/CloudCompanionScreen.tsx b/apps/mobile/src/session/CloudCompanionScreen.tsx
index 8497dc74c4..e0c721b2e2 100644
--- a/apps/mobile/src/session/CloudCompanionScreen.tsx
+++ b/apps/mobile/src/session/CloudCompanionScreen.tsx
@@ -22,6 +22,7 @@ import { fontWeight, lineHeight, radius, spacing, typeScale } from '@/theme/toke
import { useUserBubbleAppearance } from '@/theme/userBubblePreference';
import { goBackGuarded } from '@/utils/backGuard';
import { BOT_GROUP_MESSAGE_AVATAR_SIZE } from './BotGroupAvatars';
+import { BotGroupMessageAttachments } from './BotGroupMessageAttachments';
import { BotGroupMarkdownText, BotGroupUserText } from './BotGroupMessageText';
import { hasRichAnswer } from '@cindy/maker-shared/rich-answer';
import { MarkdownBody } from './MessageRenderer';
@@ -42,6 +43,8 @@ const REPLY_AVATAR_GAP = 10;
const LOAD_OLDER_THRESHOLD_PX = 120;
const STICK_TO_BOTTOM_PX = 48;
const NO_MENTIONS: readonly string[] = [];
+/** Room attachments are signed server files; nothing in this room lives on a computer. */
+const noRemoteMedia = async (): Promise<never> => { throw new Error('REMOTE_MEDIA_UNAVAILABLE'); };
type Notice = 'noTargets' | 'devicesFailed' | null;
@@ -208,17 +211,26 @@ export function CloudCompanionScreen({ actorId, botId, deviceId, deviceName, tit
</View>
{messages.length === 0 ? <Text style={styles.centerText} testID="cloudCompanion.empty">{t('devices.cloudCompanion.empty')}</Text> : null}
{messages.map((message, index) => {
+ const attachments = message.attachments.length
+ ? <BotGroupMessageAttachments messageId={message.id} attachments={message.attachments} align={message.fromCompanion ? 'left' : 'right'}
+ onResolveRemoteMedia={noRemoteMedia} resolveServerMedia={room.media} /> : null;
if (!message.fromCompanion) return <View key={message.id} style={styles.userRow} testID="cloudCompanion.message.user">
- <View style={[styles.userBubble, userBubbleColors && { backgroundColor: userBubbleColors.background, borderColor: userBubbleColors.border }]}>
- <BotGroupUserText content={message.text} mentionLabels={NO_MENTIONS} />
+ <View style={styles.userColumn}>
+ {message.text ? <View style={[styles.userBubble, userBubbleColors && { backgroundColor: userBubbleColors.background, borderColor: userBubbleColors.border }]}>
+ <BotGroupUserText content={message.text} mentionLabels={NO_MENTIONS} />
+ </View> : null}
+ {attachments}
</View>
</View>;
const continued = index > 0 && messages[index - 1]!.fromCompanion;
return <View key={message.id} style={[styles.replyRow, continued && styles.replyRowContinued]} testID="cloudCompanion.message.companion">
{continued ? <View style={styles.avatarSpacer} /> : <View style={styles.avatarSlot}>{avatar(BOT_GROUP_MESSAGE_AVATAR_SIZE)}</View>}
- <View style={styles.replyColumn}>{hasRichAnswer(message.text)
- ? <MarkdownBody renderRichAnswers markdownImageCacheKey={`cloud:${actorId}:${message.id}`} layout={answerLayout} text={message.text} selectable />
- : <BotGroupMarkdownText content={message.text} />}</View>
+ <View style={styles.replyColumn}>
+ {!message.text ? null : hasRichAnswer(message.text)
+ ? <MarkdownBody renderRichAnswers markdownImageCacheKey={`cloud:${actorId}:${message.id}`} layout={answerLayout} text={message.text} selectable />
+ : <BotGroupMarkdownText content={message.text} />}
+ {attachments}
+ </View>
</View>;
})}
</ScrollView>;
@@ -280,14 +292,15 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({
timeline: { flexGrow: 1, justifyContent: 'flex-end', gap: spacing.lg, paddingHorizontal: spacing.lg, paddingVertical: spacing.md },
olderSlot: { alignItems: 'center' },
userRow: { flexDirection: 'row', justifyContent: 'flex-end' },
+ userColumn: { maxWidth: '86%', alignItems: 'flex-end', gap: spacing.xs },
// The 1:1 user bubble: 86% wide, padding 12.
- userBubble: { maxWidth: '86%', backgroundColor: colors.surfaceElevated, borderColor: colors.border, borderWidth: StyleSheet.hairlineWidth,
+ userBubble: { backgroundColor: colors.surfaceElevated, borderColor: colors.border, borderWidth: StyleSheet.hairlineWidth,
borderRadius: radius.container, padding: spacing.md },
replyRow: { flexDirection: 'row', alignItems: 'flex-start', gap: REPLY_AVATAR_GAP },
replyRowContinued: { marginTop: -spacing.sm },
avatarSlot: { marginTop: 2 },
avatarSpacer: { width: BOT_GROUP_MESSAGE_AVATAR_SIZE },
- replyColumn: { flex: 1, minWidth: 0 },
+ replyColumn: { flex: 1, minWidth: 0, gap: spacing.xs },
// Where the composer would be: a quiet, disabled-looking strip with the explanation.
footer: { marginHorizontal: spacing.lg, marginTop: spacing.xs, marginBottom: spacing.sm, minHeight: 44, justifyContent: 'center',
paddingHorizontal: spacing.lg, paddingVertical: spacing.sm, borderRadius: radius.pill, backgroundColor: colors.surfaceChip },
diff --git a/docs/product-rules/cloud-companions.md b/docs/product-rules/cloud-companions.md
index d471ef21b4..8d96147401 100644
--- a/docs/product-rules/cloud-companions.md
+++ b/docs/product-rules/cloud-companions.md
@@ -140,6 +140,11 @@
交出前补完。房间按到达顺序排列,读取时(离线查看、接管导入、手机)按消息时间排序。
- 主力电脑在线时,其他电脑与手机继续用现有远程方式(device-link)直接看和发主任务,体验不变。
- 主力电脑离线时,其他端从房间读取对话层;用户在离线横幅里选择切换电脑后再继续。
+- 手机的云端对话也显示附件:主人消息和伙伴回复下,房间消息里的每个附件(主人发的图片 / 文件、伙伴回复随带的产物)
+ 与群聊时间线同一种呈现——文件条显示文件名,点开时才向服务器取短期地址(图片进看图器,其他文件用系统浏览器打开);
+ 取不到(地址过期、网络失败、附件已删)时提示失败,再点一次即重试。只有附件没有文字的消息照常显示,没有文字气泡;
+ 附件名不再作为文字重复显示。手机读的是房间原始消息,不含桌面端换电脑导入时追加在正文后的图片 / 文件链接,所以不会重复。
+ 不认识的内容块不显示;没有名字的附件显示「附件」占位名。
- 房间里由主人直接发出的消息(例如未来的离线排队)在主力电脑上线后由它领取,作为「来自其他设备」的
消息投递进主任务;伙伴回复由导入同步回房间,不重复写。主任务未在运行时按它保存的权限档唤醒,不借后台唤醒的默认完全访问。房间消息等同同账号设备远程操作这台电脑,只在这台电脑开启「允许同账号设备控制本机」时投递(否则该条执行失败、不进主任务);房间消息没有经认证的设备标识,无法按「已撤销的控制设备」逐台拒绝。