fix(studio): harden keyframe editing semantics

This commit is contained in:
Miguel Angel Simon Sierra
2026-07-28 00:13:46 +02:00
parent 9fc0011703
commit d57039882f
41 changed files with 1294 additions and 435 deletions
+28 -12
View File
@@ -236,7 +236,7 @@ export function useGsapKeyframeOps({
);
const moveKeyframe = useCallback(
(
async (
selection: DomEditSelection,
animationId: string,
fromPercentage: number,
@@ -247,18 +247,26 @@ export function useGsapKeyframeOps({
// updateKeyframeCacheFromParsed re-keys the diamond from the fresh parse, so no
// optimistic cache write is needed (mapping the tween-% to clip-% here would
// duplicate that math). softReload mirrors remove-keyframe.
void commitMutation(selection, mutation, {
label: `Move keyframe to ${toPercentage}%`,
softReload: true,
}).catch((error) => {
try {
let changed = false;
await commitMutation(selection, mutation, {
label: `Move keyframe to ${toPercentage}%`,
softReload: true,
onResult: (result) => {
changed = result.changed !== false;
},
});
return changed;
} catch (error) {
trackGsapSaveFailure(error, selection, mutation, `Move keyframe to ${toPercentage}%`);
});
return false;
}
},
[commitMutation, trackGsapSaveFailure],
);
const resizeKeyframedTween = useCallback(
(
async (
selection: DomEditSelection,
animationId: string,
position: number,
@@ -275,12 +283,20 @@ export function useGsapKeyframeOps({
// Boundary drag-to-retime: the server re-keys keyframes in place + grows the
// tween window, preserving _auto / per-keyframe ease / easeEach / outer ease.
// softReload re-keys the diamonds from the fresh parse (mirrors moveKeyframe).
void commitMutation(selection, mutation, {
label: "Retime keyframe (resize tween)",
softReload: true,
}).catch((error) => {
try {
let changed = false;
await commitMutation(selection, mutation, {
label: "Retime keyframe (resize tween)",
softReload: true,
onResult: (result) => {
changed = result.changed !== false;
},
});
return changed;
} catch (error) {
trackGsapSaveFailure(error, selection, mutation, "Retime keyframe (resize tween)");
});
return false;
}
},
[commitMutation, trackGsapSaveFailure],
);