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([issue-2104]): backfill 500 Miles TikTok references on pre-2026-06-07 installs

Adam Eivy5eb927592d68
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index c5d8c6fe8c..5005926b72 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -1,5 +1,9 @@
# Unreleased Changes
+## Rounds
+
+- **[issue-2104] Fixed: 500 Miles' reference TikTok videos now show up on older installs.** The built-in "500 Miles" round shipped with three TikTok reference performances, but any install that already had its data saved from before those were added never picked them up — the Reference material section stayed empty. A one-time backfill now restores the three references for those installs, without touching anything you may have added of your own.
+
## Media
- **[issue-2036] Sketch & Annotation Canvas (phase 2): re-render an image guided by your annotations.** The annotate page (`/media/annotate/:mediaKey`) gained a "Re-render" action: draw over a generated image, then feed your markup back through local img2img so the marks reshape the render. A confirmation dialog names the exact local model it will run (no surprise AI calls) and lets you add an optional prompt and tune how much to change before it starts; the new render is queued and appears in Media History. Requires a local FLUX img2img runner — the action explains when one isn't available. Phase 3 (blank-canvas storyboard) remains open on #2036.
diff --git a/scripts/migrations/157-seed-500-miles-references.js b/scripts/migrations/157-seed-500-miles-references.js
new file mode 100644
index 0000000000..5832164d4d
--- /dev/null
+++ b/scripts/migrations/157-seed-500-miles-references.js
@@ -0,0 +1,76 @@
+/**
+ * Backfill the TikTok reference performances onto the built-in "500 Miles" for
+ * installs that already have the song but no reference material.
+ *
+ * Background:
+ * `server/services/rounds.js#SEED_ROUNDS` ships "500 Miles" with three TikTok
+ * reference videos (SEED_500_MILES_REFERENCES) — added in 6b7b81c27 and
+ * 26cd58e8b (2026-06-07). Fresh installs seed them directly. An install whose
+ * `data/rounds.json` was seeded BEFORE that date already has its own
+ * `seed-500-miles` record on disk, which predates the `references` field
+ * entirely — unlike `score` (migration 073) and `scoreParts` (migrations
+ * 076/086), nothing ever backfilled `references` onto it.
+ *
+ * This migration adds the shipped references ONLY when the record has none
+ * (absent or empty array), so a user who already added their own reference
+ * material is never clobbered. The references come from the single shipped
+ * source (no drift). The user can also pull the latest bundled content any
+ * time via "Refresh from template".
+ *
+ * Fresh installs (no file) are a clean no-op. Re-runs detect references are
+ * present and skip.
+ *
+ * NOTE: unlike migration 076 (which targeted the pre-rename `data/songs.json`
+ * / `songs` key), this migration runs after migration 120's Songs→Rounds
+ * rename, so it targets the CURRENT `data/rounds.json` / `rounds` key.
+ */
+
+import { readFile, writeFile, stat } from 'fs/promises';
+import { join } from 'path';
+import { SEED_500_MILES_REFERENCES } from '../../server/services/rounds.js';
+
+const ROUND_ID = 'seed-500-miles';
+
+const fileExists = (path) => stat(path).then(() => true, (err) => {
+ if (err.code === 'ENOENT') return false;
+ throw err;
+});
+
+export default {
+ async up({ rootDir }) {
+ const path = join(rootDir, 'data', 'rounds.json');
+ if (!(await fileExists(path))) {
+ console.log('📦 migration 157: no data/rounds.json — fresh install seeds the references directly.');
+ return { updated: 0, reason: 'no-file' };
+ }
+
+ const raw = await readFile(path, 'utf-8');
+ let doc;
+ try { doc = JSON.parse(raw); } catch (err) {
+ console.warn(`⚠️ migration 157: data/rounds.json is unparseable (${err.message}); skipping.`);
+ return { updated: 0, reason: 'unreadable' };
+ }
+ if (!doc || !Array.isArray(doc.rounds)) {
+ return { updated: 0, reason: 'unexpected-shape' };
+ }
+
+ const round = doc.rounds.find((r) => r && r.id === ROUND_ID);
+ if (!round) {
+ console.log('📦 migration 157: built-in 500 Miles not present; nothing to backfill.');
+ return { updated: 0, reason: 'round-absent' };
+ }
+ if (Array.isArray(round.references) && round.references.length > 0) {
+ console.log('📦 migration 157: 500 Miles already has reference material; leaving it untouched.');
+ return { updated: 0, reason: 'already-applied' };
+ }
+
+ // Deep-clone the shipped references so the persisted record can't share
+ // references with the in-memory seed (defensive — the seed is reused across
+ // reads).
+ round.references = SEED_500_MILES_REFERENCES.map((r) => ({ ...r }));
+ round.updatedAt = new Date().toISOString();
+ await writeFile(path, JSON.stringify(doc, null, 2) + '\n');
+ console.log(`📦 migration 157: seeded ${round.references.length} reference video(s) onto built-in 500 Miles.`);
+ return { updated: 1 };
+ },
+};
diff --git a/scripts/migrations/157-seed-500-miles-references.test.js b/scripts/migrations/157-seed-500-miles-references.test.js
new file mode 100644
index 0000000000..3aad8ba93b
--- /dev/null
+++ b/scripts/migrations/157-seed-500-miles-references.test.js
@@ -0,0 +1,81 @@
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync, existsSync } from 'fs';
+import { tmpdir } from 'os';
+import { join } from 'path';
+
+import migration from './157-seed-500-miles-references.js';
+import { SEED_500_MILES_REFERENCES, SEED_ROUNDS } from '../../server/services/rounds.js';
+
+const writeJson = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');
+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));
+const findRound = (path, id) => readJson(path).rounds.find((r) => r.id === id);
+
+describe('migration 157 — seed 500 Miles reference videos', () => {
+ let rootDir;
+ let roundsPath;
+
+ beforeEach(() => {
+ rootDir = mkdtempSync(join(tmpdir(), 'migration-157-'));
+ mkdirSync(join(rootDir, 'data'), { recursive: true });
+ roundsPath = join(rootDir, 'data', 'rounds.json');
+ });
+
+ afterEach(() => {
+ rmSync(rootDir, { recursive: true, force: true });
+ });
+
+ it('the seed round carries the shipped references (single source, no drift)', () => {
+ const seed = SEED_ROUNDS.find((r) => r.id === 'seed-500-miles');
+ expect(seed.references).toBe(SEED_500_MILES_REFERENCES);
+ expect(SEED_500_MILES_REFERENCES).toHaveLength(3);
+ expect(SEED_500_MILES_REFERENCES.every((r) => r.url.startsWith('https://www.tiktok.com/'))).toBe(true);
+ });
+
+ it('no-ops when data/rounds.json is missing (fresh install seeds references directly)', async () => {
+ const result = await migration.up({ rootDir });
+ expect(result).toEqual({ updated: 0, reason: 'no-file' });
+ expect(existsSync(roundsPath)).toBe(false);
+ });
+
+ it('backfills references onto a 500 Miles record that has none', async () => {
+ writeJson(roundsPath, { rounds: [{ id: 'seed-500-miles', title: '500 Miles' }] });
+ const result = await migration.up({ rootDir });
+ expect(result.updated).toBe(1);
+ const round = findRound(roundsPath, 'seed-500-miles');
+ expect(round.references).toHaveLength(3);
+ expect(round.references.map((r) => r.id)).toEqual(SEED_500_MILES_REFERENCES.map((r) => r.id));
+ });
+
+ it('treats an empty references array as missing and fills it', async () => {
+ writeJson(roundsPath, { rounds: [{ id: 'seed-500-miles', references: [] }] });
+ const result = await migration.up({ rootDir });
+ expect(result.updated).toBe(1);
+ expect(findRound(roundsPath, 'seed-500-miles').references).toHaveLength(3);
+ });
+
+ it('never clobbers an existing user reference list', async () => {
+ writeJson(roundsPath, { rounds: [{ id: 'seed-500-miles', references: [{ id: 'mine', url: 'https://example.com/mine', label: 'Mine', note: '' }] }] });
+ const result = await migration.up({ rootDir });
+ expect(result).toEqual({ updated: 0, reason: 'already-applied' });
+ expect(findRound(roundsPath, 'seed-500-miles').references).toEqual([{ id: 'mine', url: 'https://example.com/mine', label: 'Mine', note: '' }]);
+ });
+
+ it('is idempotent across re-runs', async () => {
+ writeJson(roundsPath, { rounds: [{ id: 'seed-500-miles' }] });
+ await migration.up({ rootDir });
+ const second = await migration.up({ rootDir });
+ expect(second.reason).toBe('already-applied');
+ });
+
+ it('no-ops when 500 Miles is absent (user deleted it)', async () => {
+ writeJson(roundsPath, { rounds: [{ id: 'round-custom' }] });
+ const result = await migration.up({ rootDir });
+ expect(result).toEqual({ updated: 0, reason: 'round-absent' });
+ });
+
+ it('skips an unparseable rounds.json instead of throwing', async () => {
+ writeFileSync(roundsPath, '{ not json');
+ const result = await migration.up({ rootDir });
+ expect(result).toEqual({ updated: 0, reason: 'unreadable' });
+ });
+});
diff --git a/server/services/rounds.js b/server/services/rounds.js
index 58e3c3d652..d33b1863f2 100644
--- a/server/services/rounds.js
+++ b/server/services/rounds.js
@@ -430,6 +430,16 @@ export const SEED_500_MILES_SCORE_PARTS = [
},
];
+// Reference performances for the built-in "500 Miles" — TikTok clips the user
+// pointed at as worked examples for the Reference material section. Kept as a
+// named export so SEED_ROUNDS and the backfill migration share ONE source (no
+// drift), the same pattern as SEED_500_MILES_SCORE_PARTS above.
+export const SEED_500_MILES_REFERENCES = [
+ { id: 'ref-tt-marie', url: 'https://www.tiktok.com/@marie.celestinee/video/7638358831205977376', label: 'TikTok · @marie.celestinee', note: 'Reference performance.' },
+ { id: 'ref-tt-eric', url: 'https://www.tiktok.com/@ericolsith/video/7633158760659176718', label: 'TikTok · @ericolsith', note: 'Reference performance.' },
+ { id: 'ref-tt-eric-2', url: 'https://www.tiktok.com/@ericolsith/video/7647221045618887949', label: 'TikTok · @ericolsith', note: 'Reference performance.' },
+];
+
// --- Traditional rounds: melodies + canonic voice stacks --------------------
// The four built-in rounds are canons — the harmony IS the melody sung against
// itself, each voice entering a fixed number of bars late. Rather than hand-
@@ -644,11 +654,7 @@ export const SEED_ROUNDS = [
{ id: 'high-harmony-2', label: 'High Harmony II', part: 'Soprano / Tenor', notes: 'Held upper pad — keep the leading tone (the B in G7) so it resolves up to C.' },
{ id: 'high-harmony-1', label: 'High Harmony I', part: 'Soprano', notes: 'Sparse top descant — high chord tones on the emotional phrases. Enter late; mostly long notes.' },
],
- references: [
- { id: 'ref-tt-marie', url: 'https://www.tiktok.com/@marie.celestinee/video/7638358831205977376', label: 'TikTok · @marie.celestinee', note: 'Reference performance.' },
- { id: 'ref-tt-eric', url: 'https://www.tiktok.com/@ericolsith/video/7633158760659176718', label: 'TikTok · @ericolsith', note: 'Reference performance.' },
- { id: 'ref-tt-eric-2', url: 'https://www.tiktok.com/@ericolsith/video/7647221045618887949', label: 'TikTok · @ericolsith', note: 'Reference performance.' },
- ],
+ references: SEED_500_MILES_REFERENCES,
createdAt: '2026-01-01T00:00:00.000Z',
updatedAt: '2026-01-01T00:00:00.000Z',
},