Skip to content

feat: add search functionality to environment variables#6659

Merged
sid-bruno merged 1 commit intousebruno:feat/add-env-var-search-extendedfrom
Pragadesh-45:feat/add-env-var-search
Jan 29, 2026
Merged

feat: add search functionality to environment variables#6659
sid-bruno merged 1 commit intousebruno:feat/add-env-var-search-extendedfrom
Pragadesh-45:feat/add-env-var-search

Conversation

@Pragadesh-45
Copy link
Contributor

@Pragadesh-45 Pragadesh-45 commented Jan 5, 2026

Jira

Description

This PR implements the feature for searching environment variables.

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.

Demo:
image
image

Summary by CodeRabbit

  • New Features

    • Added search functionality to filter environment variables by name and value across multiple settings panels.
    • Search input displays "No variables found matching" message when no results match the query.
    • Search can be toggled with Escape key for quick exit.
  • Style

    • Added styling for search input fields, icons, and right-aligned action sections.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • main
  • release/*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Walkthrough

Introduces 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

Cohort / File(s) Summary
EnvironmentVariables filtering logic
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
Added searchQuery prop (default: empty string) and filteredVariables memoized selector performing case-insensitive matching on variable names and string values. Replaced direct formik.values mapping with filtered results. Added UI message for empty filter results.
EnvironmentDetails search UI and state
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js
Added search state (isSearching, searchQuery, searchInputRef), handlers for opening search and Escape-key exit, conditional rendering of search input vs. action buttons, and wired searchQuery prop to EnvironmentVariables. Imported IconSearch.
EnvironmentDetails styling
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js
Added .right-section flex container and .search-container with .search-icon and .search-input styling, including theme-aware colors and hover/focus states.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • #6407: Modifies the same EnvironmentDetails and EnvironmentVariables components with overlapping search UI and prop signature changes.
  • #6498: Updates EnvironmentVariables component props and filtering logic in parallel locations.

Suggested labels

size/M

Suggested reviewers

  • lohit-bruno
  • helloanoop
  • bijin-bruno

Poem

🔍 A search light flickers in the variables' night,
Filtering through the clutter, bringing clarity to sight.
Escape clears the query with a gentle keystroke's might,
Environment secrets now found—everything's right! ✨

Pre-merge checks and finishing touches

✅ 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 concisely describes the main feature added: search functionality for environment variables, which aligns with the changeset modifications across multiple components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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: 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-section and .search-container styles 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 handleSearchVariablesClick suggests toggling behavior, but it only opens the search UI (the button is only visible when !isSearching per line 207). Closing search is handled by handleSearchKeyDown on 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

📥 Commits

Reviewing files that changed from the base of the PR and between f9af22d and 744e00b.

📒 Files selected for processing (6)
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js
  • packages/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() 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/index.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js
  • packages/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.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/EnvironmentVariables/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js
  • packages/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.js
  • packages/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.js
  • packages/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 filteredVariables memo 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 handleOpenSearch and handleSearchKeyDown are clean and consistent with the rename functionality's approach. The timeout-based focus pattern matches handleRenameClick.


222-227: Correct prop wiring to EnvironmentVariables.

The searchQuery prop is correctly passed down to enable filtering. This aligns with the EnvironmentVariables component's expected interface.

@sid-bruno
Copy link
Collaborator

the search should have a close icon according to design, which is missing

@Pragadesh-45 Pragadesh-45 force-pushed the feat/add-env-var-search branch from 744e00b to eee6504 Compare January 22, 2026 14:05
@Pragadesh-45 Pragadesh-45 marked this pull request as draft January 22, 2026 14:05
@sid-bruno
Copy link
Collaborator

Screenshot 2026-01-28 at 8 12 12 PM

Clear seach button isn't in the right position

@sid-bruno sid-bruno changed the base branch from main to feat/add-env-var-search-extended January 29, 2026 06:46
@sid-bruno sid-bruno marked this pull request as ready for review January 29, 2026 06:46
@sid-bruno sid-bruno merged commit 5cdb8ae into usebruno:feat/add-env-var-search-extended Jan 29, 2026
6 of 8 checks passed
sid-bruno pushed a commit that referenced this pull request Jan 30, 2026
feat: add search functionality to environment variables. (#6659)
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