[codex] Handle binary and video file changes

Merged
KI
4mo ago
+826-113

Summary

Adds explicit binary-file handling for the desktop Changes view so binary blobs are not loaded into the text diff renderer. Videos are treated as non-diffable in Changes and can now be previewed in the v2 FilePane using the same registry pattern as images.

Details

  • Propagates git --numstat binary markers through ChangedFile.isBinary.
  • Adds binary sniffing for untracked files before UTF-8 line counting.
  • Adds shared video file detection and MIME helpers.
  • Adds a v2 FilePane VideoView registered alongside ImageView.
  • Updates Changes diff rows to show a simple unsupported-diff state for binary/video files.
  • Updates virtualized row height estimates and focused tests.

Validation

  • bun test apps/desktop/src/shared/file-types.test.ts apps/desktop/src/lib/trpc/routers/changes/utils/parse-status.test.ts apps/desktop/src/renderer/screens/main/components/WorkspaceView/ChangesContent/components/VirtualizedFileList/utils/getEstimatedFileDiffSectionHeight.test.ts
  • bun run typecheck --filter=@superset/desktop
  • bun run lint

Open in Stage

Summary by cubic

Adds binary handling to Changes and the v2 DiffPane with a single placeholder that preserves review threads, and adds video previews to the v2 FilePane. Media detection is unified in @superset/shared/media-files, and untracked files are streamed to detect binaries and count lines with constant memory.

  • New Features

    • Propagates git --numstat binary markers into ChangedFile.isBinary (including renames); shares extension-based media detection via @superset/shared/media-files (raster images incl. TIFF, all video containers; SVG remains text).
    • Skips diff requests for binaries and shows a unified “Binary file hidden” placeholder with an “Open file” button; keeps review threads visible by re-anchoring to line 1; focuses/scrolls only for real diff items; disables editing and hides stats for binaries.
    • Adds video preview in the v2 FilePane (VideoView); includes helpers (isVideoFile, isPreviewableVideoFile, getVideoMimeType, getFileExtension) and reads videos as bytes.
  • Bug Fixes

    • Streams untracked files in 64KB chunks, sniffs the first 8KB for NULs, flags media by extension before reading, skips LOC for files >1MB, and counts lines correctly across chunk boundaries and CRLF.
    • Ensures isBinary propagates through host-service numstat, status snapshots, rename detection, desktop change lists, and parse-status; removes duplicate binary placeholder text; aligns Quick Open with the tree-click open flow for consistent reveal/pinning.
    • Updates virtualized heights and placeholders for binary/video files.

Summary by CodeRabbit

  • New Features
    • Binary diffs now show a dedicated “Binary file hidden” placeholder, with an optional “Open file” action.
    • Video files are now supported with a preview player and appropriate diff/placeholder behavior.
  • Bug Fixes
    • Binary/video status is propagated consistently across change lists, diff stats, and untracked file line counting (including safer binary detection and correct zeroed line counts).
    • Focus-line scrolling now targets only valid diff items; placeholder anchoring is more accurate.
    • Quick Open file selection now uses the tree-click open flow for consistent navigation.
  • Tests
    • Updated and expanded coverage for binary/video classification, numstat parsing, and untracked file line counting.