mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* feat(studio): track completed preview editing gestures * fix(studio): preserve gesture receipts and suppress duplicate usage * fix(studio): count semantic keyframe writes once per gesture * fix(studio): isolate recording state during pending saves * fix(studio): count marquee selection changes from owner receipts * fix(studio): retain accurate empty marquee receipts * refactor(studio): simplify recording transitions and selection tests * refactor(studio): share recording timing and marquee fixtures * fix(studio): preserve recording targets and batch attribution * fix(studio): retain per-member telemetry suppression * style(studio): format batch receipt attribution * test(studio): match writer receipts and animation metadata * docs(studio): clarify paused position save rejection * fix(studio): replace telemetry route names with route identity * style(studio): format route identity regression * Use random tab-local route identities in Studio telemetry * Preserve route identities inherited through session storage * Separate route storage validation from token creation
59 lines
2.2 KiB
TypeScript
59 lines
2.2 KiB
TypeScript
import { useCallback } from "react";
|
|
import type { DomEditSelection } from "../components/editor/domEditing";
|
|
import type { PatchOperation } from "../utils/sourcePatcher";
|
|
import { trackStudioSaveFailure } from "../utils/studioSaveDiagnostics";
|
|
import { DomEditSaveQueueOpenError } from "../utils/domEditSaveQueue";
|
|
import type { PersistDomEditOperations } from "./domEditCommitTypes";
|
|
import { wasAlreadyToasted } from "./domEditPersistFailure";
|
|
|
|
interface UseDomEditPositionPatchCommitParams {
|
|
activeCompPath: string | null;
|
|
persistDomEditOperations: PersistDomEditOperations;
|
|
showToast: (message: string, tone?: "error" | "info") => void;
|
|
}
|
|
|
|
type PositionPatchOptions = {
|
|
label: string;
|
|
coalesceKey: string;
|
|
coalesceMs?: number;
|
|
skipRefresh?: boolean;
|
|
deferRender?: boolean;
|
|
};
|
|
|
|
export function useDomEditPositionPatchCommit({
|
|
activeCompPath,
|
|
persistDomEditOperations,
|
|
showToast,
|
|
}: UseDomEditPositionPatchCommitParams) {
|
|
return useCallback(
|
|
(selection: DomEditSelection, patches: PatchOperation[], options: PositionPatchOptions) => {
|
|
return persistDomEditOperations(selection, patches, {
|
|
label: options.label,
|
|
coalesceKey: options.coalesceKey,
|
|
coalesceMs: options.coalesceMs,
|
|
skipRefresh: options.skipRefresh ?? true,
|
|
deferRender: options.deferRender,
|
|
}).catch((error) => {
|
|
// The paused-save banner already explains this refusal. Rethrow so the
|
|
// caller reverts the preview instead of treating an unsaved edit as committed.
|
|
if (error instanceof DomEditSaveQueueOpenError) throw error;
|
|
if (!wasAlreadyToasted(error)) {
|
|
showToast(error instanceof Error ? error.message : "Failed to save position");
|
|
}
|
|
trackStudioSaveFailure({
|
|
source: "dom_edit",
|
|
error,
|
|
filePath: selection.sourceFile ?? activeCompPath ?? "index.html",
|
|
mutationType: "position",
|
|
label: options.label,
|
|
targetId: selection.id,
|
|
targetSelector: selection.selector,
|
|
targetSourceFile: selection.sourceFile,
|
|
});
|
|
throw error;
|
|
});
|
|
},
|
|
[activeCompPath, persistDomEditOperations, showToast],
|
|
);
|
|
}
|