Ignore stale playLoomTurn responses after restarting or switching episodes in LoomPlayPanel

Đang mở
#19,052 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, react
Lĩnh vực
frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
JavaScript
Star
38
Fork
32
Merge trung bình
14 phút
Pull request đã merge (30 ngày)
995

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của atomantic/PortOS

Tất cả issue của atomantic/PortOS

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.