fix(code-review): order diff review files to match the changes file tree#3736
Draft
adboio wants to merge 2 commits into
Draft
fix(code-review): order diff review files to match the changes file tree#3736adboio wants to merge 2 commits into
adboio wants to merge 2 commits into
Conversation
The diff review panel listed files in git-diff order (byte/ASCII sort: uppercase first) while the changes file tree beside it sorts with localeCompare and groups directory contents together, so the two views diverged as you scrolled. Untracked files also clustered at the end of "Changes" in the review instead of interleaving by path like the tree. Extract the tree's build/compact/flatten logic into a shared @posthog/core helper and have both the changes tree and the review list consume it, so the review mirrors the tree's leaf order (staged group and the merged unstaged+untracked "Changes" group) by construction. Generated-By: PostHog Code Task-Id: 4eb23888-6afa-4fb9-9b7a-22d6a48e1721
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
👋 Visual changes detected for this PR. Review and approve in PostHog Visual Review If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix. |
…irection Cleanup pass on the diff-review-matches-file-tree change: - Extract orderedTreeDirs/orderedTreeFiles into the shared changeTree helper and have both flattenNode (review ordering) and ChangesTreeView (the rendered tree) consume them. The two surfaces now share one traversal, so they can't drift on sort order again — the original bug. - Drop the orderPathsLikeTree/sortReviewItemsByTreeOrder re-export aliases from reviewItemBuilders; ReviewPage imports the core helpers directly. Removes a layer of indirection with no consumer relying on the renamed names. - Drop the unused TreeNode/buildChangesTree/compactTree back-compat aliases from ChangesTreeView; it uses the core names directly. Net -73 lines; behavior unchanged. Generated-By: PostHog Code Task-Id: 4eb23888-6afa-4fb9-9b7a-22d6a48e1721
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.
Problem
In the diff review panel, files scroll past in a different order than they appear in the changes file tree beside it, so the two views disagree as you navigate.
Why
The review list rendered files in raw git-diff order (byte/ASCII sort — uppercase paths first), while the changes tree sorts with
localeCompareand groups a directory's contents together. Untracked files also dumped at the end of "Changes" in the review instead of interleaving by path like the tree does. SoBeta.txt/ZETA_CAPS.txtjumped to the top in the review but sat mid-list in the tree.Changes
@posthog/core/git-interaction/changeTree(buildChangeTree,compactChangeTree,flattenChangeTree, plusorderPathsLikeChangeTreeand a genericsortByChangeTreeOrder).ChangesTreeViewnow imports the shared tree builders instead of defining its own, so the tree and the review share one source of truth for ordering.How did you test this?
Created with PostHog Code