Repository navigation
tooltip: Make show delay and grace period configurable with TooltipDefaults - #3376
Merged
Merged
Conversation
…efaults` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Managed tooltips (the ones components set up through
.tooltip(), shown by the per-windowTooltipOverlay) had their timing hard-coded ingpui-base: a 500 ms show delay and a 300 ms grace period. Applications could not change either.gpui_base::TooltipDefaultsholds the show delay and grace period and is installed as a global, following theTextViewDefaultspattern.TooltipOverlayreads it on every show and hide request, so installing new defaults also applies to windows that are already open. Without it, timing is unchanged.TooltipRequest::with_show_delayoverrides the show delay for one request. The components with built-in tooltips expose it astooltip_show_delay. A zero delay shows the tooltip immediately instead of going through a timer.Direct GPUI
.tooltip()calls (includingAttachment's tooltip) bypassTooltipOverlayand are not affected; they keep using GPUI's own.tooltip_show_delay(). The docs say so.TooltipRequest's setters now use thewith_prefix required for public data types with non-boolean fields:placementbecomeswith_placementand stays as a deprecated alias.The Tooltip story gains a "Show delay" section with immediate, default and 1 s triggers in one row. The English and Chinese Tooltip docs (component and Base primitive) describe the timing and both settings.
This is an AI-assisted implementation.
Screenshot
Screen.Recording.2026-10-06.at.14.45.01.mov
Public API
gpui-base
gpui_base::TooltipDefaults— application-wide timing for tooltips shown throughTooltipOverlay.Clone + Copy + Debug + PartialEq + Eq + Default; implementsGlobal.TooltipDefaults::new() -> Self— the Base defaults: 500 ms show delay, 300 ms grace period.TooltipDefaults::with_show_delay(self, delay: Duration) -> Self— sets how long the pointer must rest on a trigger before its tooltip shows.TooltipDefaults::with_grace_period(self, period: Duration) -> Self— sets how long a tooltip stays after the pointer leaves; entering another trigger within it switches immediately.TooltipDefaults::show_delay(&self) -> Duration— reads the show delay.TooltipDefaults::grace_period(&self) -> Duration— reads the grace period.TooltipDefaults::install(self, cx: &mut App)— installs the defaults for the whole application.TooltipDefaults::global(cx: &App) -> Self— returns the installed defaults, or the Base ones when none were installed.TooltipRequest::with_show_delay(self, delay: Duration) -> Self— overridesTooltipDefaults::show_delayfor this request.TooltipRequest::with_placement(self, placement: Placement) -> Self— prefers a side for the tooltip; replacesplacement.TooltipRequest::placement— now#[deprecated], forwarding towith_placement.gpui-component
gpui_component::tooltip::TooltipDefaults— re-export ofgpui_base::TooltipDefaults.Button::tooltip_show_delay(self, delay: Duration) -> Self— overrides the show delay of the button's tooltip.Toggle::tooltip_show_delay(self, delay: Duration) -> Self— same, forToggle.Switch::tooltip_show_delay(self, delay: Duration) -> Self— same, forSwitch.Checkbox::tooltip_show_delay(self, delay: Duration) -> Self— same, forCheckbox.Radio::tooltip_show_delay(self, delay: Duration) -> Self— same, forRadio.Clipboard::tooltip_show_delay(self, delay: Duration) -> Self— same, forClipboard.InputGroupButton::tooltip_show_delay(self, delay: Duration) -> Self— same, forInputGroupButton.Breaking Changes
TooltipRequest::placementis deprecated in favor ofwith_placement. It still compiles and behaves the same, with a deprecation warning.How to Test
cargo test -p gpui-base --lib tooltip— 5 passed, including the newshow_delay_follows_defaults_and_request_override: with a 100 ms default the tooltip is absent at 99 ms and present at 100 ms, and a zerowith_show_delayshows it synchronously.cargo test -p gpui-component --lib— 603 passed (test_button_buildercoverstooltip_show_delay).RUSTFLAGS="-D warnings" cargo clippy -p gpui-base -p gpui-component --lib --tests -- --deny warningsandcargo clippy -p gpui-component-story -- --deny warnings— passed.cargo fmt --check— passed.cargo run, open Tooltip → Show delay on macOS: Immediate shows at once, Default after about 0.5 s, Slow after about 1 s, and moving between them within the grace period switches without waiting.Checklist
cargo runfor story tests related to the changes.