Skip to content

fix: persist environment color on import/export#7045

Open
pooja-bruno wants to merge 1 commit intousebruno:mainfrom
pooja-bruno:fix/environment-color-import-export
Open

fix: persist environment color on import/export#7045
pooja-bruno wants to merge 1 commit intousebruno:mainfrom
pooja-bruno:fix/environment-color-import-export

Conversation

@pooja-bruno
Copy link
Collaborator

@pooja-bruno pooja-bruno commented Feb 5, 2026

Description

JIRA

Preserve env color when we export and import the environment

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.
Screen.Recording.2026-02-04.at.1.30.16.PM.mov

Summary by CodeRabbit

Release Notes

  • New Features

    • Environments now support custom color properties that are preserved during import and export operations.
  • Tests

    • Added comprehensive test coverage for environment color import functionality, including single and multiple environment color preservation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

Walkthrough

This 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

Cohort / File(s) Summary
Redux Environment Actions
packages/bruno-app/src/providers/ReduxStore/slices/global-environments.js, packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
Extended Redux action signatures to accept and propagate color parameter; updated global environment action payload and store state to include color field.
IPC Handlers (Electron)
packages/bruno-electron/src/ipc/global-environments.js, packages/bruno-electron/src/ipc/collection.js
Updated IPC handler signatures to accept color parameter in payloads; handlers now return color in responses alongside existing environment metadata.
Environment Stores
packages/bruno-electron/src/store/global-environments.js, packages/bruno-electron/src/store/workspace-environments.js
Extended store method signatures to accept and persist color property; environment objects now include color field in state.
Import/Export Utilities
packages/bruno-app/src/utils/importers/bruno-environment.js, packages/bruno-app/src/utils/exporters/bruno-environment.js, packages/bruno-app/src/components/Environments/Common/ImportEnvironmentModal/index.js
Enhanced environment validation, export mapping, and import modal dispatch to include color in environment payloads during import/export operations.
Test Suite & Fixtures
tests/environments/import-environment/env-color-import/env-color-import.spec.ts, tests/environments/import-environment/env-color-import/fixtures/*
Added Playwright test suite verifying color preservation during global environment import; included fixture files (collection, requests, colored environment JSONs) and test initialization data.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

pr-feature, size/M

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🎨 Colors bloom through every layer—Redux flows with chromatic grace,
IPC wires paint the Electron space, stores remember hues in place.
Imports and exports now carry the hue, testing verifies each shade rings true! 🌈

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: persisting environment color during import/export operations across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 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 | 🟡 Minor

Missing await on stringifyEnvironment call.

At line 345, stringifyEnvironment is called without await, 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.

♻️ 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();
As per coding guidelines: Use locator variables for locators.
packages/bruno-electron/src/store/global-environments.js (1)

137-145: copyGlobalEnvironment does not copy the color property.

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 color here 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: copyGlobalEnvironment does not propagate the color property.

The copy operation doesn't pass color to 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: _copyGlobalEnvironment reducer doesn't include color.

To maintain consistency with _addGlobalEnvironment, the copy reducer should also handle the color property.

♻️ 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
         });
       }
     },

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.

1 participant