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
address review (copilot): whitelist /active params, guard resume against stale closure, drop tqdm message spam, add route tests
[._.]/ Adam Eivy193fdf8fbcae
diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsxindex 0fe438181c..0f8a126b95 100644--- a/client/src/pages/VideoGen.jsx+++ b/client/src/pages/VideoGen.jsx@@ -497,7 +497,13 @@ export default function VideoGen() {getActiveVideoJob().then((data) => {const job = data?.activeJob;if (!job?.jobId) return;- if (generating || eventSourceRef.current) return;+ // Bail if the user already started a render in this tab. `generating`+ // would be stale here (effect deps are []), so gate on the live ref:+ // runTokenRef is bumped at the top of every runGeneration() and stays+ // > 0 for the session afterward. eventSourceRef is also checked as a+ // belt-and-suspenders signal for the in-flight POST window before+ // attachJobEvents runs.+ if (runTokenRef.current > 0 || eventSourceRef.current) return;const p = job.params || {};if (p.prompt) setPrompt(p.prompt);if (p.negativePrompt) setNegativePrompt(p.negativePrompt);diff --git a/server/routes/videoGen.js b/server/routes/videoGen.jsindex 81953230bd..2cbacf83f0 100644--- a/server/routes/videoGen.js+++ b/server/routes/videoGen.js@@ -715,6 +715,26 @@ router.post('/', frameImageUpload, asyncHandler(async (req, res) => {// what cancelVideoGen() targets when nothing is running, so resuming the// oldest queued would leave the resumed page's Cancel button hitting a// different job.+//+// Whitelist the params the UI form actually consumes — `job.params`+// carries server-internal absolute file paths (sourceImagePath,+// audioFilePath, uploadedTempPath(s), extendFromVideoPath) and the+// resolved pythonPath, none of which belong on a client surface.+const ACTIVE_JOB_PARAM_FIELDS = [+ 'prompt', 'negativePrompt', 'modelId',+ 'width', 'height', 'numFrames', 'fps',+ 'steps', 'guidanceScale', 'seed',+ 'tiling', 'disableAudio', 'mode', 'chunks', 'imageStrength',+];+const pickJobParams = (params) => {+ if (!params || typeof params !== 'object') return {};+ const out = {};+ for (const k of ACTIVE_JOB_PARAM_FIELDS) {+ if (params[k] !== undefined) out[k] = params[k];+ }+ return out;+};+router.get('/active', (_req, res) => {const running = listJobs({ kind: 'video', status: 'running' })[0];const queuedList = !running ? listJobs({ kind: 'video', status: 'queued' }) : [];@@ -727,7 +747,7 @@ router.get('/active', (_req, res) => {generationId: job.id,status: job.status,position: job.position,- params: job.params || {},+ params: pickJobParams(job.params),},});});diff --git a/server/routes/videoGen.test.js b/server/routes/videoGen.test.jsindex bbc01db895..e01e80f604 100644--- a/server/routes/videoGen.test.js+++ b/server/routes/videoGen.test.js@@ -697,6 +697,82 @@ describe('videoGen routes', () => {});});+ describe('GET /active', () => {+ const listJobsByFilter = (jobs) => ({ status, kind } = {}) => jobs.filter((j) => {+ if (status && j.status !== status) return false;+ if (kind && j.kind !== kind) return false;+ return true;+ });++ it('returns { activeJob: null } when no video jobs exist', async () => {+ mediaJobQueue.listJobs.mockReturnValue([]);+ const r = await request(app).get('/api/video-gen/active');+ expect(r.status).toBe(200);+ expect(r.body).toEqual({ activeJob: null });+ });++ it('prefers the running job over queued jobs', async () => {+ mediaJobQueue.listJobs.mockImplementation(listJobsByFilter([+ { id: 'running-1', kind: 'video', status: 'running', position: 1, params: { prompt: 'P running' } },+ { id: 'queued-1', kind: 'video', status: 'queued', position: 2, params: { prompt: 'P queued' } },+ ]));+ const r = await request(app).get('/api/video-gen/active');+ expect(r.status).toBe(200);+ expect(r.body.activeJob.jobId).toBe('running-1');+ expect(r.body.activeJob.status).toBe('running');+ expect(r.body.activeJob.params.prompt).toBe('P running');+ });++ // Selection of the newest queued (not oldest) matches /cancel's fallback+ // selection — see the surrounding comment in routes/videoGen.js. Diverging+ // would mean Cancel from a resumed-queued page targets a different job.+ it('returns newest queued when nothing is running (matches /cancel order)', async () => {+ mediaJobQueue.listJobs.mockImplementation(listJobsByFilter([+ { id: 'queued-old', kind: 'video', status: 'queued', position: 1, params: { prompt: 'P old' } },+ { id: 'queued-new', kind: 'video', status: 'queued', position: 2, params: { prompt: 'P new' } },+ ]));+ const r = await request(app).get('/api/video-gen/active');+ expect(r.status).toBe(200);+ expect(r.body.activeJob.jobId).toBe('queued-new');+ expect(r.body.activeJob.status).toBe('queued');+ });++ // params is a whitelist — never leak server-internal absolute file paths+ // (sourceImagePath, audioFilePath, uploadedTempPath(s), extendFromVideoPath)+ // or the resolved pythonPath to the browser.+ it('whitelists params and never leaks server-internal file paths', async () => {+ mediaJobQueue.listJobs.mockImplementation(listJobsByFilter([+ { id: 'running-1', kind: 'video', status: 'running', position: 1, params: {+ prompt: 'safe prompt',+ modelId: 'ltx2_unified',+ width: 768, height: 512,+ numFrames: 121, fps: 24,+ steps: 25, guidanceScale: 3, seed: 42,+ tiling: 'auto', disableAudio: false, mode: 'text', chunks: 1,+ // sensitive fields that must NOT round-trip:+ pythonPath: '/Users/secret/venv/bin/python',+ sourceImagePath: '/Users/secret/data/uploads/source.png',+ audioFilePath: '/Users/secret/data/uploads/voice.wav',+ uploadedTempPath: '/tmp/upload-xyz',+ uploadedTempPaths: ['/tmp/last-abc'],+ extendFromVideoPath: '/Users/secret/data/videos/prev.mp4',+ } },+ ]));+ const r = await request(app).get('/api/video-gen/active');+ expect(r.status).toBe(200);+ const p = r.body.activeJob.params;+ expect(p.prompt).toBe('safe prompt');+ expect(p.modelId).toBe('ltx2_unified');+ expect(p.width).toBe(768);+ expect(p.pythonPath).toBeUndefined();+ expect(p.sourceImagePath).toBeUndefined();+ expect(p.audioFilePath).toBeUndefined();+ expect(p.uploadedTempPath).toBeUndefined();+ expect(p.uploadedTempPaths).toBeUndefined();+ expect(p.extendFromVideoPath).toBeUndefined();+ });+ });+describe('GET /:jobId/events', () => {it('returns 404 when the job is unknown', async () => {mediaJobQueue.attachSseClient.mockReturnValue(false);diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.jsindex a37de62298..a19839cc06 100644--- a/server/services/videoGen/local.js+++ b/server/services/videoGen/local.js@@ -815,7 +815,11 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', mif (m) {const pct = parseInt(m[1], 10) / 100;broadcastSse(job, { type: 'progress', progress: pct, message: line });- videoGenEvents.emit('progress', { generationId: jobId, progress: pct, message: line });+ // Omit `message` on the queue-dispatcher emit: the raw tqdm bar+ // (`60%|██████ | 6/10 [00:30<00:20, ...]`) is terminal noise that+ // would clobber the last meaningful STATUS/STAGE line on every+ // percent update. Client renders the percentage separately.+ videoGenEvents.emit('progress', { generationId: jobId, progress: pct });return true;}return false;