Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): keep group attachment previews within safe area
ylliuuu66aa383f1f28cc
diff --git a/apps/mobile/src/__tests__/BotGroupTextAttachmentPreview.test.tsx b/apps/mobile/src/__tests__/BotGroupTextAttachmentPreview.test.tsxindex 92738df6d1..6783316772 100644--- a/apps/mobile/src/__tests__/BotGroupTextAttachmentPreview.test.tsx+++ b/apps/mobile/src/__tests__/BotGroupTextAttachmentPreview.test.tsx@@ -60,7 +60,10 @@ vi.mock('@/session/MarkdownFileReader', async () => {});vi.mock('react-native-safe-area-context', async () => {const React = await import('react');- return { SafeAreaView: ({ children }: any) => React.createElement('div', null, children) };+ return {+ SafeAreaProvider: ({ children }: any) => React.createElement('div', null, children),+ SafeAreaView: ({ children }: any) => React.createElement('div', null, children),+ };});vi.mock('react-native', async () => {const React = await import('react');diff --git a/apps/mobile/src/session/BotGroupTextAttachmentPreview.tsx b/apps/mobile/src/session/BotGroupTextAttachmentPreview.tsxindex 808b3cf72b..8758b831b9 100644--- a/apps/mobile/src/session/BotGroupTextAttachmentPreview.tsx+++ b/apps/mobile/src/session/BotGroupTextAttachmentPreview.tsx@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { ExternalLink, X } from 'lucide-react-native';import { ActivityIndicator, FlatList, Modal, Pressable, StyleSheet, View } from 'react-native';-import { SafeAreaView } from 'react-native-safe-area-context';+import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';import { openBrowserAsync } from 'expo-web-browser';import type { BotGroupAttachment } from '@cindy/maker-shared/botGroupChat';import { extractRemoteFileExt, isHtmlFilePreviewCandidate, remoteFilePreviewKind } from '@cindy/maker-shared/file-preview';@@ -128,68 +128,70 @@ export function BotGroupTextAttachmentPreview({ attachmentId, fileName, kind, rereturn (<Modal visible animationType="slide" presentationStyle="fullScreen" onRequestClose={onClose}>- <SafeAreaView edges={['top', 'bottom']} style={[styles.fill, { backgroundColor: colors.surface }]}>- <View style={[styles.header, { borderBottomColor: colors.border }]}>- <Pressable- accessibilityRole="button"- accessibilityLabel={t('groupChat.server.attachmentPreviewClose')}- onPress={onClose}- style={styles.closeButton}- testID="groupChat.server.attachmentPreviewCloseButton"- >- <X color={colors.textSecondary} size={20} />- </Pressable>- <Text numberOfLines={1} style={[textStyles.body, styles.title, { color: colors.textPrimary }]}>{fileName}</Text>- </View>- {state.status === 'loading' ? (- <View style={styles.messageState} testID="groupChat.server.attachmentPreviewLoading">- <ActivityIndicator color={colors.textSecondary} />- <Text style={[textStyles.footnote, { color: colors.textSecondary }]}>{t('groupChat.server.attachmentPreviewLoading')}</Text>+ <SafeAreaProvider>+ <SafeAreaView edges={['top', 'bottom']} style={[styles.fill, { backgroundColor: colors.surface }]}>+ <View style={[styles.header, { borderBottomColor: colors.border }]}>+ <Pressable+ accessibilityRole="button"+ accessibilityLabel={t('groupChat.server.attachmentPreviewClose')}+ onPress={onClose}+ style={styles.closeButton}+ testID="groupChat.server.attachmentPreviewCloseButton"+ >+ <X color={colors.textSecondary} size={20} />+ </Pressable>+ <Text numberOfLines={1} style={[textStyles.body, styles.title, { color: colors.textPrimary }]}>{fileName}</Text></View>- ) : null}- {state.status === 'failed' || state.status === 'too-large' || state.status === 'binary' || state.status === 'empty' ? (- <View style={styles.messageState} testID={'groupChat.server.attachmentPreview.' + state.status}>- <Text style={[textStyles.footnote, styles.stateCopy, { color: colors.textSecondary }]}>{message}</Text>- {state.status === 'failed' || state.status === 'too-large' ? (- <Pressable accessibilityRole="button" onPress={() => { void load(); }} style={[styles.action, { backgroundColor: colors.surfaceElevated, borderColor: colors.border }]} testID="groupChat.server.attachmentPreviewRetry">- <Text style={[textStyles.body, { color: colors.textPrimary }]}>{t('groupChat.server.attachmentPreviewRetry')}</Text>- </Pressable>- ) : null}- {kind !== 'html' && (state.status === 'too-large' || state.status === 'binary') ? (- <Pressable accessibilityRole="button" onPress={() => { void openOutside(); }} style={[styles.action, { backgroundColor: colors.surfaceElevated, borderColor: colors.border }]} testID="groupChat.server.attachmentPreviewOpenOutside">- <ExternalLink color={colors.textPrimary} size={16} />- <Text style={[textStyles.body, { color: colors.textPrimary }]}>{t('groupChat.server.attachmentPreviewOpenOutside')}</Text>- </Pressable>- ) : null}- </View>- ) : null}- {state.status === 'ready' && kind === 'html' ? (- <HtmlFileReader html={state.text} javaScriptEnabled={false} testID="groupChat.server.attachmentHtmlPreview" />- ) : null}- {state.status === 'ready' && kind === 'markdown' ? (- <MarkdownFileReader markdown={state.text} imageSources={NO_EXTERNAL_IMAGES} testID="groupChat.server.attachmentMarkdownPreview" />- ) : null}- {state.status === 'ready' && kind === 'json' ? (- <View style={styles.fill}>- {jsonPreview?.truncated ? (- <Text style={[textStyles.footnote, styles.truncated, { color: colors.textSecondary }]}>{t('groupChat.server.attachmentPreviewTruncated')}</Text>- ) : null}- <FlatList- data={jsonPreview?.lines ?? []}- keyExtractor={(_, index) => String(index)}- renderItem={({ item, index }) => (- <View style={styles.codeRow}>- <Text selectable={false} style={[textStyles.caption, styles.lineNumber, { color: colors.textTertiary }]}>{index + 1}</Text>- <Text selectable style={[styles.codeText, { color: colors.textPrimary }]}>{item || ' '}</Text>- </View>- )}- style={styles.fill}- contentContainerStyle={styles.codeList}- testID="groupChat.server.attachmentJsonPreview"- />- </View>- ) : null}- </SafeAreaView>+ {state.status === 'loading' ? (+ <View style={styles.messageState} testID="groupChat.server.attachmentPreviewLoading">+ <ActivityIndicator color={colors.textSecondary} />+ <Text style={[textStyles.footnote, { color: colors.textSecondary }]}>{t('groupChat.server.attachmentPreviewLoading')}</Text>+ </View>+ ) : null}+ {state.status === 'failed' || state.status === 'too-large' || state.status === 'binary' || state.status === 'empty' ? (+ <View style={styles.messageState} testID={'groupChat.server.attachmentPreview.' + state.status}>+ <Text style={[textStyles.footnote, styles.stateCopy, { color: colors.textSecondary }]}>{message}</Text>+ {state.status === 'failed' || state.status === 'too-large' ? (+ <Pressable accessibilityRole="button" onPress={() => { void load(); }} style={[styles.action, { backgroundColor: colors.surfaceElevated, borderColor: colors.border }]} testID="groupChat.server.attachmentPreviewRetry">+ <Text style={[textStyles.body, { color: colors.textPrimary }]}>{t('groupChat.server.attachmentPreviewRetry')}</Text>+ </Pressable>+ ) : null}+ {kind !== 'html' && (state.status === 'too-large' || state.status === 'binary') ? (+ <Pressable accessibilityRole="button" onPress={() => { void openOutside(); }} style={[styles.action, { backgroundColor: colors.surfaceElevated, borderColor: colors.border }]} testID="groupChat.server.attachmentPreviewOpenOutside">+ <ExternalLink color={colors.textPrimary} size={16} />+ <Text style={[textStyles.body, { color: colors.textPrimary }]}>{t('groupChat.server.attachmentPreviewOpenOutside')}</Text>+ </Pressable>+ ) : null}+ </View>+ ) : null}+ {state.status === 'ready' && kind === 'html' ? (+ <HtmlFileReader html={state.text} javaScriptEnabled={false} testID="groupChat.server.attachmentHtmlPreview" />+ ) : null}+ {state.status === 'ready' && kind === 'markdown' ? (+ <MarkdownFileReader markdown={state.text} imageSources={NO_EXTERNAL_IMAGES} testID="groupChat.server.attachmentMarkdownPreview" />+ ) : null}+ {state.status === 'ready' && kind === 'json' ? (+ <View style={styles.fill}>+ {jsonPreview?.truncated ? (+ <Text style={[textStyles.footnote, styles.truncated, { color: colors.textSecondary }]}>{t('groupChat.server.attachmentPreviewTruncated')}</Text>+ ) : null}+ <FlatList+ data={jsonPreview?.lines ?? []}+ keyExtractor={(_, index) => String(index)}+ renderItem={({ item, index }) => (+ <View style={styles.codeRow}>+ <Text selectable={false} style={[textStyles.caption, styles.lineNumber, { color: colors.textTertiary }]}>{index + 1}</Text>+ <Text selectable style={[styles.codeText, { color: colors.textPrimary }]}>{item || ' '}</Text>+ </View>+ )}+ style={styles.fill}+ contentContainerStyle={styles.codeList}+ testID="groupChat.server.attachmentJsonPreview"+ />+ </View>+ ) : null}+ </SafeAreaView>+ </SafeAreaProvider></Modal>);}diff --git a/docs/assets/mobile-group-text-preview/README.md b/docs/assets/mobile-group-text-preview/README.mdnew file mode 100644index 0000000000..07e6604ccb--- /dev/null+++ b/docs/assets/mobile-group-text-preview/README.md@@ -0,0 +1,28 @@+# Mobile 群聊文本附件预览(#6881 / PR #7400)++2026-10-27 在独立系统模拟器 `Cindy6881PR-iPhone17Pro-20261027` 上采集:+iPhone 17 Pro / iOS 26.5,Global 原生开发客户端 `com.xd.cindy`,版本+`0.1.0 (2026072301)`。未使用 UI mock;从已登录群聊的历史附件入口实际点开。++Metro 来自本 PR worktree;采集基于 `d0cc4525e9` 加本次安全区修正,经 Fast Refresh+加载。`mobile:sim:whoami` 在修正前确认该 worktree 的 Metro、源码和已安装原生指纹匹配。+修正后的页面已目检,并实际点击关闭返回群聊。没有发送群消息或修改附件。++| 格式 | 历史附件 | 浅色截图 |+| --- | --- | --- |+| HTML | `research-evidence.html` | [端内 HTML 预览](ios-html-light.png) |+| Markdown | `execution-plan.md` | [端内 Markdown 预览](ios-markdown-light.png) |+| JSON | `2026-10-22-PAYATHON小红书选题证据.json` | [带行号的 JSON 预览](ios-json-light.png) |++JSON 截图的来源 URL 行已用实色块遮盖,避免发布来源链接的签名查询参数;其余内容未修改。+HTML 与 Markdown 截图未做内容编辑。截图不包含群成员列表、群时间线或登录凭据。++验收时发现全屏预览标题和关闭按钮进入 iOS 状态栏区域;本次在 Modal 内增加独立+`SafeAreaProvider`,修正后重新采集上述截图,标题与关闭按钮均位于安全区内。++已验证:三种格式的历史附件端内打开、正文显示和关闭返回;三种格式浅色目检;+JSON 深色目检。HTML 作者页面在系统深色下的正文样式也已查看,但不据此声称+HTML / Markdown 的完整深色界面已验证。++自动检查:Mobile typecheck、两个定向测试文件(30 项)和设计台账检查通过。+尚未验证 Android、物理真机、新消息路径、弱网、完整冷缓存与重启矩阵。diff --git a/docs/assets/mobile-group-text-preview/ios-html-light.png b/docs/assets/mobile-group-text-preview/ios-html-light.pngnew file mode 100644index 0000000000..e72c2e4687Binary files /dev/null and b/docs/assets/mobile-group-text-preview/ios-html-light.png differdiff --git a/docs/assets/mobile-group-text-preview/ios-json-light.png b/docs/assets/mobile-group-text-preview/ios-json-light.pngnew file mode 100644index 0000000000..bfde2504e6Binary files /dev/null and b/docs/assets/mobile-group-text-preview/ios-json-light.png differdiff --git a/docs/assets/mobile-group-text-preview/ios-markdown-light.png b/docs/assets/mobile-group-text-preview/ios-markdown-light.pngnew file mode 100644index 0000000000..460ebd0412Binary files /dev/null and b/docs/assets/mobile-group-text-preview/ios-markdown-light.png differ