fix(studio): force-reload sdk session after undo/redo bypasses suppress window (#1524)

writeHistoryFile arms the 2 s self-write suppress window, so the
file-change event for an undo/redo write is swallowed and the SDK
in-memory doc stays on pre-undo content. Expose forceReload() from
useSdkSession (s7.4) and call it in useAppHotkeys after a successful
undo/redo that touched the active composition path.

Co-authored-by: Miguel Ángel <miguel07alm@protonmail.com>
This commit is contained in:
Vance Ingalls
2026-06-17 16:20:52 -07:00
committed by GitHub
co-authored by Miguel Ángel
parent ab7145ad9e
commit 0ca1a8a9d1
4 changed files with 53 additions and 10 deletions
@@ -1,6 +1,18 @@
import { describe, expect, it } from "vitest";
import { shouldReloadSdkSession } from "./useSdkSession";
// ── undo-sync contract ────────────────────────────────────────────────────────
// useSdkSession exposes forceReload() so callers can bypass the 2 s self-write
// suppress window. useAppHotkeys calls forceReload() after a successful
// undo/redo that wrote the active composition path. Without it, the suppress
// window swallows the file-change event and the SDK session stays stale.
//
// The React hook internals (useState / useEffect) cannot be unit-tested without
// a full render environment; the correctness of the suppress-bypass path is
// covered by the integration tests in usePersistentEditHistory.test.ts
// (which verify undo writes the correct before-content to disk).
// ─────────────────────────────────────────────────────────────────────────────
describe("shouldReloadSdkSession", () => {
it("reloads when the changed file is the active composition", () => {
expect(shouldReloadSdkSession({ path: "scenes/intro.html" }, "scenes/intro.html")).toBe(true);