Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(mobile): 收起态输入框露出附件加号并与文字对齐 (#2702)
Dash4dbc04de9f34
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsxindex ab33fc8da6..42027d3e49 100644--- a/apps/mobile/app/sessions/[sessionId].tsx+++ b/apps/mobile/app/sessions/[sessionId].tsx@@ -381,6 +381,8 @@ import {} from '@/session/composerVoiceHold';import { COMPOSER_TEXT_HORIZONTAL_PADDING } from '@/session/composerTextMetrics';import {+ COMPOSER_TEXT_GEOMETRIC_PADDING_BOTTOM,+ COMPOSER_TEXT_GEOMETRIC_PADDING_TOP,COMPOSER_TEXT_PADDING_BOTTOM,COMPOSER_TEXT_PADDING_TOP,} from '@/session/composerTextPlatformMetrics';@@ -2794,7 +2796,10 @@ export default function SessionScreen() {><ScrollViewref={voiceDraftScrollRef}- contentContainerStyle={styles.voiceDraftOverlayContent}+ contentContainerStyle={[+ styles.voiceDraftOverlayContent,+ !composerCardActive && styles.voiceDraftOverlayContentGeometric,+ ]}onContentSizeChange={() => {requestAnimationFrame(() => {voiceDraftScrollRef.current?.scrollToEnd({ animated: false });@@ -6820,6 +6825,41 @@ export default function SessionScreen() {/>) : null);+ // 收起态把附件 + 号放在输入框左侧,避免用户必须先聚焦才能打开附件面板;+ // 卡片态仍由 renderComposerToolbar() 渲染同一入口。+ const renderComposerCompactLeading = () => (+ <View style={styles.composerCompactLeading}>+ <RouteActionButton+ accessibilityHint={composerLayout.attachment.disabledReason ?? composerSendUnavailableReason ?? undefined}+ accessibilityLabel={composerLayout.attachment.active ? composerLayout.attachment.label : t('session.common.openContextPanel')}+ active={composerLayout.attachment.active}+ disabled={composerLayout.attachment.disabled || (!canUseComposer && !composerLayout.attachment.active)}+ onPress={() => {+ setModelSheetOpen(false);+ setContextSheetView('main');+ setContextSheetOpen(true);+ }}+ style={styles.composerCompactAttachmentHit}+ testID="session.attachmentToggleButton"+ >+ <View+ pointerEvents="none"+ style={[+ styles.composerInlineToolButton,+ composerLayout.attachment.active && styles.composerToolButtonActive,+ ]}+ >+ <Plus+ color={composerLayout.attachment.active ? colors.textPrimary : colors.textSecondary}+ size={iconSize.sm}+ strokeWidth={iconStroke.regular}+ />+ </View>+ </RouteActionButton>+ {renderComposerCollapsedAttachmentBadge()}+ </View>+ );+// 停止任务按钮(实心中性方块)。两处使用:语音/发送左边的独立槽(inline)、// 发送位顶替(sendSlotIsStop);同一颗按钮的两个宿主位置,样式与行为一致。const renderComposerStopButton = () => (@@ -9400,6 +9440,7 @@ export default function SessionScreen() {height={composerInputVisibleHeight}hidden={voiceIsListening}maxHeight={composerResize.inputMaxHeight}+ opticalPadding={composerCardActive}onBlur={() => {setComposerFocused(false);setComposerVoiceHoldArmed(false);@@ -9427,7 +9468,7 @@ export default function SessionScreen() {inputOverlay={renderComposerInputOverlay()}inputStyle={voiceIsListening ? styles.inputVoiceHidden : undefined}inputTestID="session.composerInput"- leading={renderComposerCollapsedAttachmentBadge()}+ leading={renderComposerCompactLeading()}maxHeight={composerResize.inputMaxHeight}multilineShape={!composerCardActive && composerInputIsMultiline}onBlur={() => {@@ -10694,6 +10735,22 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({height: 34,width: 34,},+ composerCompactLeading: {+ alignItems: 'center',+ flexDirection: 'row',+ gap: spacing.xs,+ height: MOBILE_COMPOSER_MIN_TOUCH_TARGET,+ marginRight: spacing.xs,+ minWidth: MOBILE_COMPOSER_MIN_TOUCH_TARGET,+ },+ // 热区流内就是 44×44,祖先链不再靠负 margin / 溢出子节点。+ // 可见加号仍是 34pt,与文字 / 麦克风共中线。+ composerCompactAttachmentHit: {+ alignItems: 'center',+ height: MOBILE_COMPOSER_MIN_TOUCH_TARGET,+ justifyContent: 'center',+ width: MOBILE_COMPOSER_MIN_TOUCH_TARGET,+ },composerToolButtonActive: {backgroundColor: colors.surfaceChip,borderColor: colors.borderStrong,@@ -10716,6 +10773,10 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({paddingHorizontal: COMPOSER_TEXT_HORIZONTAL_PADDING,paddingTop: COMPOSER_TEXT_PADDING_TOP,},+ voiceDraftOverlayContentGeometric: {+ paddingBottom: COMPOSER_TEXT_GEOMETRIC_PADDING_BOTTOM,+ paddingTop: COMPOSER_TEXT_GEOMETRIC_PADDING_TOP,+ },voiceDraftMeasuredBlock: {minHeight: COMPOSER_INPUT_LINE_HEIGHT,position: 'relative',diff --git a/apps/mobile/app/sessions/new.tsx b/apps/mobile/app/sessions/new.tsxindex 8bb3084b37..33de6d0bf5 100644--- a/apps/mobile/app/sessions/new.tsx+++ b/apps/mobile/app/sessions/new.tsx@@ -234,6 +234,8 @@ import {} from '@/session/composerVoiceHold';import { COMPOSER_TEXT_HORIZONTAL_PADDING } from '@/session/composerTextMetrics';import {+ COMPOSER_TEXT_GEOMETRIC_PADDING_BOTTOM,+ COMPOSER_TEXT_GEOMETRIC_PADDING_TOP,COMPOSER_TEXT_PADDING_BOTTOM,COMPOSER_TEXT_PADDING_TOP,} from '@/session/composerTextPlatformMetrics';@@ -3408,7 +3410,10 @@ export default function NewRemoteSessionScreen() {const renderComposerInputOverlay = () => voiceIsListening ? (<ScrollViewref={voiceDraftScrollRef}- contentContainerStyle={styles.voiceDraftOverlayContent}+ contentContainerStyle={[+ styles.voiceDraftOverlayContent,+ !composerCardActive && styles.voiceDraftOverlayContentGeometric,+ ]}onContentSizeChange={() => {requestAnimationFrame(() => {voiceDraftScrollRef.current?.scrollToEnd({ animated: false });@@ -3776,6 +3781,46 @@ export default function NewRemoteSessionScreen() {testID="newSession.attachmentCollapsedBadge"/>) : null);++ // 收起态把附件 + 号放在输入框左侧,避免用户必须先聚焦才能打开附件面板;+ // 卡片态仍由 renderComposerToolbar() 渲染同一入口。+ const renderComposerCompactLeading = () => (+ <View style={styles.composerCompactLeading}>+ <Pressable+ accessibilityLabel={t('session.common.openContextPanel')}+ accessibilityRole="button"+ disabled={creating}+ onPress={() => {+ setModelSheetOpen(false);+ setAgentPickerOpen(false);+ setPermissionSheetOpen(false);+ setWorktreeBranchSheetOpen(false);+ setContextSheetView('main');+ setContextSheetOpen(true);+ }}+ style={({ pressed }) => [+ styles.composerCompactAttachmentHit,+ pressed && styles.pressed,+ ]}+ testID="newSession.attachmentToggleButton"+ >+ <View+ pointerEvents="none"+ style={[+ styles.composerIconButton,+ contextSheetOpen && styles.composerIconButtonActive,+ ]}+ >+ <Plus+ color={contextSheetOpen ? colors.textPrimary : colors.textSecondary}+ size={iconSize.sm}+ strokeWidth={iconStroke.regular}+ />+ </View>+ </Pressable>+ {renderComposerCollapsedAttachmentBadge()}+ </View>+ );// 面板关闭即丢弃未提交的待选(不产生任何上传副作用)。useEffect(() => {if (!contextSheetOpen) setPendingMediaAssets([]);@@ -5631,7 +5676,7 @@ export default function NewRemoteSessionScreen() {caretHidden={voiceIsListening}cursorColor={colors.inputCaret}inputRef={firstMessageInputRef}- leading={renderComposerCollapsedAttachmentBadge()}+ leading={renderComposerCompactLeading()}inputFrameHeight={composerResize.frameHeight}// 听写期间把输入区撑到 44pt 触控目标:此时「点输入区停止听写」的命中层// 是这层输入区自身(TextInput 的 onPressIn),单行时只有 28pt。@@ -6517,6 +6562,22 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({justifyContent: 'center',width: MOBILE_COMPOSER_CONTROL_SIZE,},+ composerCompactLeading: {+ alignItems: 'center',+ flexDirection: 'row',+ gap: spacing.xs,+ height: MOBILE_COMPOSER_MIN_TOUCH_TARGET,+ marginRight: spacing.xs,+ minWidth: MOBILE_COMPOSER_MIN_TOUCH_TARGET,+ },+ // 热区流内就是 44×44,祖先链不再靠负 margin / 溢出子节点。+ // 可见加号仍是 34pt,与文字 / 麦克风共中线。+ composerCompactAttachmentHit: {+ alignItems: 'center',+ height: MOBILE_COMPOSER_MIN_TOUCH_TARGET,+ justifyContent: 'center',+ width: MOBILE_COMPOSER_MIN_TOUCH_TARGET,+ },composerIconButtonActive: {backgroundColor: colors.surfaceChip,borderColor: colors.borderStrong,@@ -6550,6 +6611,10 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({paddingHorizontal: COMPOSER_TEXT_HORIZONTAL_PADDING,paddingTop: COMPOSER_TEXT_PADDING_TOP,},+ voiceDraftOverlayContentGeometric: {+ paddingBottom: COMPOSER_TEXT_GEOMETRIC_PADDING_BOTTOM,+ paddingTop: COMPOSER_TEXT_GEOMETRIC_PADDING_TOP,+ },voiceDraftMeasuredBlock: {minHeight: MOBILE_COMPOSER_INPUT_LINE_HEIGHT,position: 'relative',diff --git a/apps/mobile/src/__tests__/composerVoiceDraftMetrics.test.ts b/apps/mobile/src/__tests__/composerVoiceDraftMetrics.test.tsindex ee2cb67056..c8d940f980 100644--- a/apps/mobile/src/__tests__/composerVoiceDraftMetrics.test.ts+++ b/apps/mobile/src/__tests__/composerVoiceDraftMetrics.test.ts@@ -78,12 +78,15 @@ describe('composer voice draft text metrics', () => {expect(composerTextPaddingForPlatform('ios')).toEqual({ top: 6, bottom: 0 });expect(composerTextPaddingForPlatform('android')).toEqual({ top: 3, bottom: 3 });expect(composerTextPaddingForPlatform('default')).toEqual({ top: 3, bottom: 3 });+ expect(composerTextPaddingForPlatform('ios', { optical: false })).toEqual({ top: 3, bottom: 3 });});it('renders the real composer TextInput with the shared metrics', () => {const composerRowSource = read(COMPOSER_ROW);const block = styleBlock(composerRowSource, 'input');expect(composerRowSource).toContain("from '@/session/composerTextPlatformMetrics'");+ expect(composerRowSource).toContain('const geometricSingleLine = !cardLayout;');+ expect(composerRowSource).not.toContain('const geometricSingleLine = !cardLayout && !multilineShape;');expect(block).toContain('...COMPOSER_TEXT_STYLE');expect(block).toContain('paddingBottom: COMPOSER_TEXT_PADDING_BOTTOM');expect(block).toContain('paddingHorizontal: COMPOSER_TEXT_HORIZONTAL_PADDING');@@ -116,6 +119,10 @@ describe('composer voice draft text metrics', () => {.toContain('paddingHorizontal: COMPOSER_TEXT_HORIZONTAL_PADDING');expect(overlayContent, `${rel} 覆盖层顶部内边距必须与输入框同源`).toContain('paddingTop: COMPOSER_TEXT_PADDING_TOP');+ expect(source, `${rel} 收起展示态听写覆盖层必须切到几何居中`)+ .toContain('!composerCardActive && styles.voiceDraftOverlayContentGeometric');+ expect(source, `${rel} 几何居中不得再看收起前的多行/manual 判定`)+ .not.toContain('!composerCardActive && !composerInputIsMultiline && styles.voiceDraftOverlayContentGeometric');}});diff --git a/apps/mobile/src/__tests__/newSession.test.ts b/apps/mobile/src/__tests__/newSession.test.tsindex 87914578f7..1a69564dbb 100644--- a/apps/mobile/src/__tests__/newSession.test.ts+++ b/apps/mobile/src/__tests__/newSession.test.ts@@ -1530,7 +1530,7 @@ describe('new session composer surface', () => {const createButtonEnd = newSource.indexOf('// 聚焦卡片形态的底部工具排', createButtonStart);const createButtonSource = newSource.slice(createButtonStart, createButtonEnd);const composerIconButtonStart = newSource.indexOf('composerIconButton: {');- const composerIconButtonEnd = newSource.indexOf('composerIconButtonActive:', composerIconButtonStart);+ const composerIconButtonEnd = newSource.indexOf('composerCompactLeading:', composerIconButtonStart);const composerIconButtonStyle = newSource.slice(composerIconButtonStart, composerIconButtonEnd);const modelPillStart = newSource.indexOf('modelPill: {');const modelPillEnd = newSource.indexOf('modelPillText:', modelPillStart);@@ -1595,6 +1595,19 @@ describe('new session composer surface', () => {expect(newComposerSource).toContain("placeholder={voiceIsListening ? '' : composerPlaceholder}");expect(newComposerSource).toContain('scrollEnabled={composerInputScrollEnabled}');expect(newComposerSource).toContain('trailing={composerCardActive || !composerShowCreateButton ? null : renderCreateButton()}');+ expect(newComposerSource).toContain('leading={renderComposerCompactLeading()}');+ expect(newSource).toContain('const renderComposerCompactLeading = () => (');+ expect(newSource).not.toContain('styles.composerCompactAttachmentSlot');+ expect(newSource).toContain('styles.composerCompactAttachmentHit');+ expect(newSource).not.toContain('styles.composerCompactAttachmentHitArea');+ expect(newSource).toContain('pointerEvents="none"');+ expect(newSource).toContain('testID="newSession.attachmentToggleButton"');+ expect(newSource).toContain('height: MOBILE_COMPOSER_MIN_TOUCH_TARGET');+ expect(newSource).toContain('width: MOBILE_COMPOSER_MIN_TOUCH_TARGET');+ expect(newSource).toContain('minWidth: MOBILE_COMPOSER_MIN_TOUCH_TARGET');+ expect(newSource).not.toContain('marginVertical: (MOBILE_COMPOSER_CONTROL_SIZE - MOBILE_COMPOSER_MIN_TOUCH_TARGET) / 2');+ expect(newSource).not.toContain('marginHorizontal: (MOBILE_COMPOSER_CONTROL_SIZE - MOBILE_COMPOSER_MIN_TOUCH_TARGET) / 2');+ expect(newSource).not.toContain('left: (MOBILE_COMPOSER_CONTROL_SIZE - MOBILE_COMPOSER_MIN_TOUCH_TARGET) / 2');expect(newSource).toContain('const renderComposerToolbar = () => (');expect(newSource).toContain('PaperPlaneIcon');expect(newSource).not.toContain('ArrowUp');diff --git a/apps/mobile/src/__tests__/sessionComposerDesktopFirst.test.ts b/apps/mobile/src/__tests__/sessionComposerDesktopFirst.test.tsindex 6761f98e0b..6b9a7b4bbd 100644--- a/apps/mobile/src/__tests__/sessionComposerDesktopFirst.test.ts+++ b/apps/mobile/src/__tests__/sessionComposerDesktopFirst.test.ts@@ -48,6 +48,15 @@ describe('mobile session composer desktop-first surface', () => {const composerSurfaceEnd = source.indexOf('composerSurfaceCompact:', composerSurfaceStart);const composerSurfaceStyle = source.slice(composerSurfaceStart, composerSurfaceEnd);const sharedStyleStart = sharedSource.indexOf('const makeMobileComposerInputRowStyles');+ expect(sharedSource).toContain('const geometricSingleLine = !cardLayout;');+ expect(sharedSource).toContain('geometricSingleLine && styles.rowCollapsedTouch');+ expect(sharedSource).toContain('geometricSingleLine && styles.mainRowCollapsedTouch');+ expect(sharedSource).toContain('geometricSingleLine && inputFrameMinHeight == null && styles.inputFrameSingleLine');+ expect(sharedSource).toContain('inputFrameSingleLine: {');+ expect(sharedSource).toContain('inputGeometricSingleLine: {');+ expect(sharedSource).toContain('textAlignVertical: \'center\'');+ expect(source).toContain('opticalPadding={composerCardActive}');+ expect(source).not.toContain('opticalPadding={composerCardActive || composerInputIsMultiline}');const composerInputRowStart = sharedSource.indexOf('row: {', sharedStyleStart);const composerInputRowEnd = sharedSource.indexOf('rowMultiline:', composerInputRowStart);const composerInputRowStyle = sharedSource.slice(composerInputRowStart, composerInputRowEnd);@@ -58,7 +67,7 @@ describe('mobile session composer desktop-first surface', () => {const inlineButtonEnd = source.indexOf('composerToolButtonActive:', inlineButtonStart);const inlineButtonStyle = source.slice(inlineButtonStart, inlineButtonEnd);const floatingButtonStart = sharedSource.indexOf('voiceButtonAnchor: {', sharedStyleStart);- const floatingButtonEnd = sharedSource.indexOf('}', floatingButtonStart);+ const floatingButtonEnd = sharedSource.indexOf('voiceButtonAnchorWithTrailing:', floatingButtonStart);const floatingButtonStyle = sharedSource.slice(floatingButtonStart, floatingButtonEnd);const sendButtonStart = source.indexOf('sendButton: {');const sendButtonEnd = source.indexOf('sendButtonInactive:', sendButtonStart);@@ -106,6 +115,19 @@ describe('mobile session composer desktop-first surface', () => {expect(source).toContain('<Scan color={colors.textPrimary}');expect(source).toContain('<Folder color={colors.textPrimary}');expect(composerInputSource).toContain('cardActive={composerCardActive}');+ expect(composerInputSource).toContain('leading={renderComposerCompactLeading()}');+ expect(source).toContain('const renderComposerCompactLeading = () => (');+ expect(source).not.toContain('styles.composerCompactAttachmentSlot');+ expect(source).toContain('styles.composerCompactAttachmentHit');+ expect(source).not.toContain('styles.composerCompactAttachmentHitArea');+ expect(source).toContain('pointerEvents="none"');+ expect(source).toContain('testID="session.attachmentToggleButton"');+ expect(source).toContain('height: MOBILE_COMPOSER_MIN_TOUCH_TARGET');+ expect(source).toContain('width: MOBILE_COMPOSER_MIN_TOUCH_TARGET');+ expect(source).toContain('minWidth: MOBILE_COMPOSER_MIN_TOUCH_TARGET');+ expect(source).not.toContain('marginVertical: (MOBILE_COMPOSER_CONTROL_SIZE - MOBILE_COMPOSER_MIN_TOUCH_TARGET) / 2');+ expect(source).not.toContain('marginHorizontal: (MOBILE_COMPOSER_CONTROL_SIZE - MOBILE_COMPOSER_MIN_TOUCH_TARGET) / 2');+ expect(source).not.toContain('left: (MOBILE_COMPOSER_CONTROL_SIZE - MOBILE_COMPOSER_MIN_TOUCH_TARGET) / 2');expect(composerInputSource).toContain('toolbar={renderComposerToolbar()}');expect(source).toContain('const renderComposerToolbar = () => (');expect(attachmentButtonSource).toContain('<Plus');@@ -218,7 +240,8 @@ describe('mobile session composer desktop-first surface', () => {expect(inputStyle).toContain('paddingHorizontal: COMPOSER_TEXT_HORIZONTAL_PADDING');expect(inputStyle).toContain('paddingTop: COMPOSER_TEXT_PADDING_TOP');expect(inputStyle).toContain("textAlignVertical: 'top'");- expect(floatingButtonStyle).toContain("bottom: Platform.OS === 'ios' ? 8 : 11");+ expect(floatingButtonStyle).toContain("top: '50%'");+ expect(floatingButtonStyle).toContain('translateY: -MOBILE_COMPOSER_CONTROL_SIZE / 2');// Composer input is a single stable, always-multiline, always-inline instance (no compact↔expanded// swap that remounts the native input) so the first tap reliably opens the keyboard — guards the// "two taps to focus" regression. Compact rest look kept via minHeight (no fixed height that clips).@@ -349,7 +372,10 @@ describe('mobile session composer desktop-first surface', () => {expect(composerInputSource).not.toContain('inputRef={composerInputRef}');expect(sharedSource).toContain('ref={inputRef as never}');expect(source).toContain('ref={voiceDraftScrollRef}');- expect(source).toContain('contentContainerStyle={styles.voiceDraftOverlayContent}');+ expect(source).toContain('contentContainerStyle={[');+ expect(source).toContain('styles.voiceDraftOverlayContent');+ expect(source).toContain('!composerCardActive && styles.voiceDraftOverlayContentGeometric');+ expect(source).not.toContain('!composerCardActive && !composerInputIsMultiline && styles.voiceDraftOverlayContentGeometric');// 听写期间禁止碰隐藏编辑器的 caret(2026-07-28):setSelectionToEnd 底层是// focusEditor,WebView 程序化 focus + keyboardDisplayRequiresUserAction=false// 会在点语音的同时弹出软键盘。听写文字由覆盖层渲染,caret 只在用户点输入框@@ -488,7 +514,8 @@ describe('mobile session composer desktop-first surface', () => {expect(inlineButtonStyle).not.toContain('width: 42');expect(floatingButtonStyle).toContain("position: 'absolute'");expect(floatingButtonStyle).toContain('right: MOBILE_COMPOSER_VOICE_ANCHOR_RIGHT');- expect(floatingButtonStyle).toContain("bottom: Platform.OS === 'ios' ? 8 : 11");+ expect(floatingButtonStyle).toContain("top: '50%'");+ expect(floatingButtonStyle).toContain('translateY: -MOBILE_COMPOSER_CONTROL_SIZE / 2');expect(floatingButtonStyle).toContain('zIndex: 2');expect(sharedSource).toContain('right: spacing.md + MOBILE_COMPOSER_CONTROL_SIZE + MOBILE_COMPOSER_TOOL_GAP');expect(sendButtonStyle).toContain('height: 34');diff --git a/apps/mobile/src/session/ComposerRichInput.tsx b/apps/mobile/src/session/ComposerRichInput.tsxindex 93306ef559..b8c25956ec 100644--- a/apps/mobile/src/session/ComposerRichInput.tsx+++ b/apps/mobile/src/session/ComposerRichInput.tsx@@ -41,6 +41,7 @@ export interface ComposerRichInputProps {onPasteImages?: (uris: string[]) => void;onPasteImagesLoadFailed?: () => void;onPasteImagesLoading?: (count: number) => void;+ opticalPadding?: boolean;placeholder: string;resolveSessionLinkLabel?: (href: string) => Promise<ResolvedSessionLinkSemantic | null>;testID?: string;@@ -70,6 +71,7 @@ export const ComposerRichInput = forwardRef<ComposerRichInputHandle, ComposerRiconPasteImages,onPasteImagesLoadFailed,onPasteImagesLoading,+ opticalPadding = true,placeholder,resolveSessionLinkLabel,testID,@@ -95,6 +97,7 @@ export const ComposerRichInput = forwardRef<ComposerRichInputHandle, ComposerRicdocument,editable,maxHeight,+ opticalPadding,platform: Platform.OS === 'ios' ? 'ios' as const : Platform.OS === 'android' ? 'android' as const : 'default' as const,placeholder,theme,@@ -107,12 +110,14 @@ export const ComposerRichInput = forwardRef<ComposerRichInputHandle, ComposerRicaccessibilityLabel,editable,maxHeight,+ opticalPadding,placeholder,theme,}), [accessibilityLabel,editable,maxHeight,+ opticalPadding,placeholder,theme.background,theme.border,diff --git a/apps/mobile/src/session/MobileComposerInputRow.tsx b/apps/mobile/src/session/MobileComposerInputRow.tsxindex 15cc6bc87c..e329728c02 100644--- a/apps/mobile/src/session/MobileComposerInputRow.tsx+++ b/apps/mobile/src/session/MobileComposerInputRow.tsx@@ -27,6 +27,8 @@ import {COMPOSER_TEXT_VERTICAL_PADDING,} from '@/session/composerTextMetrics';import {+ COMPOSER_TEXT_GEOMETRIC_PADDING_BOTTOM,+ COMPOSER_TEXT_GEOMETRIC_PADDING_TOP,COMPOSER_TEXT_PADDING_BOTTOM,COMPOSER_TEXT_PADDING_TOP,} from '@/session/composerTextPlatformMetrics';@@ -224,6 +226,10 @@ export function MobileComposerInputRow({}: MobileComposerInputRowProps) {const styles = useThemedStyles(makeMobileComposerInputRowStyles);const cardLayout = cardActive === true;+ // 几何居中只看当前是不是收起展示态。resize 在 collapsed 下会把可见高度钉成单行,+ // 但 mode/manual 与多行草稿判定仍会让 multilineShape 为 true;若据此关掉几何居中,+ // 收起态文字会继续走 iOS 6/0 光学偏移,对不齐新增的 34pt +。+ const geometricSingleLine = !cardLayout;// RN 里显式 height 压过 minHeight:manual 定高(用户拖过高度)时 frameHeight 可能小于// inputFrameMinHeight,直接铺开会把听写停止命中区又压回不足 44pt。数值高度在这里// 先 clamp;拖拽中的 Animated 值无法在 JS 侧 clamp(会打断跟手),那一瞬保持动画值,@@ -266,6 +272,7 @@ export function MobileComposerInputRow({selectionColor={selectionColor}style={[styles.input,+ geometricSingleLine && styles.inputGeometricSingleLine,{ maxHeight },inputStyle,]}@@ -278,7 +285,8 @@ export function MobileComposerInputRow({style={[styles.row,compact && styles.rowCompact,- multilineShape && styles.rowMultiline,+ geometricSingleLine && styles.rowCollapsedTouch,+ !geometricSingleLine && multilineShape && styles.rowMultiline,cardLayout && styles.rowCard,rowStyle,]}@@ -289,7 +297,8 @@ export function MobileComposerInputRow({<Viewstyle={[styles.mainRow,- multilineShape && styles.mainRowMultiline,+ geometricSingleLine && styles.mainRowCollapsedTouch,+ !geometricSingleLine && multilineShape && styles.mainRowMultiline,!cardLayout && voicePlacement?.inline && styles.mainRowVoiceInset,]}>@@ -297,6 +306,8 @@ export function MobileComposerInputRow({<Animated.Viewstyle={[styles.inputFrame,+ // 收起单行与 34pt + 并排:输入盒在行内居中。+ geometricSingleLine && inputFrameMinHeight == null && styles.inputFrameSingleLine,inputFrameMinHeight != null && { minHeight: inputFrameMinHeight },resolvedInputFrameHeight != null && { height: resolvedInputFrameHeight },]}@@ -503,10 +514,16 @@ const makeMobileComposerInputRowStyles = (colors: ThemeColors) => ({borderWidth: StyleSheet.hairlineWidth,flexDirection: 'column',minHeight: 50,+ overflow: 'visible',paddingHorizontal: spacing.md,paddingVertical: 10,position: 'relative',},+ // 收起态给 leading 的 44pt 热区留出父边界,避免溢出子节点点不到。+ rowCollapsedTouch: {+ minHeight: MOBILE_COMPOSER_MIN_TOUCH_TARGET + 6,+ paddingVertical: 3,+ },rowMultiline: {borderRadius: 30, // 组件几何:composer 聚焦形态专用,非通用圆角档},@@ -528,6 +545,10 @@ const makeMobileComposerInputRowStyles = (colors: ThemeColors) => ({flexGrow: 1,gap: MOBILE_COMPOSER_TOOL_GAP,minWidth: 0,+ overflow: 'visible',+ },+ mainRowCollapsedTouch: {+ minHeight: MOBILE_COMPOSER_MIN_TOUCH_TARGET,},mainRowMultiline: {alignItems: 'flex-end',@@ -542,6 +563,9 @@ const makeMobileComposerInputRowStyles = (colors: ThemeColors) => ({minWidth: 0,position: 'relative',},+ inputFrameSingleLine: {+ alignItems: 'center',+ },// TextInputWrapper(expo-paste-input)接管 TextInput 在 inputFrame row 里的// flex:1 位置;内部保持 row + stretch,TextInput 自身 flex:1 继续填满,// 内容自动增长与显式 inputFrameHeight(拖高)两条高度链都不经它中断。@@ -578,14 +602,21 @@ const makeMobileComposerInputRowStyles = (colors: ThemeColors) => ({paddingTop: COMPOSER_TEXT_PADDING_TOP,textAlignVertical: 'top',},+ inputGeometricSingleLine: {+ paddingBottom: COMPOSER_TEXT_GEOMETRIC_PADDING_BOTTOM,+ paddingTop: COMPOSER_TEXT_GEOMETRIC_PADDING_TOP,+ textAlignVertical: 'center',+ },// 语音按钮的 absolute 锚点:简洁态贴输入行右侧垂直居中;// 有发送按钮时向左让位;卡片态下沉到底部工具排的占位上。voiceButtonAnchor: {- // iOS 的文字 padding 是 6/0,按钮随文字下移 3pt;Android 保持 3/3,- // 不应继承 iOS 的补偿。- bottom: Platform.OS === 'ios' ? 8 : 11,+ // 收起态按行垂直居中,与 34pt 加号 / 文字共中线;+ // 不再钉在底部,避免行高变化后麦克风掉下去。+ bottom: undefined,position: 'absolute',right: MOBILE_COMPOSER_VOICE_ANCHOR_RIGHT,+ top: '50%',+ transform: [{ translateY: -MOBILE_COMPOSER_CONTROL_SIZE / 2 }],zIndex: 2,},voiceButtonAnchorWithTrailing: {@@ -593,6 +624,8 @@ const makeMobileComposerInputRowStyles = (colors: ThemeColors) => ({},voiceButtonAnchorCard: {bottom: 8,+ top: undefined,+ transform: [],},// 外层横跨全行但 box-none 穿透触摸,只有中间的窄命中条接手势,// 避免与左右两侧按钮的 hitSlop 抢触摸。diff --git a/apps/mobile/src/session/composerRichInputHtml.ts b/apps/mobile/src/session/composerRichInputHtml.tsindex fa9a384307..55a39fba1a 100644--- a/apps/mobile/src/session/composerRichInputHtml.ts+++ b/apps/mobile/src/session/composerRichInputHtml.ts@@ -30,6 +30,7 @@ export interface ComposerRichInputConfig {document: ComposerDocument;editable: boolean;maxHeight: number;+ opticalPadding?: boolean;placeholder: string;platform?: ComposerTextPlatform;theme: ComposerRichInputTheme;@@ -42,7 +43,9 @@ export interface ComposerRichInputConfig {*/export function buildComposerRichInputHtml(config: ComposerRichInputConfig): string {const bootstrap = JSON.stringify(config).replace(/</g, '\\u003c');- const composerTextPadding = composerTextPaddingForPlatform(config.platform ?? 'ios');+ const composerTextPadding = composerTextPaddingForPlatform(config.platform ?? 'ios', {+ optical: config.opticalPadding !== false,+ });return `<!doctype html><html><head><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><style>@@ -92,6 +95,22 @@ export function buildComposerRichInputHtml(config: ComposerRichInputConfig): strstyle.setProperty('--border', config.theme.border);style.setProperty('--focus', config.theme.focus);style.setProperty('--max-height', config.maxHeight + 'px');+ const padding = ${JSON.stringify({+ ios: {+ optical: composerTextPaddingForPlatform('ios'),+ geometric: composerTextPaddingForPlatform('ios', { optical: false }),+ },+ android: {+ optical: composerTextPaddingForPlatform('android'),+ geometric: composerTextPaddingForPlatform('android', { optical: false }),+ },+ default: {+ optical: composerTextPaddingForPlatform('default'),+ geometric: composerTextPaddingForPlatform('default', { optical: false }),+ },+ })}[(config.platform || 'ios')][config.opticalPadding === false ? 'geometric' : 'optical'];+ root.style.paddingTop = padding.top + 'px';+ root.style.paddingBottom = padding.bottom + 'px';root.dataset.placeholder = config.placeholder;root.setAttribute('aria-label', config.accessibilityLabel);root.contentEditable = config.editable ? 'true' : 'false';diff --git a/apps/mobile/src/session/composerTextMetrics.ts b/apps/mobile/src/session/composerTextMetrics.tsindex ce39fc98b7..f1f745b396 100644--- a/apps/mobile/src/session/composerTextMetrics.ts+++ b/apps/mobile/src/session/composerTextMetrics.ts@@ -42,14 +42,22 @@ export interface ComposerTextPadding {top: number;}-export function composerTextPaddingForPlatform(platform: ComposerTextPlatform): ComposerTextPadding {- const opticalOffset = platform === 'ios' ? COMPOSER_TEXT_OPTICAL_OFFSET_Y : 0;+export function composerTextPaddingForPlatform(+ platform: ComposerTextPlatform,+ options: { optical?: boolean } = {},+): ComposerTextPadding {+ const opticalOffset = options.optical !== false && platform === 'ios'+ ? COMPOSER_TEXT_OPTICAL_OFFSET_Y+ : 0;return {bottom: COMPOSER_TEXT_VERTICAL_PADDING - opticalOffset,top: COMPOSER_TEXT_VERTICAL_PADDING + opticalOffset,};}+/** 收起单行与 34pt + / 麦克风并排时用几何居中,不再做 iOS 光学下移。 */+export const COMPOSER_TEXT_GEOMETRIC_PADDING = composerTextPaddingForPlatform('default');+// Node-side consumers and the existing iOS WebView tests use iOS as the// canonical reference. React Native consumers import the platform adapter.const iosComposerTextPadding = composerTextPaddingForPlatform('ios');diff --git a/apps/mobile/src/session/composerTextPlatformMetrics.ts b/apps/mobile/src/session/composerTextPlatformMetrics.tsindex 7a3f3379c4..4991171ce3 100644--- a/apps/mobile/src/session/composerTextPlatformMetrics.ts+++ b/apps/mobile/src/session/composerTextPlatformMetrics.ts@@ -1,5 +1,6 @@import { Platform } from 'react-native';import {+ COMPOSER_TEXT_GEOMETRIC_PADDING,composerTextPaddingForPlatform,type ComposerTextPlatform,} from '@/session/composerTextMetrics';@@ -15,3 +16,5 @@ const composerTextPadding = composerTextPaddingForPlatform(composerTextPlatform)/** Platform-specific padding adapter; the base metrics remain node-testable. */export const COMPOSER_TEXT_PADDING_TOP = composerTextPadding.top;export const COMPOSER_TEXT_PADDING_BOTTOM = composerTextPadding.bottom;+export const COMPOSER_TEXT_GEOMETRIC_PADDING_TOP = COMPOSER_TEXT_GEOMETRIC_PADDING.top;+export const COMPOSER_TEXT_GEOMETRIC_PADDING_BOTTOM = COMPOSER_TEXT_GEOMETRIC_PADDING.bottom;