Add git graph panel - #44405
Conversation
|
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 check |
|
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'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
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? |
#44405 Co-authored-by: pyundev <pyundev@users.noreply.github.com>
#44405 Co-authored-by: pyundev <pyundev@users.noreply.github.com>
|
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? Or even from 8am JST is fine in case |
|
@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. |
|
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:
|
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>
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>
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>

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 ...