Ignore stale playLoomTurn responses after restarting or switching episodes in LoomPlayPanel

オープン
#19,052 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, react
領域
frontend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
JavaScript
スター
38
フォーク
32
平均マージ
14分
マージ済み PR(30日)
995

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

atomantic/PortOS のほかの issue

atomantic/PortOS の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。