Skip to content

Conversation

danvk
Copy link
Owner

@danvk danvk commented May 31, 2025

Deals with some of the tasks in #239.

Also refactors some of the options code.

Warning banner if the first line is longer than 200k:

image

Message if the content is identical post-normalization:

image

I went with z as the shortcut for normalization.

@danvk danvk requested a review from Copilot May 31, 2025 20:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements JSON normalization features and refactors diff options handling alongside some UI tweaks. Key changes include renaming CSS classes for diff mode controls, consolidating diff options parsing/encoding in TypeScript, and adding the keyboard shortcut z for JSON normalization.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
webdiff/static/css/style.css Renamed CSS classes from image-diff-controls to diff-mode-controls and added styling for warning banner.
ts/utils.ts Added a new Unionize type.
ts/options.ts Refactored options logic to merge GitDiffOptions into a unified Options interface.
ts/diff-options.ts Renamed and updated encoding/decoding functions to operate on GitDiffOptions.
ts/codediff/codediff.tsx Introduced a safety check for large diffs with a bypass mechanism.
ts/codediff/NormalizeJSONOption.tsx Updated normalization option component with new class names and label text.
ts/DiffView.tsx, ts/DiffOptions.tsx, ts/CodeDiffContainer.tsx, ts/Root.tsx Updated diff options usages and renamed functions to align with new options workflow.
ts/ImageDiff.tsx Updated image diff controls to use the new diff-mode-controls class and added an explicit property for normalization equality.
ts/tests/diff-options.test.ts Updated tests to use the new diff options functions.
Other files Version bump and minor adjustments in test data and project config.
Comments suppressed due to low confidence (1)

ts/Root.tsx:63

  • Consider using a functional update (e.g., setDiffOptions(prev => ({...prev, ...update(prev)}))) to merge option changes, which can help prevent potential stale closure issues when options are updated asynchronously.
const updateOptions = React.useCallback<UpdateOptionsFn>( update => { setDiffOptions({...options, ...(typeof update === 'function' ? update(options) : update)}); }, [options, setDiffOptions]);

@danvk danvk merged commit 4a88ab5 into main May 31, 2025
2 checks passed
@danvk danvk deleted the json-followup branch May 31, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant