Repository navigation
fix(app): scope env variable/secret search per tab - #8491
Conversation
WalkthroughEnvironment 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. ChangesTab-scoped environment search
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]
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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: 3
🧹 Nitpick comments (1)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js (1)
44-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated tab-scoped search wiring across collection/global EnvironmentList.
The
activeTabUid/activeEnvTabderivation plus the fourenvVarSearchselectors/dispatchers here are duplicated almost verbatim inWorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.js(lines 47-51). Extracting a shareduseEnvVarSearch(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
📒 Files selected for processing (4)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/index.jspackages/bruno-app/src/providers/ReduxStore/slices/app.jstests/environments/variable-secret-tabs/variable-secret-tabs.spec.ts
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
tests/environments/variables-tab/variables-tab.spec.ts
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
tests/environments/variables-tab/variables-tab.spec.ts (2)
23-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the centralized
searchInputlocator instead of a raw CSS selector.
resetSearchreaches forpage.locator('.search-input')directly, while the same element already has a page-module locator (environment.searchInput(), exposed here assearchInputLocator). 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 inlinepage.locator/page.getByTestIdin 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 winExtract 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 smallresetBothTabsSearch(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
📒 Files selected for processing (4)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.jstests/environments/variables-tab/variables-tab.spec.tstests/utils/page/locators.ts
✅ Files skipped from review due to trivial changes (1)
- tests/utils/page/locators.ts
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:
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
Screen.Recording.2026-07-06.at.6.32.41.PM.mov