From ff8accba87006f70a4d4fde3f68e850c973f07f6 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 15 May 2026 18:46:43 -0700 Subject: [PATCH] Fix full-height image diffs in combined view Preserve intrinsic image height for binary image diffs in combined View all mode while keeping text diffs on measured Monaco heights. --- .../src/components/editor/DiffSectionItem.tsx | 28 +++---- .../src/components/editor/ImageDiffViewer.tsx | 57 ++++++++++--- .../src/components/editor/ImageViewer.tsx | 37 ++++++-- .../editor/diff-section-layout.test.ts | 84 +++++++++++++++++++ .../components/editor/diff-section-layout.ts | 38 +++++++++ 5 files changed, 210 insertions(+), 34 deletions(-) create mode 100644 src/renderer/src/components/editor/diff-section-layout.test.ts create mode 100644 src/renderer/src/components/editor/diff-section-layout.ts diff --git a/src/renderer/src/components/editor/DiffSectionItem.tsx b/src/renderer/src/components/editor/DiffSectionItem.tsx index 351bb9631..b4e6dea45 100644 --- a/src/renderer/src/components/editor/DiffSectionItem.tsx +++ b/src/renderer/src/components/editor/DiffSectionItem.tsx @@ -23,8 +23,10 @@ import { getDiffCommentPopoverTop } from '../diff-comments/diff-comment-popover- import { applyDiffEditorLineNumberOptions } from './diff-editor-line-number-options' import { computeLineStats } from './diff-line-stats' import { DiffSectionHeader } from './DiffSectionHeader' +import { getDiffSectionBodyHeight, isIntrinsicHeightImageDiff } from './diff-section-layout' import type { DiffSection } from './diff-section-types' import type { DiffComment } from '../../../../shared/types' +import { cn } from '@/lib/utils' import { isDiffComment } from '@/lib/diff-comment-compat' const ImageDiffViewer = lazy(() => import('./ImageDiffViewer')) @@ -217,6 +219,15 @@ export function DiffSectionItem({ : computeLineStats(section.originalContent, section.modifiedContent, section.status), [section.loading, section.originalContent, section.modifiedContent, section.status] ) + // Why: image diffs need document-flow height in the combined view; the text + // fallback only knows line counts and would squash screenshots into one row. + const useIntrinsicImageHeight = isIntrinsicHeightImageDiff(section.diffResult) + const sectionBodyHeight = getDiffSectionBodyHeight({ + measuredContentHeight: sectionHeight, + originalContent: section.originalContent, + modifiedContent: section.modifiedContent, + useIntrinsicImageHeight + }) const handleOpenInEditor = (e: React.MouseEvent): void => { e.stopPropagation() @@ -292,20 +303,8 @@ export function DiffSectionItem({ {!section.collapsed && (