From 55f638e703fa993cd2affd1aee1cf2ae2ea7ea6f Mon Sep 17 00:00:00 2001 From: khatibqa Date: Mon, 28 Sep 2026 01:14:20 -0400 Subject: [PATCH] fix(gen2): fix CI lint failure in turn-activity.tsx react-hooks/set-state-in-effect flagged two setState calls in Gen2TurnActivity's "reset on empty" branches, spread across two separate effects that both fired on the exact same visible.length === 0 transition -- one calling setElapsed(0), the other calling setOpen(false) and duplicating the startedAt.current reset. Merged the second effect into the first (real simplification, not just a lint workaround: one effect, one place resetting state on that transition, instead of two). The remaining setElapsed(0) call still trips the rule since it's genuinely synchronizing a ref-tracked wall-clock timer with an external prop change (items disappearing), which isn't expressible as derived render-time state -- disabled with a comment explaining why, matching the convention already used elsewhere in this codebase (e.g. chat-panel.tsx). Verified: eslint . across apps/web now reports 0 errors (was 2), same 3 pre-existing unrelated warnings as before. turn-activity.test.tsx: 7/7 pass. tsc --noEmit clean. Co-Authored-By: Claude Sonnet 5 --- apps/web/components/gen2/turn-activity.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/web/components/gen2/turn-activity.tsx b/apps/web/components/gen2/turn-activity.tsx index 53d03dc2b..9883ff2bf 100644 --- a/apps/web/components/gen2/turn-activity.tsx +++ b/apps/web/components/gen2/turn-activity.tsx @@ -45,8 +45,16 @@ export function Gen2TurnActivity({ useEffect(() => { if (visible.length === 0) { + // No items left to show: reset so a fresh set of items later starts + // its own clean timer instead of inheriting a stale elapsed/open + // state. This subsumed a second, fully redundant effect that only + // ever fired on this same `visible.length === 0` transition. startedAt.current = null; + // Resets the wall-clock timer this effect owns when items disappear -- + // not state derivable from props/state alone. + // eslint-disable-next-line react-hooks/set-state-in-effect setElapsed(0); + setOpen(false); return; } startedAt.current ??= Date.now(); @@ -70,13 +78,6 @@ export function Gen2TurnActivity({ return () => window.clearInterval(id); }, [visible.length, active]); - useEffect(() => { - if (visible.length === 0) { - setOpen(false); - startedAt.current = null; - } - }, [visible.length]); - if (visible.length === 0) return null; const summary = active