Skip to content

fix(app): scope env variable/secret search per tab - #8491

Merged
sid-bruno merged 5 commits into
usebruno:mainfrom
pooja-bruno:fix/env-search-scope-per-tab
Jul 7, 2026
Merged

sid-bruno merged 5 commits into
usebruno:mainfrom
pooja-bruno:fix/env-search-scope-per-tab

Conversation

@pooja-bruno

@pooja-bruno pooja-bruno commented Jul 6, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Scopes environment variable/secret search state per tab so Variables and Secrets each keep their own search text and expand/collapse state

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

  • New Features
    • Environment variable search now maintains separate search text and expansion state for each environment tab (e.g., Variables vs Secrets) in both collection and global views.
  • Bug Fixes
    • Switching environment tabs no longer reuses or overwrites another tab’s search state.
    • Tab changes now update the displayed search results immediately using the correct tab’s current input.
  • UI Changes
    • The “Save All” action button was moved to the main header actions area.
  • Tests
    • Expanded UI coverage to verify per-tab input persistence, prevent cross-tab leakage, and added an environment search input locator.
Screen.Recording.2026-07-06.at.6.32.41.PM.mov

@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Environment search state is now scoped per environment tab in both collection and global views. The UI reads and writes the active tab’s search state, switches displayed search text on tab changes, and tests verify Variables and Secrets keep separate search inputs.

Changes

Tab-scoped environment search

Layer / File(s) Summary
Redux envVarSearch state and reducers
packages/bruno-app/src/providers/ReduxStore/slices/app.js
envVarSearch now nests variables and secrets under each context, and the search reducers update the selected tab entry with missing-entry guards.
EnvironmentDetails tab-switch search wiring
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js
Both EnvironmentDetails components track tab changes, choose immediate versus debounced search text, and pass the derived query into EnvironmentVariables.
Collection and global EnvironmentList tab-aware wiring
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js
Both EnvironmentList components use the active env tab to select envVarSearch[context][activeEnvTab] and dispatch search updates with the tab included.
Per-tab search persistence tests
tests/utils/page/locators.ts, tests/environments/variables-tab/variables-tab.spec.ts
Adds a search-input locator and reset helper, then verifies Variables and Secrets keep independent search values in both collection and global suites.
Save All header action
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js
Moves the Save All action into the header actions area.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EnvironmentDetails
    participant ReduxStore
    participant EnvironmentVariables

    User->>EnvironmentDetails: Switches tab or types search
    EnvironmentDetails->>ReduxStore: reads active tab and search state
    ReduxStore-->>EnvironmentDetails: returns tab-scoped query/expanded values
    EnvironmentDetails->>EnvironmentVariables: passes tableSearchQuery
    User->>EnvironmentDetails: updates search input
    EnvironmentDetails->>ReduxStore: dispatch(setEnvVarSearchQuery({context, tab, query}))
    ReduxStore-->>EnvironmentDetails: stores query under envVarSearch[context][tab]
Loading

Possibly related PRs

  • usebruno/bruno#6659: Related environment-variable searchQuery flow into EnvironmentVariables and tab-aware filtering behavior.
  • usebruno/bruno#6966: Related searchQuery plumbing through EnvironmentDetails and EnvironmentVariables for environment filtering.
  • usebruno/bruno#7287: Related envVarSearch state and reducer wiring in EnvironmentList and app.js.

Suggested labels: size/XL

Suggested reviewers: helloanoop, bijin-bruno, lohit-bruno, naman-bruno, sid-bruno

Poem

Two tabs now keep their own small lore,
No search leaks through the open door.
Variables hum, Secrets stay bright,
Each query resting just right.
✨ State splits clean, and all is neat,
A tidy hop on tabbed-out feet.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: scoping env variable and secret search per tab.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js (1)

44-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated tab-scoped search wiring across collection/global EnvironmentList.

The activeTabUid/activeEnvTab derivation plus the four envVarSearch selectors/dispatchers here are duplicated almost verbatim in WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js (lines 47-51). Extracting a shared useEnvVarSearch(context) hook would consolidate this Redux read/write contract in one place.

Based on coding guidelines: "MUST: Prefer custom hooks for business logic, data fetching, and side-effects in React."

♻️ Sketch of a shared hook
// packages/bruno-app/src/hooks/useEnvVarSearch.js
export const useEnvVarSearch = (context) => {
  const dispatch = useDispatch();
  const activeTabUid = useSelector((state) => state.tabs.activeTabUid);
  const activeEnvTab = useSelector((state) => state.tabs.tabs.find((t) => t.uid === activeTabUid)?.tabState?.envTab) || 'variables';
  const query = useSelector((state) => state.app.envVarSearch?.[context]?.[activeEnvTab]?.query ?? '');
  const expanded = useSelector((state) => state.app.envVarSearch?.[context]?.[activeEnvTab]?.expanded ?? false);

  return {
    activeEnvTab,
    query,
    expanded,
    setQuery: (q) => dispatch(setEnvVarSearchQuery({ context, tab: activeEnvTab, query: q })),
    setExpanded: (v) => dispatch(setEnvVarSearchExpanded({ context, tab: activeEnvTab, expanded: v }))
  };
};
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js`
around lines 44 - 50, The tab-scoped env search state wiring is duplicated in
both EnvironmentList variants, so move the activeTabUid/activeEnvTab lookup plus
envVarSearch selectors and dispatchers into a shared custom hook. Create and use
a hook like useEnvVarSearch(context) to centralize the Redux read/write contract
for query, expanded, setQuery, and setExpanded, then update this EnvironmentList
component and the WorkspaceHome/WorkspaceEnvironments counterpart to consume it.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js`:
- Around line 45-50: The tab-scoped environment search state is showing a stale
query briefly after switching tabs because EnvironmentVariablesTable is driven
by debouncedSearchQuery while activeEnvTab changes immediately. Update the
EnvironmentList component to either reset the debounced search value whenever
activeEnvTab changes or pass envSearchQuery directly into
EnvironmentVariablesTable so the table always reflects the current tab’s query
immediately.

In `@tests/environments/variable-secret-tabs/variable-secret-tabs.spec.ts`:
- Line 199: The spec is using a raw page.getByTestId locator for searchInput
instead of the shared page module pattern. Move this selector into the
environment page module by adding an environment.searchInput() locator alongside
buildCommonLocators(page), then update the spec to use that shared locator so
all selectors stay centralized with variablesTab, secretsTab, varRow, and
saveTab.
- Around line 225-230: The cleanup in the variable/secrets tab spec clears the
query but leaves the search UI expanded, so reset the search state fully at the
end of the test. Update the test teardown around searchEnv, variablesTab, and
secretsTab to also collapse the search box back to its initial state for both
tabs, not just empty the text. Make sure the shared search state is explicitly
cleared so later tests start with the same collapsed UI state and are not
affected by persisted Redux values.

---

Nitpick comments:
In
`@packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js`:
- Around line 44-50: The tab-scoped env search state wiring is duplicated in
both EnvironmentList variants, so move the activeTabUid/activeEnvTab lookup plus
envVarSearch selectors and dispatchers into a shared custom hook. Create and use
a hook like useEnvVarSearch(context) to centralize the Redux read/write contract
for query, expanded, setQuery, and setExpanded, then update this EnvironmentList
component and the WorkspaceHome/WorkspaceEnvironments counterpart to consume it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cdaffde0-9f9d-4628-90f1-66784a3918f3

📥 Commits

Reviewing files that changed from the base of the PR and between b1f08b5 and 8c12d0f.

📒 Files selected for processing (4)
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/app.js
  • tests/environments/variable-secret-tabs/variable-secret-tabs.spec.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/environments/variables-tab/variables-tab.spec.ts`:
- Line 183: Remove the focused test declaration from variables-tab.spec by
changing the test.only on the search input persistence case back to a normal
test invocation. This issue is in the Playwright variables-tab suite around the
search input value persists per tab test, and the fix is simply to eliminate the
.only so the full suite runs in CI without triggering forbidOnly and hiding
other regressions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a1227684-7bfe-4bc7-860f-861c91ad3409

📥 Commits

Reviewing files that changed from the base of the PR and between 8c12d0f and 76aa7ca.

📒 Files selected for processing (1)
  • tests/environments/variables-tab/variables-tab.spec.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
tests/environments/variables-tab/variables-tab.spec.ts (2)

23-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the centralized searchInput locator instead of a raw CSS selector.

resetSearch reaches for page.locator('.search-input') directly, while the same element already has a page-module locator (environment.searchInput(), exposed here as searchInputLocator). Centralizing avoids selector drift if the class name changes.

♻️ Suggested fix
 const resetSearch = async (page: Page) => {
-  const input = page.locator('.search-input');
+  const input = searchInputLocator(page);
   if ((await input.count()) === 0) return;
   await input.fill('');
   await input.blur();
   await input.waitFor({ state: 'detached' });
 };

As per path instructions: "Centralize selectors/locator usage inside tests/utils/page/* page modules—do not inline page.locator/page.getByTestId in specs."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/environments/variables-tab/variables-tab.spec.ts` around lines 23 - 30,
The resetSearch helper is using an inline CSS selector instead of the shared
page-module locator, so update it to use the existing searchInputLocator from
environment.searchInput() rather than page.locator('.search-input'). Keep the
same fill/blur/detached flow, but route the element lookup through the
centralized locator to match the rest of the test module and avoid selector
drift.

Source: Path instructions


186-189: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the repeated "reset, switch tab, reset" cleanup into a helper.

The await resetSearch(page); await <tab>(page).click(); await resetSearch(page); sequence is repeated 4 times across this file. A small resetBothTabsSearch(page, otherTab) helper would remove the duplication and reduce the risk of one call site drifting from the others.

Also applies to: 233-237, 421-423, 468-470

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/environments/variables-tab/variables-tab.spec.ts` around lines 186 -
189, The repeated reset/switch-tab/reset cleanup in variables-tab.spec.ts should
be extracted into a shared helper to avoid duplicated test setup. Add a small
helper such as resetBothTabsSearch(page, otherTab) near the existing test
utilities and use it in place of the repeated await resetSearch(page); await
<tab>(page).click(); await resetSearch(page); pattern in the affected specs.
Keep the helper generic enough to work with variablesTab and the other tab
switcher used in this file so all call sites stay consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js`:
- Line 2: Remove the unnecessary useEffect from EnvironmentDetails and update
the tab tracking ref inline during render instead. The tabJustChanged/prevTabRef
logic should be handled directly where the active tab state is derived so the
ref is synchronized without an extra effect/commit cycle. Keep useRef (and
useState if still needed) and delete the useEffect import and effect block
related to tab changes. Use the EnvironmentDetails component and its tab-change
logic to locate the ref update path.

In
`@packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js`:
- Line 2: The EnvironmentDetails component is using useEffect to keep a ref in
sync, which adds an unnecessary commit cycle; update the ref inline during
render or in the relevant event handler instead. Remove useEffect from the hooks
import and apply the same ref-sync pattern used in the collection
EnvironmentDetails component, keeping the logic centered in the
EnvironmentDetails function and any related ref setup.

---

Nitpick comments:
In `@tests/environments/variables-tab/variables-tab.spec.ts`:
- Around line 23-30: The resetSearch helper is using an inline CSS selector
instead of the shared page-module locator, so update it to use the existing
searchInputLocator from environment.searchInput() rather than
page.locator('.search-input'). Keep the same fill/blur/detached flow, but route
the element lookup through the centralized locator to match the rest of the test
module and avoid selector drift.
- Around line 186-189: The repeated reset/switch-tab/reset cleanup in
variables-tab.spec.ts should be extracted into a shared helper to avoid
duplicated test setup. Add a small helper such as resetBothTabsSearch(page,
otherTab) near the existing test utilities and use it in place of the repeated
await resetSearch(page); await <tab>(page).click(); await resetSearch(page);
pattern in the affected specs. Keep the helper generic enough to work with
variablesTab and the other tab switcher used in this file so all call sites stay
consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: defd1407-f4a6-4fc1-a11f-103896de51f0

📥 Commits

Reviewing files that changed from the base of the PR and between 76aa7ca and 0bcc89b.

📒 Files selected for processing (4)
  • packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js
  • tests/environments/variables-tab/variables-tab.spec.ts
  • tests/utils/page/locators.ts
✅ Files skipped from review due to trivial changes (1)
  • tests/utils/page/locators.ts

@sachin-thakur-bruno sachin-thakur-bruno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sid-bruno
sid-bruno merged commit 4592d2c into usebruno:main Jul 7, 2026
10 of 16 checks passed
ravindra-bruno pushed a commit to ravindra-bruno/bruno that referenced this pull request Jul 9, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jul 17, 2026
6 tasks
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.

3 participants