Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): fire the cues a long loop wrap skipped, and pose the export player on creation (#4542)

[._.]/ Adam Eivyc04448f5054c
diff --git a/client/src/pages/ThreejsModelDetail.jsx b/client/src/pages/ThreejsModelDetail.jsx
index 62adbd504b..9448b4266a 100644
--- a/client/src/pages/ThreejsModelDetail.jsx
+++ b/client/src/pages/ThreejsModelDetail.jsx
@@ -409,10 +409,13 @@ export default function ThreejsModelDetail() {
const materialFindings = Array.isArray(record.materialPlausibility?.findings)
? record.materialPlausibility.findings
: null;
- // Clip findings only mean something for a model that declared clips: a static
- // assembly evaluates to an empty list, and rendering a clean "clip playback"
- // panel on every static model would be noise about a feature it never used.
- const animationFindings = Array.isArray(record.animation?.findings) && record.animation?.animated
+ // A clean verdict only means something for a model that declared clips —
+ // rendering "clips play cleanly" on every static model would be noise about a
+ // feature it never used. A finding is worth showing either way: the gate also
+ // reports an articulation graph that declares motion with no clip to play it,
+ // which by definition arrives on a model with no clips.
+ const animationFindings = Array.isArray(record.animation?.findings)
+ && (record.animation.animated || record.animation.findings.length > 0)
? record.animation.findings
: null;
// Undecided contact is a note the reader is meant to judge, never something a
diff --git a/client/src/pages/ThreejsModelDetail.test.jsx b/client/src/pages/ThreejsModelDetail.test.jsx
index 8dce5ffa47..f7be3ea2a9 100644
--- a/client/src/pages/ThreejsModelDetail.test.jsx
+++ b/client/src/pages/ThreejsModelDetail.test.jsx
@@ -552,6 +552,29 @@ describe('ThreejsModelDetail clip inventory', () => {
expect(screen.getByText('0 error · 1 warning · 0 note')).toBeInTheDocument();
});
+ // The gate also reports an articulation graph with no clip to play it, which
+ // by definition arrives on a model that declared no clips at all.
+ it('renders a clip finding raised against a model with no clips', async () => {
+ getThreejsModel.mockResolvedValue({
+ ...baseRecord,
+ animation: {
+ animated: false,
+ clipCount: 0,
+ warningCount: 1,
+ clips: [],
+ findings: [{
+ code: 'articulation-without-clips',
+ severity: 'warning',
+ message: 'the spec declares an articulation graph over 4 joints but no animation clip',
+ }],
+ },
+ });
+ renderDetail();
+
+ await waitFor(() => expect(screen.getByText('Clip playback')).toBeInTheDocument());
+ expect(screen.getByText(/declares an articulation graph over 4 joints/)).toBeInTheDocument();
+ });
+
// A static assembly evaluates to an empty finding list, which is not a verdict
// about clips — it never declared any.
it('shows no clip-playback gate for a static assembly that was evaluated', async () => {
diff --git a/server/lib/threejsModelAnimation.js b/server/lib/threejsModelAnimation.js
index 70ba917f29..a23d75ceb5 100644
--- a/server/lib/threejsModelAnimation.js
+++ b/server/lib/threejsModelAnimation.js
@@ -161,7 +161,7 @@ function evaluateClipFindings(clip, partsById) {
findings.push({
code: 'clip-holds-still',
severity: 'warning',
- message: `clip ${clipLabel} finishes moving at ${lastEnd}s and then holds still for ${Number(tail.toFixed(2))}s of its ${clip.durationSeconds}s duration`,
+ message: `clip ${clipLabel} finishes its last sequence at ${lastEnd}s and then holds still for ${Number(tail.toFixed(2))}s of its ${clip.durationSeconds}s duration`,
});
}
diff --git a/server/lib/threejsModelAnimation.test.js b/server/lib/threejsModelAnimation.test.js
index c7171409f8..2c9b091e47 100644
--- a/server/lib/threejsModelAnimation.test.js
+++ b/server/lib/threejsModelAnimation.test.js
@@ -183,7 +183,7 @@ describe('summarizeThreejsAnimation playback findings', () => {
const spec = animatedSpec();
spec.animation.clips[0].durationSeconds = 20;
const finding = summarizeThreejsAnimation(spec).findings.find((entry) => entry.code === 'clip-holds-still');
- expect(finding.message).toContain('finishes moving at 2s and then holds still for 18s of its 20s duration');
+ expect(finding.message).toContain('finishes its last sequence at 2s and then holds still for 18s of its 20s duration');
});
it('leaves a clip that holds its final pose briefly alone', () => {
diff --git a/server/lib/threejsModelPlayerSource.js b/server/lib/threejsModelPlayerSource.js
index bd66ddc455..6edc800672 100644
--- a/server/lib/threejsModelPlayerSource.js
+++ b/server/lib/threejsModelPlayerSource.js
@@ -304,33 +304,36 @@ export function createSculptAnimationPlayer(root, options) {
const total = duration();
if (!playing || !clip || !(total > 0) || !Number.isFinite(deltaSeconds) || deltaSeconds <= 0) return [];
const from = timeSeconds;
- let to = from + (deltaSeconds * speed);
+ const raw = from + (deltaSeconds * speed);
let crossed;
- if (to < total) {
- crossed = collectSculptCues(clip, from, to);
+ if (raw < total) {
+ crossed = collectSculptCues(clip, from, raw);
+ timeSeconds = raw;
} else if (clip.loop) {
- // A frame gap longer than the whole clip — a backgrounded tab, a stall —
- // crossed every cue in it. Fire each ONCE for the gap rather than
- // replaying the clip's audio for every lap it skipped.
- crossed = collectSculptCues(clip, from, total);
- const wrapped = ((to - total) % total + total) % total;
- const fired = new Set(crossed.map((event) => event.sequenceId));
- for (const event of collectSculptCues(clip, 0, wrapped)) {
- if (!fired.has(event.sequenceId)) crossed.push(event);
- }
- to = wrapped;
+ crossed = raw - from >= total
+ // A frame gap at least as long as the whole clip — a backgrounded tab,
+ // a stall — crossed every cue in it. Fire each ONCE for the gap
+ // instead of replaying a backlog per skipped cycle: a resumed tab must
+ // not burst N copies of the same sound, and reporting only the tail
+ // and the wrapped remainder would silently drop the cues in between.
+ ? collectSculptCues(clip, 0, total)
+ : [...collectSculptCues(clip, from, total), ...collectSculptCues(clip, 0, raw % total)];
+ timeSeconds = raw % total;
} else {
crossed = collectSculptCues(clip, from, total);
- to = total;
+ timeSeconds = total;
playing = false;
}
- timeSeconds = to;
applyPose();
emit(crossed);
return crossed;
},
- /** Put the assembly back exactly as the factory built it, and stop. */
+ /**
+ * Put the assembly back exactly as the factory built it, and stop. The
+ * player poses the model at frame 0 of its first clip when it is created,
+ * so this is how a consumer gets the un-posed assembly back.
+ */
restore() {
playing = false;
timeSeconds = 0;
@@ -339,6 +342,10 @@ export function createSculptAnimationPlayer(root, options) {
},
};
+ // Frame 0 of the first clip, the way the preview opens a transport. Without
+ // this the model would sit at its authored pose while the player reported
+ // \`timeSeconds: 0\` of a clip whose opening frame hides or fades a part.
+ applyPose();
return player;
}
`;
diff --git a/server/lib/threejsModelPlayerSource.test.js b/server/lib/threejsModelPlayerSource.test.js
index 1689217f39..f924f0cdb2 100644
--- a/server/lib/threejsModelPlayerSource.test.js
+++ b/server/lib/threejsModelPlayerSource.test.js
@@ -186,6 +186,44 @@ describe('emitted clip player', () => {
expect(player.timeSeconds).toBeCloseTo(2, 6);
});
+ it('fires the cues a wrap skipped over, not just the ones either side of it', async () => {
+ const looping = spec();
+ looping.animation.clips[0].loop = true;
+ const cues = [];
+ const { player } = await mountPlayer(looping, { onCue: (event) => cues.push(event) });
+
+ player.seek(3);
+ player.play();
+ // A 10s gap from 3s of a 4s clip laps it twice. The cue at 2s sits in the
+ // skipped interval — neither in the tail [3, 4) nor in the wrapped [0, 1).
+ const crossed = player.update(10);
+ expect(crossed.map((event) => event.sequenceId)).toEqual(['lift', 'swing']);
+ expect(cues).toHaveLength(2);
+ expect(player.timeSeconds).toBeCloseTo(1, 6);
+ });
+
+ it('crosses the loop point within a single lap without firing a cue twice', async () => {
+ const looping = spec();
+ looping.animation.clips[0].loop = true;
+ const { player } = await mountPlayer(looping);
+
+ player.seek(3);
+ player.play();
+ // [3, 4) holds nothing; the wrapped [0, 0.5) picks up the cue at 0.
+ const crossed = player.update(1.5);
+ expect(crossed.map((event) => event.sequenceId)).toEqual(['lift']);
+ expect(player.timeSeconds).toBeCloseTo(0.5, 6);
+ });
+
+ it('poses the model at frame 0 of its first clip as soon as it is created', async () => {
+ const opening = spec();
+ // A clip whose opening frame is not the assembled pose: the panel starts
+ // hidden and appears part-way through.
+ opening.animation.clips[0].sequences[0].channels.visible = { from: false, to: true };
+ const { nodes } = await mountPlayer(opening);
+ expect(nodes.panel.visible).toBe(false);
+ });
+
it('clones a shared material before driving opacity, and gives it back on restore', async () => {
const { nodes, player } = await mountPlayer();
const sharedPanelMaterial = nodes.panel.material;