Skip to content

feat(differ): add Graphite stack support for scoped PR diffs#499

Merged
matt2e merged 1 commit intoblock:mainfrom
rnc505:robbyc/03-26-feat_differ_add_graphite_stack_support_for_scoped_pr_diffs
Mar 26, 2026
Merged

feat(differ): add Graphite stack support for scoped PR diffs#499
matt2e merged 1 commit intoblock:mainfrom
rnc505:robbyc/03-26-feat_differ_add_graphite_stack_support_for_scoped_pr_diffs

Conversation

@rnc505
Copy link
Copy Markdown
Collaborator

@rnc505 rnc505 commented Mar 26, 2026

Stack overview

This is PR 1/4 in a stack of Differ improvements:

  1. → Graphite stack support (this PR)
  2. Diff color contrast (feat(differ): improve diff color contrast with per-side tinting #500)
  3. Font sizing & titlebar fixes (feat(differ): fix font sizing, padding, and titlebar responsiveness #501)
  4. Keyboard shortcuts (feat(differ): add keyboard shortcuts for file navigation and font sizing #502)

Background

Differ currently shows the full diff from trunk for any branch, which is noisy when working with Graphite stacked PRs — you see all changes from every branch in the stack, not just the current one.

Overview of Changes

  • Add get_stack_info Tauri command that shells out to gt state, parses the JSON, and returns structured StackInfo/StackBranchInfo types
  • Add Stack dropdown UI with upstack/downstack branch navigation
  • When a Graphite stack is detected, auto-select "stack" diff mode to scope the diff to only the current branch's changes (parent branch as base instead of trunk)
  • Navigate to other stack branches without checkout (reads refs directly)
  • Show needs-restack warning indicator on branches that are out of date
  • Graceful fallback: Stack UI is hidden when gt is not installed or repo is not in a stack

Testing Performed

  • Manual testing with Graphite stacks of various depths
  • Verified fallback behavior when gt is not installed (Stack UI hidden)

Video testing (with all 4 from stack)

with gt installed without gt installed
Screen.Recording.2026-03-26.at.10.38.26.AM_compressed.mp4
Screen.Recording.2026-03-26.at.10.41.16.AM_compressed.mp4

Fixed the text overflow artifacts that you can see in the video

I just didn't want to rerecord
Screenshot 2026-03-26 at 11 20 05 AM
Screenshot 2026-03-26 at 11 20 00 AM
Screenshot 2026-03-26 at 11 19 57 AM


✨🤖 heavily assisted by AmpCode

Comment on lines +797 to +805
let output = Command::new("gt")
.args(["state"])
.current_dir(repo)
.output()
.ok()?;

if !output.status.success() {
return None;
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

apparently this would be a good hook to also offer non-graphite stacking options like jj but probably worth punting on that

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b0ffee4b0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

const si = await commands.getStackInfo();
stackInfo = si;
if (si && !args.mode) {
setMode('stack');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid racing diff loads when auto-selecting stack mode

loadRepoInfo() triggers loadDiff() but does not await its completion, and this new setMode('stack') call immediately kicks off another loadDiff(). In a Graphite repo on startup, the two requests can resolve out of order and the later completion overwrites files/selectedFile, leaving the UI in stack mode while showing results from the earlier mode; the same sequence is repeated in the repo-switch path.

Useful? React with 👍 / 👎.

@rnc505 rnc505 force-pushed the robbyc/03-26-feat_differ_add_graphite_stack_support_for_scoped_pr_diffs branch from 0b0ffee to 1000c03 Compare March 26, 2026 20:34
Add stack-aware diff mode that shows only the current branch's changes
instead of the entire branch diff from trunk. Detects Graphite stacks
via `gt state` and auto-selects stack mode when available.

- Add `get_stack_info` Tauri command that parses `gt state` JSON
- Add `StackInfo`/`StackBranchInfo` types and spec builders
- Add Stack dropdown with upstack/downstack branch navigation
- Navigate other stack branches without checkout (read-only refs)
- Show needs-restack warning indicator
- Graceful fallback: Stack button hidden when gt not installed

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d28f5-71eb-7256-af52-1b4c406e53a7
@rnc505 rnc505 force-pushed the robbyc/03-26-feat_differ_add_graphite_stack_support_for_scoped_pr_diffs branch from 1000c03 to e368dba Compare March 26, 2026 20:58
@matt2e matt2e merged commit ffddad1 into block:main Mar 26, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants