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): preserve send row measurement on confirmation

Chris458bf07f9521
diff --git a/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts b/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts
index f15e77b7ab..aef5873b3e 100644
--- a/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts
+++ b/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts
@@ -64,6 +64,10 @@ it('uses LegendList virtualization with platform-scoped history anchoring', () =
expect(perfHarness).toContain("const recycle = params.recycle === '1';");
expect(listSource).toContain('recycleItems={recycleItems}');
expect(listSource).toContain('getItemType={mobileMessageListItemType}');
+ // Confirmation must stay in the same LegendList pool as the optimistic row;
+ // changing its type would discard the measured cell just as the persisted
+ // message replaces the pending bubble.
+ expect(source).toContain("return item.type === 'pending_send' ? 'message' : item.type;");
expect(source).toContain('useRecyclingState');
// 可见性必须由 cell 自己订阅。把可见 key 集合放进 React Context 会在每个
// onViewableItemsChanged 回调里广播给所有已挂载长消息,快滑时造成整窗重渲染、GC 和白屏。
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index b2b6892e0c..565daf59f2 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -474,7 +474,10 @@ const MOBILE_MESSAGE_DRAW_DISTANCE = 800;
const FOLDABLE_HEADER_HIT_SLOP = { bottom: 10, left: 4, right: 4, top: 10 };
function mobileMessageListItemType(item: MobileMessageRenderItem): MobileMessageRenderItem['type'] {
- return item.type;
+ // A confirmed local send keeps the same logical row as its optimistic bubble.
+ // Reusing the message pool preserves the measured height while the item data
+ // changes from pending_send to the persisted message.
+ return item.type === 'pending_send' ? 'message' : item.type;
}
function resolveMobileMessageHistoryAnchorOffset(