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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: present autonomousRun.interrupted on music-video project reads (#10022)
Adam Eivy4b70d698998a
diff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.jsindex 9cf238c5dc..9143660ffa 100644--- a/server/routes/musicVideo.js+++ b/server/routes/musicVideo.js@@ -132,7 +132,7 @@ import {startProduction, resumeProduction, stopProduction, cancelProduction, getProduction,} from '../services/musicVideo/productionService.js';import {- startAutonomousVideo, getAutonomousRun, resumeAutonomousVideo, stopAutonomousVideo, cancelAutonomousVideo,+ startAutonomousVideo, getAutonomousRun, presentProjectAutonomousRun, resumeAutonomousVideo, stopAutonomousVideo, cancelAutonomousVideo,} from '../services/musicVideo/autonomousService.js';import { planProject } from '../services/musicVideo/planner.js';import {@@ -200,8 +200,11 @@ const projectUpdateSchema = musicVideoProjectUpdateSchema.extend(recordRenderPin// Backward-compatible by default: returns the full projects array. When a client// passes `limit`/`offset`, the response becomes the bounded// `{ items, total, limit, offset }` envelope every paginated PortOS list shares.+// Both pins are process-local, so only the server can say which stages a restart orphaned.+const presentProjectForRead = (project) => presentProjectAutonomousRun(presentProjectCastAndSets(project));+router.get('/', asyncHandler(async (req, res) => {- const projects = (await listProjects()).map(presentProjectCastAndSets);+ const projects = (await listProjects()).map(presentProjectForRead);if (!isPaginationRequested(req.query)) {return res.json(projects);}@@ -213,7 +216,7 @@ router.get('/:id', asyncHandler(async (req, res) => {if (!p) throw new ServerError('Project not found', { status: 404, code: 'NOT_FOUND' });// Transient (never persisted): lets a reloaded page reattach to a running publishing-kit build.const activePublishKitBuild = getActivePublishKitBuild(p.id);- const presented = presentProjectCastAndSets(p);+ const presented = presentProjectForRead(p);res.json(activePublishKitBuild ? { ...presented, activePublishKitBuild } : presented);}));diff --git a/server/services/musicVideo/autonomousRunPresentation.test.js b/server/services/musicVideo/autonomousRunPresentation.test.jsnew file mode 100644index 0000000000..ba84d8e35f--- /dev/null+++ b/server/services/musicVideo/autonomousRunPresentation.test.js@@ -0,0 +1,43 @@+/**+ * Project reads present `autonomousRun.interrupted` (#10022) — through the real+ * router and file-backed project store, so a reloaded page can offer Resume.+ */+import { describe, it, expect, vi, afterAll } from 'vitest';+import express from 'express';+import { request } from '../../lib/testHelper.js';+import { errorMiddleware } from '../../lib/errorHandler.js';+import { makePathsProxy, lazyTempDataRoot, cleanupTempDataRoots } from '../../lib/mockPathsDataRoot.js';++const ROOT = () => lazyTempDataRoot('mv-auto-present-test-');+vi.mock('../../lib/paths.js', async (importOriginal) => makePathsProxy(await importOriginal(), { dataRoot: ROOT }));+vi.mock('../settings.js', () => ({ getSettings: vi.fn(async () => ({})) }));++const { default: musicVideoRoutes } = await import('../../routes/musicVideo.js');+const projects = await import('./projects.js');+const { __autonomousProcessId } = await import('./autonomousService.js');++const app = express();+app.use(express.json());+app.use('/api/music-video', musicVideoRoutes);+app.use(errorMiddleware);++afterAll(() => cleanupTempDataRoots());++describe('autonomous run restart presentation (#10022)', () => {+ it('project reads mark a run pinned to another process as interrupted — but never store the flag', async () => {+ const project = await projects.createProject({ name: 'Auto Present' });+ const pin = (processId) => projects.mutateProjectRecord(project.id, (record) => ({+ project: { ...record, autonomousRun: { id: 'run-1', status: 'running', processId } },+ }));+ await pin('proc-before-restart');+ const one = await request(app).get(`/api/music-video/${project.id}`);+ expect(one.body.autonomousRun).toMatchObject({ status: 'running', interrupted: true });+ const list = await request(app).get('/api/music-video');+ expect(list.body.find((p) => p.id === project.id).autonomousRun.interrupted).toBe(true);++ await pin(__autonomousProcessId());+ const live = await request(app).get(`/api/music-video/${project.id}`);+ expect(live.body.autonomousRun.interrupted).toBe(false);+ expect((await projects.getProject(project.id)).autonomousRun).not.toHaveProperty('interrupted');+ });+});diff --git a/server/services/musicVideo/autonomousService.js b/server/services/musicVideo/autonomousService.jsindex 6a8df1013c..3b11fa3ab4 100644--- a/server/services/musicVideo/autonomousService.js+++ b/server/services/musicVideo/autonomousService.js@@ -116,6 +116,14 @@ export const presentAutonomousRun = (run) => (run? { ...run, interrupted: run.status === 'running' && run.processId !== PROCESS_ID }: null);+/** `presentAutonomousRun` for a project read; reader-only — never persist the result. */+export const presentProjectAutonomousRun = (project) => (project?.autonomousRun+ ? { ...project, autonomousRun: presentAutonomousRun(project.autonomousRun) }+ : project);++/** Test seam: this process's pin id. */+export const __autonomousProcessId = () => PROCESS_ID;+function publish(project, run) {musicVideoEvents.emit('autonomous', { projectId: project.id, runId: run.id, run: presentAutonomousRun(run), project: { ...project, autonomousRun: presentAutonomousRun(run) } });}