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 (codex): stage annotation snapshot under a GC-swept name

Adam Eivy5273afd8e312
diff --git a/server/routes/imageGen.js b/server/routes/imageGen.js
index 8912ad8f0f..0f7ba8a146 100644
--- a/server/routes/imageGen.js
+++ b/server/routes/imageGen.js
@@ -724,9 +724,11 @@ router.post('/:filename/regenerate', asyncHandler(async (req, res) => {
// sidecar path directly would make the re-render ignore the annotation.
// Stage a snapshot of the flattened annotation into the image-refs root the
// runner accepts; the copy also freezes the markup at enqueue time so a
- // later re-save can't change what this queued job renders from.
+ // later re-save can't change what this queued job renders from. Use the
+ // `init-<uuid>` name (it IS this job's init image) so imageRefsGc.js sweeps
+ // it once unreferenced — a canceled/failed re-render doesn't leak the file.
await ensureDir(PATHS.imageRefs);
- initImageAbsPath = join(PATHS.imageRefs, `annot-${randomUUID()}.png`);
+ initImageAbsPath = join(PATHS.imageRefs, `init-${randomUUID()}.png`);
await copyFile(sketchPngPath, initImageAbsPath);
}
diff --git a/server/routes/imageGen.test.js b/server/routes/imageGen.test.js
index 061b270f46..e11dbef4f9 100644
--- a/server/routes/imageGen.test.js
+++ b/server/routes/imageGen.test.js
@@ -1233,8 +1233,10 @@ describe('Image Gen Routes', () => {
expect(params.annotatedRegen).toBe(true);
expect(params.initImageStrength).toBe(regen.REGEN_ANNOTATED_STRENGTH_DEFAULT);
// Regression guard for the silently-dropped-init-image bug: the staged
- // path must resolve under an approved image-input root.
- expect(params.initImagePath).toContain('image-refs');
+ // path must resolve under an approved image-input root, AND carry the
+ // `init-<uuid>` name that imageRefsGc.js sweeps (so a canceled re-render
+ // doesn't leak the snapshot).
+ expect(params.initImagePath).toMatch(/[/\\]image-refs[/\\]init-[0-9a-f-]+\.png$/i);
expect(fileUtils.resolveImageInputPath(params.initImagePath)).not.toBeNull();
await rm(params.initImagePath, { force: true });