fix: persist environment color on import/export#7045
fix: persist environment color on import/export#7045pooja-bruno wants to merge 1 commit intousebruno:mainfrom
Conversation
WalkthroughThis PR adds color property support to environments across the application stack. The color field is propagated through Redux slices, IPC handlers, store methods, and import/export utilities, enabling colored environment identification in the UI. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-electron/src/store/workspace-environments.js (1)
345-346:⚠️ Potential issue | 🟡 MinorMissing
awaitonstringifyEnvironmentcall.At line 345,
stringifyEnvironmentis called withoutawait, but elsewhere in this file (e.g., lines 202, 237, 268) it's awaited. This inconsistency could cause issues if the function returns a Promise.🐛 Proposed fix
- const content = stringifyEnvironment(environment, { format: 'yml' }); + const content = await stringifyEnvironment(environment, { format: 'yml' });
🧹 Nitpick comments (4)
tests/environments/import-environment/env-color-import/env-color-import.spec.ts (1)
33-44: Use locator variables for the import controls.Inline locators make the steps harder to scan and reuse; assigning them to variables keeps the flow consistent with the rest of the test.
As per coding guidelines: Use locator variables for locators.♻️ Suggested refactor
- // Click Import button - await page.getByRole('button', { name: 'Import', exact: true }).click(); + // Click Import button + const importButton = page.getByRole('button', { name: 'Import', exact: true }); + await expect(importButton).toBeVisible(); + await importButton.click(); @@ - await page.getByTestId('import-global-environment').click(); + const importTrigger = page.getByTestId('import-global-environment'); + await expect(importTrigger).toBeVisible(); + await importTrigger.click();packages/bruno-electron/src/store/global-environments.js (1)
137-145:copyGlobalEnvironmentdoes not copy thecolorproperty.When copying an environment, the color is not included in the copied environment object. If the intent is to preserve all environment properties during copy, consider adding
colorhere as well.♻️ Proposed fix to include color in copy
- copyGlobalEnvironment({ uid, name, variables }) { + copyGlobalEnvironment({ uid, name, variables, color }) { let globalEnvironments = this.getGlobalEnvironments(); globalEnvironments.push({ uid, name, - variables + variables, + color }); this.setGlobalEnvironments(globalEnvironments); }packages/bruno-app/src/providers/ReduxStore/slices/global-environments.js (2)
139-164:copyGlobalEnvironmentdoes not propagate thecolorproperty.The copy operation doesn't pass
colorto the IPC call or include it in the dispatched action. If color should be preserved when copying environments, this needs updating.♻️ Proposed fix to include color in copy
export const copyGlobalEnvironment = ({ name, environmentUid: baseEnvUid }) => (dispatch, getState) => { return new Promise((resolve, reject) => { const state = getState(); const { workspaceUid, workspacePath } = getWorkspaceContext(state); const globalEnvironments = state.globalEnvironments.globalEnvironments; const baseEnv = globalEnvironments?.find((env) => env?.uid == baseEnvUid); if (!baseEnv) { return reject(new Error('Base environment not found')); } const uid = uuid(); const environment = { uid, name, variables: baseEnv.variables }; const { ipcRenderer } = window; environmentSchema .validate(environment) - .then(() => ipcRenderer.invoke('renderer:create-global-environment', { uid, name, variables: baseEnv.variables, workspaceUid, workspacePath })) + .then(() => ipcRenderer.invoke('renderer:create-global-environment', { uid, name, variables: baseEnv.variables, color: baseEnv.color, workspaceUid, workspacePath })) .then((result) => { const finalUid = result?.uid || uid; const finalName = result?.name || name; const finalVariables = result?.variables || baseEnv.variables; - dispatch(_copyGlobalEnvironment({ name: finalName, uid: finalUid, variables: finalVariables })); + const finalColor = result?.color || baseEnv.color; + dispatch(_copyGlobalEnvironment({ name: finalName, uid: finalUid, variables: finalVariables, color: finalColor })); }) .then(resolve) .catch(reject); }); };
49-58:_copyGlobalEnvironmentreducer doesn't includecolor.To maintain consistency with
_addGlobalEnvironment, the copy reducer should also handle thecolorproperty.♻️ Proposed fix
_copyGlobalEnvironment: (state, action) => { - const { name, uid, variables } = action.payload; + const { name, uid, variables, color } = action.payload; if (name?.length && uid) { state.globalEnvironments.push({ uid, name, - variables + variables, + color }); } },
Description
JIRA
Preserve env color when we export and import the environment
Contribution Checklist:
Screen.Recording.2026-02-04.at.1.30.16.PM.mov
Summary by CodeRabbit
Release Notes
New Features
Tests