Skip to content

Commit a413e2a

Browse files
feat(sdk,studio): ws-4 — add history:false option; disable unused sdk undo in studio
Co-authored-by: Miguel Ángel <miguel07alm@protonmail.com>
1 parent d77c32b commit a413e2a

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

packages/sdk/src/session.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ export interface OpenCompositionOptions {
4848
trackedOrigins?: unknown[];
4949
/** Auto-coalesce window for history entries (ms). Default: 300. */
5050
coalesceMs?: number;
51+
/**
52+
* Pass `false` to skip attaching the history module (undo/redo).
53+
* Default: history is attached in standalone (non-embedded) mode.
54+
* Use when the host owns the undo stack and SDK undo is dead weight.
55+
*/
56+
history?: false;
5157
}
5258

5359
// ─── Implementation ───────────────────────────────────────────────────────────
@@ -495,7 +501,7 @@ export async function openComposition(
495501

496502
const isEmbedded = opts?.overrides !== undefined;
497503

498-
if (!isEmbedded) {
504+
if (!isEmbedded && opts?.history !== false) {
499505
const history = createHistory(session, {
500506
coalesceMs: opts?.coalesceMs ?? 300,
501507
trackedOrigins: opts?.trackedOrigins,

packages/studio/src/hooks/useSdkSession.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ export function useSdkSession(
9797
// 'change' AND Studio writes explicitly) and race on disk; it would
9898
// also write the full active-composition serialization to the fixed
9999
// persistPath even when an edit targeted a sub-composition file.
100-
const comp = await openComposition(content);
100+
// Studio's editHistory is the authoritative undo stack — SDK history
101+
// is unused dead weight here (forceReloadSdkSession discards it on undo).
102+
const comp = await openComposition(content, { history: false });
101103
// Cleanup may have fired while openComposition was awaited; dispose immediately.
102104
if (cancelled) {
103105
comp.dispose();

0 commit comments

Comments
 (0)