Skip to content

Add git graph panel - #44405

Closed
pyundev wants to merge 7 commits into
zed-industries:mainfrom
pyundev:feature/git-graph
Closed

Add git graph panel#44405
pyundev wants to merge 7 commits into
zed-industries:mainfrom
pyundev:feature/git-graph

Conversation

@pyundev

@pyundev pyundev commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Closes #ISSUE
Ref: #26866

Release Notes:

  • Adds a new Git Graph panel for visualizing commit history with branch/merge lines

  • Supports full context menu with git operations (checkout, merge, rebase, cherry-pick, reset, etc.)

  • Includes branch/tag badges with double-click to checkout

  • Expandable commit details showing changed files

  • 16 unit tests for graph building and badge parsing

  • N/A or Added/Fixed/Improved ...

@cla-bot

cla-bot Bot commented Dec 8, 2025

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @pyundev on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@MrSubidubi MrSubidubi changed the title Feature/git graph Add git graph panel Dec 8, 2025
@pyundev

pyundev commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot

cla-bot Bot commented Dec 8, 2025

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @pyundev on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot

cla-bot Bot commented Dec 8, 2025

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@pyundev

pyundev commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Dec 8, 2025
@cla-bot

cla-bot Bot commented Dec 8, 2025

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@Anthony-Eid Anthony-Eid self-assigned this Dec 8, 2025
@Anthony-Eid

Copy link
Copy Markdown
Contributor

Hey @pyundev, thanks for creating this PR! It doesn't quite fix our design that we want for the git graph, but the backend is a great starting point. I'm planning on forking this and applying some changes. Would you be interested in pairing on it?

https://cal.com/anthony-eid/community-pairing

Anthony-Eid added a commit that referenced this pull request Dec 8, 2025
#44405

Co-authored-by: pyundev <pyundev@users.noreply.github.com>
Anthony-Eid added a commit that referenced this pull request Dec 8, 2025
#44405

Co-authored-by: pyundev <pyundev@users.noreply.github.com>
@pyundev

pyundev commented Dec 9, 2025

Copy link
Copy Markdown
Contributor Author

Hey @Anthony-Eid, There are some time zone issues unfortunately. Would it be fine doing it async? If not would you consider doing it earlier for me around 10/11pm JST?
Screenshot 2025-12-09 123531

Or even from 8am JST is fine in case

@Anthony-Eid

Copy link
Copy Markdown
Contributor

@pyundev Could you message me on Discord to figure out a time? You can find me from the Zed Discord https://discord.gg/g4k7bPbR.

Funny enough, I actually think I'm going to change the backend of this implementation and use the UI you made instead of the other way around now.

@Anthony-Eid

Copy link
Copy Markdown
Contributor

I'm closing this because the Zed team is in the process of building this feature ourselves, but this was a good base for me to start out from! So thank you for contributing.

Some transparency’s sake, here are the main things I'm planning on improving:

  1. Right now each row of the graph is rendered as a cell, this makes curved lines look pretty bad. So I want to render the whole graph as one canvas.
  2. The graph isn't horizontally scrollable, and always takes up the minimal amount of width it needs in the view.
  3. A lot of git commands we already support were reimplemented here.
  4. The graph would fetch the whole git log at once, causing a small loading screen to take place for larger repos.
  5. Doesn't have collab support.

@github-project-automation github-project-automation Bot moved this from Community PRs to Done in Quality Week – December 2025 Dec 15, 2025
Anthony-Eid added a commit that referenced this pull request Jan 23, 2026
Closes #26866

### Summary
Adds a git graph to Zed, accessible via the `git_graph::Open` action if
a project has an active repository. There's still more to do, but this
is a solid foundation to expand upon. The code structure is in line with
Zed's codebase and shouldn't require architectural changes to add
missing features.

The git graph can be opened via the command palette (`git graph: open`)
or by binding a key to `git_graph::Open`. It's available when the
project has an active git repository.

### Architecture

Similar to the Debugger, the git graph is split between a data layer and
a view/UI layer. When the view layer is rendering, it queries the data
layer for its active state. This setup allows the data layer to lazily
request graph data (only when needed for rendering), abstracts collab
from the view layer, allows most of the data loading to happen on a
background thread, and makes caching easy to implement.

#### Graph Loading

The graph data is loaded in two phases:
1. `Repository::graph_data()` streams commit structure (SHA, parents,
refs) in chunks of 1000 via `git log`
2. `CommitDataReader` lazily fetches full commit details (author,
timestamp, subject) on-demand using a persistent `git cat-file --batch`
process

This two-phase approach makes the initial loading of the graph as fast
as possible, because `git log` takes significantly longer when all the
needed graph data is queried through it. Zed then lazily loads commits
in the user's viewport through `cat-file --batch`. This makes scrolling
to any place in the graph extremely snappy and benefits the
collaborative architecture by only fetching data needed to render the
graph. It also allows Zed to share commit data between different graph
visualizations (e.g., date order vs. topological order).

#### Performance

Tested on both the Zed and LLVM repositories with good performance in
both cases. The two-phase loading approach and lazy fetching keep the UI
responsive even with large commit histories.

#### Testing 

I added property testing that builds randomized commit graphs and
verifies that the graph is constructed correctly. This also works as an
integration test and will be expanded in the future to test collab graph
visualization, graph filtering, commit actions, etc.

### New Crate
- `git_graph` (GPL-licensed) — contains UI and graph computation logic

### Not Yet Implemented
- Remote repository support (collab)
- Filtering by branch
- Commit actions (checkout, cherry-pick, etc.)
- Search
- Open commit view for selected commit
- Resizable columns 
- Column filtering

#### Reference
<img width="1624" height="976" alt="Screenshot 2025-01-22 at 8 15 39 PM"
src="https://github.com/user-attachments/assets/0f10924a-3964-462f-b320-42d84d02f7bf"
/>

Special thanks to [Alberto Slavica](https://github.com/pyundev) for
submitting #44405, which was a good base to work off of.

Release Notes:

- git: Add initial version of git graph

---------

Co-authored-by: pyundev <pyundev@users.noreply.github.com>
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
Closes zed-industries#26866

### Summary
Adds a git graph to Zed, accessible via the `git_graph::Open` action if
a project has an active repository. There's still more to do, but this
is a solid foundation to expand upon. The code structure is in line with
Zed's codebase and shouldn't require architectural changes to add
missing features.

The git graph can be opened via the command palette (`git graph: open`)
or by binding a key to `git_graph::Open`. It's available when the
project has an active git repository.

### Architecture

Similar to the Debugger, the git graph is split between a data layer and
a view/UI layer. When the view layer is rendering, it queries the data
layer for its active state. This setup allows the data layer to lazily
request graph data (only when needed for rendering), abstracts collab
from the view layer, allows most of the data loading to happen on a
background thread, and makes caching easy to implement.

#### Graph Loading

The graph data is loaded in two phases:
1. `Repository::graph_data()` streams commit structure (SHA, parents,
refs) in chunks of 1000 via `git log`
2. `CommitDataReader` lazily fetches full commit details (author,
timestamp, subject) on-demand using a persistent `git cat-file --batch`
process

This two-phase approach makes the initial loading of the graph as fast
as possible, because `git log` takes significantly longer when all the
needed graph data is queried through it. Zed then lazily loads commits
in the user's viewport through `cat-file --batch`. This makes scrolling
to any place in the graph extremely snappy and benefits the
collaborative architecture by only fetching data needed to render the
graph. It also allows Zed to share commit data between different graph
visualizations (e.g., date order vs. topological order).

#### Performance

Tested on both the Zed and LLVM repositories with good performance in
both cases. The two-phase loading approach and lazy fetching keep the UI
responsive even with large commit histories.

#### Testing 

I added property testing that builds randomized commit graphs and
verifies that the graph is constructed correctly. This also works as an
integration test and will be expanded in the future to test collab graph
visualization, graph filtering, commit actions, etc.

### New Crate
- `git_graph` (GPL-licensed) — contains UI and graph computation logic

### Not Yet Implemented
- Remote repository support (collab)
- Filtering by branch
- Commit actions (checkout, cherry-pick, etc.)
- Search
- Open commit view for selected commit
- Resizable columns 
- Column filtering

#### Reference
<img width="1624" height="976" alt="Screenshot 2025-01-22 at 8 15 39 PM"
src="https://github.com/user-attachments/assets/0f10924a-3964-462f-b320-42d84d02f7bf"
/>

Special thanks to [Alberto Slavica](https://github.com/pyundev) for
submitting zed-industries#44405, which was a good base to work off of.

Release Notes:

- git: Add initial version of git graph

---------

Co-authored-by: pyundev <pyundev@users.noreply.github.com>
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Closes zed-industries#26866

### Summary
Adds a git graph to Zed, accessible via the `git_graph::Open` action if
a project has an active repository. There's still more to do, but this
is a solid foundation to expand upon. The code structure is in line with
Zed's codebase and shouldn't require architectural changes to add
missing features.

The git graph can be opened via the command palette (`git graph: open`)
or by binding a key to `git_graph::Open`. It's available when the
project has an active git repository.

### Architecture

Similar to the Debugger, the git graph is split between a data layer and
a view/UI layer. When the view layer is rendering, it queries the data
layer for its active state. This setup allows the data layer to lazily
request graph data (only when needed for rendering), abstracts collab
from the view layer, allows most of the data loading to happen on a
background thread, and makes caching easy to implement.

#### Graph Loading

The graph data is loaded in two phases:
1. `Repository::graph_data()` streams commit structure (SHA, parents,
refs) in chunks of 1000 via `git log`
2. `CommitDataReader` lazily fetches full commit details (author,
timestamp, subject) on-demand using a persistent `git cat-file --batch`
process

This two-phase approach makes the initial loading of the graph as fast
as possible, because `git log` takes significantly longer when all the
needed graph data is queried through it. Zed then lazily loads commits
in the user's viewport through `cat-file --batch`. This makes scrolling
to any place in the graph extremely snappy and benefits the
collaborative architecture by only fetching data needed to render the
graph. It also allows Zed to share commit data between different graph
visualizations (e.g., date order vs. topological order).

#### Performance

Tested on both the Zed and LLVM repositories with good performance in
both cases. The two-phase loading approach and lazy fetching keep the UI
responsive even with large commit histories.

#### Testing 

I added property testing that builds randomized commit graphs and
verifies that the graph is constructed correctly. This also works as an
integration test and will be expanded in the future to test collab graph
visualization, graph filtering, commit actions, etc.

### New Crate
- `git_graph` (GPL-licensed) — contains UI and graph computation logic

### Not Yet Implemented
- Remote repository support (collab)
- Filtering by branch
- Commit actions (checkout, cherry-pick, etc.)
- Search
- Open commit view for selected commit
- Resizable columns 
- Column filtering

#### Reference
<img width="1624" height="976" alt="Screenshot 2025-01-22 at 8 15 39 PM"
src="https://github.com/user-attachments/assets/0f10924a-3964-462f-b320-42d84d02f7bf"
/>

Special thanks to [Alberto Slavica](https://github.com/pyundev) for
submitting zed-industries#44405, which was a good base to work off of.

Release Notes:

- git: Add initial version of git graph

---------

Co-authored-by: pyundev <pyundev@users.noreply.github.com>
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants