Repository navigation
refactor(list): extract WorktreePresence for the worktree gutter arm - #3154
Merged
Merged
Conversation
ItemKind::gutter_glyph's worktree arm branched inline on is_current and is_main. Extract that precedence into a typed WorktreePresence enum (Current/Primary/Linked) with its own gutter_glyph, mirroring BranchScope so both match arms read X.gutter_glyph(). WorktreePresence is derived from WorktreeData (via WorktreeData::presence), not stored like BranchScope: is_current and is_main are orthogonal bits (the main worktree is also current when you sit in it), and is_main is consumed independently by the status column and JSON, so the pair can't collapse into one stored discriminant. is_current wins when both are set. Behavior is byte-identical (no snapshot churn); adds the previously untested both-current-and-primary precedence case to the gutter test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk-bot
approved these changes
Jun 22, 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.
What
Extracts the worktree gutter-glyph classification in
ItemKind::gutter_glyph()from an inlineif is_current { '@' } else if is_main { '^' } else { '+' }into a typedWorktreePresenceenum (Current/Primary/Linked) with its owngutter_glyph(), plus aWorktreeData::presence()accessor. Both match arms now read symmetrically:data.presence().gutter_glyph()for worktrees,scope.gutter_glyph()for branches (the existingBranchScope).Why
The worktree arm was the one place still hand-rolling the gutter precedence inline, while branch rows already had the typed
BranchScope. Extracting it gives the precedence rule a name and a single documented home, finishing the symmetry the gutter-search work started.Derived, not stored
WorktreePresenceis computed fromWorktreeData(viapresence()), not stored likeBranchScope.is_currentandis_mainare orthogonal bits (the main worktree is also current when you sit in it), andis_mainis consumed independently by the status column (render.rs), the status tier (MainState::IsMain), and JSON output. So the pair can't collapse into a single stored 3-variant discriminant without losing theis_mainbit for a current-and-main worktree. The enum's doc records this, so a future reader doesn't try to "simplify" it into a stored field.is_currentwins when both bits are set.Behavior
Byte-identical — no snapshot churn. The existing
gutter_glyph_marks_each_row_kindtest gains the previously-untested both-current-and-primary precedence case (@wins over^).