Skip to content

git_ui: Show uncommitted change count badge on git panel icon#49624

Merged
danilo-leal merged 13 commits intozed-industries:mainfrom
IVainqueur:git-panel-icon-badge
Mar 16, 2026
Merged

git_ui: Show uncommitted change count badge on git panel icon#49624
danilo-leal merged 13 commits intozed-industries:mainfrom
IVainqueur:git-panel-icon-badge

Conversation

@IVainqueur
Copy link
Copy Markdown
Contributor

@IVainqueur IVainqueur commented Feb 19, 2026

Summary

  • Implements icon_label on GitPanel to return the total count of uncommitted changes (new_count + changes_count) when non-zero, capped at "99+" for large repos.
  • Updates PanelButtons::render() to render that label as a small green badge overlaid on the panel's sidebar icon, using absolute positioning within a div().relative() wrapper.
  • The badge uses version_control_added theme color and LabelSize::XSmall text with LineHeightStyle::UiLabel for accurate vertical centering, positioned at the top-right corner of the icon button.

The icon_label method already existed on the Panel/PanelHandle traits with a default None impl, and was already implemented by NotificationPanel (unread notification count) and TerminalPanel (open terminal count) — but was never rendered. This wires it up for all three panels at once.

Notes

  • Badge is positioned with non-negative offsets (top(0), right(0)) to stay within the parent container's bounds. The status bar's render_left_tools() uses .overflow_x_hidden(), which in GPUI clips both axes (the overflow_mask returns a full content mask whenever any axis is non-Visible), so negative offsets would be clipped.
  • LineHeightStyle::UiLabel collapses line height to relative(1.) so flex centering aligns the visual glyph rather than a taller-than-necessary line box.
  • No new data tracking logic — GitPanel already maintains new_count and changes_count reactively.
  • No feature flag or settings added per YAGNI.

Suggested .rules additions

The following pattern came up repeatedly and would prevent future sessions from hitting the same issue:

## GPUI overflow clipping

`overflow_x_hidden()` (and any single-axis overflow setter) clips **both** axes in GPUI.
The `overflow_mask()` implementation in `style.rs` returns a full `ContentMask` (bounding box)
whenever any axis is non-`Visible`. Absolute-positioned children that extend outside the element
bounds will be clipped even if only the X axis is set to Hidden.
Avoid negative `top`/`right`/`bottom`/`left` offsets on absolute children of containers
that have any overflow hidden — keep badge/overlay elements within the parent's bounds instead.

Release Notes:

  • Added a numeric badge to the git panel sidebar icon showing the count of uncommitted changes.

@IVainqueur IVainqueur requested review from a team as code owners February 19, 2026 16:55
@IVainqueur IVainqueur requested review from Veykril and reflectronic and removed request for a team February 19, 2026 16:55
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Feb 19, 2026

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

@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 Feb 19, 2026
@maxdeviant maxdeviant changed the title git_ui, workspace: Show uncommitted change count badge on git panel icon git_ui: Show uncommitted change count badge on git panel icon Feb 19, 2026
@IVainqueur
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 Feb 19, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Feb 19, 2026

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

@Dima-369
Copy link
Copy Markdown
Contributor

Hey, thanks. Mind sharing some screenshots?

@Veykril
Copy link
Copy Markdown
Member

Veykril commented Feb 20, 2026

Yea a screenshot for this would be appreciated to aid in reviewing

@IVainqueur
Copy link
Copy Markdown
Contributor Author

Sure thing.
(peep the bottom right corner)

image

Lemme know if it's clear enough or..?

@bowenxuuu
Copy link
Copy Markdown
Contributor

The number 2 in the badge doesn't appear to be horizontally centered.

@IVainqueur
Copy link
Copy Markdown
Contributor Author

Fixed, @bowenxuuu 👍🏼 Nice Catch!

Copy link
Copy Markdown
Member

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@IVainqueur IVainqueur force-pushed the git-panel-icon-badge branch from e282f75 to 3fafda8 Compare March 3, 2026 08:18
@IVainqueur
Copy link
Copy Markdown
Contributor Author

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
@IVainqueur IVainqueur force-pushed the git-panel-icon-badge branch from 3fafda8 to d884e9f Compare March 5, 2026 10:36
@IVainqueur IVainqueur requested a review from danilo-leal March 5, 2026 10:37
@simonfelding
Copy link
Copy Markdown

simonfelding commented Mar 5, 2026

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

Copy link
Copy Markdown
Member

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@danilo-leal danilo-leal merged commit ae44563 into zed-industries:main Mar 16, 2026
29 checks passed
@simonfelding
Copy link
Copy Markdown

Fair enough 🙂 Nice work!

@kczx3
Copy link
Copy Markdown

kczx3 commented Mar 18, 2026

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.

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

@danilo-leal
Copy link
Copy Markdown
Member

@kczx3 we should add them there, yes! Feel free to contribute if you're feeling like it :)

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