Add support for staged and unstaged changes in project diff view - #48792
Add support for staged and unstaged changes in project diff view#48792bnjjj wants to merge 2 commits into
Conversation
…ndustries#36703 Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
|
I need this so badly. Praying this gets merged sooner rather than later. The select box is a perfectly clean, non-intrusive UI solution, IMO. |
|
I'm open to update it if needed, I just need feedback from zed team, cc @esthertrapadoux |
|
To review agents work this is incredibly useful |
|
Agreeing that this is a really useful feature, but one question/piece of feedback on the design side. In most git tools we see a separation like this for staged vs unstaged, where all the changes and items are visible in a single pane, but logically separated. This makes it really easy to switch between staged/unstaged versions of the code and selectively stage sections for committing. Is there a specific reason for using a different approach here? I can see that swapping being a little tedious when there are lots of changes to look through |
|
Hey, Are there any plans in moving forward with this feature? |
maxbrunsfeld
left a comment
There was a problem hiding this comment.
Hi @bnjjj, thanks for this — and sorry for the delayed review.
Since you opened this, we ended up implementing staged/unstaged diffs on main ourselves. The bulk of it landed in #58266 (a BufferDiff refactor by @cole-miller) and #46541 ("Git partially staged changes"), so the backend part of your PR now overlaps heavily with code that's already merged.
The main difference is in the data model for the index text. Your PR keeps the index content for the staged diff in a separate, standalone buffer that's manually kept in sync with the index, which is why the staged view has to be read-only. The refactor on main instead lets multiple diffs share the same base-text buffer entity: there's a single canonical index buffer that serves as the base of the unstaged diff and simultaneously the content of the staged diff, and a single head buffer shared by the staged and uncommitted diffs. Because there's one source of truth for the index, the staged view becomes interactive (you can unstage individual hunks straight from it), there's no risk of the two copies drifting, and it avoids a second full copy + foreground reparse of the file.
UI Work Needed
We are still open to contributions that add new UI around these diffs. Right now, the staged and unstaged diffs are only accessible by right-clicking a file in the git panel and choosing Staged Changes and Unstaged Changes - and we'd like to add a more clear way of accessing these views.
My concern about the dropdown that you added is that it might not interact well with the search bar that appears when you type command-f in the project diff view. It seems like that header could get very crowded.
If you're interested, you could rebase this PR onto main, removing the changes to the model layer (since main already has the needed core functionality) leaving only the UI parts of your PR, and share a video of what it looks like on a small screen when you have the search active.



Closes #36703
I asked several times on #36703 to know what kind of design we would like to have for this feature. I tried to add a non intrusive new select box to select the different diff views we would like to have. cc @cole-miller, @mattermill or @esthertrapadoux if you can give me feedback that would be really nice.
Screencast:
Enregistrement.de.l.ecran.2026-02-09.a.14.34.28.mov
Release Notes: