Add tooltip support to preview bar and introduce safe findElement utility#132
Merged
Add tooltip support to preview bar and introduce safe findElement utility#132
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
BernardGatt
approved these changes
Mar 26, 2026
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.

Summary
Adds tooltip support to the preview bar and hardens DOM element lookup across the SDK.
Preview bar: tooltip display type
buildElementSelectorControlfrom inline controls so both inline and tooltip can reuse itfindElementutilityfindElement(selector)insrc/utilities/dom.ts— a safe wrapper that triesgetElementByIdfirst, falls back toquerySelector, and catches invalid selector errors instead of throwingquerySelectorblocks inmessage-manager.tswith the new utility, simplifying bothshowTooltipMessageandhandleGistEventsButton hardening & style fixes
type="button"to toggle, end-session, and select-element buttons to prevent unintended form submissions when the preview bar is embedded inside a customer's<form>appearance: none,min-width: auto,box-sizing: border-box) on preview bar buttons so host-page stylesheets don't distort themTests
dom.test.tscoveringfindElement— bare IDs, CSS selectors, missing elements, invalid selectorspreview-bar-manager.test.tscovering init, display type dropdown options, tooltip-specific controls, buttontypeattributes, step changes, and teardownExample app
cioPreviewIdis present in the URLNote
Medium Risk
Touches message display flow for tooltips and preview-session UI, so regressions could prevent messages from rendering or cause preview settings to apply incorrectly. Changes are localized and backed by new unit tests for selector safety and preview-bar behavior.
Overview
Adds tooltip as a new preview-bar display type, including element-selector + tooltip-position controls, and cleans up incompatible settings when switching display types.
Introduces a safe
findElementDOM helper (id-first, selector fallback, catches invalid selectors) and replaces ad-hocquerySelectortry/catch checks inmessage-manager/preview-bar-managerto avoid throwing on malformed selectors.Hardens preview bar buttons by setting
type="button"and adds CSS resets to reduce host-page style interference; expands tests for tooltip selector error handling, preview-bar UI behavior, andfindElement, and updates the example page with a simple preview-bar activation demo.Written by Cursor Bugbot for commit e2a08bd. This will update automatically on new commits. Configure here.