Repository navigation
Conversation
huacnlee
left a comment
There was a problem hiding this comment.
This adds an opt-in destination preview to native Markdown links while keeping the existing link wrapping, selection, and click path. The Base behavior / application-owned preview view boundary is reasonable, and link_tooltip describes its scope accurately. Replacing links with custom inline elements is a weaker app-level workaround because it changes their text behavior.
No correctness blocker found in the reviewed diff at ba285bb. Before accepting the new public API (crates/base/src/text/text_view.rs:462 and the Component wrapper), please identify an actual downstream consumer/use case beyond the new demonstration example; the current description establishes the mechanism but does not establish product demand. The documented cache lasts until another destination is shown, so callers also need to understand that replacing the callback alone will not rebuild an already cached preview for the same URL.
Validation: cargo fmt --all --check, the focused gpui-base tooltip regression with --features test-support, Base all-target Clippy with that feature, Component library Clippy, and the native example build passed. The combined Base/Component all-target invocation with Base test support hits an unrelated Observed<E>::vertical_scrollbar compilation issue in popup_menu.rs:1600; the separate checks above pass. All 19 current GitHub checks are green.
On Linux/Xvfb I compared an actual main build (1ded8be, same local example fixture without the unavailable builder) with this PR, verified file destinations and the second row of a wrapped label, pointer-following movement and dismissal. The regression additionally covers overlay occlusion and idle frame requests. macOS/Windows interactive behavior, HiDPI, and a full keyboard navigation pass were not independently exercised here. No approval or merge performed.
Description
Native Markdown links have no destination preview. Applications currently have to replace a link with a custom inline element to attach one, which changes how its label wraps and selects.
Add an opt-in
link_tooltipbuilder to Base and ComponentTextView. It receives the destination and returns an application-owned view. The preview follows the pointer while the native link keeps its wrapping, selection, and click handling.Hover eligibility comes from painted hitboxes, so a link behind an overlay cannot activate a preview. A hover transition requests its first preview frame; an idle preview does not keep requesting frames.
Screenshot
Captured from the native example on Linux. The left image uses
--no-preview.The preview also works over the second line of a wrapped link:
Public API
gpui-base
Build a pointer-following tooltip for the hovered destination. No preview is shown unless the builder is configured. The returned view is cached until a different destination is shown.
gpui-component
Expose the same hook through the styled wrapper.
How to test
cargo run -p example-link-tooltip. Hover the file link, move along its label, then hover the second line of the wrapped link. Move away to dismiss the preview.cargo run -p example-link-tooltip -- --no-previewruns the same example without the builder.Checklist
AI disclosure
This PR is AI generated by GPT 6.1 Sol Extra High reasoning.