@@ -34,6 +34,7 @@ import {
3434} from "./useDomEditCommitsHelpers" ;
3535import type { CutoverResult } from "../utils/sdkCutover" ;
3636import { studioWriteHeaders } from "../utils/studioFileVersion" ;
37+ import { reseekPreviewRuntime } from "./timelineTrackVisibility" ;
3738interface RecordEditInput {
3839 label : string ;
3940 kind : EditHistoryKind ;
@@ -154,6 +155,10 @@ export function useDomEditCommits({
154155 if ( options ?. shouldSave && ! options . shouldSave ( ) ) return ;
155156
156157 const targetPath = selection . sourceFile || activeCompPath || "index.html" ;
158+ const completePersistence = < T > ( result : T , changed : boolean ) : T => {
159+ if ( options ?. skipRefresh && changed ) reseekPreviewRuntime ( previewIframeRef . current ) ;
160+ return result ;
161+ } ;
157162
158163 const readResponse = await fetch (
159164 `/api/projects/${ pid } /files/${ encodeURIComponent ( targetPath ) } ` ,
@@ -201,7 +206,10 @@ export function useDomEditCommits({
201206 if ( cutover . status === "committed" ) {
202207 // SDK handled it — its in-memory doc is already current, so do NOT
203208 // forceReload (that would echo-reload the session we just wrote).
204- return { sourceFile : targetPath , version : cutover . version , changed : true } ;
209+ return completePersistence (
210+ { sourceFile : targetPath , version : cutover . version , changed : true } ,
211+ true ,
212+ ) ;
205213 }
206214 }
207215
@@ -249,9 +257,12 @@ export function useDomEditCommits({
249257 throw new DomEditPersistUnresolvableError ( targetPath ) ;
250258 }
251259 warnDomEditPersistNoOp ( selection , operations ) ;
252- return typeof patchData . path === "string" && typeof patchData . version === "string"
253- ? { sourceFile : patchData . path , version : patchData . version , changed : false }
254- : undefined ;
260+ return completePersistence (
261+ typeof patchData . path === "string" && typeof patchData . version === "string"
262+ ? { sourceFile : patchData . path , version : patchData . version , changed : false }
263+ : undefined ,
264+ false ,
265+ ) ;
255266 }
256267
257268 const patchedContent =
@@ -289,11 +300,14 @@ export function useDomEditCommits({
289300 if ( ! options ?. skipRefresh ) {
290301 reloadPreview ( ) ;
291302 }
292- return finalContent === patchedContent &&
293- typeof patchData . path === "string" &&
294- typeof patchData . version === "string"
295- ? { sourceFile : patchData . path , version : patchData . version , changed : true }
296- : undefined ;
303+ return completePersistence (
304+ finalContent === patchedContent &&
305+ typeof patchData . path === "string" &&
306+ typeof patchData . version === "string"
307+ ? { sourceFile : patchData . path , version : patchData . version , changed : true }
308+ : undefined ,
309+ true ,
310+ ) ;
297311 } ,
298312 [
299313 activeCompPath ,
@@ -305,6 +319,7 @@ export function useDomEditCommits({
305319 showToast ,
306320 forceReloadSdkSession ,
307321 onTrySdkPersist ,
322+ previewIframeRef ,
308323 ] ,
309324 ) ;
310325
0 commit comments