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: advance project cursors past concurrent deletions

[._.]/ Adam Eivyfdbe5edb4f40
diff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.js
index 466560520d..d4239858a3 100644
--- a/server/routes/musicVideo.js
+++ b/server/routes/musicVideo.js
@@ -277,7 +277,8 @@ router.get('/', asyncHandler(async (req, res) => {
const page = await listProjectPage({ ...paging, ...(summary ? { compare: compareMusicVideoProjectsNewestFirst } : {}) });
const presented = await Promise.all(page.items.map((project) => presentProjectForRead(project)));
const items = summary ? presented.map(project => summarizeMusicVideoProject(project, project.productionReadiness)) : presented;
- const next = page.offset + page.items.length;
+ // A deletion between header selection and hydration still consumes its slot.
+ const next = Math.min(page.offset + page.limit, page.total);
return res.json({ ...page, items, ...(summary ? { nextCursor: next < page.total ? String(next) : null } : {}) });
}
res.json(await Promise.all((await listProjects()).map((project) => presentProjectForRead(project))));
diff --git a/server/routes/musicVideo.test.js b/server/routes/musicVideo.test.js
index 8c33d1b7f8..93d98f9f96 100644
--- a/server/routes/musicVideo.test.js
+++ b/server/routes/musicVideo.test.js
@@ -266,6 +266,13 @@ describe('musicVideo routes', () => {
expect(readOffPage).not.toHaveBeenCalled();
});
+ it('advances past a page whose project was deleted between selection and hydration', async () => {
+ svc.listProjectPage.mockResolvedValueOnce({ items: [], total: 2, limit: 1, offset: 0 });
+ const response = await request(app).get('/api/music-video?summary=1&limit=1');
+ expect(response.status).toBe(200);
+ expect(response.body).toMatchObject({ items: [], total: 2, offset: 0, nextCursor: '1' });
+ });
+
it('GET /:id 404s when missing', async () => {
svc.getProject.mockResolvedValue(null);
const r = await request(app).get('/api/music-video/mv-x');