Skip to content

Commit 880304c

Browse files
committed
feat(giselle): reset lifecycle refs when generation changes to avoid stale state
1 parent 745fbbe commit 880304c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/giselle/src/react/generations/generate-content-runner.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ export function GenerateContentRunner({
6767
const messageUpdateQueue = useRef<Map<UIMessage["id"], UIMessage>>(new Map());
6868
const pendingUpdate = useRef<number | null>(null);
6969

70+
// Reset lifecycle refs when generation changes
71+
// biome-ignore lint/correctness/useExhaustiveDependencies: intentionally depend on generation.id only
72+
useEffect(() => {
73+
didPerformingContentGeneration.current = false;
74+
didListeningContentGeneration.current = false;
75+
reachedStreamEnd.current = false;
76+
}, [generation.id]);
77+
7078
const flushMessageUpdates = useCallback(() => {
7179
if (messageUpdateQueue.current.size === 0) return;
7280

0 commit comments

Comments
 (0)