Repository navigation
feat: Stabilize variable info editor transition and popup lifecycle - #7912
Conversation
…7458) (#7818) * fix: prevent var-info split second UI flicker. Co-authored-by: Mhammed Reda El Jirari <[email protected]> Co-authored-by: Fred Rukundo <[email protected]> Co-authored-by: El Mehdi Bennamrouche <[email protected]> Co-authored-by: Ahmed Bouregba <[email protected]>
WalkthroughStaged editor reveal avoids flicker; edited variables maintain live resolved/masked state and copy reads the latest value; popup lifecycle adds pin/unpin with immediate hide control; tests cover pinning, persistence, and clipboard correctness. ChangesCodeMirror Variable Tooltip System
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Improves the CodeMirror variable-info tooltip UX in brunoVarInfo by stabilizing the inline value editor’s transition into edit mode and making the popup lifecycle more robust (pin-to-interact, outside-click dismiss, and safer teardown when replacing an active popup).
Changes:
- Adjusts click-to-edit to stage and size the embedded CodeMirror editor before swapping the visible display (to reduce flicker).
- Updates popup management to support pinning on internal click, ignoring auto-hide while pinned, and closing on outside click.
- Ensures existing popups are hidden/cleaned up via a stored hide hook before opening a new popup.
Comments suppressed due to low confidence (1)
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js:963
- The popup fade-out removal waits 600ms, but the CSS transition for
.CodeMirror-brunoVarInfoopacity is 0.15s. Keeping anopacity: 0fixed-position element in the DOM for ~450ms longer than needed can intercept clicks (opacity doesn’t disable pointer events) and cause UI flakiness. Consider aligning the timeout with the transition duration (plus a small buffer) or removing ontransitionend, and/or setpointer-events: nonewhen starting the hide.
if (popup.style.opacity) {
popup.style.opacity = 0;
setTimeout(function () {
if (popup.parentNode) {
popup.parentNode.removeChild(popup);
}
}, 600);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Don't SQUASH, community PR extension |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js (2)
891-919: 💤 Low valueDefensive
popup.contains(e.target)inonPopupClickis effectively always true.
onPopupClickis bound viaCodeMirror.on(popup, 'click', ...), so it only fires for events that bubble throughpopup— the guard is dead defensive code. Not a bug, just noise. Happy to leave as-is if you prefer the explicit intent.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js` around lines 891 - 919, The onPopupClick handler contains a redundant defensive check (popup.contains(e.target)) because it is registered with CodeMirror.on(popup, 'click', onPopupClick) so events will always originate from within popup; remove the unnecessary if-statement from the onPopupClick function (or replace it with a short explanatory comment) to eliminate dead code while leaving the rest of the handler logic (setting isPinned = true and clearing popupTimeout) intact; locate the function named onPopupClick and the registration CodeMirror.on(popup, 'click', ...) to make the change.
135-184: 💤 Low valuePolymorphic
getCopyButtonargument is a small code smell.
getCopyButtonnow accepts either a getter function or a raw value, with the read-only path at line 624 still passing a plain string (variableValue || ''). Tightening to "always a getter" would make the contract uniform and avoid thetypeof === 'function'branch at click time. Trivial follow-up if you'd like to keep this tidy.♻️ Suggested tweak
-const getCopyButton = (getVariableValue, onCopyCallback) => { +const getCopyButton = (getVariableValue, onCopyCallback) => { @@ - // Resolve the latest value at click time so edits/saves are reflected. - const valueToCopy = typeof getVariableValue === 'function' ? getVariableValue() : getVariableValue; + // Resolve the latest value at click time so edits/saves are reflected. + const valueToCopy = getVariableValue();And at the read-only call site (line 624):
- const copyButton = getCopyButton(variableValue || ''); + const copyButton = getCopyButton(() => variableValue ?? '');🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js` around lines 135 - 184, The getCopyButton function currently accepts either a getter or a raw value causing a runtime typeof check; change its contract to require a getter function (getVariableValue) and remove the typeof branch inside getCopyButton, resolving the value by calling getVariableValue() unconditionally. Update all call sites (e.g., the read-only call that currently passes variableValue || '') to pass a zero-arg function like () => variableValue || '' and keep onCopyCallback behavior unchanged so click handling and clipboard writes work the same.tests/variable-tooltip/variable-tooltip.spec.ts (1)
568-636: 💤 Low valueConsider a tighter "icon reverted" wait before the second click.
At line 607
await expect(copyButton.locator('svg rect')).toBeVisible()waits for the copy icon to come back, which gates the next click. The<rect>selector is correct (it's part ofCOPY_ICON_SVG_TEXT), but it relies on internal SVG markup; if the icon ever changes shape this test becomes a silent timeout. A class-based check (e.g.,not.toHaveClass(/copy-success/)) would be more resilient.♻️ Suggested tweak
- // Wait for the icon to revert so the next click is allowed - await expect(copyButton.locator('svg rect')).toBeVisible(); + // Wait for the icon to revert so the next click is allowed + await expect(copyButton).not.toHaveClass(/copy-success/);Same idea applies to the
svg polylinecheckmark waits at lines 601 and 631 —toHaveClass(/copy-success/)would be equivalent and decoupled from SVG internals.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/variable-tooltip/variable-tooltip.spec.ts` around lines 568 - 636, The test uses brittle SVG-internal selectors (copyButton.locator('svg polyline') and 'svg rect') to detect copy success and revert; replace those checks with class-based assertions on the copy button (e.g., await expect(copyButton).toHaveClass(/copy-success/) for success and await expect(copyButton).not.toHaveClass(/copy-success/) for the reverted state) so the waits no longer depend on SVG markup — update the two success waits (previously checking 'svg polyline') and the revert wait (previously checking 'svg rect') in the "should copy latest value after editing within the same tooltip" test to use toHaveClass/not.toHaveClass on the copyButton locator instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js`:
- Around line 891-919: The onPopupClick handler contains a redundant defensive
check (popup.contains(e.target)) because it is registered with
CodeMirror.on(popup, 'click', onPopupClick) so events will always originate from
within popup; remove the unnecessary if-statement from the onPopupClick function
(or replace it with a short explanatory comment) to eliminate dead code while
leaving the rest of the handler logic (setting isPinned = true and clearing
popupTimeout) intact; locate the function named onPopupClick and the
registration CodeMirror.on(popup, 'click', ...) to make the change.
- Around line 135-184: The getCopyButton function currently accepts either a
getter or a raw value causing a runtime typeof check; change its contract to
require a getter function (getVariableValue) and remove the typeof branch inside
getCopyButton, resolving the value by calling getVariableValue()
unconditionally. Update all call sites (e.g., the read-only call that currently
passes variableValue || '') to pass a zero-arg function like () => variableValue
|| '' and keep onCopyCallback behavior unchanged so click handling and clipboard
writes work the same.
In `@tests/variable-tooltip/variable-tooltip.spec.ts`:
- Around line 568-636: The test uses brittle SVG-internal selectors
(copyButton.locator('svg polyline') and 'svg rect') to detect copy success and
revert; replace those checks with class-based assertions on the copy button
(e.g., await expect(copyButton).toHaveClass(/copy-success/) for success and
await expect(copyButton).not.toHaveClass(/copy-success/) for the reverted state)
so the waits no longer depend on SVG markup — update the two success waits
(previously checking 'svg polyline') and the revert wait (previously checking
'svg rect') in the "should copy latest value after editing within the same
tooltip" test to use toHaveClass/not.toHaveClass on the copyButton locator
instead.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 94f65b61-db17-43bb-8eae-f1133558293a
📒 Files selected for processing (2)
packages/bruno-app/src/utils/codemirror/brunoVarInfo.jstests/variable-tooltip/variable-tooltip.spec.ts
…sebruno#7912) * feat: Stabilize variable info editor transition and popup lifecycle (usebruno#7458) (usebruno#7818) * fix: prevent var-info split second UI flicker. Co-authored-by: Mhammed Reda El Jirari <[email protected]> Co-authored-by: Fred Rukundo <[email protected]> Co-authored-by: El Mehdi Bennamrouche <[email protected]> Co-authored-by: Ahmed Bouregba <[email protected]> * fix: variable-tooltip hover issues (usebruno#7907) --------- Co-authored-by: Avictos <[email protected]> Co-authored-by: Mhammed Reda El Jirari <[email protected]> Co-authored-by: Fred Rukundo <[email protected]> Co-authored-by: El Mehdi Bennamrouche <[email protected]> Co-authored-by: Ahmed Bouregba <[email protected]> Co-authored-by: shubh-bruno <[email protected]>
Description
JIRA
Extends #7818
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
Bug Fixes
Tests