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。

Revert "feat(mobile): 会话页收起态输入区常驻显示当前模型 (#1291)"

Lizi6947e755dfbf
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index 69315b5492..69fbf64e4c 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -2234,40 +2234,6 @@ export default function SessionScreen() {
visible
/>
);
- // 模型 pill:展开态进 toolbar,收起态进 leading(见 renderComposerCollapsedLeading)。
- // 两处共用同一颗,避免收起时只能进选择器才知道当前模型(#900)。
- // 收起态另传 maxWidth:长/自定义 label 不得把 inputFrame 挤没(toolbar 仍不设上限)。
- const renderComposerModelPill = (testID: string, maxWidth?: number) => (
- composerRuntimeSummary ? (
- <ComposerRuntimePill
- fastOn={composerPillFastOn}
- label={composerRuntimeLabel}
- leading={agentSwitchIntent ? (
- <MobileAgentMark
- agentKind={agentSwitchIntent.targetAgentKind}
- color={colors.textSecondary}
- size={iconSize.sm}
- />
- ) : composerPillSourceId ? (
- // 正常态显示真正生效来源;断开态显示 DB 中的真实来源并使用状态色,
- // 不静默换成 activeSourceId 的默认回退 Logo。
- <MobileModelIconMark
- color={composerSelectedSourceDisconnected ? colors.statusError : undefined}
- icon={currentSession && composerPillSourceProvider
- ? getModel(composerPillSourceProvider, currentSession.model, sessionAgentKind)?.icon
- : undefined}
- name={composerPillSourceProvider?.name ?? composerPillSourceId}
- providerId={composerPillSourceId}
- routing={composerPillSourceProvider?.routing}
- logoKind={composerPillSourceProvider?.logoKind}
- />
- ) : null}
- maxWidth={maxWidth}
- onPress={toggleComposerModelPicker}
- testID={testID}
- />
- ) : null
- );
// 聚焦卡片形态的底部工具排:[+][模型] …… [语音][停止/发送]。
// + 号打开 Context 面板(附件 / 计划模式 / 目标模式收在面板内);权限模式入口收进会话设置。
// 权限模式图标钮(2026-07-29 用户裁决,对齐 Codex,与新建页同位同款):
@@ -2316,7 +2282,34 @@ export default function SessionScreen() {
/>
) : null}
<ComposerToolbarSpacer />
- {renderComposerModelPill('session.composerModelButton')}
+ {composerRuntimeSummary ? (
+ <ComposerRuntimePill
+ fastOn={composerPillFastOn}
+ label={composerRuntimeLabel}
+ leading={agentSwitchIntent ? (
+ <MobileAgentMark
+ agentKind={agentSwitchIntent.targetAgentKind}
+ color={colors.textSecondary}
+ size={iconSize.sm}
+ />
+ ) : composerPillSourceId ? (
+ // 正常态显示真正生效来源;断开态显示 DB 中的真实来源并使用状态色,
+ // 不静默换成 activeSourceId 的默认回退 Logo。
+ <MobileModelIconMark
+ color={composerSelectedSourceDisconnected ? colors.statusError : undefined}
+ icon={currentSession && composerPillSourceProvider
+ ? getModel(composerPillSourceProvider, currentSession.model, sessionAgentKind)?.icon
+ : undefined}
+ name={composerPillSourceProvider?.name ?? composerPillSourceId}
+ providerId={composerPillSourceId}
+ routing={composerPillSourceProvider?.routing}
+ logoKind={composerPillSourceProvider?.logoKind}
+ />
+ ) : null}
+ onPress={toggleComposerModelPicker}
+ testID="session.composerModelButton"
+ />
+ ) : null}
{/* 工具排右段顺序:[模型][停止任务][语音占位][发送槽](spacer 已在模型左侧,
模型右对齐对齐 Codex)。停止任务在语音左边(对齐桌面),语音占位宽度随录音
胶囊(红点+计时)展开,把停止任务推开——语音右缘与发送槽的邻接关系全程不变。 */}
@@ -5974,16 +5967,6 @@ export default function SessionScreen() {
/>
) : null);
- // 收起态 leading:[模型 chip][附件徽标]。模型常驻可见、点开选择器(#900);
- // card 态 leading 被 MobileComposerInputRow 收掉,改由 toolbar 的同款 pill 承接。
- // pill maxWidth 200:长 label 截断;与 inputFrameMinWidth 120 互为兜底。
- const renderComposerCollapsedLeading = () => (
- <>
- {renderComposerModelPill('session.composerCollapsedModelButton', 200)}
- {renderComposerCollapsedAttachmentBadge()}
- </>
- );
-
// 停止任务按钮(实心中性方块)。两处使用:语音/发送左边的独立槽(inline)、
// 发送位顶替(sendSlotIsStop);同一颗按钮的两个宿主位置,样式与行为一致。
const renderComposerStopButton = () => (
@@ -8477,8 +8460,6 @@ export default function SessionScreen() {
// 听写期间把输入区撑到 44pt 触控目标:命中层盖在 inputFrame 上,
// hitSlop 越不过父边界(见常量注释)。
inputFrameMinHeight={voiceIsListening ? MOBILE_COMPOSER_MIN_TOUCH_TARGET : undefined}
- // 收起态 leading 有模型 pill:给输入区留可见/可点宽度;展开态无 leading,不必占位。
- inputFrameMinWidth={composerCardActive ? undefined : 120}
inputElement={(
<ComposerRichInput
ref={composerInputRef}
@@ -8516,7 +8497,7 @@ export default function SessionScreen() {
inputOverlay={renderComposerInputOverlay()}
inputStyle={voiceIsListening ? styles.inputVoiceHidden : undefined}
inputTestID="session.composerInput"
- leading={renderComposerCollapsedLeading()}
+ leading={renderComposerCollapsedAttachmentBadge()}
maxHeight={composerResize.inputMaxHeight}
multilineShape={!composerCardActive && composerInputIsMultiline}
onBlur={() => {
@@ -9148,7 +9129,6 @@ function ComposerRuntimePill({
fastOn = false,
label,
leading,
- maxWidth,
onPress,
testID,
tone,
@@ -9159,8 +9139,6 @@ function ComposerRuntimePill({
label: string;
/** 前缀节点(模型药丸传来源官方 mark);与 icon 二选一。 */
leading?: ReactNode;
- /** 收起态 leading 用:限制长/自定义 label 宽度;工具排调用不传(故意不设上限)。 */
- maxWidth?: number;
onPress(): void;
testID: string;
tone?: 'bypassPermissions';
@@ -9173,7 +9151,7 @@ function ComposerRuntimePill({
accessibilityLabel={label}
hitSlop={COMPOSER_CONTROL_HIT_SLOP}
onPress={onPress}
- style={[styles.composerRuntimePill, maxWidth != null && { maxWidth }]}
+ style={styles.composerRuntimePill}
testID={testID}
>
{leading ?? null}
@@ -9703,9 +9681,8 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({
fontWeight: fontWeight.medium,
lineHeight: lineHeight.caption,
},
- // 工具排默认不设 maxWidth 硬上限:模型名尽量显示全,空间不足时再收缩截断
+ // 不设 maxWidth 硬上限:模型名尽量显示全,只在工具排空间不足时才收缩截断
// (flexShrink + 文本 numberOfLines,剩余空间归 toolbarSpacer)。
- // 收起态 leading 经 ComposerRuntimePill.maxWidth 另行封顶,避免挤掉输入区。
composerRuntimePill: {
alignItems: 'center',
backgroundColor: colors.sheetActionSurface,
diff --git a/apps/mobile/scripts/maestro-flow-smoke.mjs b/apps/mobile/scripts/maestro-flow-smoke.mjs
index 9fea3957fe..973674a847 100644
--- a/apps/mobile/scripts/maestro-flow-smoke.mjs
+++ b/apps/mobile/scripts/maestro-flow-smoke.mjs
@@ -430,7 +430,6 @@ const requiredSourceAnchors = [
'session.openWorkspaceButton',
'session.copyWorkspacePath',
'session.composerModelButton',
- 'session.composerCollapsedModelButton',
'session.extraDirsSection',
'session.extraDirsStatus',
'session.extraDirsDraftStatus',
diff --git a/apps/mobile/src/__tests__/composerRichInputHtml.test.ts b/apps/mobile/src/__tests__/composerRichInputHtml.test.ts
index b487643d92..1fd09b1ecc 100644
--- a/apps/mobile/src/__tests__/composerRichInputHtml.test.ts
+++ b/apps/mobile/src/__tests__/composerRichInputHtml.test.ts
@@ -55,18 +55,6 @@ describe('mobile composer rich input HTML', () => {
expect(html).not.toContain('border-radius: 4px');
});
- it('stretches the editor across the inputFrame width when leading chrome is present', () => {
- // row 里 WebView flex:0 不拉宽时,placeholder 会离开 inputFrame 左缘留下死白;
- // HTML #editor 与 RN 外壳都钉 width:100%。
- expect(html).toContain('width: 100%;');
- const inputSource = readFileSync(
- resolve(process.cwd(), 'src/session/ComposerRichInput.tsx'),
- 'utf8',
- ).replace(/\r\n/g, '\n');
- expect(inputSource).toContain("width: '100%'");
- expect(inputSource).toContain("alignSelf: 'stretch'");
- });
-
it('keeps the WebKit caret in an editable text anchor after every atom', () => {
expect(html).toContain("const CARET_ANCHOR = '\\u200B'");
expect(html).toContain('return node.type === \'text\' ? [element] : [element, makeCaretAnchor()]');
diff --git a/apps/mobile/src/__tests__/sessionComposerDesktopFirst.test.ts b/apps/mobile/src/__tests__/sessionComposerDesktopFirst.test.ts
index f3dff6437d..a148b48d24 100644
--- a/apps/mobile/src/__tests__/sessionComposerDesktopFirst.test.ts
+++ b/apps/mobile/src/__tests__/sessionComposerDesktopFirst.test.ts
@@ -124,24 +124,7 @@ describe('mobile session composer desktop-first surface', () => {
expect(source).toContain('<MobilePermissionPickerList');
expect(source).toContain('hidePermissionTrigger');
expect(source).toContain('setPermissionSheetOpen(false)');
- // 展开态 toolbar(spacer 右侧) / 收起态 leading 共用 renderComposerModelPill(testID)(#900)。
- expect(source).toContain("renderComposerModelPill('session.composerModelButton')");
- // 收起态封顶 200 + 输入区 minWidth 120:长/自定义 label 不得挤没 TextInput。
- expect(source).toContain("renderComposerModelPill('session.composerCollapsedModelButton', 200)");
- expect(source).toContain('const renderComposerModelPill = (testID: string, maxWidth?: number) => (');
- expect(source).toContain('maxWidth?: number;');
- expect(source).toContain('style={[styles.composerRuntimePill, maxWidth != null && { maxWidth }]}');
- expect(source).toContain('const renderComposerCollapsedLeading = () => (');
- expect(composerInputSource).toContain('leading={renderComposerCollapsedLeading()}');
- expect(composerInputSource).not.toContain('leading={renderComposerCollapsedAttachmentBadge()}');
- expect(composerInputSource).toContain('inputFrameMinWidth={composerCardActive ? undefined : 120}');
- expect(sharedSource).toContain('inputFrameMinWidth?: number;');
- expect(sharedSource).toContain('inputFrameMinWidth != null && { minWidth: inputFrameMinWidth }');
- // 间距 hack(inputFrameStyle / marginLeft 负值)不进本 PR;徽标右边距交给 mainRow.gap。
- expect(composerInputSource).not.toContain('inputFrameStyle=');
- expect(sharedSource).not.toContain('inputFrameStyle?:');
- expect(attachmentTraySource).toContain('collapsedBadge: {');
- expect(attachmentTraySource).not.toContain('marginRight: spacing.sm');
+ expect(source).toContain('testID="session.composerModelButton"');
// 模型 + 权限浮窗:ContextSheet 同款独立 Modal(单 Modal 双 SheetSurface 叠层),
// 不再是 composer 上方的 in-flow drop-up。
expect(source).toContain('<ModelPickerSheet');
diff --git a/apps/mobile/src/session/ComposerAttachmentTray.tsx b/apps/mobile/src/session/ComposerAttachmentTray.tsx
index 2597bbdeb1..5afa92c4e4 100644
--- a/apps/mobile/src/session/ComposerAttachmentTray.tsx
+++ b/apps/mobile/src/session/ComposerAttachmentTray.tsx
@@ -375,8 +375,7 @@ function makeTrayStyles(colors: ThemeColors) {
borderRadius: radius.container,
borderWidth: StyleSheet.hairlineWidth,
height: COLLAPSED_BADGE_SIZE,
- // 与 leading 兄弟的间距交给 MobileComposerInputRow.mainRow 的 gap,避免
- // marginRight 再叠一层,收起态附件徽标与 placeholder 之间出现多余空白。
+ marginRight: spacing.sm,
overflow: 'hidden' as const,
width: COLLAPSED_BADGE_SIZE,
},
diff --git a/apps/mobile/src/session/ComposerRichInput.tsx b/apps/mobile/src/session/ComposerRichInput.tsx
index 2dc7d1a578..689cc48451 100644
--- a/apps/mobile/src/session/ComposerRichInput.tsx
+++ b/apps/mobile/src/session/ComposerRichInput.tsx
@@ -416,13 +416,9 @@ async function deleteComposerPastedImageUris(uris: readonly string[]): Promise<v
const styles = StyleSheet.create({
webView: {
backgroundColor: 'transparent',
- // react-native-webview defaults the native child to flex: 1. Override flex
- // grow/shrink because this composer drives height explicitly; keep width
- // stretched so placeholder/text start at the inputFrame's left edge instead
- // of leaving a dead gap when leading (model pill / attachment) is present.
- alignSelf: 'stretch',
+ // react-native-webview defaults the native child to flex: 1. Override it
+ // because this composer drives the child with an explicit measured height.
flex: 0,
minHeight: COMPOSER_SINGLE_LINE_HEIGHT,
- width: '100%',
},
});
diff --git a/apps/mobile/src/session/MobileComposerInputRow.tsx b/apps/mobile/src/session/MobileComposerInputRow.tsx
index 17a601e6a4..eee17b6938 100644
--- a/apps/mobile/src/session/MobileComposerInputRow.tsx
+++ b/apps/mobile/src/session/MobileComposerInputRow.tsx
@@ -114,11 +114,6 @@ export interface MobileComposerInputRowProps {
* hitSlop 解决不了——RN 的命中区不会越过父视图边界,必须让父容器本身够高。
*/
inputFrameMinHeight?: number;
- /**
- * 输入区(inputFrame)的最小宽度。收起态 leading 放长模型 pill 时用来给 TextInput
- * 留出可点/可见宽度;不设则保持 `minWidth: 0`(flex 子项默认可被压扁)。
- */
- inputFrameMinWidth?: number;
/** Rich composer replacement for the plain TextInput. */
inputElement?: ReactNode;
inputOverlay?: ReactNode;
@@ -193,7 +188,6 @@ export function MobileComposerInputRow({
floatingVoiceButtonStyle,
inputFrameHeight,
inputFrameMinHeight,
- inputFrameMinWidth,
inputElement,
inputOverlay,
inputRef,
@@ -299,7 +293,6 @@ export function MobileComposerInputRow({
style={[
styles.inputFrame,
inputFrameMinHeight != null && { minHeight: inputFrameMinHeight },
- inputFrameMinWidth != null && { minWidth: inputFrameMinWidth },
resolvedInputFrameHeight != null && { height: resolvedInputFrameHeight },
]}
>
diff --git a/apps/mobile/src/session/composerRichInputHtml.ts b/apps/mobile/src/session/composerRichInputHtml.ts
index eac3575157..246e2ed8dc 100644
--- a/apps/mobile/src/session/composerRichInputHtml.ts
+++ b/apps/mobile/src/session/composerRichInputHtml.ts
@@ -53,7 +53,6 @@ export function buildComposerRichInputHtml(config: ComposerRichInputConfig): str
color: var(--text); caret-color: var(--focus);
font-size: ${COMPOSER_TEXT_FONT_SIZE}px; line-height: ${COMPOSER_TEXT_LINE_HEIGHT}px;
min-height: ${COMPOSER_SINGLE_LINE_HEIGHT}px; max-height: var(--max-height);
- width: 100%;
overflow-y: auto; outline: none;
padding: ${COMPOSER_TEXT_VERTICAL_PADDING}px ${COMPOSER_TEXT_HORIZONTAL_PADDING}px;
white-space: pre-wrap; overflow-wrap: anywhere; -webkit-user-select: text;