Fix graph routing for dirty worktrees#56
Open
noahbclarkson wants to merge 1 commit into
Open
Conversation
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
Fixes graph rendering for dirty (uncommitted-changes) worktrees so a worktree's pending-changes pseudo-node is drawn as a proper child of its HEAD commit rather than being spliced inline onto an existing child→parent path.
Previously, when a worktree's HEAD already had a real child commit visible in the graph, the pending-changes node was placed on the HEAD's own lane. It then visually consumed the real child's incoming edge, producing crossed/overlapping lines and a misleading "the worktree is the parent of this commit" layout.
What changed
All logic lives in
crates/rgitui_graph/src/lib.rs.graph_lane_count) and carries an explicit edge back toparent_lane.WorktreeRowPositiongainedparent_lane: Option<usize>— the lane of the visible HEAD commit the pseudo-node descends from.Nonefor orphan worktrees (unborn HEAD, or HEAD outside the loaded commit window), which intentionally draw no dangling parent edge.GraphStyle(Curvedquarter-arc,Railsmid-step,Angularelbow), and draws nothing for orphan rows.compute_worktree_row_positions,worktree_pass_through_edges, andworktree_targets_commit_immediately_above— out ofGraphViewmethods and the render closure, so the routing logic is testable without a display.Tests
Added unit tests covering the previously-broken cases:
dirty_worktree_beside_real_child_uses_sibling_lane— the original bug: worktree HEAD has a real child, so the pseudo-node takes a sibling lane with a parent edge instead of hijacking the child's lane.dirty_worktree_at_branch_tip_reuses_tip_lane— a tip HEAD with no child keeps the natural lane.worktrees_sharing_a_head_are_siblings_not_a_chain— multiple dirty worktrees on one HEAD stack as siblings; the current worktree keeps the natural lane.unloaded_worktree_head_has_no_false_parent_edge— out-of-window HEAD becomes an orphan with no parent edge.Test plan
cargo test -p rgitui_graphcargo clippy --workspace --all-targets -- -D warningscargo fmt --all --check🤖 Generated with Claude Code