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: move collage grid helpers to moodBoard logic so they are reachable

Adam Eivyf3abfd7bbe62
diff --git a/server/services/moodBoard/collage.js b/server/services/moodBoard/collage.js
index f3ddd08a50..e34629b6c3 100644
--- a/server/services/moodBoard/collage.js
+++ b/server/services/moodBoard/collage.js
@@ -22,7 +22,7 @@ import { PATHS, ensureDir, atomicWrite } from '../../lib/fileUtils.js';
import { findFfmpeg, runFfmpegProcess, probeVideoDuration, safeUnder } from '../../lib/ffmpeg.js';
import { assetBasename } from '../../lib/localImageFilename.js';
import { emitRecordUpdated } from '../sharing/recordEvents.js';
-import { boardItemLocalImage } from './logic.js';
+import { boardItemLocalImage, squareGridDims, frameSampleTimes } from './logic.js';
import * as store from './db.js';
export const MAX_FRAMES_PER_VIDEO = 24;
@@ -32,23 +32,6 @@ const GAP_PX = 4;
const BG = { r: 15, g: 15, b: 15 };
const RESIZE_CONCURRENCY = 6;
-/**
- * Grid dimensions that keep the composite as square as possible: the smallest
- * column count whose square covers `count`, then only as many rows as needed
- * (e.g. 5 → 3×2, 10 → 4×3, 16 → 4×4). Cells are square, so the image aspect
- * follows the grid aspect.
- */
-export function squareGridDims(count) {
- const n = Math.max(1, Math.floor(count) || 1);
- const cols = Math.ceil(Math.sqrt(n));
- return { cols, rows: Math.ceil(n / cols) };
-}
-
-/** Evenly spaced sample times — the midpoint of each of `count` equal segments. */
-export function frameSampleTimes(durationSec, count) {
- return Array.from({ length: count }, (_, i) => ((i + 0.5) * durationSec) / count);
-}
-
function videoFilename(item) {
if (item?.type !== 'video' || typeof item.mediaKey !== 'string' || !item.mediaKey.startsWith('video:')) return null;
return assetBasename(item.mediaKey.slice('video:'.length)) || null;
diff --git a/server/services/moodBoard/collage.test.js b/server/services/moodBoard/logic.collage.test.js
similarity index 93%
rename from server/services/moodBoard/collage.test.js
rename to server/services/moodBoard/logic.collage.test.js
index a7e31f4451..fdf775c7a1 100644
--- a/server/services/moodBoard/collage.test.js
+++ b/server/services/moodBoard/logic.collage.test.js
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
-import { squareGridDims, frameSampleTimes } from './collage.js';
+import { squareGridDims, frameSampleTimes } from './logic.js';
describe('squareGridDims', () => {
it.each([
diff --git a/server/services/moodBoard/logic.js b/server/services/moodBoard/logic.js
index b4e61b17f0..90b813e2db 100644
--- a/server/services/moodBoard/logic.js
+++ b/server/services/moodBoard/logic.js
@@ -467,3 +467,22 @@ export function applyLocalizedImageUrls(board, replacements) {
if (!changed) return { board, changed: 0 };
return { board: { ...board, items: nextItems, updatedAt: nowIso() }, changed };
}
+
+// ─── Collage geometry ────────────────────────────────────────────────────────
+
+/**
+ * Grid dimensions that keep the composite as square as possible: the smallest
+ * column count whose square covers `count`, then only as many rows as needed
+ * (e.g. 5 → 3×2, 10 → 4×3, 16 → 4×4). Cells are square, so the image aspect
+ * follows the grid aspect.
+ */
+export function squareGridDims(count) {
+ const n = Math.max(1, Math.floor(count) || 1);
+ const cols = Math.ceil(Math.sqrt(n));
+ return { cols, rows: Math.ceil(n / cols) };
+}
+
+/** Evenly spaced sample times — the midpoint of each of `count` equal segments. */
+export function frameSampleTimes(durationSec, count) {
+ return Array.from({ length: count }, (_, i) => ((i + 0.5) * durationSec) / count);
+}