Skip to content

git_graph: Add branch filter, push dialog, commit context menu, and graph settings - #53316

Closed
nguyenphutrong wants to merge 9 commits into
zed-industries:mainfrom
nguyenphutrong:feature/implement-git-graph-enhancements
Closed

git_graph: Add branch filter, push dialog, commit context menu, and graph settings#53316
nguyenphutrong wants to merge 9 commits into
zed-industries:mainfrom
nguyenphutrong:feature/implement-git-graph-enhancements

Conversation

@nguyenphutrong

@nguyenphutrong nguyenphutrong commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Summary

This PR enhances the Git Graph panel with comprehensive new features for branch management, commit operations, and graph visualization options. It introduces interactive dialogs for pushing branches with force options, filtering commits by branch, and performing various git operations directly from the commit graph.

Screenshot 2026-04-07 at 22 18 32@2x

Features Added

1. Branch Filter with Picker

  • Added a branch filter picker that allows users to selectively display commits from specific branches
  • Shows branch selection state with checkboxes (all/none/indeterminate)
  • Supports both local and remote branches with visual indicators
  • Quick search/filter functionality for finding branches
Screenshot 2026-04-07 at 22 19 00@2x

2. Push Branch Dialog

  • New dialog for pushing branches with configurable options
  • Supports --set-upstream flag for setting upstream tracking
  • Force push options: --force-with-lease and --force
  • Remote selection dropdown with automatic detection of tracked upstream
  • Visual indicators for remote/branch configuration
Screenshot 2026-04-07 at 22 19 20@2x

3. Commit Context Menu Operations

Added comprehensive right-click context menu on commits with the following operations:

  • Create branch - Create a new branch at the selected commit
  • Create tag - Create an annotated or lightweight tag
  • Checkout commit - Checkout in detached HEAD state
  • Cherry-pick - Cherry-pick with -x option support and merge commit handling
  • Revert commit - Revert changes with optional no-commit flag
  • Drop commit - Remove commit from history (with preflight checks)
  • Merge commit - Merge the selected commit into current branch
  • Rebase onto - Rebase current branch onto selected commit
  • Reset - Soft, Mixed, or Hard reset to commit
  • Copy commit hash - Copy SHA to clipboard
  • Copy commit subject - Copy commit message to clipboard
Screenshot 2026-04-07 at 22 19 43@2x Screenshot 2026-04-07 at 22 19 59@2x Screenshot 2026-04-07 at 22 20 11@2x

4. Graph Settings Dropdown

Added settings panel to control graph visualization:

  • Show stashes - Include stash references in the graph
  • Show tags - Include tag references in the graph
  • Show remote branches - Include remote branch refs
  • Include reflog commits - Show commits reachable only via reflog (--reflog)
  • First parent only - Simplify history to first parent line (--first-parent)
Screenshot 2026-04-07 at 22 20 23@2x

Technical Details

New Types Added

pub struct GraphLogOptions {
    pub show_stashes: bool,
    pub show_tags: bool,
    pub include_reflog_commits: bool,
    pub first_parent_only: bool,
}

pub enum PushMode {
    Normal,
    ForceWithLease,
    Force,
}

pub struct PushOptions {
    pub set_upstream: bool,
    pub push_mode: PushMode,
}

New Git Operations

  • create_branch_at - Create branch at specific SHA
  • create_tag - Create annotated tags with messages
  • checkout_commit - Detached HEAD checkout
  • cherry_pick - With merge commit detection and -m 1 handling
  • revert_commit - With no-commit option
  • drop_commit / drop_commit_support - With safety preflight checks
  • merge_commit - Fast-forward merge
  • rebase_onto - Rebase operation
  • delete_tag / push_tag - Tag management
  • Enhanced delete_branch with force_delete parameter

Files Changed

  • crates/git_graph/src/git_graph.rs - Main UI implementation with pickers, dialogs, and context menu
  • crates/git/src/repository.rs - New git operations and types (PushOptions, GraphLogOptions, etc.)
  • crates/project/src/git_store.rs - Repository state management and job handling
  • crates/fs/src/fake_git_repo.rs - Fake git implementation for testing
  • crates/proto/proto/git.proto - Protocol messages for collab support
  • crates/git_ui/src/branch_picker.rs - Branch picker integration
  • crates/git_ui/src/git_panel.rs - Git panel integration
  • crates/ui/src/components/chip.rs - Chip component styling for branch tags
  • crates/icons/src/icons.rs - New icons for stash and tag

Testing

  • Manual testing on local repositories with various branch configurations
  • Test branch filtering with mixed local/remote branch selection
  • Test push dialog with different remote and upstream setups
  • Test all commit context menu operations
  • Verify graph settings apply correctly and persist
  • Test on repositories with stashes, tags, and merge commits

Backward Compatibility

  • All proto changes are backward compatible (new fields are optional, defaults to false)
  • New UI features are additive and don't change existing workflows
  • Default settings match previous graph behavior (stashes and tags shown, reflog off)

Closes #53112 #53108 #53112

Release Notes:

  • Added branch filter picker to selectively display commits by branch in the Git Graph
  • Added push branch dialog with force push options (--force, --force-with-lease)
  • Added commit context menu with operations: create branch/tag, checkout, cherry-pick, revert, drop, merge, rebase, reset, and copy commit hash/subject
  • Added graph settings to control visibility of stashes, tags, remote branches, reflog commits, and first-parent filtering

Add a gear menu next to the search bar for toggling graph display options.

Wire the selected settings into git log loading so stashes, tags, reflog-only commits,
and first-parent traversal affect the rendered graph instead of only the UI state.
…, drop, merge, rebase, reset) and stash management
- Add BranchFilterState with picker for filtering commits by branch
- Add LogSource::Branches variant for multi-branch filtering
- Implement branch selection logic with show/hide remote branches support
- Add comprehensive tests for branch filtering functionality
- Refactor PushOptions from simple enum to struct with set_upstream flag and PushMode
- Add PushMode enum with Normal, ForceWithLease, and Force variants
- Add PushBranchModal with UI for selecting remote, set upstream, and push mode
- Update protobuf Push message to match new PushOptions structure
- Add tests for push dialog state and default remote selection
…eset in fake git

Add missing force_delete field to the GitDeleteBranch proto message and
wire it through the handler. Also add ResetMode::Hard handling to
FakeGitRepository::reset.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 7, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Apr 7, 2026
@zed-codeowner-coordinator
zed-codeowner-coordinator Bot requested review from a team, Veykril and cole-miller and removed request for a team April 7, 2026 15:22
@Veykril Veykril assigned Anthony-Eid and unassigned Veykril Apr 7, 2026
@Anthony-Eid

Copy link
Copy Markdown
Contributor

This PR is too large for me to review in a reasonable amount of time. Could you please split this up in several smaller PRs where each PR == 1 feature?

@maxdeviant maxdeviant changed the title git_graph - Add branch filter, push dialog, commit context menu, and graph settings git_graph: Add branch filter, push dialog, commit context menu, and graph settings Apr 8, 2026
@nguyenphutrong

Copy link
Copy Markdown
Contributor Author

This PR is too large for me to review in a reasonable amount of time. Could you please split this up in several smaller PRs where each PR == 1 feature?

I appreciate the feedback. I'll split these changes into smaller, more manageable PRs soon to make the review process easier for you. Thanks for checking it out!

@nguyenphutrong

nguyenphutrong commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Anthony-Eid ,

Thank you for the feedback! I've split the original PR into 8 smaller, focused PRs as requested. Each PR contains exactly 1 feature for easier review:

Split PRs

# Feature PR Description
1 Graph Settings Dropdown #55769 Add gear menu to control graph display options (stashes, tags, reflog, first-parent)
2 UI Infrastructure #55774 Add Git stash/tag icons and enhance chip component with leading icons
3 Branch Filter #TBD Add branch filter picker for selecting which branches to display
4 Push Dialog #TBD Add push branch dialog with force options (--force, --force-with-lease)
5 Basic Context Menu Operations #TBD Create branch, Create tag, Checkout commit, Copy hash/subject
6 Cherry-pick & Revert #TBD Cherry-pick with merge handling + Revert with no-commit option
7 Reset & Rebase #TBD Soft/Mixed/Hard reset + Rebase onto commit
8 Merge & Drop #TBD Merge commit + Drop commit with preflight checks

Please review them at your convenience!

@Anthony-Eid

Copy link
Copy Markdown
Contributor

@nguyenphutrong I'm going to need a week or two until I can start adding git graph features, we're in the middle of an important launch and I want to finish remote git graph support before moving on to anything else

@nguyenphutrong

Copy link
Copy Markdown
Contributor Author

Thanks for the update, @Anthony-Eid!

Quick thought: I wanted to bring up #53403 - "Allow Extensions to Render GUI". If we had that, I (or other developers) could build Git Graph as an extension instead of being built-in to Zed. This would accelerate Git Graph development specifically, and more importantly, grow Zed's ecosystem overall.

Compared to VSCode, Cursor, or JetBrains IDEs, Zed's extension ecosystem is still quite limited (I listed some use cases in that discussion). Enabling UI rendering in extensions would be a game-changer for bringing more developers to build on Zed.

Would love to hear your thoughts on this direction!

@Anthony-Eid

Copy link
Copy Markdown
Contributor

Thanks for the update, @Anthony-Eid!

Quick thought: I wanted to bring up #53403 - "Allow Extensions to Render GUI". If we had that, I (or other developers) could build Git Graph as an extension instead of being built-in to Zed. This would accelerate Git Graph development specifically, and more importantly, grow Zed's ecosystem overall.

Compared to VSCode, Cursor, or JetBrains IDEs, Zed's extension ecosystem is still quite limited (I listed some use cases in that discussion). Enabling UI rendering in extensions would be a game-changer for bringing more developers to build on Zed.

Would love to hear your thoughts on this direction!

This is something we eventually want to do, but I can't say when it will be on our roadmap because we have a lot of other things in development right now. Plus, it's a big task to complete because we would have to expose GPUI APIs, which means we need to keep GPUI backwards compatible. Which is difficult with how often we change GPUI right now.

@nguyenphutrong

Copy link
Copy Markdown
Contributor Author

Understood, thanks for explaining! Look forward to seeing this on the roadmap eventually.

@singalen

Copy link
Copy Markdown

I'm going to need a week or two until I can start adding git graph features, we're in the middle of an important launch and I want to finish remote git graph support before moving on to anything else

@Anthony-Eid, is this accurate that the core team is going to implement what was attempted here?

  • If yes, can you please post an issue link?
  • If no, shall the PR author or somebody else revive this PR?

Thanks.

@nicojerome

Copy link
Copy Markdown

This is absolutely genius; it would turn Zed into a full-fledged Git client. Why is this closed? Too large for the Zed team to review?

@ianldgs

ianldgs commented May 5, 2026

Copy link
Copy Markdown

This would be so useful! Could finally migrate from vscode to zed completely if this is implemented.

@nguyenphutrong

Copy link
Copy Markdown
Contributor Author

Hi @Anthony-Eid, quick question to make sure I do not duplicate work.

I noticed #55720 was merged, and it looks like the team is starting to add more Git Graph functionality internally. Since you previously asked me to split #53316 into smaller PRs, should I still continue opening small, one-feature PRs for the remaining Git Graph features, or is the Zed team planning to implement these features yourselves?

If the team already has an internal direction or tracking issue for Git Graph improvements, I’m happy to pause my follow-up PRs and avoid creating review noise. Just want to align before I continue.

Thanks!

@Anthony-Eid

Copy link
Copy Markdown
Contributor

@nguyenphutrong Do you have discord? We should talk over there because any help would be appreciated

Also, I'm sorry for how long it's taken me to get back to you and review your PR. I don't have much bandwidth these days and have been trying to get others to take over the easy parts of the graph code base

If you could make a PR expanding our right click context menu that would be a great first step btw!

@nguyenphutrong

Copy link
Copy Markdown
Contributor Author

Here is my Discord https://discord.com/users/820488821162115103 or username: trng.ng

@JosephTLyons

JosephTLyons commented May 5, 2026

Copy link
Copy Markdown
Collaborator

@nguyenphutrong - thats my fault. I jumped onto add a context menu without knowing there were any PRs that might've been attempting to do the same. I should've looked through them and found out. Sorry about that.

@nguyenphutrong

Copy link
Copy Markdown
Contributor Author

I created a new PR here: #55844

It is still fairly large (+6,063 / -1,705), but it is focused on the first step you suggested: expanding the graph right-click context menu. It adds the context menu flow for commits, branches, tags, and stashes, so I would appreciate it if @Anthony-Eid and @JosephTLyons could take a first look and let me know whether this direction works for the graph codebase.

Also, yes, I’m happy to discuss on Discord if that is easier. Thanks again for taking the time to review this despite the limited bandwidth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants