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

address review (claude): harden 3 LOW defensive-asymmetry gaps

Adam Eivy3c42dc95a710
diff --git a/client/src/hooks/useSceneRenderLifecycle.js b/client/src/hooks/useSceneRenderLifecycle.js
index 71ba121d87..62be97be2a 100644
--- a/client/src/hooks/useSceneRenderLifecycle.js
+++ b/client/src/hooks/useSceneRenderLifecycle.js
@@ -101,6 +101,10 @@ export default function useSceneRenderLifecycle({
const onAttach = (data) => cfgRef.current.apply(data);
// jobId → pending error-toast timer (running-cancel deferral; see onFailed).
const failTimers = new Map();
+ // Unmount/re-run guard for the deferred fail-toast fetch below: cleared in
+ // cleanup so a `getMediaJob` promise still in flight (or a re-arm) can't pop
+ // a "render failed" toast onto whatever page the user navigated to.
+ let mounted = true;
const settle = (data, failed) => {
const jobId = data?.generationId || data?.jobId;
if (!jobId) return;
@@ -132,14 +136,16 @@ export default function useSceneRenderLifecycle({
const armFailToast = (jobId, attempt = 0) => {
failTimers.set(jobId, setTimeout(() => {
failTimers.delete(jobId);
+ if (!mounted) return; // navigated away before the timer fired
getMediaJob(jobId)
.then((job) => {
+ if (!mounted) return; // unmounted while the status fetch was in flight
const status = job?.status;
if (status === 'canceled') return; // user cancel — never a failure toast
if (status === 'failed' || status === 'error') { toast.error(cfgRef.current.failMessage); return; }
if (attempt < 2) armFailToast(jobId, attempt + 1); // non-terminal: wait, don't toast yet
})
- .catch(() => toast.error(cfgRef.current.failMessage));
+ .catch(() => { if (mounted) toast.error(cfgRef.current.failMessage); });
}, 800));
};
const onFailed = (data) => {
@@ -175,6 +181,7 @@ export default function useSceneRenderLifecycle({
socket.off(completedEvent, onCompleted);
socket.off(failedEvent, onFailed);
socket.off(canceledEvent, onCanceled);
+ mounted = false;
for (const t of failTimers.values()) clearTimeout(t);
failTimers.clear();
};
diff --git a/server/services/cosTaskMerge.js b/server/services/cosTaskMerge.js
index 41e5254efe..9d858a59ba 100644
--- a/server/services/cosTaskMerge.js
+++ b/server/services/cosTaskMerge.js
@@ -234,7 +234,7 @@ export function mergeTaskLists(localTasks, remoteTasks, { now = Date.now() } = {
const merged = [];
const seen = new Set();
for (const l of local) {
- if (!l || typeof l.id !== 'string' || !l.id) continue;
+ if (!l || typeof l.id !== 'string' || !l.id || seen.has(l.id)) continue;
seen.add(l.id);
const r = remoteById.get(l.id);
if (!r) { merged.push(l); continue; }
@@ -243,6 +243,7 @@ export function mergeTaskLists(localTasks, remoteTasks, { now = Date.now() } = {
// Remote-only tasks — adopt so the backlog replicates both directions.
for (const r of remote) {
if (!r || typeof r.id !== 'string' || !r.id || seen.has(r.id)) continue;
+ seen.add(r.id);
merged.push(normalizeAdopted(r));
}
return merged;
diff --git a/server/services/cosTaskMerge.test.js b/server/services/cosTaskMerge.test.js
index 7a25bb901e..c805c5a5bb 100644
--- a/server/services/cosTaskMerge.test.js
+++ b/server/services/cosTaskMerge.test.js
@@ -34,6 +34,20 @@ describe('mergeTaskLists', () => {
expect(merged.map((t) => t.id).sort()).toEqual(['task-a', 'task-b']);
});
+ it('de-duplicates ids within each list — never emits a task id twice', () => {
+ // A hand-corrupted file (or any producer that leaks a duplicate id) must not
+ // round-trip into two task lines: the local loop skips an already-seen id and
+ // the remote-only loop records adopted ids so a repeated remote id is dropped.
+ const local = [task('dup-local'), task('dup-local', 'completed')];
+ const remote = [task('dup-remote'), task('dup-remote', 'in_progress')];
+ const merged = mergeTaskLists(local, remote, { now: NOW });
+ const ids = merged.map((t) => t.id);
+ expect(ids.filter((id) => id === 'dup-local')).toHaveLength(1);
+ expect(ids.filter((id) => id === 'dup-remote')).toHaveLength(1);
+ // First occurrence wins for the local duplicate (status stays 'pending').
+ expect(merged.find((t) => t.id === 'dup-local').status).toBe('pending');
+ });
+
it('adopts a remote-only task and re-derives priorityValue from its priority', () => {
const remote = [task('task-x', 'pending', { priority: 'CRITICAL', priorityValue: 999 })];
const [merged] = mergeTaskLists([], remote, { now: NOW });
diff --git a/server/services/musicVideo/render.js b/server/services/musicVideo/render.js
index 7c88853e4a..8ab1947af3 100644
--- a/server/services/musicVideo/render.js
+++ b/server/services/musicVideo/render.js
@@ -126,6 +126,10 @@ export async function resolveSceneClips(project) {
if (!entry || !videoPath || !existsSync(videoPath)) { missing.push(scene.videoHistoryId); continue; }
const duration = entry.numFrames && entry.fps ? entry.numFrames / entry.fps : null;
if (!duration || duration <= 0) { missing.push(scene.videoHistoryId); continue; }
+ // A dimensionless history entry would make buildMusicVideoFfmpegArgs emit
+ // `scale=undefined:undefined` (opaque ffmpeg failure); treat it as a missing
+ // clip so the caller gets the clean MISSING_CLIPS 4xx, matching the duration guard.
+ if (!entry.width || entry.width <= 0 || !entry.height || entry.height <= 0) { missing.push(scene.videoHistoryId); continue; }
clips.push({
sceneId: scene.sceneId,
videoPath,
diff --git a/server/services/musicVideo/render.test.js b/server/services/musicVideo/render.test.js
index 126be07a61..bccc95f403 100644
--- a/server/services/musicVideo/render.test.js
+++ b/server/services/musicVideo/render.test.js
@@ -137,6 +137,14 @@ describe('resolveSceneClips', () => {
await expect(resolveSceneClips({ scenes: [{ sceneId: 's1', order: 0, videoHistoryId: 'h1' }] }))
.rejects.toMatchObject({ status: 404, code: 'MISSING_CLIPS' });
});
+
+ it('throws MISSING_CLIPS for a dimensionless history entry instead of an opaque ffmpeg failure', async () => {
+ // A clip lacking width/height would render `scale=undefined:undefined`; treat
+ // it as a missing clip so the caller gets the clean 4xx (mirrors the duration guard).
+ loadHistory.mockResolvedValue([{ id: 'h1', filename: 'a.mp4', fps: 24, numFrames: 48 }]); // no width/height
+ await expect(resolveSceneClips({ scenes: [{ sceneId: 's1', order: 0, videoHistoryId: 'h1' }] }))
+ .rejects.toMatchObject({ status: 404, code: 'MISSING_CLIPS' });
+ });
});
describe('renderMusicVideo mutex (#1760 re-entrancy guard)', () => {