Skip to content

fix: env vars loading and switching using react-virtuoso#6790

Merged
sid-bruno merged 11 commits intousebruno:mainfrom
shubh-bruno:fix/env-vars-loading
Jan 14, 2026
Merged

fix: env vars loading and switching using react-virtuoso#6790
sid-bruno merged 11 commits intousebruno:mainfrom
shubh-bruno:fix/env-vars-loading

Conversation

@shubh-bruno
Copy link
Collaborator

@shubh-bruno shubh-bruno commented Jan 13, 2026

Description

Environment variables table is virtualised using react-virtuoso for loading environment variables
This PR is only fixes loading of issues we still need to improve the code-mirror instancing

For fixing issue : #6728

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

  • Performance
    • Virtualized rendering for environment variables tables, improving responsiveness and reducing UI lag when viewing or editing large lists across environment screens.
  • Refactor
    • Internal rendering updated to enable dynamic table height and more efficient row updates without changing public behavior or user workflows.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

Walkthrough

Introduces virtualized rendering for environment-variable tables using react-virtuoso, replaces static table markup with TableVirtuoso in two EnvironmentVariables components, and adds dynamic table height management while preserving existing Formik-based form logic and public component signatures.

Changes

Cohort / File(s) Summary
Dependency Update
packages/bruno-app/package.json
Added runtime dependency react-virtuoso@^4.18.1.
Virtualized Environment Variable Tables
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js,
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
Replaced static <table>/<thead>/<tbody> markup with TableVirtuoso virtualization. Introduced TableRow memo wrapper, MIN_H constant, tableHeight state, and handleTotalHeightChanged to clamp/manage height. Moved per-row rendering into itemContent, preserved Formik setup, validation, draft restore, save/reset, and per-row error handling; component signatures unchanged.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

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

Poem

🪄 A list once long, now swift in scroll,
Cells rendered on demand, not all,
Heights kept tidy, headers fixed in place,
Forms unchanged, each input finds its space —
Virtuoso hums, the table wins the race.

🚥 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 accurately describes the main change: virtualizing environment variables tables using react-virtuoso to fix loading and switching behavior.
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.

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 (4)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)

29-38: Constants can be hoisted; tableContainerRef appears unused.

MIN_H and MAX_H are stable values—consider moving them outside the component to avoid redefinition on each render. Also, tableContainerRef is assigned via scrollerRef but never consumed elsewhere in this file.

Suggested refactor
+const MIN_H = 50;
+const MAX_H = 650;
+
 const EnvironmentVariables = ({ environment, setIsModified, collection }) => {
   const dispatch = useDispatch();
   const { storedTheme } = useTheme();
   const { globalEnvironments, activeGlobalEnvironmentUid } = useSelector((state) => state.globalEnvironments);

   const environmentsDraft = collection?.environmentsDraft;
   const hasDraftForThisEnv = environmentsDraft?.environmentUid === environment.uid;
-  const MIN_H = 50;
-  const MAX_H = 650;
-
-  const tableContainerRef = React.useRef(null);
   const [tableHeight, setTableHeight] = React.useState(MIN_H);

405-413: Consider using <th> for header cells.

For semantic HTML and accessibility, table headers should use <th> elements rather than <td>.

Suggested change
             fixedHeaderContent={() => (
               <tr>
-                <td className="text-center"></td>
-                <td>Name</td>
-                <td>Value</td>
-                <td className="text-center">Secret</td>
-                <td></td>
+                <th className="text-center"></th>
+                <th>Name</th>
+                <th>Value</th>
+                <th className="text-center">Secret</th>
+                <th></th>
               </tr>
             )}
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)

31-40: Same refactor opportunity as the sibling component.

Similar to the EnvironmentSettings variant: MIN_H and MAX_H could be hoisted outside the component, and tableContainerRef is assigned but never consumed.


343-351: Use <th> for header cells for consistency.

Same recommendation as the sibling component—semantic headers improve accessibility.

Suggested change
             fixedHeaderContent={() => (
               <tr>
-                <td className="text-center"></td>
-                <td>Name</td>
-                <td>Value</td>
-                <td className="text-center">Secret</td>
-                <td></td>
+                <th className="text-center"></th>
+                <th>Name</th>
+                <th>Value</th>
+                <th className="text-center">Secret</th>
+                <th></th>
               </tr>
             )}
📜 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 59ff9bd and 86b5458.

📒 Files selected for processing (3)
  • packages/bruno-app/package.json
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
🧰 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. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
🧠 Learnings (2)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
📚 Learning: 2026-01-09T18:25:14.640Z
Learnt from: kanakkholwal
Repo: usebruno/bruno PR: 6767
File: packages/bruno-app/src/components/ResponseExample/index.js:221-226
Timestamp: 2026-01-09T18:25:14.640Z
Learning: In the Bruno Electron renderer code (packages/bruno-app), assume window.ipcRenderer is always available and skip existence checks. Do not guard for ipcRenderer in this Electron context; use window.ipcRenderer directly (e.g., window.ipcRenderer.send(...), window.ipcRenderer.on(...)). If there are non-Electron contexts (such as test environments or non-Electron builds), add guards or mocks to avoid runtime errors there, but for the intended Electron renderer files, this pattern should be applied broadly within packages/bruno-app.

Applied to files:

  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
🔇 Additional comments (5)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)

400-404: Verify scroll behavior with overflowY: 'hidden'.

With overflowY: 'hidden' and a capped maxHeight of 650px, ensure users can still scroll through rows when content exceeds this limit. TableVirtuoso typically manages its own internal scroller, but this style may interfere with that behavior.


414-503: LGTM!

The itemContent implementation correctly returns a fragment with <td> cells, which is the expected pattern for TableVirtuoso. Row logic, form inputs, error handling, and conditional rendering are properly preserved.

packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)

338-342: Same overflowY: 'hidden' concern applies here.

Verify that scrolling still works when the list exceeds MAX_H (650px). If both components are tested and scrolling works correctly, this can be disregarded.


352-435: LGTM!

The itemContent implementation correctly renders row content as a fragment. Form integration, conditional rendering, and error handling are all properly preserved from the original implementation.

packages/bruno-app/package.json (1)

87-87: No issues—react-virtuoso 4.18.1 is the latest stable version and fully compatible with React 19.0.0. The dependency choice is sound.

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: 1

🤖 Fix all issues with AI agents
In
`@packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js`:
- Around line 340-346: The TableVirtuoso usage in EnvironmentVariables is
missing the computeItemKey prop, causing unstable virtualization when items
change; update the TableVirtuoso component (the instance using props
className="table-container", data={formik.values}, fixedItemHeight={35},
components={{ TableRow }}) to pass a computeItemKey function that returns a
stable unique key for each row (e.g., use the environment variable id or another
persistent identifier from each item in formik.values) so react-virtuoso can
track items when added/removed/reordered.
🧹 Nitpick comments (4)
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)

25-29: TableRow memoization has limited effectiveness.

The custom comparison function checks prevProps.children === nextProps.children via reference equality. Since itemContent recreates children on each render, this comparison will almost always return false, defeating the memoization purpose. Also, the key prop inside the returned <tr> is ineffective—keys are handled at the parent level, not within the component.

Consider simplifying or removing the custom comparison if children are always recreated.

♻️ Suggested simplification
-const TableRow = React.memo(({ children, item }) => <tr key={item.uid} data-testid={`env-var-row-${item.name}`}>{children}</tr>, (prevProps, nextProps) => {
-  const prevUid = prevProps?.item?.uid;
-  const nextUid = nextProps?.item?.uid;
-  return prevUid === nextUid && prevProps.children === nextProps.children;
-});
+const TableRow = React.memo(({ children, item }) => (
+  <tr data-testid={`env-var-row-${item?.name}`}>{children}</tr>
+));

347-355: Use <th> for header cells instead of <td>.

Semantic HTML: header cells should use <th> elements for accessibility and proper table semantics.

♻️ Proposed fix
         fixedHeaderContent={() => (
           <tr>
-            <td className="text-center"></td>
-            <td>Name</td>
-            <td>Value</td>
-            <td className="text-center">Secret</td>
-            <td></td>
+            <th className="text-center"></th>
+            <th>Name</th>
+            <th>Value</th>
+            <th className="text-center">Secret</th>
+            <th></th>
           </tr>
         )}
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)

22-26: Same TableRow memoization concern as the other file.

Reference comparison on children won't be effective since children are recreated each render. The key prop inside the <tr> is also ineffective.

♻️ Suggested simplification
-const TableRow = React.memo(({ children, item }) => <tr key={item.uid} data-testid={`env-var-row-${item.name}`}>{children}</tr>, (prevProps, nextProps) => {
-  const prevUid = prevProps?.item?.uid;
-  const nextUid = nextProps?.item?.uid;
-  return prevUid === nextUid && prevProps.children === nextProps.children;
-});
+const TableRow = React.memo(({ children, item }) => (
+  <tr data-testid={`env-var-row-${item?.name}`}>{children}</tr>
+));

408-416: Use <th> for header cells instead of <td>.

Same semantic HTML issue as the other file—header cells should use <th> elements.

♻️ Proposed fix
         fixedHeaderContent={() => (
           <tr>
-            <td className="text-center"></td>
-            <td>Name</td>
-            <td>Value</td>
-            <td className="text-center">Secret</td>
-            <td></td>
+            <th className="text-center"></th>
+            <th>Name</th>
+            <th>Value</th>
+            <th className="text-center">Secret</th>
+            <th></th>
           </tr>
         )}
📜 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 86b5458 and 9ab5d5e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
🧰 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. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
🧠 Learnings (2)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
📚 Learning: 2026-01-09T18:25:14.640Z
Learnt from: kanakkholwal
Repo: usebruno/bruno PR: 6767
File: packages/bruno-app/src/components/ResponseExample/index.js:221-226
Timestamp: 2026-01-09T18:25:14.640Z
Learning: In the Bruno Electron renderer code (packages/bruno-app), assume window.ipcRenderer is always available and skip existence checks. Do not guard for ipcRenderer in this Electron context; use window.ipcRenderer directly (e.g., window.ipcRenderer.send(...), window.ipcRenderer.on(...)). If there are non-Electron contexts (such as test environments or non-Electron builds), add guards or mocks to avoid runtime errors there, but for the intended Electron renderer files, this pattern should be applied broadly within packages/bruno-app.

Applied to files:

  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.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: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - macOS
🔇 Additional comments (3)
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (1)

356-439: LGTM on the virtualized row rendering.

The itemContent implementation correctly handles the last-empty-row pattern, checkbox controls, error messages, and the MultiLineEditor integration. The logic mirrors the previous static table approach appropriately within the virtualized context.

packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)

417-418: Good use of computeItemKey.

Providing computeItemKey={(index, variable) => variable.uid} ensures stable keys for virtualized items. This is correct and should also be added to the other EnvironmentVariables file.


419-508: LGTM on the virtualized row content.

The itemContent implementation correctly handles all row states, including the last-empty-row pattern, SensitiveFieldWarning integration, and the non-string value info tooltip. Logic is consistent with the previous implementation.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@sid-bruno sid-bruno merged commit b0f27d0 into usebruno:main Jan 14, 2026
8 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Feb 1, 2026
6 tasks
FraCata00 pushed a commit to FraCata00/bruno that referenced this pull request Feb 9, 2026
* fix: environment variables fetching and switching

* chore: formatting

* fix: support active, inactive, secret vars popup

* fix: variable highlight styles

* chore: codemirror styles

* fix: show variable highlighting when editor is inactive

* fix: tab press for switching columns

* fix: environment variables loading with react-virtuoso

* fix: refactor EnvironmentVariables component for improved table rendering

* fix: update react-virtuoso to version 4.18.1

---------

Co-authored-by: shubh-bruno <shubh-bruno@shubh-brunos-MacBook-Air.local>
Co-authored-by: Sid <siddharth@usebruno.com>
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