fix: scope stack comments to connected branches only#67
Merged
nvandessel merged 1 commit intomainfrom Mar 15, 2026
Merged
Conversation
Stack comments on PRs were showing ALL tracked branches instead of only the branches in the same connected stack. This was noisy and confusing when multiple independent stacks existed (e.g., main -> a1 -> a2 and main -> b1 -> b2 would all appear in every PR's comment). Add ConnectedStack() which computes the subset of branches connected to a given target by walking up the Parent chain to trunk (the "spine") and then collecting all descendants of spine nodes. RenderStackComment now uses this to filter branches before rendering. For merged comments, the caller (sync.go) pre-computes connected sets before deletion and passes only the relevant remaining branches. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR fixes a bug where independent stacks (e.g.,
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| internal/dag/dag.go | Adds ConnectedStack function with correct spine-walk + descendant-collection algorithm; integrates filtering into RenderStackComment. Logic is sound and well-tested. |
| cmd/stack_comments.go | Refactored updateMergedComments to accept pre-filtered connected sets and compute readiness per-stack. Clean signature change with correct per-branch readiness computation. |
| cmd/sync.go | Pre-computes connected stacks before state mutation, then intersects with post-merge DAG to produce accurate remaining-stack data for merged comments. Well-structured two-phase approach. |
| internal/dag/dag_test.go | Adds 9 new tests covering ConnectedStack edge cases (single/multi-stack, leaf/middle/root targets, branching, unknown target) plus integration tests for filtered rendering. Good coverage. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["RenderStackComment(trunk, branches, highlight)"] --> B{"highlight != '' ?"}
B -- Yes --> C["ConnectedStack(branches, highlight)"]
B -- No --> D["Use all branches"]
C --> E["Walk up Parent chain to trunk (spine)"]
E --> F["Collect all descendants of spine nodes (DFS)"]
F --> G["Filter branches to connected set"]
G --> H["renderTree(trunk, filtered, ...)"]
D --> H
I["sync: runSync"] --> J["Pre-compute connectedSets before merge"]
J --> K["Process merges: delete branches, reparent children"]
K --> L["Intersect pre-merge connected sets with post-merge DAG"]
L --> M["updateMergedComments(ctx, st, mergedData, postConnected)"]
M --> N["Per merged branch: compute readiness from connected subset"]
N --> O["RenderMergedStackComment with filtered branches"]
K --> P["updateStackComments(ctx, st)"]
P --> A
Last reviewed commit: d7a9de2
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
ConnectedStack()function ininternal/dag/dag.gothat computes the subset of branches belonging to the same connected stack as a target branch (walk up Parent chain to trunk, then include all descendants)RenderStackCommentnow filters to only connected branches before rendering, so each PR's comment shows only its own stackRenderMergedStackCommentreceives pre-filtered branches from the caller (sync.go), which computes connected sets before deleting merged branchesmain -> a1 -> a2andmain -> b1 -> b2) would both appear in every PR's stack commentTest plan
ConnectedStackcovering: single stack, two independent stacks, target as leaf/middle/root, branching stacks, unknown target, single branchTestRenderStackComment_FiltersToConnectedStackverifying thatRenderStackCommentexcludes unrelated stacksgo test ./...)RenderTree(used byfrond status) is unchanged and still shows all branchesgo build,go vet,gofmt -l🤖 Generated with Claude Code