Skip to content

Fix another issue with Graph post-processing#12243

Merged
Byron merged 4 commits intomasterfrom
fix2
Feb 6, 2026
Merged

Fix another issue with Graph post-processing#12243
Byron merged 4 commits intomasterfrom
fix2

Conversation

@Byron
Copy link
Collaborator

@Byron Byron commented Feb 6, 2026

The issue roughly is related to some special handling of the sibling_segment_id which is used to associate
tips with stack tips.
While the feature is meant for one specific case, it also triggers in the place to be reproduce here which
causes bad workspace projections.

A fix might be either in the graph post-processing, in the workspace projection, or both.

Tasks

  • reproduce in test
  • fix
  • follow-up fix related to remote connections.

Fixes #12146

Follow-up

  • One fix still to be done, it's the new TODO added here. Yet I still think the PR should be in the next release.

Reproduction

Screenshot 2026-02-06 at 10 51 03

tsbs.tar.gz

Experiment: Can Opus 4.6 figure it out?

The current commit adds a test for a problem I am trying to solve. It's related to the sibling_segment_id being set, probably in post-processing. Either it's fixed there, or where
the workspace is created, but let's make a plan first.

I knew what's causing this but not much more than I stated in the prompt.

Within minutes I found the post-process that sets up the 'bad' link:

self[sidx].sibling_segment_id = named_segment_id;

I had to point it at that to focus its solution search and it came up with something that worked in this case, but not the other tests.

In any case, from there I just took it upon myself as I had arrived in the right 'mind-space' to know what has to be done and what the problem is.

Overall, definitely useful, but it's possible to get lost in prompting when becoming too reliant - I'd always want to be able to do the thinking, and just use Claude to get there faster.

@vercel
Copy link

vercel bot commented Feb 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Feb 6, 2026 1:16pm

Request Review

@github-actions github-actions bot added the rust Pull requests that update Rust code label Feb 6, 2026
Byron and others added 2 commits February 6, 2026 10:00
Co-authored-by: Claude <noreply@anthropic.com>
@Byron Byron marked this pull request as ready for review February 6, 2026 13:07
Copilot AI review requested due to automatic review settings February 6, 2026 13:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect workspace projections caused by sibling_segment_id being overloaded for both “remote tracking branch linkage” and other post-processing/workspace reconstruction purposes. It introduces a dedicated remote_tracking_branch_segment_id and updates graph post-processing, projections, debug output, and fixtures to use the new field.

Changes:

  • Add remote_tracking_branch_segment_id to graph/projection segment types and route remote-tracking linkage through it.
  • Update workspace projection and debug/visualization helpers to prefer remote_tracking_branch_segment_id over sibling_segment_id.
  • Add a regression scenario + test reproducing #12146 and update affected snapshots/fixtures.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/but-workspace/src/ref_info.rs Adjusts destructuring to accommodate the new segment field.
crates/but-testsupport/src/graph.rs Updates debug tree rendering to prefer the new remote-tracking linkage field.
crates/but-graph/tests/graph/vis.rs Updates visualization test data to use remote_tracking_branch_segment_id instead of sibling_segment_id.
crates/but-graph/tests/graph/init/with_workspace.rs Updates snapshots and adds regression test for #12146.
crates/but-graph/tests/graph/init/mod.rs Updates debug snapshots for new debug formatting/fields.
crates/but-graph/tests/fixtures/scenarios.sh Adds fixture repo for reproducing #12146.
crates/but-graph/src/segment.rs Adds remote_tracking_branch_segment_id to Segment and updates Debug formatting.
crates/but-graph/src/projection/workspace/init.rs Uses remote_tracking_branch_segment_id when deriving target refs and marking remote reachability.
crates/but-graph/src/projection/stack.rs Propagates the new field into stack projection segments and debug string output.
crates/but-graph/src/init/post.rs Updates post-processing to maintain the new remote-tracking linkage separately from sibling_segment_id.
crates/but-graph/src/init/mod.rs Updates graph initialization to set the new remote-tracking linkage field appropriately.
crates/but-graph/src/debug.rs Extends debug string helpers to incorporate the new linkage field.
crates/but-graph/src/api.rs Adds an API helper to look up the remote-tracking-branch segment directly.

Copilot AI review requested due to automatic review settings February 6, 2026 13:16
@Byron Byron enabled auto-merge February 6, 2026 13:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.

@Byron Byron merged commit 1e8838e into master Feb 6, 2026
31 checks passed
@Byron Byron deleted the fix2 branch February 6, 2026 13:24
Byron added a commit that referenced this pull request Feb 6, 2026
@Byron Byron mentioned this pull request Feb 6, 2026
2 tasks
Byron added a commit that referenced this pull request Feb 6, 2026
Problem: When add_stack_with_segments declared "A" as a segment within the "B" stack, the workspace conversion produced two separate segments both named "A":
- :5:A with only the remote commit
- :0:A (anonymous, borrowing A's identity via sibling) with both remote and local commits

Root cause: In collect_first_parent_segments_until, the stop condition (line 227) unconditionally stops at anonymous segments with sibling_segment_id.
This prevents the anonymous segment from being collected together with its named counterpart, even when the named segment is the direct predecessor in the first-parent chain.

Fix (workspace/init.rs:470): Override the stop condition when the anonymous segment's sibling is already in the collected output.
This merges the anonymous segment's commits into the same StackSegment as its named counterpart, producing a single "A" segment with both the remote
tracking commit and the local commits.

Co-authored-by: Claude <noreply@anthropic.com>
Byron added a commit that referenced this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants