Skip to content

Conversation

@pooja-bruno
Copy link
Collaborator

@pooja-bruno pooja-bruno commented Dec 4, 2025

Description

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

Summary by CodeRabbit

  • New Features

    • Support for dynamic (faker) variables that generate random values at runtime and OAuth2-backed variables with token lookup.
  • UI

    • Dynamic and OAuth2 variables show read-only notes, display tokens when available, or show warnings when invalid/missing.
    • Improved header text truncation and scope badge layout.
  • Tests

    • Expanded tests covering dynamic/faker and OAuth2 rendering, warnings, and read-only behavior.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

Adds handling for dynamic (faker) variables prefixed with $ and OAuth2 variables using $oauth2.*, including validation, scope labeling, read-only/edit behavior, UI warnings, test coverage, and small CSS header truncation/flex tweaks.

Changes

Cohort / File(s) Summary
Dynamic & OAuth2 Variable Core
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
Detects variables starting with $ and $oauth2.*; validates dynamic faker names via mockDataFunctions/isValidFakerVariable, and OAuth2 tokens via isValidOAuth2Variable; adjusts scope labels, read-only/edit rules, shows warnings/notes for invalid or runtime-generated values, and updates editor init/render paths to support both types.
Tests — Dynamic & OAuth2
packages/bruno-app/src/utils/codemirror/brunoVarInfo.spec.js
Adds mockDataFunctions mocks and test helpers; covers valid/invalid dynamic variable rendering (read-only note, missing value container, warnings) and OAuth2 scenarios (scope badge, token display, missing-token warnings).
Global styles (UI tweaks)
packages/bruno-app/src/globalStyles.js
Adds truncation/flex rules for .var-name in variable headers (flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap) and prevents .var-scope-badge shrinking (flex-shrink: 0).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review isValidFakerVariable / isValidOAuth2Variable edge cases and lookup fallbacks.
  • Verify editor initialization branches (CodeMirror setup, masking, autocomplete) to avoid state/regression.
  • Confirm tests' mocks accurately reflect runtime behavior and cover warning/read-only UI.
  • Check CSS changes in header components for layout regressions across breakpoints.

Possibly related PRs

Suggested reviewers

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

Poem

🎲 A dollar calls for random names, a token keeps the gate,
Badges glow, warnings speak — the editor knows its fate.
Headers trim their overflow, tests hum in tidy rows,
New scopes, small notes, and UI love — the change now gently flows.

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding variable info tooltip support for faker (dynamic) variables, which is the core focus of the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link
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: 0

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

9-9: Dynamic/faker variable handling is cohesive; minor optimization possible

The integration of mockDataFunctions, the new dynamic scope label, read‑only behavior, and name/validity checks for $‑prefixed variables hangs together well and matches the intended UX (badge + warning for unknown, read‑only note for valid dynamics). One small optimization: scopeInfo.value for dynamic variables is set by calling fakerFunction(), but that value is not used anywhere on the dynamic paths (you return before any value/clipboard/editor logic), so you could avoid invoking the faker function here to save unnecessary work and side effects:

-    scopeInfo = {
-      type: 'dynamic',
-      value: fakerFunction ? fakerFunction() : '',
-      data: null,
-      isValidFakerVariable: !!fakerFunction
-    };
+    scopeInfo = {
+      type: 'dynamic',
+      value: '',
+      data: null,
+      isValidFakerVariable: !!fakerFunction
+    };

Everything else around validation and early returns for dynamic variables looks solid.

Also applies to: 67-80, 182-193, 243-245, 279-311

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 109394c and c83448d.

📒 Files selected for processing (2)
  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.js (6 hunks)
  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.spec.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation, never tabs
Use single quotes for strings instead of double quotes
Always add semicolons at the end of statements
No trailing commas in code
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line with a minimum of 2 elements for multiline formatting
No newlines inside function parentheses
Space before and after the arrow in arrow functions: () => {}
No space between function name and parentheses: func() not func ()
Semicolons should go at the end of the line, not on a new line
Function names should be concise and descriptive
Add JSDoc comments to provide details to abstractions
Avoid single-line abstractions where all that is being done is increasing the call stack with one additional function
Add meaningful comments to explain complex code flow instead of obvious comments

Files:

  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.spec.js
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

Add tests for any new functionality or meaningful changes; update corresponding tests when code is added, removed, or significantly modified

Files:

  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.spec.js
🧠 Learnings (2)
📚 Learning: 2025-12-03T08:09:57.124Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-03T08:09:57.124Z
Learning: Applies to **/*.{test,spec}.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes; update corresponding tests when code is added, removed, or significantly modified

Applied to files:

  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.spec.js
📚 Learning: 2025-12-03T08:09:57.124Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-03T08:09:57.124Z
Learning: Use consistent patterns and helper utilities where they improve clarity; prefer shared test utilities over copy-pasted setup code only when it reduces complexity

Applied to files:

  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.spec.js
🧬 Code graph analysis (1)
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js (1)
packages/bruno-common/src/index.ts (1)
  • mockDataFunctions (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: CLI Tests
🔇 Additional comments (1)
packages/bruno-app/src/utils/codemirror/brunoVarInfo.spec.js (1)

5-13: Dynamic/faker tests and mocks nicely cover the new behavior

The extended @usebruno/common mock (adding mockDataFunctions stubs) and the dynamic/faker variable rendering tests are well aligned with the implementation: you assert the read‑only note for valid dynamics, absence of a value container, and the warning + Dynamic scope badge for unknown dynamics. This gives good confidence in the new $‑prefixed variable path without overcomplicating the test setup.

Also applies to: 434-470

@pull-request-size pull-request-size bot added size/L and removed size/M labels Dec 4, 2025
Copy link
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: 0

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

253-254: Consider extracting read-only types to a constant.

The boolean chain is growing. For maintainability:

+const READ_ONLY_SCOPE_TYPES = new Set(['process.env', 'runtime', 'dynamic', 'oauth2', 'undefined']);
+
-const isReadOnly = scopeInfo.type === 'process.env' || scopeInfo.type === 'runtime' || scopeInfo.type === 'dynamic' || scopeInfo.type === 'oauth2' || scopeInfo.type === 'undefined';
+const isReadOnly = READ_ONLY_SCOPE_TYPES.has(scopeInfo.type);

321-328: Consider including the token ID in the warning message.

The current message is generic. Including the token ID would help users debug more quickly:

-    warningNote.textContent = `OAuth2 token not found. Make sure you have fetched the token with the correct Token ID.`;
+    const tokenId = variableName.substring('$oauth2.'.length);
+    warningNote.textContent = `OAuth2 token "${tokenId}" not found. Make sure you have fetched the token.`;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 627f8fa and 4fac205.

📒 Files selected for processing (1)
  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.js (7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation, never tabs
Use single quotes for strings instead of double quotes
Always add semicolons at the end of statements
No trailing commas in code
Always use parentheses around parameters in arrow functions, even for single parameters
For multiline constructs, put opening braces on the same line with a minimum of 2 elements for multiline formatting
No newlines inside function parentheses
Space before and after the arrow in arrow functions: () => {}
No space between function name and parentheses: func() not func ()
Semicolons should go at the end of the line, not on a new line
Function names should be concise and descriptive
Add JSDoc comments to provide details to abstractions
Avoid single-line abstractions where all that is being done is increasing the call stack with one additional function
Add meaningful comments to explain complex code flow instead of obvious comments

Files:

  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: CLI Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
🔇 Additional comments (5)
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js (5)

9-9: LGTM!

Clean addition of mockDataFunctions to the existing import.


76-77: LGTM!

Scope labels for new variable types are properly defined.


183-210: Logic looks correct; verify OAuth2 variable path structure.

The check ordering is correct (OAuth2 before general $ prefix). Note that lodash get will parse $oauth2.tokenId as variables['$oauth2']['tokenId'] due to dot notation. Ensure the variables object structure matches this expectation.

Edge case: $oauth2 without a trailing dot falls through to the dynamic handler and will show "Unknown dynamic variable" - this seems acceptable.


303-319: LGTM!

Clear user messaging for both valid and invalid dynamic variables. Early returns prevent unnecessary DOM construction.


582-586: LGTM!

OAuth2 read-only note is consistent with the existing process.env handling.

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.

1 participant