feat: support github's react-based diff ui#167
Merged
Conversation
This was referenced Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Support GitHub's new React-based "Files changed" UI (login-gated rollout,
/pull/N/changes) in the Chrome extension: Unity-file detection, the per-file toggle, semantic-view injection, and the global toggle bar now work on both the classic and the React layouts.Motivation
The extension only matched the classic DOM (
.file-header[data-path],.js-file-content); on the React UI those selectors match nothing and the extension silently does nothing. The React UI has been GitHub's default for logged-in users since late 2025, so the product's primary channel was at risk.Closes #159
Changes
parsePrUrlaccepts/pull/N/changesand/pull/N/changes/<sha>..<sha>(a single sha under/changes/is the commit view and stays out of scope), mirroringgithub-url-detectiondetect.ts:FileEntryis now a per-layout adapter (attachHost/setRawHidden/collapsed/globalAnchor); the classic and React scanners always both run, and the non-matching one yields[]harmlessly — no layout probe neededdiv[role="region"][id^="diff-"]plus hashed CSS-module class prefixes; the path is parsed from header text (LRM marks stripped,sr-onlyrename form preferred) because the React UI has no path attribute anywherecontent/index.ts: mounting goes through the adapter; a display-only, fetch-freesync()re-asserts hide/show on every scan because the React UI virtualizes the file list (TanStack Virtual) and recreates DOM nodes continuously; disconnected appliers are pruned every scan instead of only on PR changeDiffFileHeader-module__collapsedheader classpr-files-react.html+react.spec.tscovering detection/render, global-bar placement outside the virtualized list, collapse chevron + body remount re-hide, and a full virtualization remount inheriting the semantic defaultReact-UI DOM structure was cross-checked against refined-github, TombWater/github-codeowners, sudo-vaibhav/pr-diff-plus, dkareh/bookmarklets, DIO0550/github-html-preview-ext, a live-captured fixture (elad12390/group-gh-pr-files), and GitHub's own shipped component chunk (confirms
role="region",id="diff-${pathDigest}", header wrapper as first region child, and the CSS-module class map).Testing
pnpm test— 197 passed (17 files)pnpm typecheck— cleanpnpm lint— exit 0pnpm e2e— 14 passed (10 existing classic specs unchanged + 4 new react specs)Live verification on the real React UI (performed 2026-07-16)
Verified on https://github.com/hashiiiii/unity-yaml-playground/pull/2/changes in a logged-in browser session, by injecting the built
dist/content.jswith the samechrome.*stub the e2e suite uses (canned semantic-diff response; the background fetch/wasm path is covered separately by the existing unit + classic e2e layers):.metafiles correctly excluded, including a renamed one)sr-only"renamed to" form returns the new path)[data-testid="progressive-diffs-list"]sync()re-hides while the semantic view returnsDiff-module__diffHeaderWrapperas first region child, chevron icon swap,DiffFileHeader-module__collapsedclass stamped when collapsed)Manual verification (for reviewers)
/changes)