Ignore stale playLoomTurn responses after restarting or switching episodes in LoomPlayPanel

Abierto
#19,052 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, react
Área
frontend

Línea de trabajo

Start in client/src/components/fableloom/LoomPlayPanel.jsx, where runTurn awaits playLoomTurn and then sets scene, playbackPhase and transcript, and where restart() is wired to the useEffect keyed on start. Read how restart() resets state, then add a generation ref that restart() bumps and that runTurn checks after the await. Done when a late playLoomTurn response after Restart or an episode switch leaves scene and transcript untouched, proven by a new test in LoomPlayPanel.test.jsx.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug effort:low model:light plan planner:gemini-4-neon source:ui-runtime-bugs ui-runtime-bugs

Slice audited: FableLoom (client/src/pages/FableLoom*.jsx, client/src/components/fableloom, server/routes/fableLoom.js, server/services/fableLoom, server/sockets/fableLoomHosted.js)
Date: 2026-11-26
Scope: small

Problem

In client/src/components/fableloom/LoomPlayPanel.jsx:281-289, 296, 306-334, runTurn awaits playLoomTurn(...) and unconditionally calls setScene(result.node), setPlaybackPhase(...), and setTranscript((prev) => [...prev, ...additions]) without checking whether the session was restarted or switched to another episode while the request was in flight.

This race is directly reachable:

  • On an automatic-cut scene, the Restart button (LoomPlayPanel.jsx:697-703) remains enabled while sending is true, so clicking Restart during an in-flight playLoomTurn resets the panel to the opening scene and then the late response jumps scene back to the pre-restart destination and appends stale transcript entries.
  • Switching episodes (initialEpisode.id changing while a slow free-text LLM turn is in flight) triggers restart() via useEffect(..., [start]) (LoomPlayPanel.jsx:296), and the stale turn response from the previous episode overwrites the new episode's opening scene and transcript.
Impact

Late playLoomTurn responses corrupt the restarted or newly opened episode's scene state and transcript in LoomPlayPanel.

Fix

In client/src/components/fableloom/LoomPlayPanel.jsx:

  • Add a sessionGenerationRef = useRef(0) that increments in restart().
  • Capture const generation = sessionGenerationRef.current before await playLoomTurn(...) in runTurn, and return early without mutating scene, playbackPhase, activeHoldIndex, pendingTransition, or transcript if sessionGenerationRef.current !== generation.
  • Add a regression test in client/src/components/fableloom/LoomPlayPanel.test.jsx verifying that a playLoomTurn resolving after clicking Restart (or switching episodes) does not overwrite the reset scene or append to the reset transcript.
Acceptance criteria
  • Clicking Restart while a playLoomTurn request is in flight ignores the stale response when it resolves.
  • Switching episodes while a playLoomTurn request is in flight ignores the stale response from the previous episode.
  • Regression test in client/src/components/fableloom/LoomPlayPanel.test.jsx covers this race and passes.
Lenguaje dominante
JavaScript
Estrellas
38
Forks
32
Merge medio
14 min
PR fusionados (30 d)
995

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de atomantic/PortOS

Todos los issues de atomantic/PortOS

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.