fix: env vars loading and switching using react-virtuoso#6790
fix: env vars loading and switching using react-virtuoso#6790sid-bruno merged 11 commits intousebruno:mainfrom
Conversation
WalkthroughIntroduces 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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
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;tableContainerRefappears unused.
MIN_HandMAX_Hare stable values—consider moving them outside the component to avoid redefinition on each render. Also,tableContainerRefis assigned viascrollerRefbut 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_HandMAX_Hcould be hoisted outside the component, andtableContainerRefis 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
📒 Files selected for processing (3)
packages/bruno-app/package.jsonpackages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.jspackages/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()notfunc ()
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.jspackages/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.jspackages/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.jspackages/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 withoverflowY: 'hidden'.With
overflowY: 'hidden'and a cappedmaxHeightof 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
itemContentimplementation 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: SameoverflowY: '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
itemContentimplementation 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.
There was a problem hiding this comment.
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.childrenvia reference equality. SinceitemContentrecreates children on each render, this comparison will almost always returnfalse, defeating the memoization purpose. Also, thekeyprop 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
childrenwon't be effective since children are recreated each render. Thekeyprop 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
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.jspackages/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()notfunc ()
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.jspackages/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.jspackages/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.jspackages/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
itemContentimplementation 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 ofcomputeItemKey.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
itemContentimplementation 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.
...eHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
Show resolved
Hide resolved
* 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>
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:
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
✏️ Tip: You can customize this high-level summary in your review settings.