From 2f85e82dd9a617318f31125cf1aaeff2e294c0b8 Mon Sep 17 00:00:00 2001 From: Mike MacCana Date: Thu, 5 Nov 2026 16:46:10 +0000 Subject: [PATCH 1/3] Rename the animation player's busy to stepAnimation Player.busy held the running step's animation, the promise play() returns, or null between steps. A name like "busy" reads as a boolean, so code that used it had to know it was really a promise. stepAnimation says what it holds, and a comment where the constructor sets it says when it resolves. Deck's pass-through getter takes the same name. Claude-Session: https://claude.ai/code/session_01GZHin6BQpAqf7j2ucSZWkx --- animations/deck.js | 6 +++--- animations/engine.js | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/animations/deck.js b/animations/deck.js index b7f6aab6..84bd9a1c 100644 --- a/animations/deck.js +++ b/animations/deck.js @@ -318,8 +318,8 @@ return this.items.length; } - get busy() { - return this.player.busy; + get stepAnimation() { + return this.player.stepAnimation; } async show(i, forward) { @@ -388,7 +388,7 @@ } async next() { - if (this.player.busy) return this.player.interrupt(); + if (this.player.stepAnimation) return this.player.interrupt(); if (this.index >= this.count - 1) return; this.index += 1; await this.show(this.index, true); diff --git a/animations/engine.js b/animations/engine.js index 3658f70e..d2967151 100644 --- a/animations/engine.js +++ b/animations/engine.js @@ -390,7 +390,9 @@ this.svg = svg; this.onStep = onStep || (() => {}); this.skip = false; - this.busy = null; + // The running step's animation: the promise play() returns, which + // resolves once the step has finished. Null between steps. + this.stepAnimation = null; this.speed = 1; this.autoplay = null; // states[i] is the picture once step i has finished. A step starts @@ -438,14 +440,14 @@ } async next() { - if (this.busy) return this.interrupt(); + if (this.stepAnimation) return this.interrupt(); if (this.index >= this.count - 1) return; this.index += 1; this.onStep(this.index); const run = this.play(this.index); - this.busy = run; + this.stepAnimation = run; await run; - if (this.busy === run) this.busy = null; + if (this.stepAnimation === run) this.stepAnimation = null; } prev() { @@ -474,11 +476,11 @@ // Finishes the running animation at once, on its end state. async interrupt() { - if (!this.busy) return; + if (!this.stepAnimation) return; this.skip = true; - await this.busy; + await this.stepAnimation; this.skip = false; - this.busy = null; + this.stepAnimation = null; } tween(ms, fn) { From fff69c795f45b5dbfd0a997f2e2fd8b607fb767f Mon Sep 17 00:00:00 2001 From: Mike MacCana Date: Thu, 5 Nov 2026 22:08:31 +0000 Subject: [PATCH 2/3] Fix the two CodeQL findings in the animation code - engine.js: next() cleared stepAnimation only if it still held the promise this call started, by comparing the two promises, which CodeQL reads as a missing await. Each animation now gets a number from animationCount, and next() clears stepAnimation only if no newer animation has started. - lending/scene.js: the note() line helper was defined and never called. Claude-Session: https://claude.ai/code/session_01GZHin6BQpAqf7j2ucSZWkx --- animations/engine.js | 12 ++++++++---- animations/lending/scene.js | 1 - 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/animations/engine.js b/animations/engine.js index d2967151..67c25d3a 100644 --- a/animations/engine.js +++ b/animations/engine.js @@ -393,6 +393,8 @@ // The running step's animation: the promise play() returns, which // resolves once the step has finished. Null between steps. this.stepAnimation = null; + // How many step animations have started; next() uses it to tell them apart. + this.animationCount = 0; this.speed = 1; this.autoplay = null; // states[i] is the picture once step i has finished. A step starts @@ -444,10 +446,12 @@ if (this.index >= this.count - 1) return; this.index += 1; this.onStep(this.index); - const run = this.play(this.index); - this.stepAnimation = run; - await run; - if (this.stepAnimation === run) this.stepAnimation = null; + // Number each animation, so one that finishes after a newer step has + // started leaves the newer step's stepAnimation alone. + const animationNumber = ++this.animationCount; + this.stepAnimation = this.play(this.index); + await this.stepAnimation; + if (this.animationCount === animationNumber) this.stepAnimation = null; } prev() { diff --git a/animations/lending/scene.js b/animations/lending/scene.js index b9da8bdf..c398287b 100644 --- a/animations/lending/scene.js +++ b/animations/lending/scene.js @@ -196,7 +196,6 @@ const sol = (text) => ({ text, style: "sol" }); const balance = (text) => ({ text, style: "balance" }); const field = (text) => ({ text }); - const note = (text) => ({ text, style: "note" }); // In the order the chapter's figures list them. const HANDLERS = [ From 764bbba37534ae8fdacd9ea07822761628139c26 Mon Sep 17 00:00:00 2001 From: Mike MacCana Date: Fri, 6 Nov 2026 16:05:32 +0000 Subject: [PATCH 3/3] Rename stepAnimation to currentStepCompletion The field holds the promise that the current step's animation completes, or null when no step is animating. currentStepCompletion names that. Claude-Session: https://claude.ai/code/session_01GZHin6BQpAqf7j2ucSZWkx --- animations/deck.js | 6 +++--- animations/engine.js | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/animations/deck.js b/animations/deck.js index 84bd9a1c..f5599435 100644 --- a/animations/deck.js +++ b/animations/deck.js @@ -318,8 +318,8 @@ return this.items.length; } - get stepAnimation() { - return this.player.stepAnimation; + get currentStepCompletion() { + return this.player.currentStepCompletion; } async show(i, forward) { @@ -388,7 +388,7 @@ } async next() { - if (this.player.stepAnimation) return this.player.interrupt(); + if (this.player.currentStepCompletion) return this.player.interrupt(); if (this.index >= this.count - 1) return; this.index += 1; await this.show(this.index, true); diff --git a/animations/engine.js b/animations/engine.js index 67c25d3a..9988d3d5 100644 --- a/animations/engine.js +++ b/animations/engine.js @@ -390,9 +390,9 @@ this.svg = svg; this.onStep = onStep || (() => {}); this.skip = false; - // The running step's animation: the promise play() returns, which - // resolves once the step has finished. Null between steps. - this.stepAnimation = null; + // The promise that the current step's animation completes; null when no + // step is animating. + this.currentStepCompletion = null; // How many step animations have started; next() uses it to tell them apart. this.animationCount = 0; this.speed = 1; @@ -442,16 +442,16 @@ } async next() { - if (this.stepAnimation) return this.interrupt(); + if (this.currentStepCompletion) return this.interrupt(); if (this.index >= this.count - 1) return; this.index += 1; this.onStep(this.index); // Number each animation, so one that finishes after a newer step has - // started leaves the newer step's stepAnimation alone. + // started leaves the newer step's currentStepCompletion alone. const animationNumber = ++this.animationCount; - this.stepAnimation = this.play(this.index); - await this.stepAnimation; - if (this.animationCount === animationNumber) this.stepAnimation = null; + this.currentStepCompletion = this.play(this.index); + await this.currentStepCompletion; + if (this.animationCount === animationNumber) this.currentStepCompletion = null; } prev() { @@ -480,11 +480,11 @@ // Finishes the running animation at once, on its end state. async interrupt() { - if (!this.stepAnimation) return; + if (!this.currentStepCompletion) return; this.skip = true; - await this.stepAnimation; + await this.currentStepCompletion; this.skip = false; - this.stepAnimation = null; + this.currentStepCompletion = null; } tween(ms, fn) {