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
+14 -3
View File
@@ -1,4 +1,4 @@
import { useState, useEffect } from "react";
import { useState, useEffect, useCallback } from "react";
import type { MutableRefObject } from "react";
import { openComposition } from "@hyperframes/sdk";
import { createHttpAdapter } from "@hyperframes/sdk/adapters/http";
@@ -36,11 +36,21 @@ export function shouldReloadSdkSession(payload: unknown, activeCompPath: string
// comparison is exact rather than time-based.
const SELF_WRITE_SUPPRESS_MS = 2000;
export interface SdkSessionHandle {
session: Composition | null;
/**
* Force a session reload immediately, bypassing the self-write suppress
* window. Call after undo/redo writes the active composition file so the
* SDK in-memory document reflects the reverted content.
*/
forceReload: () => void;
}
export function useSdkSession(
projectId: string | null,
activeCompPath: string | null,
domEditSaveTimestampRef?: MutableRefObject<number>,
): Composition | null {
): SdkSessionHandle {
const [session, setSession] = useState<Composition | null>(null);
const [reloadToken, setReloadToken] = useState(0);
@@ -111,5 +121,6 @@ export function useSdkSession(
};
}, [projectId, activeCompPath, reloadToken]);
return session;
const forceReload = useCallback(() => setReloadToken((t) => t + 1), []);
return { session, forceReload };
}