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): 修复显示动画中断后消息列表持续空白

Dash9ecd34e3363a
diff --git a/apps/mobile/src/__tests__/messageEntryPositioning.test.ts b/apps/mobile/src/__tests__/messageEntryPositioning.test.ts
index eb3df9b261..9b591e6dc7 100644
--- a/apps/mobile/src/__tests__/messageEntryPositioning.test.ts
+++ b/apps/mobile/src/__tests__/messageEntryPositioning.test.ts
@@ -50,6 +50,30 @@ function fixture(focused: string | null = null, saved?: object) {
}
describe('message entry lifecycle', () => {
+ // Regression: retained history can stay blank on reentry after native reveal
+ // cancellation. Existing tests never settled the native fallback as cancelled.
+ // Execute the production layout callback with that minimum native result;
+ // unit tier checks visible reveal state, including stale-generation isolation.
+ it.each([true, false])('reveals the current history when native animation settles (finished=%s)', (finished) => {
+ const h = fixture();
+ let settle!: (result: { finished: boolean }) => void;
+ h.bindings.Animated.timing = () => ({ start: (done: typeof settle) => { settle = done; }, stop: vi.fn() });
+ h.layout();
+ expect(h.state.revealed).toBe(false);
+ settle({ finished });
+ h.layout();
+ expect(h.state.revealed).toBe(true);
+ expect(h.bindings.scrollToEndProgrammatically).toHaveBeenCalledTimes(1);
+ });
+ it.each([true, false])('ignores an old native animation after changing histories (finished=%s)', (finished) => {
+ const h = fixture();
+ let settle!: (result: { finished: boolean }) => void;
+ h.bindings.Animated.timing = () => ({ start: (done: typeof settle) => { settle = done; }, stop: vi.fn() });
+ h.layout();
+ h.bindings.initialRevealGenerationRef.current++;
+ settle({ finished });
+ expect(h.state.revealed).toBe(false);
+ });
it('positions explicit navigation first and reveals on seek completion without visiting the tail', async () => {
const h = fixture('older');
let finish!: () => void;
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index eddf8c7cc1..3336ce6281 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -2533,11 +2533,15 @@ export function MessageRenderer({
useNativeDriver: true,
});
initialRevealAnimationRef.current = revealAnimation;
- revealAnimation.start(({ finished }) => {
+ revealAnimation.start(() => {
if (initialRevealAnimationRef.current === revealAnimation) {
initialRevealAnimationRef.current = null;
}
- if (finished) finish();
+ // Native cancellation must also release the initial visibility gate. Once
+ // this handle is cleared, positioning cannot reveal the list through it,
+ // and a retained list will not rerun initial positioning on reentry.
+ // finish() fences callbacks from a previous history or an unmounted list.
+ finish();
});
// Seek once, then reconcile the bookmark as estimated row heights become measured.