@@ -20,6 +20,7 @@ import { useDomEditTextCommits } from "./useDomEditTextCommits";
2020import { useDomGeometryCommits } from "./useDomGeometryCommits" ;
2121import { useElementLifecycleOps } from "./useElementLifecycleOps" ;
2222import { formatFieldsSuffix } from "./gsapScriptCommitHelpers" ;
23+ import { cutoverCommittedOrThrow , type CutoverResult } from "../utils/sdkCutover" ;
2324
2425// ── Helpers ──
2526
@@ -81,16 +82,20 @@ export interface UseDomEditCommitsParams {
8182 * path, whose session is already current) so a later SDK edit doesn't
8283 * serialize the pre-write doc and revert the server's change. */
8384 forceReloadSdkSession ?: ( ) => void ;
84- /** Stage 7 Step 3c: called before the server-side patch path; returns true if SDK handled it . */
85+ /** Stage 7 Step 3c: called before the server-side patch path. */
8586 onTrySdkPersist ?: (
8687 selection : DomEditSelection ,
8788 operations : PatchOperation [ ] ,
8889 originalContent : string ,
8990 targetPath : string ,
9091 options ?: { label ?: string ; coalesceKey ?: string ; skipRefresh ?: boolean } ,
91- ) => Promise < boolean > ;
92- /** Stage 7 §3.1: called before the server-side delete path; returns true if SDK handled it. */
93- onTrySdkDelete ?: ( hfId : string , originalContent : string , targetPath : string ) => Promise < boolean > ;
92+ ) => Promise < CutoverResult > ;
93+ /** Stage 7 §3.1: called before the server-side delete path. */
94+ onTrySdkDelete ?: (
95+ hfId : string ,
96+ originalContent : string ,
97+ targetPath : string ,
98+ ) => Promise < CutoverResult > ;
9499 /** Resolver-shadow tripwire for z-index reorder targets (telemetry-only, decoupled from cutover). */
95100 onReorderShadow ?: ( targets : string [ ] ) => void ;
96101}
@@ -185,18 +190,17 @@ export function useDomEditCommits({
185190 // Skip the SDK path when prepareContent is set (e.g. @font-face injection
186191 // for a custom font): sdkCutoverPersist serializes only the patched DOM
187192 // and would drop the injected content. Let the server path run prepareContent.
188- if (
189- onTrySdkPersist &&
190- ! options ?. prepareContent &&
191- ( await onTrySdkPersist ( selection , operations , originalContent , targetPath , {
193+ if ( onTrySdkPersist && ! options ?. prepareContent ) {
194+ const cutover = await onTrySdkPersist ( selection , operations , originalContent , targetPath , {
192195 label : options ?. label ,
193196 coalesceKey : options ?. coalesceKey ,
194197 skipRefresh : options ?. skipRefresh ,
195- } ) )
196- ) {
197- // SDK handled it — its in-memory doc is already current, so do NOT
198- // forceReload (that would echo-reload the session we just wrote).
199- return ;
198+ } ) ;
199+ if ( cutoverCommittedOrThrow ( cutover ) ) {
200+ // SDK handled it — its in-memory doc is already current, so do NOT
201+ // forceReload (that would echo-reload the session we just wrote).
202+ return ;
203+ }
200204 }
201205
202206 // Mark the save timestamp before the file write so the SSE file-change
0 commit comments