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。

fix(mobile): 完善建群表单原生操作栏与键盘交互

nanaeb015303cab2
diff --git a/apps/mobile/docs/mobile-design-guide.md b/apps/mobile/docs/mobile-design-guide.md
index d745723e8b..28bdf7373b 100644
--- a/apps/mobile/docs/mobile-design-guide.md
+++ b/apps/mobile/docs/mobile-design-guide.md
@@ -325,6 +325,7 @@ iOS 新增与改造界面遵循 [iOS 原生界面规范](../../../docs/design-ru
- 颜色走 token(`colors.textPrimary` / `textSecondary` / `statusAccent` / `permAutoAccent` 等),不写死。
- 会话 Agent 身份图标走 `MobileVendorIcon`;provider / model 厂牌图标分别走 `MobileProviderMark` / `MobileModelIconMark`。
- **底部浮窗按平台承载**:iOS 新增与迁移优先系统 sheet,详情默认中等高度、短工具按内容高度,具体见 iOS 规范。Android 和尚未迁移的兼容实现继续复用 `SheetModal` / `SheetSurface`,不另造自绘外壳;其二级内容保留单 Modal 内导航。不同面板之间等待关闭回调后再呈现,避免叠加遮罩。
+- **创建群表单(2026-10-28 用户修正)**:iOS 使用展开的系统 page sheet 与 UIKit 导航栏,正文采用不透底的主题 surface。左侧为系统关闭图标按钮,右侧为文字创建按钮,均保留中性玻璃底;创建不用蓝色或 prominent 填充。标题、按钮几何与交互由导航栏负责,不在内容里用自定义标题行模拟 toolbar。表单可滚动并避让键盘,呈现完成后聚焦群名;有草稿或提交中禁止滑动关闭,显式关闭沿用丢弃确认。
---
diff --git a/apps/mobile/src/__tests__/BotGroupList.test.tsx b/apps/mobile/src/__tests__/BotGroupList.test.tsx
index b0bfad17d5..dcd7261b23 100644
--- a/apps/mobile/src/__tests__/BotGroupList.test.tsx
+++ b/apps/mobile/src/__tests__/BotGroupList.test.tsx
@@ -8,9 +8,12 @@ const h = vi.hoisted(() => ({
invoke: vi.fn(),
openLink: vi.fn(async () => undefined),
inputs: {} as Record<string, any>,
+ focus: vi.fn(),
+ onShow: undefined as undefined | (() => void),
teammates: { rows: [] as any[], loading: false, failed: false },
alert: vi.fn(),
nativeMenu: true,
+ dark: false,
}));
vi.mock('expo-router', () => ({ Stack: { Toolbar: Object.assign(({ children }: any) => children, {
@@ -41,7 +44,8 @@ vi.mock('react-i18next', async (importOriginal) => ({
vi.mock('lucide-react-native', () => ({ Plus: () => null, Check: () => null, Users: () => null }));
vi.mock('@/theme', async () => {
const tokens = await import('@/theme/tokens');
- return { ...tokens, useThemedStyles: () => ({}), useTheme: () => ({ colors: {} }) };
+ const colors = () => h.dark ? tokens.darkColors : tokens.lightColors;
+ return { ...tokens, useThemedStyles: (make: any) => make(colors()), useTheme: () => ({ colors: colors() }) };
});
vi.mock('@/hooks/useReduceMotion', () => ({ useReduceMotionEnabled: () => true }));
vi.mock('@/auth/AuthContext', () => ({ useAuth: () => ({ user: { id: 'owner' }, accountGeneration: 1 }) }));
@@ -50,7 +54,7 @@ vi.mock('@/utils/useMinuteNow', () => ({ useMinuteNow: () => 0 }));
vi.mock('@/session/sessionList', () => ({ formatRemoteSessionSidebarTime: () => '9:41' }));
vi.mock('@/session/SessionRightSpinner', () => ({ SessionRightSpinner: ({ testID }: any) => el('i', { 'data-testid': testID }) }));
vi.mock('@/components/AppText', () => ({
- Text: ({ children, testID }: any) => el('span', { 'data-testid': testID }, children),
+ Text: ({ children, testID, style, accessibilityRole }: any) => el('span', { 'data-testid': testID, role: accessibilityRole, style: { color: style?.color } }, children),
TextInput: ({ testID, ...props }: any) => { h.inputs[testID] = props; return el('input', { 'data-testid': testID, value: props.value ?? '', readOnly: true }); },
}));
vi.mock('@/session/CompanionSettingsRow', () => ({ CompanionSettingsRow: (props: any) => el('button', { 'data-testid': props.testID, onClick: props.onPress }, props.label) }));
@@ -68,10 +72,12 @@ vi.mock('@/platform/chrome/NativePullDownMenu', () => ({
},
}));
vi.mock('@/session/CompanionSheet', () => ({
- CompanionSheet: ({ visible, children, onClosed, testID }: any) => {
+ CompanionSheet: ({ visible, children, onClosed, onShow, testID, leadingAction, trailingAction }: any) => {
+ h.onShow = onShow;
const was = useRef(visible);
useEffect(() => { if (was.current && !visible) onClosed?.(); was.current = visible; }, [visible]);
- return visible ? el('div', { 'data-testid': testID }, children) : null;
+ const action = (item: any) => item ? el('button', { 'data-testid': item.testID, disabled: item.disabled || item.busy, onClick: item.onPress }, item.label) : null;
+ return visible ? el('div', { 'data-testid': testID }, el('header', null, action(leadingAction), action(trailingAction)), children) : null;
},
}));
vi.mock('@/session/HomeHeaderGlassButton', () => ({
@@ -121,7 +127,7 @@ async function click(id: string) {
}
beforeEach(() => {
- vi.clearAllMocks(); h.inputs = {}; h.nativeMenu = true;
+ vi.clearAllMocks(); h.inputs = {}; h.nativeMenu = true; h.dark = false;
h.teammates = { rows: [teammate('mimi', '咪咪'), teammate('abu', '阿布'), teammate('xiaoman', '小满')], loading: false, failed: false };
node = document.createElement('div'); root = createRoot(node);
});
@@ -175,7 +181,7 @@ describe('create from the home teammate section + menu', () => {
return onGroupCreated;
}
- it('offers 新建伙伴 and 新建群聊, creates with 2–6 teammates in list order, then opens it after the sheet closes', async () => {
+ it('offers 新建伙伴 and 新建群聊, creates with teammates in list order, then opens it after the sheet closes', async () => {
const onGroupCreated = await render();
const titles = [...node.querySelectorAll('[data-testid^="teammates.createMenu.action."]')].map((entry) => entry.textContent);
expect(titles).toEqual(['devices.companions.createTeammate', 'groupChat.create.title']);
@@ -183,7 +189,7 @@ describe('create from the home teammate section + menu', () => {
expect(byId('botGroup.create')).not.toBeNull();
await click('botGroup.create.submit');
expect(node.textContent).toContain('groupChat.create.nameRequired');
- expect(node.textContent).toContain('groupChat.create.minMembers(min=2)');
+ expect(node.textContent).not.toContain('groupChat.create.minMembers');
expect(h.invoke).not.toHaveBeenCalled();
await act(async () => { h.inputs['botGroup.create.name'].onChangeText(' 官网 '); });
// Equal timestamps now have a stable identity tie-breaker. Select in the
@@ -207,6 +213,64 @@ describe('create from the home teammate section + menu', () => {
expect(onGroupCreated).toHaveBeenCalledWith(mac, 'g9');
});
+ // Regression: the real create sheet used to block 0/1 selected bots and render
+ // required-name errors in neutral text. Existing coverage only exercised 2 bots.
+ // Tier: unit (rendered form + outgoing remote-resource request, no network).
+ it.each([0, 1])('creates with %i selected teammates and no minimum-count notice', async (count) => {
+ if (count === 0) h.teammates.rows = [];
+ const onGroupCreated = await render();
+ await click('teammates.createMenu.action.group:mac');
+ expect(node.textContent).not.toContain('groupChat.create.description');
+ expect(node.textContent).not.toContain('groupChat.create.computerNote');
+ expect(node.textContent).not.toContain('groupChat.create.notEnoughBots');
+ await act(async () => { h.inputs['botGroup.create.name'].onChangeText(' 官网 '); });
+ if (count) await click('botGroup.create.member.abu');
+ h.invoke.mockResolvedValueOnce({ effects: [
+ { kind: 'navigate', target: { kind: 'resource', ref: { collectionId: 'bot-groups', kind: 'bot-group', id: 'g9' } } },
+ ] });
+ await click('botGroup.create.submit');
+ expect(h.invoke.mock.calls[0]?.[2][0]).toMatchObject({
+ collectionId: 'bot-groups', actionId: 'create', input: { name: '官网', botIds: count ? ['abu'] : [] },
+ });
+ expect(onGroupCreated).toHaveBeenCalledWith(mac, 'g9');
+ });
+
+ it.each([false, true])('shows a red required-name error and clears it after correction (dark=%s)', async (dark) => {
+ h.dark = dark;
+ const { lightColors, darkColors } = await import('@/theme/tokens');
+ await render();
+ await click('teammates.createMenu.action.group:mac');
+ await act(async () => { h.inputs['botGroup.create.name'].onChangeText(' '); });
+ await click('botGroup.create.submit');
+ const error = node.querySelector('[role="alert"]') as HTMLElement;
+ expect(error?.textContent).toBe('groupChat.create.nameRequired');
+ const expected = document.createElement('span');
+ expected.style.color = (dark ? darkColors : lightColors).statusError;
+ expect(error.style.color).toBe(expected.style.color);
+ expect(h.invoke).not.toHaveBeenCalled();
+ await act(async () => { h.inputs['botGroup.create.name'].onChangeText('官网'); });
+ expect(node.querySelector('[role="alert"]')).toBeNull();
+ });
+
+ // #7658: six selected is a cap, not a truncation of the available roster.
+ it('focuses the name and can select a teammate beyond the sixth row', async () => {
+ h.teammates.rows = Array.from({ length: 12 }, (_, index) => teammate(`bot-${index}`, `Bot ${index}`));
+ await render();
+ await click('teammates.createMenu.action.group:mac');
+ h.inputs['botGroup.create.name'].ref.current = { focus: h.focus };
+ expect(h.focus).not.toHaveBeenCalled();
+ h.onShow?.();
+ expect(h.focus).toHaveBeenCalledOnce();
+ expect(node.querySelectorAll('[data-testid^="botGroup.create.member."]')).toHaveLength(12);
+ await click('botGroup.create.member.bot-11');
+ await act(async () => { h.inputs['botGroup.create.name'].onChangeText('More teammates'); });
+ h.invoke.mockResolvedValueOnce({ effects: [
+ { kind: 'navigate', target: { kind: 'resource', ref: { collectionId: 'bot-groups', kind: 'bot-group', id: 'g9' } } },
+ ] });
+ await click('botGroup.create.submit');
+ expect(h.invoke.mock.calls[0]?.[2][0].input.botIds).toEqual(['bot-11']);
+ });
+
it('shows the host’s reason when it refuses', async () => {
await render();
await click('teammates.createMenu.action.group:mac');
@@ -223,7 +287,8 @@ describe('create from the home teammate section + menu', () => {
const hosts = [...node.querySelectorAll('[data-testid^="teammates.createMenu.action.group:"]')].map((entry) => entry.textContent);
expect(hosts).toEqual(['PC', 'Mac']);
await click('teammates.createMenu.action.group:pc');
- expect(node.textContent).toContain('groupChat.create.computerNote(deviceName=PC)');
+ expect(byId('botGroup.create')).not.toBeNull();
+ expect(node.textContent).not.toContain('groupChat.create.computerNote');
expect(onGroupCreated).not.toHaveBeenCalled();
});
@@ -235,7 +300,8 @@ describe('create from the home teammate section + menu', () => {
await click('teammates.createChooser.group.pc');
// The create sheet opens only after the chooser has closed.
expect(byId('teammates.createChooser')).toBeNull();
- expect(node.textContent).toContain('groupChat.create.computerNote(deviceName=PC)');
+ expect(byId('botGroup.create')).not.toBeNull();
+ expect(node.textContent).not.toContain('groupChat.create.computerNote');
});
it('keeps the single-purpose teammate button when no computer supports group chats', async () => {
diff --git a/apps/mobile/src/__tests__/CompanionSheet.test.tsx b/apps/mobile/src/__tests__/CompanionSheet.test.tsx
index 267f686f38..3a1070f801 100644
--- a/apps/mobile/src/__tests__/CompanionSheet.test.tsx
+++ b/apps/mobile/src/__tests__/CompanionSheet.test.tsx
@@ -4,6 +4,9 @@ import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
const h = vi.hoisted(() => ({ modal: null as any, surface: null as any, mounts: 0 }));
+vi.mock('@/components/MobilePrimitives', () => ({ MainWindowActionButton: () => null }));
+vi.mock('@/theme', () => ({ useTheme: () => ({ colors: {} }), iconSize: {}, iconStroke: {}, radius: {} }));
+vi.mock('lucide-react-native', () => ({ X: () => null }));
vi.mock('react-native', () => ({ useWindowDimensions: () => ({ width: 400, height: 800 }) }));
vi.mock('react-native-safe-area-context', () => ({ useSafeAreaInsets: () => ({ top: 40, bottom: 20, left: 0, right: 0 }) }));
vi.mock('@/session/SheetModal', () => ({ SheetModal: (props: any) => { h.modal = props; return props.children; } }));
diff --git a/apps/mobile/src/__tests__/composerSheetOrientation.test.tsx b/apps/mobile/src/__tests__/composerSheetOrientation.test.tsx
index 1a0a0abbae..f96359feb6 100644
--- a/apps/mobile/src/__tests__/composerSheetOrientation.test.tsx
+++ b/apps/mobile/src/__tests__/composerSheetOrientation.test.tsx
@@ -4,14 +4,27 @@ import { createRoot } from 'react-dom/client';
import { expect, it, vi } from 'vitest';
import { ComposerSheet } from '../session/ComposerSheet.ios';
import { CompanionSheet } from '../session/CompanionSheet.ios';
+import { FormSheet } from '../session/FormSheet.ios';
import { ScrollView as RNScrollView } from 'react-native';
import { onGeometryChange, presentationDetents } from '@expo/ui/swift-ui/modifiers';
-const state = vi.hoisted(() => ({ width: 402, height: 874, sheet: null as any }));
+const state = vi.hoisted(() => ({ width: 402, height: 874, sheet: null as any, formModal: null as any }));
vi.mock('../session/ComposerSheet', async () => import('../session/ComposerSheet.ios'));
vi.mock('react-native', () => ({
View: ({ children, style }: any) => <div style={style}>{children}</div>,
ScrollView: ({ children, maintainVisibleContentPosition }: any) => <section data-rn-scroll data-preserve-position={maintainVisibleContentPosition?.minIndexForVisible}>{children}</section>,
useWindowDimensions: () => ({ width: state.width, height: state.height }),
+ Modal: (props: any) => { state.formModal = props; return props.children; },
+ ActivityIndicator: () => <span role="progressbar" />,
+ StyleSheet: { create: (styles: any) => styles },
+}));
+vi.mock('react-native-screens', () => ({
+ ScreenStack: ({ children }: any) => children,
+ ScreenStackItem: ({ headerConfig, children }: any) => <div>
+ <nav>{[...headerConfig.headerLeftBarButtonItems, ...headerConfig.headerRightBarButtonItems].map((item: any) =>
+ <button key={item.identifier} data-testid={item.identifier} aria-label={item.accessibilityLabel}
+ data-system-image={item.icon?.name} disabled={item.disabled} onClick={item.onPress}>{item.title}</button>)}</nav>
+ {children}
+ </div>,
}));
vi.mock('../session/CompanionNativeContent.ios', () => ({
CompanionNativeContent: ({ children }: any) => <div data-rn-size="content">{children}</div>,
@@ -21,7 +34,8 @@ vi.mock('@expo/ui/swift-ui', () => {
const Container = ({ children }: any) => <div>{children}</div>;
return { ScrollView: ({ children }: any) => <section data-native-scroll>{children}</section>,
Form: ({ children, modifiers }: any) => <div data-native="Form" data-modifiers={JSON.stringify(modifiers)}>{children}</div>,
- List: ({ children, modifiers }: any) => <div data-native="List" data-modifiers={JSON.stringify(modifiers)}>{children}</div>, Button: Container, Group: Container, HStack: Container, Image: Container,
+ List: ({ children, modifiers }: any) => <div data-native="List" data-modifiers={JSON.stringify(modifiers)}>{children}</div>,
+ Button: ({ children, onPress }: any) => <button onClick={onPress}>{children}</button>, Group: Container, HStack: Container, Image: Container,
RNHostView: ({ children, matchContents }: any) => <div data-rn-size={matchContents ? 'content' : 'viewport'}>{children}</div>,
Spacer: Container, Text: Container, VStack: Container, ZStack: Container,
BottomSheet: (props: any) => { state.sheet = props; return <div>{props.children}</div>; },
@@ -41,13 +55,14 @@ it('uses a plain list only when requested and preserves form sheets', () => {
} finally { act(() => root.unmount()); }
});
vi.mock('@expo/ui/swift-ui/modifiers', () => ({
+ disabled: vi.fn(() => ({})),
environment: (key: string, value: string) => ({ environment: { key, value } }),
containerRelativeFrame: vi.fn(() => ({})),
onGeometryChange: vi.fn(() => ({})),
...Object.fromEntries(['accessibilityLabel', 'contentShape', 'buttonStyle', 'font', 'foregroundStyle', 'frame', 'padding', 'presentationDetents', 'presentationDragIndicator', 'interactiveDismissDisabled', 'scrollContentBackground', 'listStyle', 'scrollDismissesKeyboard'].map(name => [name, vi.fn(() => ({}))])),
shapes: { rectangle: () => ({}) },
}));
-vi.mock('@/theme', () => ({ iconSize: { lg: 20 }, useTheme: () => ({ mode: 'light', colors: {} }) }));
+vi.mock('@/theme', () => ({ spacing: { sm: 8, lg: 16 }, iconSize: { lg: 20 }, useTheme: () => ({ mode: 'light', colors: {} }) }));
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
@@ -104,6 +119,48 @@ it('selects a supported native detent when opening and rotating a menu', () => {
} finally { act(() => root.unmount()); }
});
+// #7658: cover the native form's callback boundary, not its pixel appearance.
+// Existing SwiftUI tests do not exercise UIBarButtonItems or Modal.onDismiss.
+// Unit input: a long form, then a pending submit. Native rendering needs iOS acceptance.
+it('keeps native form actions outside the roster and waits for completed dismissal', () => {
+ const container = document.createElement('div');
+ const root = createRoot(container);
+ const close = vi.fn(); const create = vi.fn();
+ const closed = vi.fn(); const shown = vi.fn();
+ const render = (busy = false) => act(() => root.render(<FormSheet visible title="New group" onClose={close}
+ onClosed={closed} onShow={shown} preventDismiss={busy}
+ leadingAction={{ label: 'Close', disabled: busy, onPress: close, testID: 'close' }}
+ trailingAction={{ label: 'Create', busy, onPress: create, testID: 'create' }}>
+ <span>Long roster</span>
+ </FormSheet>));
+ try {
+ render();
+ const viewport = container.querySelector('[data-rn-scroll]')!;
+ expect(viewport.textContent).toBe('Long roster');
+ expect(viewport.querySelector('button')).toBeNull();
+ expect(container.querySelector('[data-testid=close]')?.getAttribute('data-system-image')).toBe('xmark');
+ expect(container.querySelector('[data-testid=close]')?.getAttribute('aria-label')).toBe('Close');
+ expect(container.querySelector('[data-testid=create]')?.textContent).toBe('Create');
+ act(() => (container.querySelector('[data-testid=close]') as HTMLButtonElement).click());
+ act(() => (container.querySelector('[data-testid=create]') as HTMLButtonElement).click());
+ expect(close).toHaveBeenCalledOnce();
+ expect(create).toHaveBeenCalledOnce();
+ expect(closed).not.toHaveBeenCalled();
+ act(() => state.formModal.onShow());
+ expect(shown).toHaveBeenCalledOnce();
+ render(true);
+ expect(state.formModal.allowSwipeDismissal).toBe(false);
+ act(() => (container.querySelector('[data-testid=close]') as HTMLButtonElement).click());
+ act(() => (container.querySelector('[data-testid=create]') as HTMLButtonElement).click());
+ expect(close).toHaveBeenCalledOnce();
+ expect(create).toHaveBeenCalledOnce();
+ expect(container.querySelector('[role=progressbar]')).not.toBeNull();
+ expect(viewport.querySelector('[role=progressbar]')).toBeNull();
+ act(() => state.formModal.onDismiss());
+ expect(closed).toHaveBeenCalledOnce();
+ } finally { act(() => root.unmount()); }
+});
+
// DOM mocks cover composition; native scrolling needs simulator/device acceptance.
it('composes a content-sized RN bridge inside the native scroll component and a sibling footer', () => {
state.width = 402; state.height = 874;
diff --git a/apps/mobile/src/__tests__/sheetKeyboardSubscription.test.tsx b/apps/mobile/src/__tests__/sheetKeyboardSubscription.test.tsx
index 153ef1643c..05ff79bcd8 100644
--- a/apps/mobile/src/__tests__/sheetKeyboardSubscription.test.tsx
+++ b/apps/mobile/src/__tests__/sheetKeyboardSubscription.test.tsx
@@ -8,12 +8,16 @@ const native = vi.hoisted(() => ({
platform: { OS: 'ios' },
keyboard: vi.fn((enabled: boolean) => ({ height: enabled ? 300 : 0 })),
finish: undefined as undefined | ((result: { finished: boolean }) => void),
+ onShow: undefined as undefined | (() => void),
}));
vi.mock('react-native', () => {
const View = ({ children }: { children?: ReactNode }) => <div>{children}</div>;
return {
View, KeyboardAvoidingView: View, Pressable: View,
- Modal: ({ visible, children }: { visible: boolean; children: ReactNode }) => visible ? <div>{children}</div> : null,
+ Modal: ({ visible, children, onShow }: { visible: boolean; children: ReactNode; onShow: () => void }) => {
+ native.onShow = onShow;
+ return visible ? <div>{children}</div> : null;
+ },
Platform: native.platform,
useWindowDimensions: () => ({ width: 390, height: 844 }),
StyleSheet: { absoluteFill: {} },
@@ -77,3 +81,13 @@ it('never subscribes action-only sheets or Android native-resize sheets', () =>
render(true);
expect(enabled()).toBe(false);
});
+
+it('waits for the Android dialog to show before requesting form focus', () => {
+ native.platform.OS = 'android';
+ const focus = vi.fn();
+ act(() => root.render(<SheetModal visible onShow={focus}
+ onRequestClose={() => {}} onBackdropPress={() => {}}>form</SheetModal>));
+ expect(focus).not.toHaveBeenCalled();
+ act(() => native.onShow?.());
+ expect(focus).toHaveBeenCalledOnce();
+});
diff --git a/apps/mobile/src/i18n/locales/en/groupChat.json b/apps/mobile/src/i18n/locales/en/groupChat.json
index 8f01f0101a..fc6efd1e5d 100644
--- a/apps/mobile/src/i18n/locales/en/groupChat.json
+++ b/apps/mobile/src/i18n/locales/en/groupChat.json
@@ -16,19 +16,16 @@
},
"create": {
"title": "New Group Chat",
- "description": "Put a few teammates in one group. Say something and they’ll chime in together.",
"nameLabel": "Group Name",
"namePlaceholder": "e.g. Weekend Trip",
"nameRequired": "Enter a group name",
"membersLabel": "Choose Teammates",
"selectedCount_one": "{{count}} selected, up to {{max}}",
"selectedCount_other": "{{count}} selected, up to {{max}}",
- "minMembers": "Choose at least {{min}} teammates",
- "notEnoughBots": "You need at least {{min}} available teammates to start a group chat. Add a teammate first.",
+ "close": "Close",
+ "submitShort": "Create",
"submit": "Create Group Chat",
- "failed": "Couldn’t create the group chat. Try again in a moment.",
- "chooseComputer": "Choose a Computer",
- "computerNote": "This group chat lives on {{deviceName}}, and its teammates work there."
+ "failed": "Couldn’t create the group chat. Try again in a moment."
},
"memberStatus": {
"paused": "Paused",
diff --git a/apps/mobile/src/i18n/locales/ja/groupChat.json b/apps/mobile/src/i18n/locales/ja/groupChat.json
index ff8d463da8..e55c57158f 100644
--- a/apps/mobile/src/i18n/locales/ja/groupChat.json
+++ b/apps/mobile/src/i18n/locales/ja/groupChat.json
@@ -16,19 +16,16 @@
},
"create": {
"title": "グループチャットを作成",
- "description": "何人かの仲間を 1 つのグループにまとめます。あなたが話しかけると、仲間たちが一緒に返信します。",
"nameLabel": "グループ名",
"namePlaceholder": "例: 週末のお出かけ",
"nameRequired": "グループ名を入力してください",
"membersLabel": "仲間を選択",
"selectedCount_one": "{{count}} 人選択中(最大 {{max}} 人)",
"selectedCount_other": "{{count}} 人選択中(最大 {{max}} 人)",
- "minMembers": "仲間を {{min}} 人以上選択してください",
- "notEnoughBots": "グループチャットを作成するには、利用できる仲間が {{min}} 人以上必要です。まず仲間を追加してください。",
+ "close": "閉じる",
+ "submitShort": "作成",
"submit": "グループチャットを作成",
- "failed": "グループチャットを作成できませんでした。しばらくしてから再試行してください",
- "chooseComputer": "作成するパソコンを選択",
- "computerNote": "このグループチャットは {{deviceName}} に作成され、仲間はそのパソコンで作業します。"
+ "failed": "グループチャットを作成できませんでした。しばらくしてから再試行してください"
},
"memberStatus": {
"paused": "一時停止中",
diff --git a/apps/mobile/src/i18n/locales/ko/groupChat.json b/apps/mobile/src/i18n/locales/ko/groupChat.json
index c9587ad397..419eb30e04 100644
--- a/apps/mobile/src/i18n/locales/ko/groupChat.json
+++ b/apps/mobile/src/i18n/locales/ko/groupChat.json
@@ -16,19 +16,16 @@
},
"create": {
"title": "새 그룹 채팅",
- "description": "동료 몇 명을 한 그룹에 모아 보세요. 한마디 하면 동료들이 함께 이어서 답합니다.",
"nameLabel": "그룹 이름",
"namePlaceholder": "예: 주말 나들이",
"nameRequired": "그룹 이름을 입력하세요",
"membersLabel": "동료 선택",
"selectedCount_one": "{{count}}명 선택됨, 최대 {{max}}명",
"selectedCount_other": "{{count}}명 선택됨, 최대 {{max}}명",
- "minMembers": "동료를 {{min}}명 이상 선택하세요",
- "notEnoughBots": "그룹 채팅을 만들려면 사용할 수 있는 동료가 {{min}}명 이상 필요합니다. 먼저 동료를 추가하세요.",
+ "close": "닫기",
+ "submitShort": "만들기",
"submit": "그룹 채팅 만들기",
- "failed": "그룹 채팅을 만들지 못했습니다. 잠시 후 다시 시도하세요.",
- "chooseComputer": "만들 컴퓨터 선택",
- "computerNote": "이 그룹 채팅은 {{deviceName}}에 만들어지고, 동료들은 그 컴퓨터에서 작업합니다."
+ "failed": "그룹 채팅을 만들지 못했습니다. 잠시 후 다시 시도하세요."
},
"memberStatus": {
"paused": "일시 중지됨",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/groupChat.json b/apps/mobile/src/i18n/locales/zh-CN/groupChat.json
index fa02807d01..bb50caed6b 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/groupChat.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/groupChat.json
@@ -16,19 +16,16 @@
},
"create": {
"title": "新建群聊",
- "description": "选几位伙伴放进一个群。你说一句,它们会一起接话。",
"nameLabel": "群名称",
"namePlaceholder": "例如:周末出游",
"nameRequired": "给群起个名字",
"membersLabel": "选择伙伴",
"selectedCount_one": "已选 {{count}} 位,最多 {{max}} 位",
"selectedCount_other": "已选 {{count}} 位,最多 {{max}} 位",
- "minMembers": "至少选 {{min}} 位伙伴",
- "notEnoughBots": "至少需要 {{min}} 位可用的伙伴才能建群,先去添加伙伴吧。",
+ "close": "关闭",
+ "submitShort": "创建",
"submit": "创建群聊",
- "failed": "群聊没有建成,请稍后重试",
- "chooseComputer": "在哪台电脑上建群",
- "computerNote": "群聊建在 {{deviceName}} 上,伙伴们在这台电脑上干活。"
+ "failed": "群聊没有建成,请稍后重试"
},
"memberStatus": {
"paused": "已暂停",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/groupChat.json b/apps/mobile/src/i18n/locales/zh-TW/groupChat.json
index fe8e660aae..a09853566b 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/groupChat.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/groupChat.json
@@ -16,19 +16,16 @@
},
"create": {
"title": "新增群聊",
- "description": "選幾位夥伴放進一個群聊。你說一句,它們會一起接話。",
"nameLabel": "群聊名稱",
"namePlaceholder": "例如:週末出遊",
"nameRequired": "為群聊取個名字",
"membersLabel": "選擇夥伴",
"selectedCount_one": "已選 {{count}} 位,最多 {{max}} 位",
"selectedCount_other": "已選 {{count}} 位,最多 {{max}} 位",
- "minMembers": "至少選 {{min}} 位夥伴",
- "notEnoughBots": "至少需要 {{min}} 位可用的夥伴才能建立群聊,先去新增夥伴吧。",
+ "close": "關閉",
+ "submitShort": "建立",
"submit": "建立群聊",
- "failed": "群聊沒能建立,請稍後重試",
- "chooseComputer": "在哪台電腦上建群",
- "computerNote": "群聊建在 {{deviceName}} 上,夥伴們在這台電腦上做事。"
+ "failed": "群聊沒能建立,請稍後重試"
},
"memberStatus": {
"paused": "已暫停",
diff --git a/apps/mobile/src/session/BotGroupCreateSheet.tsx b/apps/mobile/src/session/BotGroupCreateSheet.tsx
index 48d9f53f49..ec42267546 100644
--- a/apps/mobile/src/session/BotGroupCreateSheet.tsx
+++ b/apps/mobile/src/session/BotGroupCreateSheet.tsx
@@ -1,23 +1,16 @@
-/**
- * 新建群聊(对照桌面 BotGroupCreateDialog.tsx):填群名称,选 2–6 位伙伴。群建在一台电脑上,
- * 只能选这台电脑上的伙伴;多台电脑时先在「+」的菜单里选电脑。成员顺序即发言顺序,跟随
- * 列表顺序而不是点选先后(与桌面一致)。群名长度与人数由电脑最终校验,这里先挡住明显不
- * 成立的提交。建好后电脑回一个跳转,页面打开新群。
- */
+/** 在所选电脑创建群聊,可选最多 6 位该电脑上的伙伴。 */
import { useEffect, useRef, useState } from 'react';
-import { ActivityIndicator, Alert, Pressable, StyleSheet, View } from 'react-native';
+import { ActivityIndicator, Alert, Pressable, StyleSheet, View, type TextInput as NativeTextInput } from 'react-native';
import { Check } from 'lucide-react-native';
import { useTranslation } from 'react-i18next';
import { resolveRemoteText } from '@cindy/device-link';
import {
BOT_GROUP_MAX_MEMBERS,
- BOT_GROUP_MIN_MEMBERS,
BOT_GROUP_NAME_MAX_CHARS,
BOT_GROUP_REMOTE_COLLECTION_ID,
} from '@cindy/maker-shared/botGroupChat';
import { useAuth } from '@/auth/AuthContext';
import { Text, TextInput } from '@/components/AppText';
-import { MainWindowActionButton } from '@/components/MobilePrimitives';
import { mobileInteractionStyles } from '@/components/mobileInteractionStyles';
import { useDeviceLink } from '@/device-link/DeviceLinkContext';
import { invokeRemoteResourceAction, type RemoteResourceHostTarget } from '@/device-link/remoteResources';
@@ -26,7 +19,7 @@ import { fontWeight, iconSize, iconStroke, lineHeight, radius, spacing, typeScal
import { BOT_GROUP_ROW_AVATAR_SIZE, BotGroupAvatar } from './BotGroupAvatars';
import { botGroupActionErrorText } from './botGroupCopy';
import { createdBotGroupId } from './botGroupRemote';
-import { CompanionSheet } from './CompanionSheet';
+import { FormSheet } from './FormSheet';
import { orderedTeammates } from './teammateNavigation';
import { useHostTeammates } from './useHostTeammates';
@@ -53,15 +46,15 @@ function CreateSheetContent({ visible, host, online, onClose, onClosed, onCreate
const [name, setName] = useState('');
const [selected, setSelected] = useState<string[]>([]);
const [nameError, setNameError] = useState(false);
- const [membersError, setMembersError] = useState(false);
const [submitError, setSubmitError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const busyRef = useRef(false);
+ const nameInput = useRef<NativeTextInput>(null);
const mounted = useRef(true);
useEffect(() => { mounted.current = true; return () => { mounted.current = false; }; }, []);
useEffect(() => {
if (!visible) return;
- setName(''); setSelected([]); setNameError(false); setMembersError(false); setSubmitError(null);
+ setName(''); setSelected([]); setNameError(false); setSubmitError(null);
}, [visible]);
const candidates = orderedTeammates(teammates.rows, '', i18n.language);
@@ -72,7 +65,6 @@ function CreateSheetContent({ visible, host, online, onClose, onClosed, onCreate
const toggle = (botId: string) => {
setSubmitError(null);
- setMembersError(false);
setSelected((current) => current.includes(botId)
? current.filter((id) => id !== botId)
: current.length >= BOT_GROUP_MAX_MEMBERS ? current : [...current, botId]);
@@ -91,10 +83,8 @@ function CreateSheetContent({ visible, host, online, onClose, onClosed, onCreate
if (busyRef.current || !host) return;
const trimmed = name.trim();
const nameInvalid = trimmed.length === 0;
- const membersInvalid = ordered.length < BOT_GROUP_MIN_MEMBERS || ordered.length > BOT_GROUP_MAX_MEMBERS;
setNameError(nameInvalid);
- setMembersError(membersInvalid);
- if (nameInvalid || membersInvalid) return;
+ if (nameInvalid || ordered.length > BOT_GROUP_MAX_MEMBERS) return;
busyRef.current = true;
setBusy(true);
setSubmitError(null);
@@ -118,20 +108,21 @@ function CreateSheetContent({ visible, host, online, onClose, onClosed, onCreate
}
};
- const notEnough = !teammates.loading && candidates.length < BOT_GROUP_MIN_MEMBERS;
- return <CompanionSheet visible={visible} title={t('groupChat.create.title')} onClose={close} onClosed={onClosed}
+ return <FormSheet visible={visible} title={t('groupChat.create.title')} onClose={close} onClosed={onClosed}
+ onShow={() => nameInput.current?.focus()}
+ leadingAction={{ label: t('groupChat.create.close'), disabled: busy, onPress: close, testID: 'botGroup.create.cancel' }}
+ trailingAction={{ label: t('groupChat.create.submitShort'), accessibilityLabel: t('groupChat.create.submit'), busy, disabled: !online || !host,
+ onPress: () => void submit(), testID: 'botGroup.create.submit' }}
preventDismiss={dirty || busy} testID="botGroup.create">
<View style={styles.content}>
- <Text style={styles.description}>{t('groupChat.create.description')}</Text>
- {host ? <Text style={styles.note}>{t('groupChat.create.computerNote', { deviceName: host.deviceName })}</Text> : null}
{!online ? <Text accessibilityRole="alert" style={styles.note}>{t('devices.resources.hostOffline')}</Text> : null}
<View style={styles.field}>
<Text style={styles.label}>{t('groupChat.create.nameLabel')}</Text>
- <TextInput accessibilityLabel={t('groupChat.create.nameLabel')} value={name} maxLength={BOT_GROUP_NAME_MAX_CHARS}
+ <TextInput ref={nameInput} accessibilityLabel={t('groupChat.create.nameLabel')} value={name} maxLength={BOT_GROUP_NAME_MAX_CHARS}
editable={!busy} placeholder={t('groupChat.create.namePlaceholder')} placeholderTextColor={colors.textPlaceholder}
onChangeText={(value) => { setName(value); if (value.trim()) setNameError(false); setSubmitError(null); }}
style={styles.input} testID="botGroup.create.name" />
- {nameError ? <Text accessibilityRole="alert" style={styles.error}>{t('groupChat.create.nameRequired')}</Text> : null}
+ {nameError ? <Text accessibilityRole="alert" style={styles.nameError}>{t('groupChat.create.nameRequired')}</Text> : null}
</View>
<View style={styles.field}>
<View style={styles.labelRow}>
@@ -157,22 +148,16 @@ function CreateSheetContent({ visible, host, online, onClose, onClosed, onCreate
})}
</View> : null}
{teammates.loading && candidates.length === 0 ? <ActivityIndicator color={colors.textSecondary} style={styles.spinner} /> : null}
- {notEnough ? <Text style={styles.note}>{t(teammates.failed ? 'devices.resources.loadFailed' : 'groupChat.create.notEnoughBots', { min: BOT_GROUP_MIN_MEMBERS })}</Text> : null}
- {membersError ? <Text accessibilityRole="alert" style={styles.error}>{t('groupChat.create.minMembers', { min: BOT_GROUP_MIN_MEMBERS })}</Text> : null}
+ {teammates.failed ? <Text style={styles.note}>{t('devices.resources.loadFailed')}</Text> : null}
</View>
{submitError ? <Text accessibilityRole="alert" style={styles.error} testID="botGroup.create.error">{submitError}</Text> : null}
- <View style={styles.actions}>
- <MainWindowActionButton action={{ label: t('devices.common.cancel'), disabled: busy, onPress: close, testID: 'botGroup.create.cancel' }} />
- <MainWindowActionButton action={{ label: t('groupChat.create.submit'), tone: 'primary', busy, disabled: !online || !host,
- onPress: () => void submit(), testID: 'botGroup.create.submit' }} />
- </View>
</View>
- </CompanionSheet>;
+ </FormSheet>;
}
const makeStyles = (colors: ThemeColors) => StyleSheet.create({
content: { gap: spacing.lg, paddingTop: spacing.sm, paddingBottom: spacing.xl },
- description: { color: colors.textSecondary, fontSize: typeScale.footnote, lineHeight: lineHeight.caption },
+ nameError: { color: colors.statusError, fontSize: typeScale.footnote, lineHeight: lineHeight.caption },
note: { color: colors.textSecondary, fontSize: typeScale.footnote, lineHeight: lineHeight.caption },
error: { color: colors.errorText, fontSize: typeScale.footnote, lineHeight: lineHeight.caption },
field: { gap: spacing.sm },
@@ -193,5 +178,4 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({
alignItems: 'center', justifyContent: 'center' },
checked: { backgroundColor: colors.cta, borderColor: colors.cta },
spinner: { paddingVertical: spacing.md },
- actions: { flexDirection: 'row', justifyContent: 'flex-end', gap: spacing.sm },
});
diff --git a/apps/mobile/src/session/CompanionSheet.tsx b/apps/mobile/src/session/CompanionSheet.tsx
index 4a659a41b8..3bad81e85d 100644
--- a/apps/mobile/src/session/CompanionSheet.tsx
+++ b/apps/mobile/src/session/CompanionSheet.tsx
@@ -1,28 +1,49 @@
import { useEffect, useMemo, useState } from 'react';
-import { useWindowDimensions } from 'react-native';
+import { Pressable, useWindowDimensions } from 'react-native';
+import { X } from 'lucide-react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { SheetModal } from './SheetModal';
import { SheetSurface } from './SheetSurface';
import { computeContextSheetSnapHeights, type ContextSheetSnap } from './contextSheetModel';
import type { ComposerSheetProps } from './ComposerSheet';
-export type CompanionSheetProps = ComposerSheetProps & { preventDismiss?: boolean };
+import { MainWindowActionButton, type MainWindowAction } from '@/components/MobilePrimitives';
+import { iconSize, iconStroke, radius, useTheme } from '@/theme';
+export type CompanionSheetProps = ComposerSheetProps & {
+ leadingAction?: MainWindowAction;
+ trailingAction?: MainWindowAction;
+ onShow?(): void;
+ initialSnap?: ContextSheetSnap;
+ keyboardAvoidingBehavior?: 'height' | 'padding';
+};
/**
* Android shell with the iOS dismissal contract (`interactiveDismissDisabled`): while a draft is
* unsaved or a submit is in flight, the backdrop, the grabber and the system back key neither close
* nor prompt. The system back key stays the in-page Back when a secondary page offers one.
*/
-export function CompanionSheet({ visible, title, onClose, onClosed, onBack, children, footer, testID, preventDismiss }: CompanionSheetProps) {
+export function CompanionSheet({ visible, title, onClose, onClosed, onShow, onBack, children, footer, testID, preventDismiss, leadingAction, trailingAction, initialSnap = 'half', keyboardAvoidingBehavior = 'height' }: CompanionSheetProps) {
+ const { colors } = useTheme();
const { height } = useWindowDimensions();
const insets = useSafeAreaInsets();
const [surfaceEpoch, setSurfaceEpoch] = useState(0);
// A blocked drag-dismiss remounts the surface so it springs back to its detent.
const dismiss = () => { if (preventDismiss) setSurfaceEpoch(value => value + 1); else onClose(); };
const requestClose = () => { if (onBack) onBack(); else if (!preventDismiss) onClose(); };
- const [snap, setSnap] = useState<ContextSheetSnap>('half');
- useEffect(() => { if (visible) setSnap('half'); }, [visible]);
+ const [snap, setSnap] = useState<ContextSheetSnap>(initialSnap);
+ useEffect(() => { if (visible) setSnap(initialSnap); }, [visible, initialSnap]);
const heights = useMemo(() => computeContextSheetSnapHeights({ screenHeight: height, safeAreaTopInset: insets.top }), [height, insets.top]);
- return <SheetModal visible={visible} onBackdropPress={() => { if (!preventDismiss) onClose(); }} onRequestClose={requestClose} onClosed={onClosed} keyboardAvoiding keyboardAvoidingBehavior="height">
- <SheetSurface key={surfaceEpoch} title={title} heights={heights} snap={snap} onSnapChange={setSnap} bottomInset={insets.bottom} onClose={dismiss} onBack={onBack} footer={footer} testID={testID}>
+ return <SheetModal visible={visible} onBackdropPress={() => { if (!preventDismiss) onClose(); }} onRequestClose={requestClose} onClosed={onClosed} onShow={onShow} keyboardAvoiding keyboardAvoidingBehavior={keyboardAvoidingBehavior}>
+ <SheetSurface key={surfaceEpoch} title={title} heights={heights} snap={snap} onSnapChange={setSnap} bottomInset={insets.bottom} onClose={dismiss} onBack={onBack} footer={footer} testID={testID}
+ headerLeading={leadingAction ? <Pressable accessibilityRole="button"
+ accessibilityLabel={leadingAction.accessibilityLabel ?? leadingAction.label}
+ accessibilityState={{ disabled: !!leadingAction.disabled || !!leadingAction.busy }}
+ disabled={leadingAction.disabled || leadingAction.busy} onPress={leadingAction.onPress}
+ testID={leadingAction.testID} hitSlop={4}
+ style={({ pressed }) => ({ width: 36, height: 36, borderRadius: radius.pill,
+ alignItems: 'center', justifyContent: 'center', backgroundColor: colors.surfaceChip,
+ opacity: leadingAction.disabled || leadingAction.busy ? 0.5 : pressed ? 0.7 : 1 })}>
+ <X size={iconSize.action} strokeWidth={iconStroke.regular} color={colors.textPrimary} />
+ </Pressable> : undefined}
+ headerTrailing={trailingAction ? <MainWindowActionButton action={trailingAction} density="compact" /> : undefined}>
{children}
</SheetSurface>
</SheetModal>;
diff --git a/apps/mobile/src/session/FormSheet.ios.tsx b/apps/mobile/src/session/FormSheet.ios.tsx
new file mode 100644
index 0000000000..9ab37a4f50
--- /dev/null
+++ b/apps/mobile/src/session/FormSheet.ios.tsx
@@ -0,0 +1,83 @@
+import { ActivityIndicator, Modal, ScrollView, StyleSheet } from 'react-native';
+import { ScreenStack, ScreenStackItem } from 'react-native-screens';
+import { spacing, useTheme } from '@/theme';
+import type { FormSheetProps } from './FormSheet';
+
+/** UIKit navigation in a page sheet; onClosed waits for native dismissal. */
+export function FormSheet({
+ visible, title, onClose, onClosed, onShow, preventDismiss = false,
+ leadingAction, trailingAction, children, testID,
+}: FormSheetProps) {
+ const { mode, colors } = useTheme();
+ return (
+ <Modal
+ visible={visible}
+ presentationStyle="pageSheet"
+ animationType="slide"
+ supportedOrientations={['portrait', 'portrait-upside-down', 'landscape-left', 'landscape-right']}
+ allowSwipeDismissal={!preventDismiss}
+ onRequestClose={onClose}
+ onDismiss={onClosed}
+ onShow={onShow}
+ >
+ <ScreenStack style={styles.fill} nativeContainerStyle={{ backgroundColor: colors.surface }}>
+ <ScreenStackItem
+ screenId={testID ?? 'form-sheet'}
+ activityState={2}
+ style={styles.fill}
+ contentStyle={{ backgroundColor: colors.surface }}
+ headerConfig={{
+ title,
+ hidden: false,
+ hideBackButton: true,
+ hideShadow: true,
+ translucent: false,
+ backgroundColor: colors.surface,
+ color: colors.textPrimary,
+ titleColor: colors.textPrimary,
+ experimental_userInterfaceStyle: mode,
+ headerLeftBarButtonItems: [{
+ type: 'button',
+ icon: { type: 'sfSymbol', name: 'xmark' },
+ variant: 'plain',
+ accessibilityLabel: leadingAction.accessibilityLabel ?? leadingAction.label,
+ identifier: leadingAction.testID,
+ disabled: !!leadingAction.disabled || !!leadingAction.busy,
+ onPress: leadingAction.onPress,
+ }],
+ headerRightBarButtonItems: [{
+ type: 'button',
+ title: trailingAction.label,
+ // iOS 26 aliases `done` to `prominent`, which fills the glass.
+ variant: 'plain',
+ accessibilityLabel: trailingAction.accessibilityLabel ?? trailingAction.label,
+ identifier: trailingAction.testID,
+ disabled: !!trailingAction.disabled || !!trailingAction.busy,
+ onPress: trailingAction.onPress,
+ }],
+ }}
+ >
+ <ScrollView
+ testID={testID}
+ style={styles.fill}
+ contentContainerStyle={styles.content}
+ contentInsetAdjustmentBehavior="automatic"
+ automaticallyAdjustKeyboardInsets
+ keyboardShouldPersistTaps="handled"
+ keyboardDismissMode="interactive"
+ >
+ {children}
+ </ScrollView>
+ {trailingAction.busy ? <ActivityIndicator style={styles.progress} color={colors.textSecondary}
+ accessibilityLabel={trailingAction.accessibilityLabel ?? trailingAction.label} /> : null}
+ </ScreenStackItem>
+ </ScreenStack>
+ </Modal>
+ );
+}
+
+const styles = StyleSheet.create({
+ fill: { flex: 1 },
+ progress: { paddingVertical: spacing.sm },
+ content: { paddingHorizontal: spacing.lg, paddingTop: spacing.sm, paddingBottom: spacing.lg },
+});
diff --git a/apps/mobile/src/session/FormSheet.tsx b/apps/mobile/src/session/FormSheet.tsx
new file mode 100644
index 0000000000..b593571d76
--- /dev/null
+++ b/apps/mobile/src/session/FormSheet.tsx
@@ -0,0 +1,17 @@
+import { CompanionSheet } from './CompanionSheet';
+import type { ComposerSheetProps } from './ComposerSheet';
+import type { MainWindowAction } from '@/components/MobilePrimitives';
+
+type FormAction = MainWindowAction & { onPress(): void };
+
+export type FormSheetProps = Pick<ComposerSheetProps,
+ 'visible' | 'title' | 'onClose' | 'onClosed' | 'preventDismiss' | 'children' | 'testID'
+> & {
+ leadingAction: FormAction;
+ trailingAction: FormAction;
+ onShow?(): void;
+};
+
+export function FormSheet(props: FormSheetProps) {
+ return <CompanionSheet {...props} initialSnap="full" keyboardAvoidingBehavior="padding" />;
+}
diff --git a/apps/mobile/src/session/SheetModal.tsx b/apps/mobile/src/session/SheetModal.tsx
index a820c29f96..04a6a487cc 100644
--- a/apps/mobile/src/session/SheetModal.tsx
+++ b/apps/mobile/src/session/SheetModal.tsx
@@ -51,6 +51,7 @@ export interface SheetModalProps {
keyboardAvoidingBehavior?: 'height' | 'padding' | undefined;
/** 淡出动画完成、Modal 真正卸载后触发(如需在关闭后再开另一个 Modal)。 */
onClosed?: () => void;
+ onShow?: () => void;
children: ReactNode;
}
@@ -72,6 +73,7 @@ function CompatibleSheetModal({
keyboardAvoiding = false,
keyboardAvoidingBehavior,
onClosed,
+ onShow,
children,
}: SheetModalProps) {
const styles = useThemedStyles(makeStyles);
@@ -149,7 +151,7 @@ function CompatibleSheetModal({
supportedOrientations={["portrait", "portrait-upside-down", "landscape-left", "landscape-right"]}
animationType="none"
onRequestClose={onRequestClose}
- onShow={onShowStartIn}
+ onShow={() => { onShowStartIn(); if (visible) onShow?.(); }}
presentationStyle="overFullScreen"
transparent
visible={mounted}
@@ -165,16 +167,13 @@ function CompatibleSheetModal({
testID={backdropTestID}
/>
</Animated.View>
- {/* Android:windowSoftInputMode=adjustResize 已在原生层处理键盘避让,若再套
- KeyboardAvoidingView(behavior='height')会与之对同一键盘反复调整高度,在 Modal 里
- 触发每帧 relayout 的布局回环 → 整窗持续重绘闪烁(用户 2026-07 报「+」/模型选择弹层
- 键盘开着时一直闪;logcat 实测键盘不开合、但 MainActivity 每帧重绘)。故 Android 直接
- 用 content、不套 KAV;iOS(adjustResize 不适用)仍需 KAV 走 padding 避让。 */}
+ {/* Android normally uses native resize. Form dialogs opt into padding when the
+ edge-to-edge window overlays the keyboard; height can cause a resize loop. */}
<View pointerEvents="box-none" style={displaced ? {
position: 'absolute', left: region.x, top: region.y, width: region.width, height: region.height,
} : styles.keyboardLayer}>
<KeyboardAvoidingView
- enabled={keyboardAvoiding && !displaced && Platform.OS !== 'android'}
+ enabled={keyboardAvoiding && !displaced && (Platform.OS !== 'android' || keyboardAvoidingBehavior === 'padding')}
behavior={keyboardAvoidingBehavior}
keyboardVerticalOffset={displaced ? region.y : 0}
pointerEvents="box-none"
diff --git a/apps/mobile/src/session/SheetSurface.tsx b/apps/mobile/src/session/SheetSurface.tsx
index d83be10f4c..e45f61611d 100644
--- a/apps/mobile/src/session/SheetSurface.tsx
+++ b/apps/mobile/src/session/SheetSurface.tsx
@@ -38,6 +38,7 @@ export interface SheetSurfaceProps {
backAccessibilityLabel?: string;
/** header 右侧插槽(如模型浮窗的权限小入口);缺省为对称占位 spacer。 */
headerTrailing?: ReactNode;
+ headerLeading?: ReactNode;
/** header 下、滚动区上的固定插槽(如搜索框);不传不占位。 */
pinnedTop?: ReactNode;
children: ReactNode;
@@ -66,6 +67,7 @@ export function SheetSurface({
onBack,
backAccessibilityLabel,
headerTrailing,
+ headerLeading,
pinnedTop,
children,
renderScrollContent,
@@ -113,7 +115,7 @@ export function SheetSurface({
<View collapsable={false} style={styles.dragZone} {...(nativeSheet ? {} : drag.panHandlers)}>
{!nativeSheet && <SheetGrabber variant={variant} />}
<View style={styles.header}>
- {onBack ? (
+ {headerLeading ?? (onBack ? (
<Pressable
accessibilityLabel={backAccessibilityLabel ?? t('shared.back')}
accessibilityRole="button"
@@ -126,7 +128,7 @@ export function SheetSurface({
</Pressable>
) : (
<View style={styles.headerSpacer} />
- )}
+ ))}
<View pointerEvents="none" style={styles.headerTitleOverlay}>
<Text numberOfLines={1} style={styles.headerTitle}>{title}</Text>
</View>
diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.md
index 39a7b085ab..d5ef06320d 100644
--- a/docs/product-rules/bot-group-chat.md
+++ b/docs/product-rules/bot-group-chat.md
@@ -284,7 +284,7 @@ Chat Server 声明 `capabilities.groupSingleSpeaker: 1` 时,服务器群按下
- 不跳、不卡:宿主对同一群的变更通知合并成一次(150ms 窗口)、Renderer 同一时刻只读一次并把最新页**并入**屏幕上已有的消息
(被挤出最新页的旧消息留着)、内容没变的消息沿用原对象不重绘;发送用实时订阅担保的最近快照(30 秒内),侧栏摘要按群的
变更头复用;自动分工判断整体不超过 8 秒(单候选 5 秒),超时按「不要」处理,不让第一条回复等它。
-- 新建群聊:填写群名称,选择 2–6 位伙伴。
+- 新建服务器群聊:群名称必填,伙伴可不选,最多选择 6 位;旧本地群仍沿用其人数校验。
- 群设置:群名称、成员(添加与移出、设为负责人)、项目文件夹、「没有 @ 人的时候」回复方式、「发言方式」(自动/始终轮流)、删除群聊(二次确认)。
本地群与服务器群的这几项用同一套文案。声明 `groupSingleSpeaker` 的服务器群没有「发言方式」(一次只有一位伙伴说话),其余照常(Desktop 与手机一致)。
- 话题面板与主时间线同一套消息样式(合并、悬停操作、@ 高亮、引用块、附件),同一个输入框(话题模式:没有「+」菜单、
@@ -456,6 +456,7 @@ Chat Server 声明 `capabilities.groupSingleSpeaker: 1` 时,服务器群按下
- 伙伴页把群聊和伙伴混排在同一个列表里,按最近活动排序:群用成员组合头像、群名、最近状态(与电脑侧栏相同的分工
状态)、运行中标记,行样式与伙伴行一致。右上角「+」菜单可新建伙伴或新建群聊。
+- 手机新建群聊不设伙伴人数下限;保留群名必填,打开时自动聚焦群名并唤起键盘,空白群名提交时用红色字段提示。关闭和创建固定在顶部工具栏,伙伴列表随内容滚动,不按最多可选人数截断候选。表单不显示顶部介绍与电脑说明,保留离线、加载失败和提交失败反馈;旧电脑拒绝创建时展示其错误。
- 群列表与聊天顶部的组合头像复用第 5 节的顺序与布局:两人斜向叠放,三人以上圆形聚拢,最多取群成员前五位,
第一位在最前层完整显示,其余依次向后。同色描边随 Light / Dark 变化;保持列表 44pt、顶部 32pt 区域与运行中呼吸环。
实现与回归见 `apps/mobile/src/session/BotGroupAvatars.tsx`、`apps/mobile/src/__tests__/BotGroupAvatars.test.tsx`。