Skip to content

fix: variable-tooltip hover issues#7907

Open
shubh-bruno wants to merge 7 commits intousebruno:feat/7458-improve-variable-tooltip-internalfrom
shubh-bruno:feat/7458-improve-variable-tooltip-internal
Open

fix: variable-tooltip hover issues#7907
shubh-bruno wants to merge 7 commits intousebruno:feat/7458-improve-variable-tooltip-internalfrom
shubh-bruno:feat/7458-improve-variable-tooltip-internal

Conversation

@shubh-bruno
Copy link
Copy Markdown
Collaborator

@shubh-bruno shubh-bruno commented May 4, 2026

Description

JIRA

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

    • Copy button now captures the latest resolved/interpolated variable value at click time
    • Editor transitions use visibility staging to eliminate visual flashes and resize issues
    • Popup hide logic now supports immediate/idempotent cleanup and respects pin/hidden state
  • New Features

    • Tooltip pinning preserves visibility and prevents unpin-based hiding during edits
  • Tests

    • Added end-to-end tests validating tooltip pinning, edit/save persistence, and clipboard copy behavior

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • main
  • release/*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2f74b0c3-7595-4d74-a64e-e955f5751967

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The PR changes the variable tooltip popup: the copy button resolves the value at click time via a getter and the tooltip tracks a live currentInterpolatedValue; editor transitions use display+visibility staging to avoid flashes; popup lifecycle adds isPinned/isHidden with support for immediate synchronous hide/cleanup. Three Playwright tests were added for pin/edit persistence and clipboard behavior.

Changes

Variable Tooltip Lifecycle & Copy Behavior

Layer / File(s) Summary
Copy API
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
getCopyButton now accepts a getter (getVariableValue) so the value is resolved at click time (was copying captured value).
Runtime Value Tracking
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
Introduces currentInterpolatedValue and currentShouldMaskValue, updated after saves; editable view uses getCopyButton(() => currentInterpolatedValue, ...) and secret toggle reads live state.
Editor Reveal/Hide Transition
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
Switches editor show/hide to staged display + visibility with requestAnimationFrame and refresh to avoid layout/text flashes during read↔edit transitions.
Popup State & Lifecycle
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
showPopup cleans previous active popup via _hidePopup({ immediate: true }); popup state gains isPinned and isHidden; hidePopup({ immediate }) is idempotent and supports immediate DOM removal and proper listener teardown.
Event Handling Wiring
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
Document clicks and editor-change handlers respect isPinned (preventing hide) and popup._hidePopup is attached for replacement/cleanup flows.
Tests
tests/variable-tooltip/variable-tooltip.spec.ts
Adds three Playwright tests: keep-open-while-editing-when-mouse-leaves, persist subsequent edits while pinned, and copy latest value after editing (clipboard assertions).

Sequence Diagram

sequenceDiagram
    actor User
    participant Popup as Variable Tooltip
    participant Editor as CodeMirror Editor
    participant Var as Variable Resolver
    participant Clipboard as Clipboard

    User->>Popup: Hover variable
    Popup->>Popup: showPopup() (cleans prior popup)
    Popup-->>User: Render tooltip with value

    User->>Popup: Click/pin or click value
    Popup->>Popup: isPinned = true / open editor
    Editor->>Editor: visibility staging (hide → raf → refresh → reveal)
    Popup-->>User: Editor visible

    User->>Editor: Type + Enter
    Editor->>Var: Save updated value
    Var-->>Editor: Resolved interpolated result
    Editor->>Popup: currentInterpolatedValue = resolved

    User->>Popup: Click copy
    Popup->>Clipboard: Copy currentInterpolatedValue
    Clipboard-->>User: Clipboard updated
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

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

Poem

A popup pinned, an editor calm and bright,
Copies fetch the freshest saved delight,
No flashing frames, just staged reveal and cheer,
Tooltips hold while you edit — clarity near. ✨

🚥 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 directly addresses the main change: fixing variable-tooltip hover behavior by implementing live state synchronization and pinning logic.
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 unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

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

135-140: ⚡ Quick win

Expose a stable test id on the copy button.

This PR adds more Playwright coverage around the tooltip copy flow, but the button is still only addressable through a styling class. Adding a data-testid here will make those tests less brittle when tooltip/CodeMirror markup shifts.

As per coding guidelines, "Add data-testid to testable elements for Playwright."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js` around lines 135 -
140, In getCopyButton (the factory that creates the copy button), add a stable
data-testid attribute—e.g., copyButton.setAttribute('data-testid',
'bruno-copy-button')—so tests can target it reliably; update the element created
in getCopyButton (used with getVariableValue and onCopyCallback) to include this
data-testid alongside the existing className and type attributes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js`:
- Around line 421-423: The live tooltip's cached copy value
currentInterpolatedValue is initialized from variableValue which drops valid
falsy values and never advances after saves; update the code so that after every
successful save path you assign the resolved/saved value (not just
variableValue) into currentInterpolatedValue and also update any mask/reveal
state used by the tooltip; specifically, in the save-success handler(s) (the
code paths referenced around currentInterpolatedValue initialization and the
other block at lines 566-576) set currentInterpolatedValue to the newly saved
value using an explicit check for undefined/null (instead of truthiness) so
0/false are preserved, and ensure any reveal/mask flags that affect redraw are
updated from the same saved-state so future redraws use the new value.

In `@tests/variable-tooltip/variable-tooltip.spec.ts`:
- Around line 435-640: Three tests are accidentally committed with test.only
which will focus and skip the rest of the suite; remove the `.only` from the
three focused test invocations — the tests whose titles begin "should keep
tooltip open while editing when mouse leaves popup area", "should persist
subsequent edits while popup stays open", and "should copy latest value after
editing within the same tooltip" — so they use plain test(...) instead of
test.only(...); ensure no other test.only remains in this file.

---

Nitpick comments:
In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js`:
- Around line 135-140: In getCopyButton (the factory that creates the copy
button), add a stable data-testid attribute—e.g.,
copyButton.setAttribute('data-testid', 'bruno-copy-button')—so tests can target
it reliably; update the element created in getCopyButton (used with
getVariableValue and onCopyCallback) to include this data-testid alongside the
existing className and type attributes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 259d6c5f-61b4-4222-901c-d337fe5b4650

📥 Commits

Reviewing files that changed from the base of the PR and between 118ba80 and 0330cda.

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

Comment thread packages/bruno-app/src/utils/codemirror/brunoVarInfo.js Outdated
Comment thread tests/variable-tooltip/variable-tooltip.spec.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js (1)

624-624: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use ?? for consistency with editable path.

The read-only copy button uses || which coerces valid falsy values (0, false) to empty string. For consistency with the editable path (line 157), use nullish coalescing.

Suggested fix
-    const copyButton = getCopyButton(variableValue || '');
+    const copyButton = getCopyButton(variableValue ?? '');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js` at line 624, Replace
the null-coercing fallback in the read-only copy button creation so valid falsy
values like 0 or false are preserved: in the expression that constructs
copyButton (getCopyButton(variableValue || '')), swap the logical OR for nullish
coalescing (use ??) to match the editable path behavior used elsewhere (see the
editable path at line with ??), i.e., call getCopyButton with variableValue ??
'' so only null/undefined fall back to empty string.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js`:
- Line 624: Replace the null-coercing fallback in the read-only copy button
creation so valid falsy values like 0 or false are preserved: in the expression
that constructs copyButton (getCopyButton(variableValue || '')), swap the
logical OR for nullish coalescing (use ??) to match the editable path behavior
used elsewhere (see the editable path at line with ??), i.e., call getCopyButton
with variableValue ?? '' so only null/undefined fall back to empty string.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 31c8ed0b-2496-47aa-8425-0085cd385ff5

📥 Commits

Reviewing files that changed from the base of the PR and between 4da15e0 and b0cef9b.

📒 Files selected for processing (1)
  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.js

naman-bruno and others added 3 commits May 4, 2026 17:04
* Enhance JSON schema validation by integrating ajv-formats for additional format support in tests and runtime assertions.

* fix: update pre-request script to stop execution instead of running it

* fix: ensure newline at end of file in pre-request script for ping.bru

* refactor: update JSON schema validation tests to assert rejection of invalid formats

* refactor: streamline JSON schema validation by using a default AJV instance and enhance tests for various ajvOptions scenarios

* refactor: update JSON schema tests to use more descriptive property names and improve error handling for invalid formats

* feat: add support for Draft-07 JSON Schema validation and improve error handling for unsupported schema versions

* fix: improve error message for unsupported JSON Schema versions in runtime assertions and tests
@sid-bruno sid-bruno changed the base branch from main to feat/7458-improve-variable-tooltip-internal May 5, 2026 06:49
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.

3 participants