Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 重排「开启协同」表单为设置类分组
kirozeng20640b755bf3
diff --git a/apps/mobile/docs/mobile-design-guide.md b/apps/mobile/docs/mobile-design-guide.mdindex 85d41b68a1..fa8177741c 100644--- a/apps/mobile/docs/mobile-design-guide.md+++ b/apps/mobile/docs/mobile-design-guide.md@@ -199,6 +199,7 @@- **点不了的入口不摆出来**:检查更新等当前不可用的动作直接不显示,原因写进 footer,不留灰按钮加解释。- 原地执行的动作行(检查更新、清空日志)传 `chevron={false}`,只有进入子页 / 外链的行画箭头。- 例外:列表条目自身的元数据(如词典别名)和录入流程里紧贴控件的步骤状态,可以留在行内。+- **「+」面板里的表单(开启协同 / 创建 Worker 等 `ContextSheet*`)同一规则**:`ContextSheetGroup` 的 `footer` 承载说明与校验提示(报错传 `footerTone="error"`),`ContextSheetRow` 用 `value` 放右侧取值、不再把说明塞进行内 `detail`;iOS 下拉行自带行名、分段控件选项自明,分组不再加标题(Android 药丸没有行名,保留分组标题);底部主按钮撑满宽度。iOS 上「+」面板的分组标题用 13/18 600 `textTertiary`(系统默认分组标题在新版 iOS 是大号粗体,由 `ComposerSectionSettingsHeader` 统一换掉);面板底与卡片保持系统玻璃样式,不改实色,以免丢掉原生 sheet 的玻璃过渡动画。### 主题接入模式(强制)diff --git a/apps/mobile/src/session/ComposerNativeSection.ios.tsx b/apps/mobile/src/session/ComposerNativeSection.ios.tsxindex c37dcb0b80..5484a6b04f 100644--- a/apps/mobile/src/session/ComposerNativeSection.ios.tsx+++ b/apps/mobile/src/session/ComposerNativeSection.ios.tsx@@ -1,8 +1,22 @@-import { Section } from '@expo/ui/swift-ui';-import { listRowBackground } from '@expo/ui/swift-ui/modifiers';+import { useContext } from 'react';+import { Section, Text } from '@expo/ui/swift-ui';+import { font, foregroundStyle, listRowBackground } from '@expo/ui/swift-ui/modifiers';import { useTheme } from '@/theme';import type { ComposerNativeSectionProps } from './ComposerNativeSection';-export function ComposerNativeSection(props: ComposerNativeSectionProps) {+import { ComposerSectionSettingsHeader } from './composerSectionHeader';+export function ComposerNativeSection({ title, ...props }: ComposerNativeSectionProps) {const { colors } = useTheme();- return <Section {...props} modifiers={[listRowBackground(colors.surfaceTranslucent)]} />;+ const smallHeader = useContext(ComposerSectionSettingsHeader) && !!title;+ return (+ <Section+ {...props}+ title={smallHeader ? undefined : title}+ header={smallHeader ? (+ <Text modifiers={[font({ textStyle: 'footnote', weight: 'semibold' }), foregroundStyle(colors.textTertiary)]}>+ {title}+ </Text>+ ) : undefined}+ modifiers={[listRowBackground(colors.surfaceTranslucent)]}+ />+ );}diff --git a/apps/mobile/src/session/ComposerNativeSection.tsx b/apps/mobile/src/session/ComposerNativeSection.tsxindex 669ed4c6ef..69a3eb3527 100644--- a/apps/mobile/src/session/ComposerNativeSection.tsx+++ b/apps/mobile/src/session/ComposerNativeSection.tsx@@ -1,3 +1,7 @@import type { ReactNode } from 'react';-export interface ComposerNativeSectionProps { title?: string; children: ReactNode; }+export interface ComposerNativeSectionProps {+ title?: string;+ footer?: ReactNode;+ children: ReactNode;+}export function ComposerNativeSection({ children }: ComposerNativeSectionProps) { return <>{children}</>; }diff --git a/apps/mobile/src/session/ContextSheet.ios.tsx b/apps/mobile/src/session/ContextSheet.ios.tsxindex ad3a502b36..b7e0cef768 100644--- a/apps/mobile/src/session/ContextSheet.ios.tsx+++ b/apps/mobile/src/session/ContextSheet.ios.tsx@@ -7,7 +7,6 @@ import {useContext,useEffect,useRef,- type ReactNode,} from "react";import { Button, HStack, Image, Picker, RNHostView, ProgressView, Spacer, Text, TextField, VStack, useNativeState } from '@expo/ui/swift-ui';import {@@ -33,6 +32,7 @@ import { useTranslation } from "react-i18next";import { View } from "react-native";import type {ContextSheetChoiceRowProps,+ ContextSheetGroupProps,ContextSheetSelectRowProps,ContextSheetProps,ContextSheetRowProps,@@ -40,6 +40,7 @@ import type {ContextSheetTextFieldProps,} from "./ContextSheet";import { ComposerSheet } from "./ComposerSheet";+import { ComposerSectionSettingsHeader } from './composerSectionHeader';const DismissAction = createContext<(action: () => void) => void>((action) =>action(),);@@ -60,37 +61,47 @@ export function ContextSheet(props: ContextSheetProps) {props.onClose();}}>- <ComposerSheet- {...props}- title={props.onBack ? props.title : ''}- aboveContent={props.media}- aboveContentTitle={t("session.common.groupAdd")}- nativeContent- onClosed={() => {- const action = pending.current;- pending.current = null;- action?.();- }}- footer={props.footer}- >- {props.children}- {props.error ? (- <Section>- <NativeErrorNotice message={props.error} />- </Section>- ) : null}- </ComposerSheet>+ <ComposerSectionSettingsHeader.Provider value>+ <ComposerSheet+ {...props}+ title={props.onBack ? props.title : ''}+ aboveContent={props.media}+ aboveContentTitle={t("session.common.groupAdd")}+ nativeContent+ onClosed={() => {+ const action = pending.current;+ pending.current = null;+ action?.();+ }}+ footer={props.footer}+ >+ {props.children}+ {props.error ? (+ <Section>+ <NativeErrorNotice message={props.error} />+ </Section>+ ) : null}+ </ComposerSheet>+ </ComposerSectionSettingsHeader.Provider></DismissAction.Provider>);}export function ContextSheetGroup({label,children,-}: {- label: string;- children: ReactNode;-}) {- return <Section title={label || undefined}>{children}</Section>;+ footer,+ footerTone,+ footerTestID,+}: ContextSheetGroupProps) {+ // 说明写在卡片下方(原生 Section footer)。+ return (+ <Section+ title={label || undefined}+ footer={footer ? <ContextSheetNote text={footer} tone={footerTone} testID={footerTestID} /> : undefined}+ >+ {children}+ </Section>+ );}export function ContextSheetRow(props: ContextSheetRowProps) {const dismiss = useContext(DismissAction);@@ -106,11 +117,13 @@ export function ContextSheetRow(props: ContextSheetRowProps) {...extraModifiers,]}>- <RNHostView matchContents>- <View style={{ width: 28, height: 28, justifyContent: "center" }}>- {props.icon}- </View>- </RNHostView>+ {props.icon ? (+ <RNHostView matchContents>+ <View style={{ width: 28, height: 28, justifyContent: "center" }}>+ {props.icon}+ </View>+ </RNHostView>+ ) : null}{props.detail ? (<VStack alignment="leading" spacing={2}><Text modifiers={[...labelModifiers, lineLimit(1)]}>{props.label}</Text>@@ -120,6 +133,9 @@ export function ContextSheetRow(props: ContextSheetRowProps) {<Text modifiers={labelModifiers}>{props.label}</Text>)}<Spacer />+ {props.value && !props.busy ? (+ <Text modifiers={[foregroundStyle(colors.textSecondary), lineLimit(1)]}>{props.value}</Text>+ ) : null}{props.busy ? (<ProgressView />) : props.trailing && props.trailing !== "chevron" ? (@@ -133,7 +149,7 @@ export function ContextSheetRow(props: ContextSheetRowProps) {} : undefined}>{props.trailing}</View></RNHostView>) : props.trailing === "chevron" ? (- <Image size={iconSize.lg} systemName="chevron.right" />+ <Image size={iconSize.lg} systemName="chevron.right" color={colors.textTertiary} />) : null}</HStack>);@@ -175,10 +191,12 @@ export function ContextSheetFooterButton(props: ContextSheetFooterButtonProps) {modifiers={[...glassStyle,disable(!!props.disabled || !!props.busy),- frame({ maxWidth: Infinity, minHeight: 44 }),]}>- {props.busy ? <ProgressView modifiers={[tint(colors.ctaText)]} /> : <Text modifiers={[foregroundStyle(colors.ctaText)]}>{props.label}</Text>}+ {/* 撑满宽度的 frame 放在标签里:放在 Button 上只会放大点击区,胶囊仍按文字收缩。 */}+ {props.busy+ ? <ProgressView modifiers={[tint(colors.ctaText), frame({ maxWidth: Infinity, minHeight: 44 })]} />+ : <Text modifiers={[foregroundStyle(colors.ctaText), frame({ maxWidth: Infinity, minHeight: 44 })]}>{props.label}</Text>}</Button>);}diff --git a/apps/mobile/src/session/ContextSheet.tsx b/apps/mobile/src/session/ContextSheet.tsxindex f4e1990f4e..207edce80a 100644--- a/apps/mobile/src/session/ContextSheet.tsx+++ b/apps/mobile/src/session/ContextSheet.tsx@@ -125,12 +125,26 @@ export function ContextSheet({);}-export function ContextSheetGroup({ label, children }: { label: string; children: ReactNode }) {+export interface ContextSheetGroupProps {+ /** 分组小标签;行自己带名称的分组(如 iOS 下拉行)传空串,不再重复一遍。 */+ label: string;+ children: ReactNode;+ /**+ * 卡片下方的说明(设置类分组惯例,对齐 SettingsGroup 的 footer):卡片里只放+ * 「名称 + 取值 / 开关 / 箭头」,成句的说明与校验提示写在这里。一组只配一段。+ */+ footer?: string | null;+ footerTone?: 'secondary' | 'error';+ footerTestID?: string;+}++export function ContextSheetGroup({ label, children, footer, footerTone, footerTestID }: ContextSheetGroupProps) {const styles = useThemedStyles(makeContextSheetStyles);return (<View style={styles.group}>- <Text style={styles.groupLabel}>{label}</Text>+ {label ? <Text style={styles.groupLabel}>{label}</Text> : null}<GroupRows>{children}</GroupRows>+ {footer ? <ContextSheetNote text={footer} tone={footerTone} testID={footerTestID} /> : null}</View>);}@@ -157,8 +171,11 @@ function flattenChildren(children: ReactNode): ReactNode[] {export interface ContextSheetRowProps {/** Dismiss the sheet before presenting a system picker. */dismissBeforePress?: boolean;- icon: ReactNode;+ /** 行首图标;设置类表单行只放名称与取值,不传。 */+ icon?: ReactNode;label: string;+ /** 右侧取值(16/22 400 textSecondary),在箭头之前;过长截断。 */+ value?: string;onPress: () => void;/** 长按(如协同 Worker 行的管理操作);不传则只有点按。 */onLongPress?: () => void;@@ -180,6 +197,7 @@ export function ContextSheetRow({dismissBeforePress = false,icon,label,+ value,onPress,onLongPress,trailing,@@ -225,10 +243,15 @@ export function ContextSheetRow({]}>{busy ? (<ActivityIndicator color={colors.textSecondary} size="small" />- ) : trailing === 'chevron' ? (- <ChevronRight color={colors.textTertiary} size={iconSize.md} strokeWidth={iconStroke.regular} />) : (- trailing ?? null+ <>+ {value ? <Text numberOfLines={1} style={styles.rowValue}>{value}</Text> : null}+ {trailing === 'chevron' ? (+ <ChevronRight color={colors.textTertiary} size={iconSize.lg} strokeWidth={iconStroke.regular} />+ ) : (+ trailing ?? null+ )}+ </>)}</View></Pressable>@@ -431,10 +454,12 @@ function makeContextSheetStyles(colors: ThemeColors) {group: {paddingTop: spacing.lg,},+ // 分组小标签:13/18 600 textTertiary(设置类分组同一档)。groupLabel: {color: colors.textTertiary,fontSize: typeScale.footnote,lineHeight: lineHeight.caption,+ fontWeight: fontWeight.semibold,},separator: {backgroundColor: colors.border,@@ -462,6 +487,15 @@ function makeContextSheetStyles(colors: ThemeColors) {lineHeight: lineHeight.body,fontWeight: fontWeight.medium,},+ // 行右侧取值:16/22 400 textSecondary。+ rowValue: {+ color: colors.textSecondary,+ flexShrink: 1,+ fontSize: typeScale.body,+ lineHeight: lineHeight.body,+ fontWeight: fontWeight.regular,+ maxWidth: '60%' as const,+ },rowTextColumn: {flexShrink: 1,gap: 2,@@ -471,10 +505,12 @@ function makeContextSheetStyles(colors: ThemeColors) {fontSize: typeScale.footnote,lineHeight: lineHeight.caption,},+ // 说明、提示(成句的话):13/18 400 textSecondary。note: {- color: colors.textTertiary,+ color: colors.textSecondary,fontSize: typeScale.footnote,lineHeight: lineHeight.caption,+ fontWeight: fontWeight.regular,paddingVertical: spacing.sm,},noteError: {@@ -534,6 +570,7 @@ function makeContextSheetStyles(colors: ThemeColors) {rowTrailing: {alignItems: 'center' as const,flexDirection: 'row' as const,+ flexShrink: 1,gap: spacing.sm,},};diff --git a/apps/mobile/src/session/ContextSheetCollabView.tsx b/apps/mobile/src/session/ContextSheetCollabView.tsxindex fb3063318a..9adc3da802 100644--- a/apps/mobile/src/session/ContextSheetCollabView.tsx+++ b/apps/mobile/src/session/ContextSheetCollabView.tsx@@ -9,8 +9,8 @@* iOS 原生面板与 Android 面板共用本文件。团队真身在被控端,这里只渲染镜像并回调页面。*/import { useTranslation } from 'react-i18next';-import { View } from 'react-native';-import { Bot, CircleStop, Folder, UserPlus } from 'lucide-react-native';+import { Platform, View } from 'react-native';+import { CircleStop, UserPlus } from 'lucide-react-native';import {ORCA_PREDEFINED_WORKER_ROLES,ORCA_WORKER_ROLE_MAX_LENGTH,@@ -43,6 +43,9 @@ import type { OrcaExecutionDeviceView } from '@cindy/device-link';const CUSTOM_ROLE = '__custom__';+/** iOS 的下拉行(Picker menu)自带行名、分段控件选项自明;Android 的药丸 / 选择行没有行名,要靠分组标题。 */+const ROW_NAMES_ITSELF = Platform.OS === 'ios';+export function isPredefinedOrcaRole(role: string): boolean {return (ORCA_PREDEFINED_WORKER_ROLES as readonly string[]).includes(role);}@@ -99,16 +102,22 @@ export function OrcaWorkerFormView({executionDevicesError,}: OrcaWorkerFormViewProps) {const { t } = useTranslation();- const { colors } = useTheme();const roleOptions = [...ORCA_PREDEFINED_WORKER_ROLES.map((role) => ({ id: role as string, label: role as string })),{ id: CUSTOM_ROLE, label: t('session.collab.customRole') },];const validation = orcaWorkerFormErrorKey(form, customRoleMode);const modelLabel = form.model?.id ?? t('session.collab.modelDefault');+ const remoteDirInvalid = form.remoteDirMode === 'path' && !!form.remoteDir && !isAbsoluteOrcaWorkerDir(form.remoteDir);+ // 设置类分组:卡片里只放「名称 + 取值」,说明与校验提示写在卡片下方(一组一段)。+ const title = (label: string) => (ROW_NAMES_ITSELF ? '' : label);return (<>- <ContextSheetGroup label={t('session.collab.roleLabel')}>+ <ContextSheetGroup+ footer={validation ? t(validation) : t('session.collab.roleHint')}+ footerTone={validation ? 'error' : 'secondary'}+ label={title(t('session.collab.roleLabel'))}+ ><ContextSheetChoiceRowdisabled={busy}label={t('session.collab.roleLabel')}@@ -136,11 +145,13 @@ export function OrcaWorkerFormView({value={form.role}/>) : null}- <ContextSheetNote text={validation ? t(validation) : t('session.collab.roleHint')} tone={validation ? 'error' : 'secondary'} /></ContextSheetGroup>{/* 运行设备与远程供应商互斥:Worker 的 Agent 已选在另一台电脑时不提供运行设备。 */}{(executionDevices.length > 0 || form.executionDeviceId) && !orcaWorkerAgentElsewhere(form) ? (- <ContextSheetGroup label={t('session.collab.executionDeviceLabel')}>+ <ContextSheetGroup+ footer={t('session.collab.executionDeviceHint')}+ label={title(t('session.collab.executionDeviceLabel'))}+ ><ContextSheetSelectRowdisabled={busy || executionDevicesLoading}label={t('session.collab.executionDeviceLabel')}@@ -160,11 +171,16 @@ export function OrcaWorkerFormView({onChange={(id) => onChange({ executionDeviceId: id === '__lead__' ? undefined : id })}testID="collab.executionDevice"/>- <ContextSheetNote text={t('session.collab.executionDeviceHint')} /></ContextSheetGroup>) : null}{form.executionDeviceId ? (- <ContextSheetGroup label={t('session.collab.remoteDirLabel')}>+ <ContextSheetGroup+ footer={t(form.remoteDirMode === 'path'+ ? remoteDirInvalid ? 'session.collab.remoteDirInvalid' : 'session.collab.remoteDirPathHint'+ : 'session.collab.remoteDirChatHint')}+ footerTone={remoteDirInvalid ? 'error' : 'secondary'}+ label={t('session.collab.remoteDirLabel')}+ ><ContextSheetChoiceRowdisabled={busy}label={t('session.collab.remoteDirLabel')}@@ -179,27 +195,23 @@ export function OrcaWorkerFormView({{form.remoteDirMode === 'path' ? (<ContextSheetRowlabel={t('session.new.selectWorkspace')}- detail={form.remoteDir || t('session.new.chooseOtherFolder')}+ value={form.remoteDir || t('session.new.chooseOtherFolder')}dismissBeforePressdisabled={busy}- icon={<Folder color={colors.textPrimary} size={iconSize.lg} strokeWidth={iconStroke.regular} />}onPress={onPickDirectory}trailing="chevron"testID="collab.remoteDirPicker"/>) : null}- <ContextSheetNote- text={t(form.remoteDirMode === 'path'- ? !form.remoteDir || isAbsoluteOrcaWorkerDir(form.remoteDir) ? 'session.collab.remoteDirPathHint' : 'session.collab.remoteDirInvalid'- : 'session.collab.remoteDirChatHint')}- tone={form.remoteDirMode === 'path' && !!form.remoteDir && !isAbsoluteOrcaWorkerDir(form.remoteDir) ? 'error' : 'secondary'}- /></ContextSheetGroup>) : null}{executionDevicesError ? <ContextSheetGroup label={t('session.collab.executionDeviceLabel')}><ContextSheetError text={executionDevicesError} /></ContextSheetGroup> : null}- <ContextSheetGroup label={t('session.collab.agentLabel')}>+ <ContextSheetGroup+ footer={form.model ? null : t('session.collab.modelDefaultHint')}+ label={title(t('session.collab.agentLabel'))}+ ><ContextSheetChoiceRowdisabled={busy || agents.length < 2}label={t('session.collab.agentLabel')}@@ -209,22 +221,22 @@ export function OrcaWorkerFormView({value={form.agent}/><ContextSheetRow- detail={form.model ? undefined : t('session.collab.modelDefaultHint')}// iOS 原生 sheet 不能叠开:先收起 + 面板再打开模型选择器。dismissBeforePressdisabled={busy}- icon={<Bot color={colors.textPrimary} size={iconSize.lg} strokeWidth={iconStroke.regular} />}label={t('session.collab.modelLabel')}onPress={onPickModel}testID="collab.modelRow"- trailing={(- <Text numberOfLines={1} style={{ color: colors.textTertiary, fontSize: typeScale.footnote, lineHeight: lineHeight.caption, maxWidth: 180 }}>- {modelLabel}- </Text>- )}+ trailing="chevron"+ value={modelLabel}/></ContextSheetGroup>- <ContextSheetGroup label={t('session.collab.permissionLabel')}>+ <ContextSheetGroup+ footer={t(form.permissionMode === 'auto'+ ? 'session.collab.permissionAutoHint'+ : 'session.collab.permissionFullHint')}+ label={title(t('session.collab.permissionLabel'))}+ ><ContextSheetChoiceRowdisabled={busy}label={t('session.collab.permissionLabel')}@@ -236,12 +248,8 @@ export function OrcaWorkerFormView({testID="collab.permissionOptions"value={form.permissionMode}/>- <ContextSheetNote text={t(form.permissionMode === 'auto'- ? 'session.collab.permissionAutoHint'- : 'session.collab.permissionFullHint')}- /></ContextSheetGroup>- <ContextSheetGroup label={t('session.collab.initialTaskLabel')}>+ <ContextSheetGroup footer={notice} label={t('session.collab.initialTaskLabel')}><ContextSheetTextFieldaccessibilityLabel={t('session.collab.initialTaskLabel')}disabled={busy}@@ -252,10 +260,9 @@ export function OrcaWorkerFormView({value={form.initialTask}/></ContextSheetGroup>- {notice || error ? (+ {error ? (<ContextSheetGroup label="">- {notice ? <ContextSheetNote text={notice} /> : null}- {error ? <ContextSheetError text={error} testID="collab.formError" /> : null}+ <ContextSheetError text={error} testID="collab.formError" /></ContextSheetGroup>) : null}</>@@ -345,7 +352,12 @@ export function OrcaTeamPanelView({<ContextSheetNote text={loading ? t('session.collab.loading') : t('session.collab.noWorkers')} />) : null}</ContextSheetGroup>- <ContextSheetGroup label={t('session.collab.manageGroup')}>+ <ContextSheetGroup+ footer={[createHint, settings+ ? t('session.collab.limitSummary', { soft: settings.workerSoftLimit, hard: settings.workerHardLimit })+ : null].filter(Boolean).join('\n') || null}+ label={t('session.collab.manageGroup')}+ ><ContextSheetRowaccessibilityHint={createHint ?? undefined}disabled={busy || slot === 'hard'}@@ -364,17 +376,11 @@ export function OrcaTeamPanelView({testID="collab.stopRow"/></ContextSheetGroup>- <ContextSheetGroup label="">- {createHint ? <ContextSheetNote text={createHint} /> : null}- {settings ? (- <ContextSheetNote text={t('session.collab.limitSummary', {- soft: settings.workerSoftLimit,- hard: settings.workerHardLimit,- })}- />- ) : null}- {error ? <ContextSheetError text={error} testID="collab.teamError" /> : null}- </ContextSheetGroup>+ {error ? (+ <ContextSheetGroup label="">+ <ContextSheetError text={error} testID="collab.teamError" />+ </ContextSheetGroup>+ ) : null}</>);}diff --git a/apps/mobile/src/session/composerSectionHeader.ts b/apps/mobile/src/session/composerSectionHeader.tsnew file mode 100644index 0000000000..29b8aeaf55--- /dev/null+++ b/apps/mobile/src/session/composerSectionHeader.ts@@ -0,0 +1,7 @@+import { createContext } from 'react';++/**+ * 原生分组(ComposerNativeSection)的标题是否按设置页同一档画(13/18 600 textTertiary)。+ * 系统默认分组标题在新版 iOS 是大号粗体;「+」面板(ContextSheet)给整块内容开启。+ */+export const ComposerSectionSettingsHeader = createContext(false);