Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(chat): preserve group follow range and keyboard unread actions
Chris351a55db66e5
diff --git a/apps/desktop/scripts/fixtures/group-control/ui-page.mjs b/apps/desktop/scripts/fixtures/group-control/ui-page.mjsindex 390a27056d..0fbb410c5f 100644--- a/apps/desktop/scripts/fixtures/group-control/ui-page.mjs+++ b/apps/desktop/scripts/fixtures/group-control/ui-page.mjs@@ -332,6 +332,17 @@ export default {}if (ui.case === 'long-thread') {+ // Browser integration: presentation translation must not enlarge the+ // native range, which onScroll would mistake for the reader leaving tail.+ const translatedRange = await scroller.evaluate(el => {+ const content = el.querySelector('[data-bot-group-message-id]').parentElement;+ const before = el.scrollHeight;+ content.style.transform = 'translateY(100px)';+ const after = el.scrollHeight;+ content.style.transform = '';+ return { before, after };+ });+ assert.equal(translatedRange.after, translatedRange.before, 'follow movement cannot add scrollable overflow');const bottomGap = () =>scroller.evaluate((el) => el.scrollHeight - el.clientHeight - el.scrollTop);await page.waitForFunction(() => {diff --git a/apps/desktop/src/renderer/__tests__/controlledBannerPlacement.test.ts b/apps/desktop/src/renderer/__tests__/controlledBannerPlacement.test.tsindex f5d56fbc3b..c05a1ebbc2 100644--- a/apps/desktop/src/renderer/__tests__/controlledBannerPlacement.test.ts+++ b/apps/desktop/src/renderer/__tests__/controlledBannerPlacement.test.ts@@ -37,9 +37,9 @@ describe('controlled banner placement', () => {expect(sessionViewSource).toContain('rightLeadingSlot={');expect(sessionViewSource).toContain('hasControlledBanner && controlledBannerCollapsed ? (');// 伙伴与普通任务共用 RunningStatusBar;折叠呼吸灯随 token 元数据一起显示。- expect(sessionViewSource).toContain(- '{!pendingPlanReview || (hasControlledBanner && controlledBannerCollapsed) ? (',- );+ // Suppression/independent collapsed indicator behavior is rendered through+ // RunningStatusBar in runningStatusBarSuppression.test.tsx. Its retained+ // exit no longer uses an outer conditional mount.expect(sessionViewSource).not.toContain('<BotWorkingStatus');expect(sessionViewSource).toContain('suppressContent={Boolean(pendingPlanReview)}');expect(sessionViewSource).toContain(@@ -57,9 +57,8 @@ describe('controlled banner placement', () => {expect(sessionViewSource).toContain('const controlledBannerMaxWidth = `min(${inputHalfWidth}, ${CONTROLLED_BANNER_MAX_WIDTH}px)`;',);- expect(sessionViewSource).toContain(- 'if (!rightLeadingSlot && (suppressContent || (isHidden && !ratePanelPinned))) return null;',- );+ // The same production render test verifies no row remains after suppression+ // without an indicator, while allowing the occupied space to close first.expect(controlledBannerSource).toContain("placement?: 'floating' | 'inline' | 'composer';");expect(controlledBannerSource).toContain('className="pointer-events-auto flex min-w-0 max-w-full shrink justify-end"',diff --git a/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx b/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsxindex b3904237fa..c6946d66fe 100644--- a/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx@@ -1188,6 +1188,8 @@ function BotGroupChatContent({ groupId, direct }: { groupId: string; direct: boo}}className="min-h-0 flex-1 overflow-y-auto overflow-x-clip px-5 pb-4 pt-4">+ {/* Keep presentation movement out of the scroller's overflow range. */}+ <div className="overflow-clip"><div ref={contentRef} className="mx-auto flex w-full max-w-[760px] flex-col">{hasMoreBefore ? (<div className="mb-2 flex justify-center">@@ -1290,6 +1292,7 @@ function BotGroupChatContent({ groupId, direct }: { groupId: string; direct: boo? <BotGroupSpeakerInteraction key={`${speaker.member.botId}:${speaker.activity}`} speaker={speaker} />: <BotGroupSpeakingLine key={`${speaker.member.botId}:${speaker.activity}`} speaker={speaker} />))}</div>+ </div></div><div className="relative h-0 shrink-0" inert={newMessageCount <= 0}><NewMessageIndicator visible={newMessageCount > 0} count={newMessageCount} bottomOffset={12} onClick={() => {diff --git a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsxindex 6dfc823c6a..1207ff4ded 100644--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx@@ -47,14 +47,14 @@ vi.mock('@/session/NativeChatViewport', () => ({get nativeChatViewportAvailable() { return h.nativeChatViewportAvailable; },get nativeAndroidKeyboardViewportAvailable() { return h.nativeChatViewportAvailable && h.platform.OS === 'android'; },NativeChatViewport: ({ children, ...props }: any) => { h.nativeChatViewport = props; return children; },- NativeAndroidComposerAnchor: ({ children }: any) => children,+ NativeAndroidComposerAnchor: ({ children, followKeyboard }: any) => el('div', { 'data-native-keyboard-follow': String(!!followKeyboard) }, children),}));vi.mock('@/session/useSmoothMessageFollow', () => ({ useSmoothMessageFollow: () => ({scrollRef: useRef(null), nativeScrollRef: useRef({ scrollTo: h.scrollTo }), move: h.moveTail, cancel: h.cancelTail,}) }));vi.mock('@/session/AnimatedContentHeight', () => ({ AnimatedContentHeight: ({ open = true, children }: any) => open ? children : null }));vi.mock('@/session/ComposerDockKeyboardFollow', () => ({ DockKeyboardLift: ({ children, ...props }: any) => {- h.keyboardLift = props; return children;+ h.keyboardLift = props; return el('div', { 'data-keyboard-lift': String(props.active) }, children);} }));vi.mock('@/session/NativeKeyboardViewport', () => ({get nativeKeyboardViewportAvailable() { return h.nativeViewportAvailable && h.platform.OS === 'ios'; },@@ -502,6 +502,26 @@ describe('group timeline', () => {expect(h.moveTail).not.toHaveBeenCalled();});+ // Unit: the actual unread action must use the same native keyboard movement+ // as the composer. A history reader must still be able to tap it with IME open.+ it.each(['ios', 'android'])('keeps the unread action under %s keyboard ownership', async (platform) => {+ h.platform.OS = platform;+ h.nativeViewportAvailable = platform === 'ios';+ h.nativeChatViewportAvailable = platform === 'android';+ const data = group();+ const props = { deviceId: 'mac', deviceName: 'Mac', groupId: 'g1', messageId: data.messages[0].id };+ h.chat = { ...h.chat, state: { kind: 'ready', group: data } };+ await act(async () => root.render(el(BotGroupChatScreen, props)));+ h.chat = { ...h.chat, state: { kind: 'ready', group: { ...data, messages: [...data.messages, message('keyboard-arrival', 20, {})] } } };+ await act(async () => root.render(el(BotGroupChatScreen, props)));+ const jump = byId('botGroup.newMessages') as HTMLButtonElement;+ expect(jump).toBeTruthy();+ expect(jump.closest(platform === 'ios' ? '[data-keyboard-lift="true"]' : '[data-native-keyboard-follow="true"]')).toBeTruthy();+ expect(h.markRead).not.toHaveBeenCalled();+ await act(async () => jump.click());+ if (platform === 'android') expect(h.nativeChatViewport.followLatest).toBe(true);+ });+// Unit: Android native layout compensation must be the only scroll writer.// The observed failure is a 22pt dip/reversal when JS corrects the next frame.it('hands Android layout and content following to native, while a reader drag relinquishes the tail', async () => {diff --git a/apps/mobile/src/__tests__/edgeBlurMask.test.ts b/apps/mobile/src/__tests__/edgeBlurMask.test.tsindex 4b44593a0f..a49211dfa7 100644--- a/apps/mobile/src/__tests__/edgeBlurMask.test.ts+++ b/apps/mobile/src/__tests__/edgeBlurMask.test.ts@@ -83,10 +83,9 @@ describe('composer edge backdrop placement', () => {});it('starts the iOS edge blur and the Android frost at the input, not at status rows above it', () => {- expect(source).toContain('const composerBackdropTop = sessionResourceCards.blocked ? 0 : composerInputTop;');- expect(source).toContain('height={Math.max(0, bottomOverlayHeight - composerBackdropTop)}');+ expect(source).toContain('height={Math.max(0, height - (sessionResourceCards.blocked ? 0 : inputTop))}');const frost = source.slice(source.indexOf('{androidFrostedComposer ? ('), source.indexOf('testID="session.composerFrost"'));- expect(frost).toContain("sessionOperationLayout.composerSlot === 'editable' && !shareSelectionActive && { top: composerBackdropTop }");+ expect(frost).toContain("sessionOperationLayout.composerSlot === 'editable' && !shareSelectionActive && { top: sessionResourceCards.blocked ? 0 : inputTop }");});it('frosts the activity pills with the shared chrome glass', () => {diff --git a/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts b/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.tsindex 2cd7dcbefa..52a24e5e81 100644--- a/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts+++ b/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts@@ -14,7 +14,7 @@ it('uses LegendList virtualization with platform-scoped history anchoring', () =const source = readFileSync(resolve(process.cwd(), 'src/session/MessageRenderer.tsx'), 'utf8');const perfHarness = readFileSync(resolve(process.cwd(), 'app/listperf.tsx'), 'utf8');- const listStart = source.search(/<LegendList\s/);+ const listStart = source.search(/<AnimatedLegendList\s/);expect(listStart).toBeGreaterThan(-1);const listEnd = source.indexOf(' />', listStart);expect(listEnd).toBeGreaterThan(listStart);@@ -32,13 +32,13 @@ it('uses LegendList virtualization with platform-scoped history anchoring', () =expect(source).not.toContain('MOBILE_TAIL_REVEAL_ITEM_COUNT');expect(listSource).not.toMatch(/\binitialScrollIndex\s*=/);// Manual data prepend 不能与 Android native MVCP 并行:它会在 cell 位置提交后异步补- // offset,中间坐标窗无 cell 而白屏。size 变化始终由 LegendList 锚定;data 变化只在读历史- // 时锚定——贴底跟随时锚定会把被整批替换的旧可见行钉住,重连补同步时先跳上去再拉回底部。+ // offset,中间坐标窗无 cell 而白屏。读历史时 data/size 变化交给 LegendList 锚定;+ // 贴底时交给唯一跟随控制器,避免 native MVCP 与连续高度/滚动补偿同时写 offset。expect(listSource).toContain('alignItemsAtEnd');expect(listSource).toContain('maintainScrollAtEnd');expect(listSource).toContain('maintainVisibleContentPosition={historyPrependNativeMvcpDisabled');expect(listSource).toContain('? false');- expect(listSource).toContain(': { data: anchorVisibleRowsOnDataChange, size: true }}');+ expect(listSource).toContain(': { data: anchorVisibleRowsOnDataChange, size: anchorVisibleRowsOnDataChange }}');expect(source).toContain('const anchorVisibleRowsOnDataChange = isAwayFromBottom || readingOlderRef.current;',);diff --git a/apps/mobile/src/__tests__/mobileNativeBoundaryContracts.test.ts b/apps/mobile/src/__tests__/mobileNativeBoundaryContracts.test.tsindex f20621b361..311a29f0e6 100644--- a/apps/mobile/src/__tests__/mobileNativeBoundaryContracts.test.ts+++ b/apps/mobile/src/__tests__/mobileNativeBoundaryContracts.test.ts@@ -250,7 +250,7 @@ describe('mobile native boundary contracts', () => {const viewport = elements.get('session.bottomViewport')!;const layer = elements.get('session.bottomLayer')!;expect(layer.parent).toBe(viewport);- expect(layer.openingElement.getText(source)).toContain('ref={bottomOverlayRef}');+ expect(layer.openingElement.getText(source)).toContain('onLayout={handleBottomOverlayLayout}');expect(viewport.openingElement.getText(source)).toContain('pointerEvents="box-none"');for (const component of ['SessionComposerPalette', 'ComposerActivityStatus', 'SessionComposerInput']) {expect(viewport.getText(source)).toContain('<' + component);diff --git a/apps/mobile/src/session/BotGroupChatScreen.tsx b/apps/mobile/src/session/BotGroupChatScreen.tsxindex 548bb4a2ac..624f97efc5 100644--- a/apps/mobile/src/session/BotGroupChatScreen.tsx+++ b/apps/mobile/src/session/BotGroupChatScreen.tsx@@ -532,7 +532,11 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId, messageId, nonEditStep={(planId, step, action, botId) => void editPlanStep(planId, step, action, botId)}onInteractionError={(message) => { if (message) Alert.alert(message); }} /></Reanimated.ScrollView>- {newMessageCount > 0 ? <View style={styles.newMessages} accessibilityLiveRegion="polite">+ {newMessageCount > 0 ? <NativeAndroidComposerAnchor surfaceId="" followKeyboard={!!androidComposerSurfaceId}+ pointerEvents="box-none" style={StyleSheet.absoluteFill}>+ <DockKeyboardLift active={nativeKeyboardViewportAvailable} restingBottom={insets.bottom} keyboardGap={0}+ pointerEvents="box-none" style={StyleSheet.absoluteFill}>+ <View style={styles.newMessages} accessibilityLiveRegion="polite"><CompanionFadeIn play distance={spacing.xs}><MainWindowActionButton density="compact" style={styles.newMessagesButton} action={{label: t('groupChat.timeline.newMessages', { count: newMessageCount }),@@ -541,7 +545,9 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId, messageId, nonPress: () => { setFollowIntent(true); followTail(); },}} /></CompanionFadeIn>- </View> : null}+ </View>+ </DockKeyboardLift>+ </NativeAndroidComposerAnchor> : null}</View><NativeAndroidComposerAnchor surfaceId={androidComposerSurfaceId ?? ''} followKeyboard={!!androidComposerSurfaceId}><DockKeyboardLift active={nativeKeyboardViewportAvailable} restingBottom={insets.bottom} keyboardGap={0}>