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 every format of a launch-video take at the list limit (#8960)

[._.]/ Adam Eivy5357cd7c9d9f
diff --git a/server/routes/apps/launchVideos.js b/server/routes/apps/launchVideos.js
index 53f8e751d8..96b566d013 100644
--- a/server/routes/apps/launchVideos.js
+++ b/server/routes/apps/launchVideos.js
@@ -187,8 +187,11 @@ router.post('/:id/launch-videos', loadApp, asyncHandler(async (req, res) => {
router.get('/:id/launch-videos', loadApp, asyncHandler(async (req, res) => {
const { loadHistory } = await import('../../services/videoGen/history.js');
// Bounded projection of the existing media store, not a new run database.
- const videos = (await loadHistory()).filter(item => item.launchVideo?.appId === req.loadedApp.id)
- .slice(0, LAUNCH_VIDEO_LIST_LIMIT).map(({ id, filename, thumbnail, createdAt, durationSec, width, height, launchVideo }) => ({
+ const all = (await loadHistory()).filter(item => item.launchVideo?.appId === req.loadedApp.id);
+ // Never cut a multi-format run at the limit: a take the tab shows keeps all
+ // of its formats (at most two past the limit).
+ const keptRuns = new Set(all.slice(0, LAUNCH_VIDEO_LIST_LIMIT).map(item => item.launchVideo.runId).filter(Boolean));
+ const videos = all.filter((item, index) => index < LAUNCH_VIDEO_LIST_LIMIT || keptRuns.has(item.launchVideo.runId)).map(({ id, filename, thumbnail, createdAt, durationSec, width, height, launchVideo }) => ({
id, filename, thumbnail, createdAt, durationSec, caption: launchVideo.caption, ...(launchVideo.sourceVideoId ? { sourceVideoId: launchVideo.sourceVideoId } : {}),
// runId groups a multi-format run's entries into one take in the tab.
runId: launchVideo.runId, format: formatOf({ width, height }),
diff --git a/server/routes/apps/launchVideos.test.js b/server/routes/apps/launchVideos.test.js
index ab8bb77576..62d49d0cc0 100644
--- a/server/routes/apps/launchVideos.test.js
+++ b/server/routes/apps/launchVideos.test.js
@@ -182,6 +182,12 @@ describe('user-triggered launch videos', () => {
expect((await request(app).get('/api/apps/example/launch-videos')).body.videos.map(({ id, runId, format }) => ({ id, runId, format }))).toEqual([
{ id: 'run-a-vertical', runId: 'run-a', format: 'vertical' }, { id: 'run-a-square', runId: 'run-a', format: 'square' },
]);
+ // The limit never splits a run: a take at the boundary keeps every format.
+ loadHistory.mockResolvedValue(Array.from({ length: 52 }, (_, n) => ({ id: `video-${n}`, launchVideo: { appId: 'example', runId: n < 48 ? `run-${n}` : 'boundary-run' } })));
+ const bounded = (await request(app).get('/api/apps/example/launch-videos')).body.videos;
+ expect(bounded).toHaveLength(52);
+ loadHistory.mockResolvedValue(Array.from({ length: 53 }, (_, n) => ({ id: `video-${n}`, launchVideo: { appId: 'example', runId: n < 50 ? `run-${n}` : 'next-run' } })));
+ expect((await request(app).get('/api/apps/example/launch-videos')).body.videos).toHaveLength(50);
loadHistory.mockRejectedValue(new Error('Storage unavailable'));
expect((await request(app).get('/api/apps/example/launch-videos')).status).toBe(500);
});