feat: add search functionality to environment variables#6659
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
WalkthroughIntroduces environment variable search functionality across two parallel component hierarchies (main app and workspace home). Adds searchQuery prop to EnvironmentVariables for filtering, implements search UI with state and handlers in EnvironmentDetails, and adds corresponding styling for search inputs and layouts. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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: 1
Fix all issues with AI Agents 🤖
In
@packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js:
- Around line 21-22: searchQuery and isSearching are component-local and
currently persist when the user switches environments; add a useEffect that
watches environment.uid and resets setSearchQuery('') and setIsSearching(false)
when it changes (apply the same reset where the other search-related useState
pair is declared); ensure the effect imports/uses useEffect and references
environment.uid so the search filter is cleared on environment switch.
🧹 Nitpick comments (4)
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js (1)
95-126: LGTM! Consider consolidating duplicate styles.The styling is correct and follows project guidelines. However, these styles are identical to those in
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js(lines 95-126).Consider extracting the shared
.right-sectionand.search-containerstyles to a common location if this duplication pattern extends to other components, though the current parallel structure may be intentional for the two component hierarchies.packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js (1)
116-124: Consider renaming for clarity.The function
handleSearchVariablesClicksuggests toggling behavior, but it only opens the search UI (the button is only visible when!isSearchingper line 207). Closing search is handled byhandleSearchKeyDownon Escape.Suggested rename
- const handleSearchVariablesClick = () => { + const handleOpenSearch = () => { setIsSearching(!isSearching); setSearchQuery(''); if (!isSearching) { setTimeout(() => { searchInputRef.current?.focus(); }, 50); } };And update the button on line 208:
- <button onClick={handleSearchVariablesClick} title="Search Variables"> + <button onClick={handleOpenSearch} title="Search Variables">packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (1)
323-336: Filtering implementation is correct; note duplication.The filtering logic correctly handles case-insensitive search and preserves original indices for Formik. This implementation is nearly identical to the one in
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js(lines 385-398).Consider extracting the filtering logic to a shared utility function if this pattern continues across the parallel component hierarchies, though the current duplication may be acceptable given the architectural separation.
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js (1)
182-218: UI integration looks solid.The right-section restructure with conditional search input and always-visible actions works well. The search toggle pattern is intuitive. Accessibility attributes (
aria-label,title) are properly included.Optional UX enhancement: Consider adding a clear button (X icon) inside the search input or a blur handler to provide an additional way to exit search mode beyond the Escape key.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/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/index.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
🧠 Learnings (5)
📚 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/index.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.{jsx,tsx} : Styled Components are used as wrappers to define both self and children components style; Tailwind classes are used specifically for layout based styles
Applied to files:
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.{jsx,tsx} : Styled Component CSS might also change layout but Tailwind classes shouldn't define colors
Applied to files:
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.{jsx,tsx} : Use styled component's theme prop to manage CSS colors and not CSS variables when in the context of a styled component or any React component using the styled component
Applied to files:
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js
📚 Learning: 2025-12-02T20:48:05.670Z
Learnt from: NikHillAgar
Repo: usebruno/bruno PR: 6279
File: packages/bruno-app/src/components/RequestPane/PromptVariables/PromptVariablesModal/index.js:79-86
Timestamp: 2025-12-02T20:48:05.670Z
Learning: In React 19+, ref callbacks support returning cleanup functions. When a ref callback returns a function, React will call it when the element unmounts or the ref changes, similar to useEffect cleanup. This is documented at https://react.dev/learn/manipulating-the-dom-with-refs#how-to-manage-a-list-of-refs-using-a-ref-callback
Applied to files:
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
🧬 Code graph analysis (3)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js (1)
searchQuery(21-21)packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js (1)
searchQuery(21-21)
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js (1)
searchQuery(21-21)packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js (1)
searchQuery(21-21)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js (1)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (1)
EnvironmentVariables(21-527)
⏰ 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 - macOS
- GitHub Check: SSL Tests - Windows
- GitHub Check: SSL Tests - Linux
- GitHub Check: Playwright E2E Tests
- GitHub Check: CLI Tests
- GitHub Check: Unit Tests
🔇 Additional comments (8)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js (1)
95-126: LGTM! Search UI styling follows project patterns.The new search container and input styles correctly use theme tokens and follow the styled-components approach per coding guidelines.
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js (1)
187-222: LGTM! Search UI implementation is solid.The conditional rendering, state management, and event handling are correctly implemented. The search input properly focuses when opened and clears on Escape.
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (2)
385-398: Filtering logic is correctly implemented.The
filteredVariablesmemo properly handles case-insensitive search across variable names and string values. The dependency array is complete, and the filtering preserves the original indices needed for Formik field paths.
414-420: Verify UX: empty "add new variable" row is hidden during search.When users search, the empty last row (for adding new variables) won't match the query and will be filtered out. This prevents adding new variables while a search is active—users must clear the search first.
Is this the intended UX? If users should be able to add variables while searching, the empty last row should be excluded from filtering:
Alternative: Always show empty last row
const filteredVariables = useMemo(() => { if (!searchQuery?.trim()) { return formik.values.map((variable, index) => ({ variable, index })); } const query = searchQuery.toLowerCase().trim(); - return formik.values + const filtered = formik.values .map((variable, index) => ({ variable, index })) .filter(({ variable }) => { const nameMatch = variable.name?.toLowerCase().includes(query); const valueMatch = typeof variable.value === 'string' && variable.value?.toLowerCase().includes(query); return nameMatch || valueMatch; }); + + // Always include the empty last row for adding new variables + const lastIndex = formik.values.length - 1; + const lastRow = formik.values[lastIndex]; + const isLastRowEmpty = !lastRow?.name || lastRow.name.trim() === ''; + + if (isLastRowEmpty && !filtered.some(({ index }) => index === lastIndex)) { + filtered.push({ variable: lastRow, index: lastIndex }); + } + + return filtered; }, [formik.values, searchQuery]);packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js (1)
352-358: Verify UX: empty "add new variable" row is hidden during search.This exhibits the same behavior as the Environments path component: the empty last row for adding new variables will be filtered out during search, preventing users from adding variables until they clear the search.
Please confirm this is the intended user experience. If users should be able to add variables while searching, refer to the alternative implementation suggested in the review comment for
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js(lines 414-420).packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js (3)
1-1: LGTM! Clean integration of search state and refs.The IconSearch import and local state setup (searchQuery, isSearching, searchInputRef) follow the existing pattern established by the rename functionality. Code style is consistent with guidelines.
Also applies to: 21-24
117-130: Handlers are well-implemented and follow existing patterns.Both
handleOpenSearchandhandleSearchKeyDownare clean and consistent with the rename functionality's approach. The timeout-based focus pattern matcheshandleRenameClick.
222-227: Correct prop wiring to EnvironmentVariables.The
searchQueryprop is correctly passed down to enable filtering. This aligns with theEnvironmentVariablescomponent's expected interface.
.../src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
Outdated
Show resolved
Hide resolved
.../src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
Show resolved
Hide resolved
...ponents/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js
Outdated
Show resolved
Hide resolved
...c/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js
Show resolved
Hide resolved
...ents/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js
Outdated
Show resolved
Hide resolved
.../src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
Outdated
Show resolved
Hide resolved
.../src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
Outdated
Show resolved
Hide resolved
|
the search should have a close icon according to design, which is missing |
744e00b to
eee6504
Compare
5cdb8ae
into
usebruno:feat/add-env-var-search-extended
feat: add search functionality to environment variables. (#6659)

Jira
Description
This PR implements the feature for searching environment variables.
Contribution Checklist:
Demo:


Summary by CodeRabbit
New Features
Style
✏️ Tip: You can customize this high-level summary in your review settings.