Skip to content

fix: refresh scopeInfo after variable save in tooltip editor - #6935

Merged
sid-bruno merged 2 commits into
usebruno:mainfrom
pooja-bruno:fix/varinfo-duplicate-variable-creation
Jan 30, 2026
Merged

sid-bruno merged 2 commits into
usebruno:mainfrom
pooja-bruno:fix/varinfo-duplicate-variable-creation

Conversation

@pooja-bruno

@pooja-bruno pooja-bruno commented Jan 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes a bug in the variable tooltip editor where editing a newly created variable multiple times (while the tooltip stays open) would create duplicate variables instead of updating the existing one.

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.

before:
https://github.com/user-attachments/assets/8d61caa7-dc78-4506-beab-f10d8d75e8f2

after:
https://github.com/user-attachments/assets/c6491012-b56b-48e6-83dc-8bd2b61e4c54

Summary by CodeRabbit

  • Bug Fixes
    • Improved variable update persistence to ensure changes are immediately reflected and available after saving, enhancing variable interpolation reliability in workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

After saving a variable, the code now re-reads the Redux state and recomputes the variable's scopeInfo by locating the updated collection/item, then updates the local scopeInfo reference so subsequent interpolation and secret/reference handling use the refreshed value.

Changes

Cohort / File(s) Summary
Variable scope state synchronization
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
Added imports findCollectionByUid and findItemInCollectionByItemUid. After dispatching updateVariableInScope, re-fetches Redux state, locates the updated collection/item, recomputes and replaces the local scopeInfo with the fresh value so UI interpolation and secret/reference logic use the updated variable.

Sequence Diagram(s)

(No sequence diagrams generated — change is a localized client-side state refresh and does not introduce a multi-component control flow requiring visualization.)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

size/XS

Suggested reviewers

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

Poem

A var was saved, the state refreshed,
scopeInfo updated, stale bits quashed,
References neat, secrets aligned,
Fresh Redux flow, interpolation primed. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: refreshing scopeInfo after variable save in the tooltip editor, which directly addresses the bug described in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js`:
- Around line 517-526: The code re-fetches freshCollection but still calls
getVariableScope with the old collection, causing stale scopeInfo; update the
call to getVariableScope to pass freshCollection (and use freshItem looked up
from freshCollection when item is present), and add a guard that freshCollection
exists before calling findItemInCollectionByItemUid or getVariableScope so you
don't dereference null; replace the existing getVariableScope(collection,
freshItem) usage with getVariableScope(freshCollection, freshItem) and ensure
updatedScopeInfo assignment uses that result.

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.

2 participants