Files
zed/crates/ui/src/components.rs
T
ISHIMWE VainqueurandDanilo Leal ae445634e0 git_ui: Show uncommitted change count badge on git panel icon (#49624)
## 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.

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2026-03-16 12:57:20 -03:00

88 lines
1.5 KiB
Rust

mod ai;
mod avatar;
mod banner;
mod button;
mod callout;
mod chip;
mod collab;
mod context_menu;
mod count_badge;
mod data_table;
mod diff_stat;
mod disclosure;
mod divider;
mod dropdown_menu;
mod facepile;
mod gradient_fade;
mod group;
mod icon;
mod image;
mod indent_guides;
mod indicator;
mod keybinding;
mod keybinding_hint;
mod label;
mod list;
mod modal;
mod navigable;
mod notification;
mod popover;
mod popover_menu;
mod progress;
mod right_click_menu;
mod scrollbar;
mod stack;
mod sticky_items;
mod tab;
mod tab_bar;
mod toggle;
mod tooltip;
mod tree_view_item;
#[cfg(feature = "stories")]
mod stories;
pub use ai::*;
pub use avatar::*;
pub use banner::*;
pub use button::*;
pub use callout::*;
pub use chip::*;
pub use collab::*;
pub use context_menu::*;
pub use count_badge::*;
pub use data_table::*;
pub use diff_stat::*;
pub use disclosure::*;
pub use divider::*;
pub use dropdown_menu::*;
pub use facepile::*;
pub use gradient_fade::*;
pub use group::*;
pub use icon::*;
pub use image::*;
pub use indent_guides::*;
pub use indicator::*;
pub use keybinding::*;
pub use keybinding_hint::*;
pub use label::*;
pub use list::*;
pub use modal::*;
pub use navigable::*;
pub use notification::*;
pub use popover::*;
pub use popover_menu::*;
pub use progress::*;
pub use right_click_menu::*;
pub use scrollbar::*;
pub use stack::*;
pub use sticky_items::*;
pub use tab::*;
pub use tab_bar::*;
pub use toggle::*;
pub use tooltip::*;
pub use tree_view_item::*;
#[cfg(feature = "stories")]
pub use stories::*;