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): octet-stream upload + honest lossy labeling (#1763)
[._.]/ Adam Eivy8837754ab1b6
diff --git a/client/src/pages/ImageClean.jsx b/client/src/pages/ImageClean.jsxindex 65d7b69ce9..27b0ac5c8b 100644--- a/client/src/pages/ImageClean.jsx+++ b/client/src/pages/ImageClean.jsx@@ -160,7 +160,7 @@ export default function ImageClean() {{key: 'metadata',label: 'Strip metadata & C2PA',- hint: 'Lossless — removes the C2PA provenance chunk plus EXIF/XMP/IPTC and PNG text chunks. Pixels untouched.',+ hint: 'Removes the C2PA provenance chunk plus EXIF/XMP/IPTC and text metadata. Lossless for PNG (pixels untouched); JPEG/WebP are re-encoded.',},{key: 'denoise',@@ -340,6 +340,11 @@ export default function ImageClean() {<span className={`w-2 h-2 rounded-full ${s.status === 'applied' ? 'bg-port-success' : 'bg-gray-600'}`} /><span className="text-white capitalize">{s.step}</span><span className="text-gray-500">— {s.status}{s.detail ? ` (${s.detail})` : ''}</span>+ {s.status === 'applied' && (+ <span className={`text-xs px-1.5 py-0.5 rounded ${s.lossless ? 'bg-port-success/15 text-port-success' : 'bg-port-warning/15 text-port-warning'}`}>+ {s.lossless ? 'lossless' : 'lossy'}+ </span>+ )}</li>))}</ul>diff --git a/client/src/services/apiMedia.js b/client/src/services/apiMedia.jsindex 4b5b16a650..85cc50de64 100644--- a/client/src/services/apiMedia.js+++ b/client/src/services/apiMedia.js@@ -41,9 +41,16 @@ export const cleanImage = async (file, steps = {}) => {if (typeof steps.denoise === 'boolean') params.set('denoise', steps.denoise ? '1' : '0');const qs = params.toString();+ // Always send application/octet-stream rather than the browser's reported+ // file.type. The server sniffs the real format from magic bytes, so a file+ // the page accepted by extension despite an unreliable MIME (image/jpg,+ // image/pjpeg, text/plain, or empty) must not be forwarded with a type the+ // route's express.raw() type-filter would refuse to parse — that would fail+ // with an empty body before the magic-byte sniff ever runs. octet-stream is+ // always in the parser's accepted set.const response = await fetch(`${API_BASE}/image-clean${qs ? `?${qs}` : ''}`, {method: 'POST',- headers: { 'Content-Type': file.type || 'application/octet-stream' },+ headers: { 'Content-Type': 'application/octet-stream' },body: file,}).catch(() => null);diff --git a/server/lib/imageClean.js b/server/lib/imageClean.jsindex 8a1d2ae19b..a010067394 100644--- a/server/lib/imageClean.js+++ b/server/lib/imageClean.js@@ -266,8 +266,8 @@ export async function cleanImageBuffer(buffer, options = {}) {width = info.width || null;height = info.height || null;c2paStripped = hadC2PA;- if (metadata) steps.push({ step: 'metadata', status: 'applied', detail: 'dropped via re-encode' });- steps.push({ step: 'denoise', status: 'applied', detail: 'median(3) + sharpen' });+ if (metadata) steps.push({ step: 'metadata', status: 'applied', lossless: false, detail: 'dropped via re-encode' });+ steps.push({ step: 'denoise', status: 'applied', lossless: false, detail: 'median(3) + sharpen' });} else if (metadata && format === 'png') {// Lossless PNG path: walk chunks and emit a new buffer minus the metadata// chunks. Pixels byte-identical, no decode/re-encode.@@ -280,20 +280,22 @@ export async function cleanImageBuffer(buffer, options = {}) {steps.push({step: 'metadata',status: stripped.stripped ? 'applied' : 'noop',+ lossless: true,detail: stripped.stripped ? `dropped ${stripped.droppedTypes.join(', ')}` : 'no metadata chunks found',});} else if (metadata) {// JPEG/WebP have no cheap lossless chunk-walk; re-encode through sharp,// which drops metadata by default. .rotate() bakes EXIF orientation into// pixels first so the image still displays right-side-up after the tag is- // dropped. This is a re-encode (not strictly lossless) — the format- // carries no separate lossless metadata path here.+ // dropped. This is a re-encode, NOT lossless — the format carries no+ // separate lossless metadata path here, so the step is flagged lossy and+ // the UI surfaces that (don't claim pixels are untouched for these).const base = sharp(buffer, { limitInputPixels: MAX_PIXELS }).rotate();const { data, info } = await applyEncoder(base, format).toBuffer({ resolveWithObject: true });outData = data;width = info.width || null;height = info.height || null;- steps.push({ step: 'metadata', status: 'applied', detail: 'dropped via re-encode' });+ steps.push({ step: 'metadata', status: 'applied', lossless: false, detail: 'dropped via re-encode (lossy)' });} else {// No steps selected — return the input untouched, but still report dims.const meta = await sharp(buffer, { limitInputPixels: MAX_PIXELS }).metadata();