Add tooltip message type with viewport-aware positioning#127
Add tooltip message type with viewport-aware positioning#127
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| log( | ||
| `Invalid tooltip target selector "${targetSelector}" for message ${currentMessage.messageId}` | ||
| ); |
There was a problem hiding this comment.
Is it possible for an exception to happen here? Would document ever be undefined?
There was a problem hiding this comment.
won't come from document as it always runs in browser, but might throw if the targetSelector is wrong .. which we are already catching.
There was a problem hiding this comment.
document.querySelector('not-existing-selector') returns null, and then !!null returns false 🤔.
There was a problem hiding this comment.
To close the loop, Karn educated me in the error of my ways. Something like
document.querySelector('/')
can throw a SyntaxError exception.

Summary
Adds a tooltip message type to the web SDK that anchors messages to DOM elements with viewport-aware positioning, auto-repositioning on scroll/resize, and directional arrow indicators.
Changes
message-manager.ts): NewshowTooltipMessage()path that validates the target element exists, dismisses any existing tooltip on the same target, and loads the tooltip without blocking overlays. Tooltips coexist with overlays and with each other on different targets. RoutesrouteLoaded,sizeChanged,error, androuteErrorevents through tooltip-specific handlers.tooltip-position-manager.ts): Full viewport-aware positioning system replacing the simple offset + single-flip logic:TooltipHandlewithcleanup()andreposition()for external resize triggerstooltip.ts): Switched from id-based selectors (#gist-tooltip) to class-based (.gist-tooltip-inner) for multiple concurrent tooltips. CSS scoped under optionalwrapperId. Added a clip wrapper around the iframe.message-component-manager.ts):showTooltipComponentreturns a boolean indicating positioning success. NewresizeTooltipComponent()sets iframe height and triggers repositioning.clearAllTooltipHandles()for bulk cleanup onsetup()andclearUserToken().gist-properties-manager.ts):isEmbeddedisfalsewhentooltipPositionis set so tooltip messages skip the embed flow.Test plan
tooltip-position-manager(visibility checks, fallback ordering, cross-axis clamping, hide/re-show, scroll ancestor clipping, arrow offset tracking)message-component-manager(handle lifecycle,clearAllTooltipHandles, resize forwarding, positioning failure paths)message-manager(tooltip show/hide flow, event routing, target validation, concurrent tooltips, overlay coexistence, invalid selector handling)tooltip.tstemplate (scoped CSS, class-based selectors, multi-instance isolation)Note
Medium Risk
Adds a new tooltip rendering path alongside existing overlay/embed flows and changes message lifecycle/event handling, which can affect how messages show/dismiss/resize across the SDK. Risk is moderated by extensive unit test coverage but touches core message routing and DOM interactions.
Overview
Adds a new tooltip message type to the web SDK, allowing
Gist.showMessageto anchor messages to a DOMelementIdusingtooltipPositionwithout blocking existing overlays or other tooltips.Implements a viewport/scroll-aware positioning engine (auto-fallback between sides, cross-axis clamping with arrow offset, hide/show when targets move in/out of view, and scroll-container listeners) and updates tooltip rendering to support multiple concurrent instances via class-based markup and optional CSS scoping.
Extends component/message managers with tooltip-specific load/show/hide/resize flows, tooltip-handle lifecycle cleanup (
clearAllTooltipHandles()called duringGist.setup()), and updates property resolution so tooltip messages don’t route through embed behavior; also adds a tooltip demo section and styling inexamples/plus broad new/updated tests around tooltip behavior and event routing.Written by Cursor Bugbot for commit 0f29bfe. This will update automatically on new commits. Configure here.