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 (codex): fix light-regen squeeze (two pipelines) + reach adaptive strength default from UI
[._.]/ Adam Eivyf7c0443e3d86
diff --git a/client/src/components/media/MediaLightbox.jsx b/client/src/components/media/MediaLightbox.jsxindex 60d91fff00..72e9ec9a6e 100644--- a/client/src/components/media/MediaLightbox.jsx+++ b/client/src/components/media/MediaLightbox.jsx@@ -389,6 +389,12 @@ function SettingsPane({const regenLightAvailable = !!regenBounds?.lightAvailable;const [regenOpen, setRegenOpen] = useState(false);const [regenStrength, setRegenStrength] = useState(regenDefault);+ // Track whether the user actually moved the slider. When untouched, the+ // request OMITS strength so the server picks its provider-aware default+ // (lighter for local-FLUX sources, conservative 0.25 for SynthID-bearing+ // ones). Always sending the slider's initialized value would pin 0.25 and+ // make that adaptive default unreachable from the UI.+ const [strengthTouched, setStrengthTouched] = useState(false);const [regenPrompt, setRegenPrompt] = useState('');const starred = !!annotation?.starred;const closeThenRun = (handler) => {@@ -666,7 +672,7 @@ function SettingsPane({max={regenMax}step={0.01}value={regenStrength}- onChange={(e) => setRegenStrength(Number(e.target.value))}+ onChange={(e) => { setRegenStrength(Number(e.target.value)); setStrengthTouched(true); }}disabled={regenerating}className="w-full accent-port-accent"/>@@ -689,10 +695,10 @@ function SettingsPane({<buttontype="button"disabled={regenerating || lightRegenerating}- onClick={runBusyAction(regenerating, setRegenerating, (it) => onRegenerate(it, { strength: regenStrength, prompt: regenPrompt.trim() || undefined }))}+ onClick={runBusyAction(regenerating, setRegenerating, (it) => onRegenerate(it, { strength: strengthTouched ? regenStrength : undefined, prompt: regenPrompt.trim() || undefined }))}className="w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs bg-port-accent text-white hover:opacity-90 rounded disabled:opacity-50 disabled:cursor-not-allowed">- <Wand2 className="w-3.5 h-3.5" /> {regenerating ? 'Queuing…' : `Regenerate at ${regenStrength.toFixed(2)}`}+ <Wand2 className="w-3.5 h-3.5" /> {regenerating ? 'Queuing…' : strengthTouched ? `Regenerate at ${regenStrength.toFixed(2)}` : 'Regenerate'}</button>{regenLightAvailable && (<buttondiff --git a/server/services/imageGen/regen.js b/server/services/imageGen/regen.jsindex be7fd5d6f9..bb8229e1da 100644--- a/server/services/imageGen/regen.js+++ b/server/services/imageGen/regen.js@@ -361,12 +361,16 @@ export async function applyLightRegen(buffer, { sharpImpl = sharp } = {}) {if (!(w > 0) || !(h > 0)) return null;const sw = floor16(w * REGEN_SQUEEZE_FACTOR);const sh = floor16(h * REGEN_SQUEEZE_FACTOR);- // No EXIF auto-orient: the gallery is PNG-only and PNGs carry no orientation- // tag, so a .rotate() would be a no-op whose dim math silently depends on that- // invariant. The squeeze targets (sw/sh) come from the un-rotated metadata, so- // skipping rotation keeps the resize aspect and the upscale-back dims exact.- const data = await sharpImpl(buffer)- .resize(sw, sh, { kernel: 'cubic' })+ // sharp applies only ONE resize per pipeline (a later .resize() OVERWRITES an+ // earlier one — they don't chain), so the downscale→upscale squeeze MUST be+ // two separate pipelines: render the squeezed buffer first, then upscale THAT+ // back to the source dims. A single chained `.resize(sw,sh).resize(w,h)` would+ // silently drop the downscale and skip the resolution shift that disrupts+ // SynthID's resolution-dependent carriers — i.e. the light pass's whole point.+ // No EXIF auto-orient: the gallery is PNG-only (no orientation tag), so the+ // squeeze targets from un-rotated metadata keep the aspect and upscale-back exact.+ const squeezed = await sharpImpl(buffer).resize(sw, sh, { kernel: 'cubic' }).png().toBuffer();+ const data = await sharpImpl(squeezed).resize(w, h, { fit: 'fill', kernel: 'lanczos3' }).modulate({ brightness: 1.01, saturation: 0.99, hue: 1 }).linear(1.02, -2)diff --git a/server/services/imageGen/regen.sharp.test.js b/server/services/imageGen/regen.sharp.test.jsindex 947f981a1d..07909c5966 100644--- a/server/services/imageGen/regen.sharp.test.js+++ b/server/services/imageGen/regen.sharp.test.js@@ -62,6 +62,34 @@ describe('applyLightRegen', () => {expect(delta.pixelDeltaPct).toBeGreaterThan(0);});+ it('actually applies the resize-squeeze, not just the color/sharpen ops', async () => {+ // Regression guard: sharp collapses chained .resize() calls to the last one,+ // so a single-pipeline implementation silently skips the downscale→upscale+ // squeeze. Build a 1px-stripe (max high-frequency) image where the squeeze+ // measurably blurs, and assert the real output differs from the same ops+ // WITHOUT the squeeze — if the squeeze regresses, the two become identical.+ const w = 256, h = 64;+ const raw = Buffer.alloc(w * h * 3);+ for (let y = 0; y < h; y++) {+ for (let x = 0; x < w; x++) {+ const v = x % 2 ? 255 : 0;+ const o = (y * w + x) * 3;+ raw[o] = raw[o + 1] = raw[o + 2] = v;+ }+ }+ const stripes = await sharp(raw, { raw: { width: w, height: h, channels: 3 } }).png().toBuffer();+ const withSqueeze = (await applyLightRegen(stripes)).data;+ const noSqueeze = await sharp(stripes)+ .modulate({ brightness: 1.01, saturation: 0.99, hue: 1 })+ .linear(1.02, -2)+ .median(2)+ .sharpen()+ .png({ compressionLevel: 6 })+ .toBuffer();+ const delta = await computePixelDelta(withSqueeze, noSqueeze);+ expect(delta.pixelDeltaPct).toBeGreaterThan(0);+ });+it('returns null for an undecodable buffer', async () => {expect(await applyLightRegen(Buffer.from('nope'))).toBeNull();});