From 00d2c77cadf0fb74380b957c8ebfeb41337d1ecb Mon Sep 17 00:00:00 2001 From: chinesepowered <22500229+chinesepowered@users.noreply.github.com> Date: Sun, 19 Jul 2026 21:49:36 -0700 Subject: [PATCH] fix(Deck): reset build ceiling when applying synced slide state The BroadcastChannel handler applied a remote slide + click count but never updated curMax. Local navigation via go() resets curMax to the target slide's registered maximum; the remote path skipped that, and because registerMax only ever raises curMax, the synced/audience tab carried the previous slide's ceiling forward. After the presenter jumped between slides, hasNext/hasPrev and the prev/next arrows on the synced tab could be wrong (e.g. Next stayed enabled at the end of a slide with fewer builds). Mirror go() by setting curMax to max(registered max for the incoming slide, incoming clicks). --- src/deck/Deck.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/deck/Deck.tsx b/src/deck/Deck.tsx index 9a58447..c1bc741 100644 --- a/src/deck/Deck.tsx +++ b/src/deck/Deck.tsx @@ -298,8 +298,14 @@ export default function Deck({ children }: { children: ReactNode }) { c.onmessage = (e) => { if (e.data?.type === 'state') { applyingRemote.current = true; - setSlide(e.data.slide); + const s = e.data.slide; + setSlide(s); setClicks(e.data.clicks); + // mirror go(): reset the build ceiling for the incoming slide. Without + // this the synced tab carries the previous slide's curMax forward + // (registerMax only ever raises it), leaving hasNext/hasPrev and the + // nav arrows wrong after the presenter jumps between slides. + setCurMax(Math.max(maxMap.current[s] || 0, e.data.clicks)); } }; return () => c.close();