Repository navigation
feat(environments): split variables and secrets into separate tabs - #8191
Conversation
…earch functionality
Remember and restore selected environment per tab by storing envUid in tabState (EnvironmentSettings, WorkspaceEnvironments) and dispatching updateTabState when selection changes. Ensure collection.activeEnvironmentUid is set in EnvironmentVariablesTable. Improve collections slice handling of environmentsDraft to reset only when switching environments and otherwise update variables in place. UI tweaks: increase DeleteEnvironment modal size to md and remove extra space before question mark, adjust StyledWrapper top margin from 12px to 16px. MenuDropdown/SubMenuItem: propagate selectedItemId and showTickMark, highlight submenu parent when a child is selected. Add .gstack to .gitignore.
Clean up .gitignore by removing the obsolete `.gstack` entry. This removes an unused ignore rule to reflect current repository files and tooling.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughSplits Environment Variables and Secrets into separate tabs with per‑tab Redux persistence; EnvironmentVariablesTable becomes tab‑scoped for filtering, saving, and resetting; UI layout and styling updated; Playwright tests added to validate tab isolation for collection and global environments. ChangesVariables/Secrets Tab Separation
Sequence DiagramsequenceDiagram
participant EnvironmentDetails
participant EnvironmentVariablesTable
participant collectionsSlice
participant tabsSlice
EnvironmentDetails->>EnvironmentVariablesTable: pass variableType (activeTab)
EnvironmentVariablesTable->>EnvironmentVariablesTable: scope visible rows by isSecretTab (keep trailing row)
EnvironmentVariablesTable->>collectionsSlice: save active-tab subset
collectionsSlice->>tabsSlice: preserve other-tab saved/draft state
EnvironmentVariablesTable->>tabsSlice: clear/retain other-tab draft based on dirty state
EnvironmentVariablesTable->>EnvironmentVariablesTable: reset form with trailing empty row(secret=isSecretTab)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/StyledWrapper.js (1)
28-55:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFix
.btn-actionscoping and remove the extra closing brace.
.sidebaris closed before the first.btn-action, and there is an extra}afterward. This creates two competing root-level.btn-actionrules (here and Line 130), making size/hitbox styling ambiguous.Suggested fix
.sidebar { width: 240px; min-width: 240px; display: flex; flex-direction: column; - } - - .btn-action { + + .btn-action { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; @@ &:hover { background: ${(props) => props.theme.sidebar.collection.item.hoverBg}; color: ${(props) => props.theme.text}; } } }🤖 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/StyledWrapper.js` around lines 28 - 55, The .btn-action rule is incorrectly scoped because .sidebar is closed early and an extra closing brace remains; move the .btn-action block so it is nested inside the .sidebar rule (remove the stray closing brace that currently creates a second root-level .btn-action) and consolidate/remove the duplicate root-level .btn-action definition to ensure size/hitbox styles come only from the nested .sidebar .btn-action selector.
🧹 Nitpick comments (2)
tests/environments/variable-secret-tabs/variable-secret-tabs.spec.ts (1)
10-17: ⚡ Quick winConsider data-testid for search button selector.
The search button is located via
titleattribute and the input via class selector.search-input. While functional,data-testidwould be more stable for E2E tests.🔍 Suggested improvement
Request the component team to add data-testids:
- await page.locator('.env-search-container button[title="Search"]').click(); - const input = page.locator('.search-input'); + await page.getByTestId('env-search-button').click(); + const input = page.getByTestId('env-search-input');🤖 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/variable-secret-tabs/variable-secret-tabs.spec.ts` around lines 10 - 17, The test uses fragile selectors in searchEnv ('.search-input' and '.env-search-container button[title="Search"]'); update the test to use stable data-testid attributes instead (e.g., replace '.search-input' and the button selector with 'data-testid' locators) and if those testids don't exist, ask the component team to add them (for example data-testid="env-search-input" and data-testid="env-search-button"), then change the locator calls in searchEnv to use those data-testid values and keep the existing waitFor/fill logic intact.packages/bruno-app/src/components/Environments/EnvironmentSettings/index.js (1)
13-29: ⚡ Quick winExtract this tab-scoped environment selection/persistence logic into a shared hook.
This block duplicates the same business logic already present in
packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/index.js, which increases drift risk for fallback and persistence behavior.As per coding guidelines: "MUST: Prefer custom hooks for business logic, data fetching, and side-effects in React".
🤖 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/index.js` around lines 13 - 29, Extract the tab-scoped environment selection/persistence logic (the useMemo computing selectedEnvironment and the setSelectedEnvironment function that dispatches updateTabState using activeTabUid and env.uid) into a shared custom hook (e.g., useTabEnvironment or useTabSelectedEnvironment) and replace the inline logic in both EnvironmentSettings and WorkspaceEnvironments with that hook; the hook should accept environments and collection (or their minimal pieces) and return { selectedEnvironment, setSelectedEnvironment }, internally use useSelector to read activeTabUid and persistedEnvUid and dispatch updateTabState, and preserve the existing fallback order (persistedEnvUid → collection.activeEnvironmentUid → first environment) and no-op behavior when activeTabUid or env.uid are missing.
🤖 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`:
- Around line 202-251: Add stable Playwright selectors by adding data-testid
attributes to the new action and search controls: add data-testid props to the
three ActionIcon instances (the Rename, Copy and Delete buttons) and the Search
ActionIcon (used when isSearchExpanded is false), add data-testid to the search
input element (the input using searchInputRef) and to the clear search button
(the element with class "clear-search"); use descriptive keys like
data-testid="env-rename-btn", "env-copy-btn", "env-delete-btn",
"env-search-btn", "env-search-input", and "env-clear-search-btn" so tests can
reliably locate these controls (ensure ActionIcon forwards unknown props if
needed).
In
`@packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js`:
- Around line 204-253: Add stable Playwright selectors by adding data-testid
attributes to the new action icons and search controls: add data-testid values
on the ActionIcon usages (e.g. the Rename, Copy, Delete and Search icons) such
as data-testid="env-action-rename", "env-action-copy", "env-action-delete",
"env-action-search"; add data-testid="env-search-input" to the input element
rendered when isSearchExpanded is true (the element using searchInputRef and
value/searchQuery), and add data-testid="env-clear-search" to the clear button
that calls handleClearSearch; ensure these attributes are placed on the elements
inside the ResponsiveTabs rightContent so tests can target ActionIcon, the
search input and the clear button reliably.
---
Outside diff comments:
In
`@packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/StyledWrapper.js`:
- Around line 28-55: The .btn-action rule is incorrectly scoped because .sidebar
is closed early and an extra closing brace remains; move the .btn-action block
so it is nested inside the .sidebar rule (remove the stray closing brace that
currently creates a second root-level .btn-action) and consolidate/remove the
duplicate root-level .btn-action definition to ensure size/hitbox styles come
only from the nested .sidebar .btn-action selector.
---
Nitpick comments:
In `@packages/bruno-app/src/components/Environments/EnvironmentSettings/index.js`:
- Around line 13-29: Extract the tab-scoped environment selection/persistence
logic (the useMemo computing selectedEnvironment and the setSelectedEnvironment
function that dispatches updateTabState using activeTabUid and env.uid) into a
shared custom hook (e.g., useTabEnvironment or useTabSelectedEnvironment) and
replace the inline logic in both EnvironmentSettings and WorkspaceEnvironments
with that hook; the hook should accept environments and collection (or their
minimal pieces) and return { selectedEnvironment, setSelectedEnvironment },
internally use useSelector to read activeTabUid and persistedEnvUid and dispatch
updateTabState, and preserve the existing fallback order (persistedEnvUid →
collection.activeEnvironmentUid → first environment) and no-op behavior when
activeTabUid or env.uid are missing.
In `@tests/environments/variable-secret-tabs/variable-secret-tabs.spec.ts`:
- Around line 10-17: The test uses fragile selectors in searchEnv
('.search-input' and '.env-search-container button[title="Search"]'); update the
test to use stable data-testid attributes instead (e.g., replace '.search-input'
and the button selector with 'data-testid' locators) and if those testids don't
exist, ask the component team to add them (for example
data-testid="env-search-input" and data-testid="env-search-button"), then change
the locator calls in searchEnv to use those data-testid values and keep the
existing waitFor/fill logic intact.
🪄 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: 01332825-d840-47c0-a93f-2a768956c2dc
📒 Files selected for processing (19)
packages/bruno-app/src/components/EnvironmentVariablesTable/index.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/DeleteEnvironment/index.jspackages/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/Environments/EnvironmentSettings/EnvironmentList/StyledWrapper.jspackages/bruno-app/src/components/Environments/EnvironmentSettings/index.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/DeleteEnvironment/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.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/StyledWrapper.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-app/src/providers/ReduxStore/slices/tabs.jspackages/bruno-app/src/ui/MenuDropdown/SubMenuItem/index.jspackages/bruno-app/src/ui/MenuDropdown/index.jstests/environments/variable-secret-tabs/variable-secret-tabs.spec.tstests/utils/page/actions.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 `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js`:
- Around line 550-592: The comparison and reset must use the post-persistence
shape that blanks secret values: compute a normalizedPersisted =
persistedVariables.map(v => v.secret ? {...v, value: ''} : v) and use
JSON.stringify(normalizedPersisted.map(stripEnvVarUid)) when computing
hasChanges (instead of using raw persistedVariables), and pass
cloneDeep(normalizedPersisted) into onSave resolution and into formik.resetForm
(appending the new empty row) so the form state matches the persisted
environment shape; update references to persistedVariables ->
normalizedPersisted in hasChanges, onSave(...), and formik.resetForm(...) while
keeping orderVarsBySecret, stripEnvVarUid, savedValues, namedValues, onSave, and
formik.resetForm as the anchors.
🪄 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: 66ec8711-c805-432e-b456-66120bc61c9b
📒 Files selected for processing (5)
packages/bruno-app/src/components/EnvironmentVariablesTable/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/StyledWrapper.jspackages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js
🚧 Files skipped from review as they are similar to previous changes (4)
- packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/StyledWrapper.js
- packages/bruno-app/src/components/WorkspaceHome/WorkspaceEnvironments/EnvironmentList/EnvironmentDetails/index.js
- packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
- packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/StyledWrapper.js
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/utils/page/actions.ts (1)
614-622: 💤 Low valueConsider using
buildCommonLocatorsfor tab locators.The inline test-id selectors duplicate what's already defined in
locators.ts. Using the centralized locators improves maintainability if test-ids change.♻️ Suggested refactor
const addEnvironmentVariable = async (page: Page, variable: EnvironmentVariable) => { await test.step(`Add environment ${variable.isSecret ? 'secret' : 'variable'} "${variable.name}"`, async () => { + const locators = buildCommonLocators(page); const tab = variable.isSecret - ? page.getByTestId('responsive-tab-secrets') - : page.getByTestId('responsive-tab-variables'); + ? locators.environment.secretsTab() + : locators.environment.variablesTab(); await tab.click(); await expect(tab).toHaveClass(/active/); await addRowToActiveTab(page, variable.name, variable.value); }); };🤖 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/utils/page/actions.ts` around lines 614 - 622, The tab locator strings are duplicated inline in addEnvironmentVariable; replace the hard-coded test-id selectors with the centralized helper from locators by calling buildCommonLocators to obtain the tab locators (use the appropriate properties for secrets and variables) and use those locators instead of page.getByTestId('responsive-tab-secrets') / page.getByTestId('responsive-tab-variables'); keep the rest of the logic (click, expect toHaveClass, and addRowToActiveTab) unchanged so the function continues to choose and operate on the correct tab.
🤖 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.
Nitpick comments:
In `@tests/utils/page/actions.ts`:
- Around line 614-622: The tab locator strings are duplicated inline in
addEnvironmentVariable; replace the hard-coded test-id selectors with the
centralized helper from locators by calling buildCommonLocators to obtain the
tab locators (use the appropriate properties for secrets and variables) and use
those locators instead of page.getByTestId('responsive-tab-secrets') /
page.getByTestId('responsive-tab-variables'); keep the rest of the logic (click,
expect toHaveClass, and addRowToActiveTab) unchanged so the function continues
to choose and operate on the correct tab.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fb531acf-2968-45f0-b202-d9a9b0c7f415
📒 Files selected for processing (3)
tests/environments/variable-secret-tabs/variable-secret-tabs.spec.tstests/utils/page/actions.tstests/utils/page/locators.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/environments/variable-secret-tabs/variable-secret-tabs.spec.ts
Description
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
New Features
Improvements
Bug Fixes
Tests
Screen.Recording.2026-06-10.at.1.53.04.PM.mov