Skip to content

Conversation

@naman-bruno
Copy link
Collaborator

@naman-bruno naman-bruno commented Jan 20, 2026

Description

JIRA: https://usebruno.atlassian.net/browse/BRU-1150

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 configurations can now be saved as drafts when closing the app
    • Support for collection-specific and globally-scoped environment configurations
  • Improvements

    • Save modal enhanced to display and manage environment drafts
    • Unsaved items list now includes environment configurations alongside requests and collections
    • Improved tracking and labeling of different draft types in the save workflow

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Walkthrough

Extends SaveRequestsModal to handle collection-specific and global environment drafts alongside existing request, folder, and collection drafts. Integrates environment persistence logic with corresponding UI labels and state tracking within the unsaved items workflow.

Changes

Cohort / File(s) Summary
Environment Draft Handling
packages/bruno-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js
Added support for collection and global environment drafts in the save flow; integrated environment selectors (findEnvironmentInCollection, globalEnvironments, globalEnvironmentDraft) and save handlers (saveEnvironment, saveGlobalEnvironment); extended allDrafts computation and memo dependencies to track environment state; updated UI to display "Collection Environment" and "Global Environment" draft types with proper labeling

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno

Poem

🌍 Environments now draft with care,
Collections, globals—handled fair,
Save flows expand with graceful flow,
Modal's reach can wider go! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: enhancing SaveRequestsModal to handle environment drafts, which aligns with the core modifications in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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-app/src/providers/App/ConfirmAppClose/SaveRequestsModal.js (1)

28-56: Avoid silently dropping environment drafts when lookup fails.
Both collection/global blocks only push drafts if the environment lookup succeeds. If the environment list hasn’t hydrated yet (or was renamed/removed), the draft is omitted, which can drive totalDraftsCount to zero and auto-close the modal, discarding unsaved variables. Consider keeping the draft with a fallback name so the save path can still attempt persistence.

✅ Suggested fix to preserve drafts even when the environment isn’t resolved
-        if (collection.environmentsDraft) {
-          const { environmentUid, variables } = collection.environmentsDraft;
-          const environment = findEnvironmentInCollection(collection, environmentUid);
-          if (environment && variables) {
-            environmentDrafts.push({
-              type: 'collection-environment',
-              name: environment.name,
-              environmentUid,
-              variables,
-              collectionUid: collectionUid
-            });
-          }
-        }
+        if (collection.environmentsDraft) {
+          const { environmentUid, variables } = collection.environmentsDraft;
+          if (variables) {
+            const environment = findEnvironmentInCollection(collection, environmentUid);
+            environmentDrafts.push({
+              type: 'collection-environment',
+              name: environment?.name || 'Unknown Environment',
+              environmentUid,
+              variables,
+              collectionUid: collectionUid
+            });
+          }
+        }
-    if (globalEnvironmentDraft) {
-      const { environmentUid, variables } = globalEnvironmentDraft;
-      const environment = globalEnvironments?.find((env) => env.uid === environmentUid);
-      if (environment && variables) {
-        environmentDrafts.push({
-          type: 'global-environment',
-          name: environment.name,
-          environmentUid,
-          variables
-        });
-      }
-    }
+    if (globalEnvironmentDraft) {
+      const { environmentUid, variables } = globalEnvironmentDraft;
+      if (variables) {
+        const environment = globalEnvironments?.find((env) => env.uid === environmentUid);
+        environmentDrafts.push({
+          type: 'global-environment',
+          name: environment?.name || 'Unknown Environment',
+          environmentUid,
+          variables
+        });
+      }
+    }

Also applies to: 84-95

@bijin-bruno bijin-bruno merged commit bac9616 into usebruno:main Jan 20, 2026
7 of 8 checks passed
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.

2 participants