git_ui: Show uncommitted change count badge on git panel icon#49624
git_ui: Show uncommitted change count badge on git panel icon#49624danilo-leal merged 13 commits intozed-industries:mainfrom
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @IVainqueur 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 |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Hey, thanks. Mind sharing some screenshots? |
|
Yea a screenshot for this would be appreciated to aid in reviewing |
|
The number 2 in the badge doesn't appear to be horizontally centered. |
|
Fixed, @bowenxuuu 👍🏼 Nice Catch! |
danilo-leal
left a comment
There was a problem hiding this comment.
Heya, thanks for the PR! This is a cool change, but can we make it be under a setting that's turned off by default? I don't think we should have this at all times. And then, even with the setting, I think we should remove the badge if the panel is open.
e282f75 to
3fafda8
Compare
|
Good suggestion @danilo-leal, added. |
Wires up the existing `icon_label` method on the `Panel` trait so that `GitPanel` exposes a count of uncommitted changes (new + modified files), and `PanelButtons` renders that label as a small green badge overlaid on the panel's sidebar icon — similar to VS Code's Source Control badge. `icon_label` already had implementations in `NotificationPanel` and `TerminalPanel` but was never rendered; this also benefits those panels.
- Set LineHeightStyle::UiLabel on the badge label so its line box matches the font height, making flex centering visually accurate - Cap the displayed count at "99+" to prevent oversized badges on repos with large numbers of changes
…l is open - Add `show_count_badge` setting to GitPanelSettings (off by default) - Hide the badge in the activity bar when the git panel is open - Add public `panels()` method to Dock for iterating panel handles Release Notes: - N/A
3fafda8 to
d884e9f
Compare
|
@danilo-leal I disagree that the count should not be visible when the panel is open. It is immensely useful if you're working with coding agents to see how many files they changed, and this can happen while the panel is open. For users that like having this badge clearly visible, they will be used to glancing there to check the current status. While the panel does have a change counter already, but it's an unnecessary mental operation to have to shift where you read the change count depending on whether the panel is open or not. It should also be enabled by default for users migrating from vscode. |
danilo-leal
left a comment
There was a problem hiding this comment.
Thank you! I pushed several changes here, most notably:
- There were what I think are changes from a different branch leaking on on this one (regarding an activity bar implementation, which is very unrelated to this PR). So I removed all of that.
- Had to add settings to the terminal and notification panels given both also implement
icon_labeland I didn't want any badges appearing on them as a result of this PR. - Created a dedicated component for the count badge instead of creating it directly in the dock file.
@simonfelding, I hear and appreciate your take here, but I think for now we'll have to agree on disagreeing; we really want to preserve Zed's UI minimalism and this could be unnecessary noise. This doesn't mean I'm not open to change it, though, in case we get enough feedback pointing that the default should have it turned on; looking forward to seeing what people will think. But I think whenever not fully sure if something should be turned on by default, a good rule of thumb is to have it turned off.
|
Fair enough 🙂 Nice work! |
@danilo-leal I'm not familiar with the process here but should those new settings have been added to docs/src/reference/all-settings.md with this change? Similar to what was done in #51601. |
|
@kczx3 we should add them there, yes! Feel free to contribute if you're feeling like it :) |

Summary
icon_labelonGitPanelto return the total count of uncommitted changes (new_count + changes_count) when non-zero, capped at"99+"for large repos.PanelButtons::render()to render that label as a small green badge overlaid on the panel's sidebar icon, using absolute positioning within adiv().relative()wrapper.version_control_addedtheme color andLabelSize::XSmalltext withLineHeightStyle::UiLabelfor accurate vertical centering, positioned at the top-right corner of the icon button.The
icon_labelmethod already existed on thePanel/PanelHandletraits with a defaultNoneimpl, and was already implemented byNotificationPanel(unread notification count) andTerminalPanel(open terminal count) — but was never rendered. This wires it up for all three panels at once.Notes
top(0),right(0)) to stay within the parent container's bounds. The status bar'srender_left_tools()uses.overflow_x_hidden(), which in GPUI clips both axes (theoverflow_maskreturns a full content mask whenever any axis is non-Visible), so negative offsets would be clipped.LineHeightStyle::UiLabelcollapses line height torelative(1.)so flex centering aligns the visual glyph rather than a taller-than-necessary line box.GitPanelalready maintainsnew_countandchanges_countreactively.Suggested .rules additions
The following pattern came up repeatedly and would prevent future sessions from hitting the same issue:
Release Notes: