SIGN IN SIGN UP

sidebar: Show tooltips for collapsed menu items (#2658)

## Description

Collapsed icon-only sidebar menu items hide their labels, leaving their
meaning unclear on hover. This change shows each item's existing label
as a managed tooltip while the item is collapsed. Expanded and iconless
menu items keep their existing behavior.

The interaction is based on the collapsed icon sidebar demonstrated by
[shadcn/ui Base
Sidebar](https://ui.shadcn.com/docs/components/base/sidebar), where
hovering an icon-only menu item reveals its label beside the sidebar.

The tooltip prefers the right side of the trigger, falls back to the
left when needed, and remains clamped to the viewport. Existing managed
tooltips preserve their current top/bottom placement behavior, and no
new public API is introduced.

## Screenshot

<img width="946" height="1020" alt="图片"
src="https://github.com/user-attachments/assets/461fff95-d916-41fe-97d6-ad86caa0669e"
/>

## How to Test

- `rustfmt --edition 2024 --check crates/ui/src/tooltip.rs
crates/ui/src/sidebar/menu.rs`
- `git diff --check`
- `cargo test -p gpui-component`: 368 passed
- `cargo clippy -p gpui-component --lib -- -D warnings`

Manual verification steps:

1. Collapse an icon sidebar.
2. Hover a menu item and confirm its label appears to the right of the
icon.
3. Expand the sidebar and confirm hovering the same item no longer shows
the label tooltip.

## AI Assistance

The implementation and tests were AI-assisted by Codex. The behavior and
final scope were directed and manually verified by the author.

## Checklist

- [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and
followed the guidelines.
- [x] Reviewed the changes in this PR and confirmed AI generated code
(If any) is accurate.
- [x] Passed `cargo run` for story tests related to the changes.
- [ ] Tested macOS, Windows and Linux platforms performance (if the
change is platform-specific)
M
mengh04 committed
f96f1576ee704b48476f6782962690e0feb7985b
Parent: 5a2a96e
Committed by GitHub <noreply@github.com> on 8/7/2026, 9:27:37 AM