Skip to content

feat: Stabilize variable info editor transition and popup lifecycle - #7912

Merged
bijin-bruno merged 2 commits into
mainfrom
feat/7458-improve-variable-tooltip-internal
May 13, 2026
Merged

bijin-bruno merged 2 commits into
mainfrom
feat/7458-improve-variable-tooltip-internal

Conversation

@sid-bruno

@sid-bruno sid-bruno commented May 5, 2026 •

Copy link
Copy Markdown
Collaborator

Description

JIRA

Extends #7818

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

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

    • Smoother variable editor transitions to eliminate flashing and layout shifts when entering/exiting edit mode.
    • Popup/tooltip pinning and dismissal made more reliable—pinned tooltips no longer close on mouse-out and respect click-to-pin/unpin behavior.
    • Copy action for editable variables now captures the latest saved/resolved value.
  • Tests

    • Added end-to-end tests validating tooltip pinning, edit persistence, and that the copy button writes the current value to the clipboard.

Review Change Stack

…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]>
Copilot AI review requested due to automatic review settings May 5, 2026 07:54
@coderabbitai

coderabbitai Bot commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Staged 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.

Changes

CodeMirror Variable Tooltip System

Layer / File(s) Summary
Live resolved value & copy wiring
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
Introduce mutable currentInterpolatedValue and currentShouldMaskValue; toggle/reveal uses live state; getCopyButton now accepts a getter and copy handler resolves value at click time.
Editor reveal, blur, and save lifecycle
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
Click-to-edit uses staged display + visibility with requestAnimationFrame to refresh layout and set editor height before swapping UI; blur restores visibility; save recalculates interpolated value and masking and updates live state or reverts on failure.
Popup show/hide and pin/unpin logic
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
showPopup prefers calling existing activePopup._hidePopup({ immediate: true }); add isPinned/isHidden guards; click-inside pins, outside-click unpins and hides; hidePopup accepts { immediate } and exposes _hidePopup.
Playwright tests: pinning, persistence, clipboard
tests/variable-tooltip/variable-tooltip.spec.ts
Copy-button test now reads navigator.clipboard.readText(); new tests pin the tooltip while editing outside, save sequential edits and verify persistence, and verify copy copies the latest saved value without re-hovering.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • usebruno/bruno#7818: Modifies the same renderVarInfo and popup lifecycle with _hidePopup and pinning changes.
  • usebruno/bruno#6935: Adjusts post-save state handling for variable edits in the same tooltip/editor area.
  • usebruno/bruno#6691: Changes tooltip/rendering flow in brunoVarInfo.js and may interact with these edits.

Suggested labels

size/M, adopted-by-maintainers

Suggested reviewers

  • helloanoop
  • bijin-bruno
  • lohit-bruno
  • naman-bruno

A popup pins when clicks are near,
Edits stay steady, no flash or tear,
Clipboard copies the freshest line,
requestAnimationFrame keeps timing fine,
Smooth reveals, saved values align.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: stabilizing the variable info editor UI transition and popup lifecycle management.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/7458-improve-variable-tooltip-internal

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented May 5, 2026 •

Copy link
Copy Markdown

CLI Test Results

  1 files  ±  0  211 suites  +19   43s ⏱️ -5s
592 tests + 69  592 ✅ + 69  0 💤 ±0  0 ❌ ±0 
705 runs  +100  698 ✅ +100  7 💤 ±0  0 ❌ ±0 

Results for commit eb3f1ea. ± Comparison against base commit d332d8e.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-brunoVarInfo opacity is 0.15s. Keeping an opacity: 0 fixed-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 on transitionend, and/or set pointer-events: none when 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.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels May 12, 2026
@sid-bruno

Copy link
Copy Markdown
Collaborator Author

Don't SQUASH, community PR extension

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js (2)

891-919: 💤 Low value

Defensive popup.contains(e.target) in onPopupClick is effectively always true.

onPopupClick is bound via CodeMirror.on(popup, 'click', ...), so it only fires for events that bubble through popup — 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 value

Polymorphic getCopyButton argument is a small code smell.

getCopyButton now 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 the typeof === '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 value

Consider 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 of COPY_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 polyline checkmark 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d8735a and eb3f1ea.

📒 Files selected for processing (2)
  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
  • tests/variable-tooltip/variable-tooltip.spec.ts

@bijin-bruno
bijin-bruno merged commit 31dedc3 into main May 13, 2026
12 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request May 22, 2026
6 tasks
sharan-bruno pushed a commit to sharan-bruno/bruno that referenced this pull request Jun 4, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants