Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(inspector): route click-impact through the zoom-pane write chain

超超超超超级喜欢你的达妮娅d29a2cf94489
diff --git a/src/lib/ai-edition/store/documentWriteAudit.test.ts b/src/lib/ai-edition/store/documentWriteAudit.test.ts
index 0d3a3fd73..263c1ab6a 100644
--- a/src/lib/ai-edition/store/documentWriteAudit.test.ts
+++ b/src/lib/ai-edition/store/documentWriteAudit.test.ts
@@ -294,7 +294,6 @@ const DECLARED: WritePath[] = [
w("src/lib/ai-edition/store/useTimeline.ts", "updateSpeedSpan", "save", "gesture"),
w("src/lib/ai-edition/store/useTimeline.ts", "updateSpeedValue", "save", "gesture"),
w("src/lib/ai-edition/store/useTimeline.ts", "updateTrim", "save", "gesture"),
- w("src/lib/ai-edition/store/useTimeline.ts", "updateZoomClickImpact", "save", "gesture"),
w("src/lib/ai-edition/store/useTimeline.ts", "updateZoomFocusLive", "set", "automatic"),
w("src/lib/ai-edition/store/useTimeline.ts", "updateZoomSpan", "save", "gesture"),
// Source-dimension backfill for assets a migration left unprobed. On load, for
diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.ts
index ed2a10478..fc267a771 100644
--- a/src/lib/ai-edition/store/useTimeline.test.ts
+++ b/src/lib/ai-edition/store/useTimeline.test.ts
@@ -1252,6 +1252,31 @@ describe("useTimeline undo history", () => {
});
});
+ // Rebase compatibility (#694 × current main): `updateZoomClickImpact` joined the zoom pane
+ // after this PR was authored, as one more one-field whole-document writer. While a level
+ // write is still pending, a click-impact toggle built from the render's document would
+ // rebuild the pill from the stale pre-level document — and whichever save landed last won,
+ // so the pending level could come back off. Click impact must share the zoom chain so both
+ // values survive.
+ it("keeps a pending zoom level when click impact toggles before it lands", async () => {
+ seed(docWithZoom);
+ const gate = gateFirstSave();
+ const { result } = renderTimeline();
+
+ const pDepth = result.current.updateZoomDepth("zoom_a", 4);
+ const pImpact = result.current.updateZoomClickImpact("zoom_a", true);
+ await waitFor(() => expect(gate.release).toEqual(expect.any(Function)));
+ await act(async () => {
+ gate.release?.();
+ await Promise.all([pDepth, pImpact]);
+ });
+
+ expect(useProjectStore.getState().document?.zoomRanges[0]).toMatchObject({
+ depth: 4,
+ clickImpact: true,
+ });
+ });
+
it("resolves a zoom-level write with whether the save took effect", async () => {
seed(docWithZoom);
const { result } = renderTimeline();
diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.ts
index 73a3a87a5..724127dd6 100644
--- a/src/lib/ai-edition/store/useTimeline.ts
+++ b/src/lib/ai-edition/store/useTimeline.ts
@@ -775,19 +775,13 @@ export function useTimeline() {
);
// Per-region, like the preset it animates. `undefined` rather than `false` so the document
- // keeps omitting the key when the option is off.
+ // keeps omitting the key when the option is off. Shares `saveZoomPatch` with the pane's
+ // other one-field writes: a toggle arriving while a level write is still pending must not
+ // rebuild the pill from the stale pre-level document and drop the level on the floor.
const updateZoomClickImpact = useCallback(
- async (id: string, clickImpact: boolean) => {
- if (!document) return;
- const next: AxcutDocument = {
- ...document,
- zoomRanges: patchPillById(document.zoomRanges, id, {
- clickImpact: clickImpact ? true : undefined,
- }) as AxcutDocument["zoomRanges"],
- };
- await saveDocument(next, { history: true });
- },
- [document, saveDocument],
+ (id: string, clickImpact: boolean) =>
+ saveZoomPatch(id, { clickImpact: clickImpact ? true : undefined }),
+ [saveZoomPatch],
);
const updateAnnotationSpan = useCallback(