fix(code-review): order diff review files to match the changes file tree - #3736
fix(code-review): order diff review files to match the changes file tree#3736adboio 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 |
|
👋 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 PR has had no activity for 7 days and has been marked stale. We are moving to the monorepo and tightening PR staleness in preparation, so it will be closed in 7 days if no further activity occurs. |
|
Hey @adboio, we've migrated this repo into the PostHog/posthog monorepo, so this PR needs to be recreated there. Easiest path: check out the monorepo and run the Shout if you get stuck. |
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