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

perf: load image regeneration metrics only when needed (#7040)

[._.]/ Adam Eivy6a0939edb761
diff --git a/server/lib/importScoping.test.js b/server/lib/importScoping.test.js
index efef14be86..8ce139138a 100644
--- a/server/lib/importScoping.test.js
+++ b/server/lib/importScoping.test.js
@@ -38,6 +38,8 @@ const reaches = (entry, target) => staticImportClosure(abs(entry)).files.has(abs
// Each row: the entry that was narrowed, the module it must no longer
const NARROWED = [
+ ['services/imageGen/local.js', 'services/imageGen/regen.js',
+ 'loads pixel comparison only for a regeneration, not gallery reads'],
['services/github.js', 'services/settings.js',
'loads settings only for secret operations, not repository reads or sync'],
['services/sharing/peerSyncPush.js', 'services/writersRoom/bibleSync.js',
diff --git a/server/services/imageGen/local.js b/server/services/imageGen/local.js
index 7d9c4443e6..ec270ee54e 100644
--- a/server/services/imageGen/local.js
+++ b/server/services/imageGen/local.js
@@ -35,7 +35,6 @@ import { claimHeavyLocalJob } from '../../lib/heavyJobClaim.js';
import { prepareLocalMemory, gpuBlockersMessage } from '../localMemory.js';
import { safeChildProcessOptions } from '../../lib/processEnv.js';
import { IMAGE_GEN_MODE, LOCAL_IMAGEGEN_DEFAULT_MODEL } from './modes.js';
-import { computePixelDelta } from './regen.js';
import { parseByteProgress, formatDownloadMessage } from '../videoGen/generateVideoHelpers.js';
const IS_WIN = process.platform === 'win32';
@@ -1022,7 +1021,9 @@ export async function generateImage({ pythonPath, prompt = '', negativePrompt =
// mflux strength-0.0 footgun, silent txt2img fallbacks, and over-mutation.
// Best-effort — a decode failure just skips the stamp.
if (regenOf && validInitImagePath) {
- const delta = await computePixelDelta(validInitImagePath, outputPath).catch(() => null);
+ const delta = await import('./regen.js')
+ .then(({ computePixelDelta }) => computePixelDelta(validInitImagePath, outputPath))
+ .catch(() => null);
if (delta) {
meta.regenPixelDeltaPct = delta.pixelDeltaPct;
meta.regenPsnr = delta.psnr;