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

fix: keep the minSceneSec floor after beat-snapping a right-edge timeline drag

[._.]/ Adam Eivy8a37ac00dc7c
diff --git a/client/src/lib/beatGrid.js b/client/src/lib/beatGrid.js
index 89966cbfc1..e08caab0fa 100644
--- a/client/src/lib/beatGrid.js
+++ b/client/src/lib/beatGrid.js
@@ -260,7 +260,10 @@ export function computeDragSpan({ kind, startSpan, deltaSec, gridPoints, toleran
if (snap) { nextEnd = snap.t + (nextEnd - nextStart); nextStart = snap.t; snapped = true; }
} else {
const snap = snapTimeToGrid(nextEnd, gridPoints, toleranceSec);
- if (snap) { nextEnd = snap.t; snapped = true; }
+ // Re-apply the minSceneSec floor after snapping: a beat sitting just below
+ // the floored out-point would otherwise commit a span shorter than the
+ // minimum (the earlier Math.max at line 255 is on the pre-snap value).
+ if (snap) { nextEnd = Math.max(startSpan.startSec + minSceneSec, snap.t); snapped = true; }
}
return { startSec: Number(nextStart.toFixed(3)), endSec: Number(nextEnd.toFixed(3)), snapped };
}
diff --git a/client/src/lib/beatGrid.test.js b/client/src/lib/beatGrid.test.js
index 46cfe0cfaa..fca2aaac0b 100644
--- a/client/src/lib/beatGrid.test.js
+++ b/client/src/lib/beatGrid.test.js
@@ -284,6 +284,23 @@ describe('computeDragSpan', () => {
const result = computeDragSpan({ kind: 'right', startSpan: { startSec: 2, endSec: 4 }, deltaSec: -10, gridPoints: [], minSceneSec: 0.5 });
expect(result.endSec).toBeCloseTo(2.5, 5);
});
+
+ it('does not let a snap target below the minSceneSec floor commit a too-short span', () => {
+ // Dragging the out-point almost onto the start floors the end at
+ // startSec + minSceneSec (10.3). A beat at 10.2 sits within tolerance of
+ // that floored end, so pre-fix the snap overwrote 10.3 -> 10.2, committing a
+ // 0.2s span below the 0.3 minimum. The floor must survive the snap.
+ const result = computeDragSpan({
+ kind: 'right',
+ startSpan: { startSec: 10, endSec: 12 },
+ deltaSec: -11.7,
+ gridPoints: [10.2],
+ toleranceSec: 0.15,
+ minSceneSec: 0.3,
+ });
+ expect(result.endSec - result.startSec).toBeGreaterThanOrEqual(0.3 - 1e-9);
+ expect(result.endSec).toBeCloseTo(10.3, 5);
+ });
});
describe('shouldMarkBeatAligned', () => {