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([issue-912]): restrict regen to reliable-i2i runners + anchor variant grouping at root
[._.]/ Adam Eivy3f9dd4d7cc01
diff --git a/server/services/imageGen/regen.js b/server/services/imageGen/regen.jsindex 38c98d892f..272aa49da4 100644--- a/server/services/imageGen/regen.js+++ b/server/services/imageGen/regen.js@@ -46,14 +46,23 @@ export const REGEN_STRENGTH_MAX = 0.6;// share the FLUX.2 venv and implement img2img via `--image-path`.export const modelUsesFluxVenv = (model) => isFlux2(model) || usesDiffusersRunner(model);-// Whether a model can do the img2img round-trip regen needs. FLUX.2/diffusers-// runners do i2i on every platform. The legacy mflux path does i2i on macOS-// (`mflux-generate --image-path`), but on Windows `imagine_win.py` silently-// drops the init-image args — a regen there would degrade to txt2img and-// produce an unrelated image, so it's excluded.+// Whether a model RELIABLY does the img2img round-trip regen needs — i.e. it+// honors the init image rather than silently degrading to txt2img (which would+// make `regenerated: true` a lie). Capability, not installed-state.+//+// - FLUX.2 (`scripts/flux2_macos.py`) — the intended i2i path; --image-path+// is forwarded to the pipeline. Regen-capable on every platform.+// - The broader diffusers family (Z-Image / ERNIE / HiDream / Qwen via+// `scripts/z_image_turbo.py`) — EXCLUDED: that runner explicitly+// "falls back to txt2img and ignores the init image" when a model family+// has no i2i sibling, so JS can't know from here whether the round-trip+// actually happened. Excluding them keeps the lineage honest.+// - Legacy mflux — reliable i2i on macOS (`mflux-generate --image-path`);+// Windows `imagine_win.py` drops the init-image args, so excluded there.export function modelSupportsRegen(model) {if (!model) return false;- if (modelUsesFluxVenv(model)) return true;+ if (isFlux2(model)) return true;+ if (usesDiffusersRunner(model)) return false;return !IS_WIN;}@@ -139,6 +148,15 @@ export function buildRegenParams({ filename, sourceAbsPath, sourceMeta = {}, souconst prompt = typeof sourceMeta.prompt === 'string' && sourceMeta.prompt.trim()? sourceMeta.prompt: 'high quality, highly detailed';+ // Anchor the variant-grouping lineage at the ROOT original, not the clicked+ // image. computeImageVariantGroup groups siblings under a single original+ // (an item with no `cleanedFrom`); regenerating a cleaned/regenerated variant+ // must therefore stamp the root's filename as `cleanedFrom` (= `regenOf`),+ // or the new render orphans from the family's variant switch. Pixels still+ // come from the clicked image (`sourceAbsPath`).+ const groupRoot = typeof sourceMeta.cleanedFrom === 'string' && sourceMeta.cleanedFrom+ ? sourceMeta.cleanedFrom+ : filename;const params = {mode: IMAGE_GEN_MODE.LOCAL,pythonPath,@@ -147,7 +165,7 @@ export function buildRegenParams({ filename, sourceAbsPath, sourceMeta = {}, sounegativePrompt: typeof sourceMeta.negativePrompt === 'string' ? sourceMeta.negativePrompt : '',initImagePath: sourceAbsPath,initImageStrength: strength,- regenOf: filename,+ regenOf: groupRoot,};if (dims) {params.width = dims.width;diff --git a/server/services/imageGen/regen.test.js b/server/services/imageGen/regen.test.jsindex 95f1ed1d33..eb2159bf78 100644--- a/server/services/imageGen/regen.test.js+++ b/server/services/imageGen/regen.test.js@@ -59,11 +59,17 @@ describe('orderRegenCandidates', () => {});describe('modelSupportsRegen / modelUsesFluxVenv', () => {- it('flux2 + diffusers models use the flux venv and support regen', () => {+ it('flux2 + diffusers models both use the flux venv (availability detection)', () => {expect(modelUsesFluxVenv(FLUX2)).toBe(true);expect(modelUsesFluxVenv(ZIMAGE)).toBe(true);+ });++ it('only FLUX.2 (not the broader diffusers family) is regen-capable', () => {+ // FLUX.2 reliably honors --image-path; Z-Image/ERNIE/HiDream/Qwen can+ // silently fall back to txt2img (z_image_turbo.py), so excluded to keep+ // the regenerated lineage honest.expect(modelSupportsRegen(FLUX2)).toBe(true);- expect(modelSupportsRegen(ZIMAGE)).toBe(true);+ expect(modelSupportsRegen(ZIMAGE)).toBe(false);});it('legacy mflux is not a flux-venv model', () => {@@ -100,12 +106,28 @@ describe('resolveRegenBackend', () => {expect(r.reason).toMatch(/no local flux runner is installed/i);});- it('prefers the source model when it is runnable', async () => {- vi.mocked(getImageModels).mockReturnValue([FLUX2, ZIMAGE]);+ it('prefers the source model when it is regen-capable and runnable', async () => {+ const FLUX2_DEV = { id: 'flux2-dev', runner: 'flux2', cfgDisabled: false };+ vi.mocked(getImageModels).mockReturnValue([FLUX2, FLUX2_DEV]);+ vi.mocked(isFlux2VenvHealthy).mockResolvedValue(true);+ const r = await resolveRegenBackend({ sourceModelId: 'flux2-dev' });+ expect(r.available).toBe(true);+ expect(r.model.id).toBe('flux2-dev');+ });++ it('skips a regen-incapable source model (diffusers) and falls to FLUX.2', async () => {+ vi.mocked(getImageModels).mockReturnValue([ZIMAGE, FLUX2]);vi.mocked(isFlux2VenvHealthy).mockResolvedValue(true);const r = await resolveRegenBackend({ sourceModelId: 'z-image-turbo' });expect(r.available).toBe(true);- expect(r.model.id).toBe('z-image-turbo');+ expect(r.model.id).toBe('flux2-klein-9b');+ });++ it('reports unavailable when only regen-incapable diffusers models exist', async () => {+ vi.mocked(getImageModels).mockReturnValue([ZIMAGE]);+ vi.mocked(isFlux2VenvHealthy).mockResolvedValue(true);+ const r = await resolveRegenBackend();+ expect(r.available).toBe(false);});});@@ -136,6 +158,27 @@ describe('buildRegenParams', () => {});});+ it('anchors regenOf at the root original when regenerating a cleaned variant', () => {+ // Regen of `a_clean-aggressive.png` (cleanedFrom: a.png) must group under+ // a.png, not orphan under the clicked variant. Pixels still come from the+ // clicked image (initImagePath stays sourceAbsPath).+ const params = buildRegenParams({+ filename: 'a_clean-aggressive.png',+ sourceAbsPath: '/data/images/a_clean-aggressive.png',+ sourceMeta: { prompt: 'x', cleanedFrom: 'a.png' },+ model: FLUX2,+ pythonPath: null,+ strength: 0.4,+ });+ expect(params.regenOf).toBe('a.png');+ expect(params.initImagePath).toBe('/data/images/a_clean-aggressive.png');+ });++ it('uses the clicked filename as regenOf when regenerating an original', () => {+ const params = buildRegenParams({ ...base, sourceMeta: { prompt: 'x' } });+ expect(params.regenOf).toBe('source.png');+ });+it('prefers measured sourceDims over the sidecar dimensions', () => {const params = buildRegenParams({...base,