From 97dc39468248b80a31bee08d5a74090c6f4a0bab Mon Sep 17 00:00:00 2001 From: "[._.]/ Adam Eivy" Date: Fri, 5 Jun 2026 11:50:37 -0700 Subject: [PATCH] refactor([issue-912]): /simplify cleanups on the regen follow-ups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quality pass over #970/#971 (no behavior change): - MediaLightbox: drop the bespoke runRegen handler and reuse the existing runBusyAction for the Regenerate run button; collapse the three slider-bound fallback ternaries into one destructure with defaults. - regen.js buildRegenParams: store the trimmed prompt once instead of re-deriving the hasPrompt guard for prompt and negativePrompt. - local.js upscale: drop redundant Number() casts in the guard and use PNG compressionLevel 6 (sharp default) instead of 9 — near-identical size, faster re-encode on the render-completion path. --- client/src/components/media/MediaLightbox.jsx | 20 ++----------------- server/services/imageGen/local.js | 11 +++++----- server/services/imageGen/regen.js | 6 +++--- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/client/src/components/media/MediaLightbox.jsx b/client/src/components/media/MediaLightbox.jsx index a365f509d..1570ebf7a 100644 --- a/client/src/components/media/MediaLightbox.jsx +++ b/client/src/components/media/MediaLightbox.jsx @@ -378,26 +378,10 @@ function SettingsPane({ // optional prompt) so a watermark-defeat pass can be tuned without leaving the // lightbox. Slider bounds come from the server (`regenBounds`) so the floor // stays in lock-step with route validation. - const regenMin = typeof regenBounds?.strengthMin === 'number' ? regenBounds.strengthMin : 0.02; - const regenMax = typeof regenBounds?.strengthMax === 'number' ? regenBounds.strengthMax : 0.6; - const regenDefault = typeof regenBounds?.strengthDefault === 'number' ? regenBounds.strengthDefault : 0.25; + const { strengthMin: regenMin = 0.02, strengthMax: regenMax = 0.6, strengthDefault: regenDefault = 0.25 } = regenBounds || {}; const [regenOpen, setRegenOpen] = useState(false); const [regenStrength, setRegenStrength] = useState(regenDefault); const [regenPrompt, setRegenPrompt] = useState(''); - const runRegen = async () => { - if (regenerating) return; - setRegenerating(true); - let ok = false; - try { - await onRegenerate(item, { strength: regenStrength, prompt: regenPrompt.trim() || undefined }); - ok = true; - } catch { - // Caller toasts its own error; stay open so the user can retry. - } finally { - setRegenerating(false); - } - if (ok) onClose(); - }; const starred = !!annotation?.starred; const closeThenRun = (handler) => { onClose?.(); @@ -697,7 +681,7 @@ function SettingsPane({