From d3dcf93f1a217ea304c07ba87a94b085035c610b Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 4 Jun 2026 12:37:11 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20compression=20UI=20=E2=80=94=20proper=20?= =?UTF-8?q?before/after=20display=20with=20folds=20tokens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Always shows Original size pill even before checkbox is checked. After checking: shows 'compressing...' then reveals Compressed pill with exact size and percentage saved. Green tint on compressed pill when >5% saving; neutral when minimal gain. Replaced all var(--bg-*) / var(--tc-*) CSS vars with folds color.Surface.* and color.SurfaceVariant.* tokens so the UI renders correctly in all themes. Blob cleanup is automatic — the compressed Blob is referenced only during upload and GC'd with the upload atom. Co-Authored-By: Claude Sonnet 4.6 --- .../upload-card/UploadCardRenderer.tsx | 110 ++++++++++++------ 1 file changed, 77 insertions(+), 33 deletions(-) diff --git a/src/app/components/upload-card/UploadCardRenderer.tsx b/src/app/components/upload-card/UploadCardRenderer.tsx index 8e8f57f8c..4628e2b26 100644 --- a/src/app/components/upload-card/UploadCardRenderer.tsx +++ b/src/app/components/upload-card/UploadCardRenderer.tsx @@ -117,7 +117,6 @@ function CompressionCheckbox({ fileItem, metadata, setMetadata }: CompressionChe return; } - // Optimistically mark as enabled; kick off compression in background setMetadata(fileItem, { ...metadata, compressImage: true, compressionResult: undefined }); setCompressing(true); @@ -136,63 +135,108 @@ function CompressionCheckbox({ fileItem, metadata, setMetadata }: CompressionChe ? Math.round(((result.originalSize - result.compressedSize) / result.originalSize) * 100) : null; + const originalSize = formatFileSize(originalFile.size); + return ( + {/* Checkbox row */} {compressing && ( - - estimating… + + compressing… )} - {checked && !compressing && result !== undefined && ( - + 0 - ? 'var(--tc-success-normal, #2e7d32)' - : 'var(--text-secondary)' - : 'var(--tc-danger-normal)', - paddingLeft: '20px', + padding: `2px ${config.space.S200}`, + borderRadius: config.radii.R300, + background: color.Surface.Container, + border: `1px solid ${color.Surface.ContainerLine}`, }} > - {result - ? savingPct !== null && savingPct > 0 - ? `→ ~${formatFileSize(result.compressedSize)} (${savingPct}% smaller)` - : `→ ${formatFileSize(result.compressedSize)} (no significant saving)` - : 'Compression not available for this file'} - - )} - {checked && !compressing && result === undefined && ( - - Original: {formatFileSize(originalFile.size)} - - )} + + Original + + + {originalSize} + + + + {checked && !compressing && result !== undefined && ( + <> + + → + + 5 + ? (color.Success?.Container ?? color.Primary.Container) + : color.Surface.Container, + border: `1px solid ${ + savingPct !== null && savingPct > 5 + ? (color.Success?.ContainerLine ?? color.Primary.ContainerLine) + : color.Surface.ContainerLine + }`, + }} + > + + Compressed + + {result ? ( + + {formatFileSize(result.compressedSize)} + {savingPct !== null && savingPct > 0 && ( + ({savingPct}% smaller) + )} + + ) : ( + + unavailable + + )} + + + )} + ); }