Skip to content

add: presets in collection setting#6389

Merged
sid-bruno merged 4 commits intousebruno:mainfrom
pooja-bruno:add/presert-in-collection-setting
Dec 16, 2025
Merged

add: presets in collection setting#6389
sid-bruno merged 4 commits intousebruno:mainfrom
pooja-bruno:add/presert-in-collection-setting

Conversation

@pooja-bruno
Copy link
Collaborator

@pooja-bruno pooja-bruno commented Dec 12, 2025

Description

JIRA

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.
image

Summary by CodeRabbit

  • New Features

    • Added Presets configuration in Collection Settings: choose default request type (HTTP, GraphQL, gRPC, WebSocket) and base URL, with a Save action.
    • New "Presets" tab and status indicator in Collection Settings.
  • Behavior

    • Sidebar / New Request flow now inherits collection presets so new requests default to the configured type and URL.
    • Presets updates are included in autosave so changes persist automatically.
  • Style

    • Updated styling for the Presets panel for improved layout and inputs.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Walkthrough

Adds a Collection-level Presets feature: UI (PresetsSettings + StyledWrapper), Redux reducer/action to store presets, autosave middleware hookup, and using collection presets as defaults when creating new requests.

Changes

Cohort / File(s) Summary
Presets UI
packages/bruno-app/src/components/CollectionSettings/Presets/StyledWrapper.js, packages/bruno-app/src/components/CollectionSettings/Presets/index.js
New StyledWrapper component and PresetsSettings React component. UI for selecting request type and base URL, local merge helper, dispatches updateCollectionPresets and saveCollectionSettings on save.
CollectionSettings integration
packages/bruno-app/src/components/CollectionSettings/index.js
Imports and adds a "Presets" tab, reads presets from draft or saved brunoConfig, computes hasPresets, and shows tab/status indicator; routes panel to Presets view.
NewRequest defaults
packages/bruno-app/src/components/Sidebar/NewRequest/index.js
Reads collection presets (draft or saved) using lodash/get, maps presets.requestType to app request-type ids, and uses requestType/requestUrl as defaults for new requests.
Redux reducer
packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
Adds updateCollectionPresets reducer/action: ensures draft exists, ensures brunoConfig on draft, assigns action.payload.presets to draft.brunoConfig.presets, and exports the action.
Autosave middleware
packages/bruno-app/src/providers/ReduxStore/middlewares/autosave/middleware.js
Registers collections/updateCollectionPresets in the list of actions that trigger autosave scheduling.

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as PresetsSettings
    participant Store as Redux Store
    participant Middleware as Autosave Middleware
    participant NewReq as NewRequest

    User->>UI: choose request type & enter base URL
    UI->>Store: dispatch updateCollectionPresets({ collectionUid, presets })
    activate Store
    Store->>Store: write presets to collection.draft.brunoConfig.presets
    deactivate Store
    Store->>Middleware: action observed (updateCollectionPresets)
    activate Middleware
    Middleware->>Middleware: schedule autosave for collection
    deactivate Middleware

    User->>NewReq: open "New Request"
    NewReq->>Store: read collection (draft or saved) brunoConfig.presets
    Store-->>NewReq: return presets
    NewReq->>NewReq: apply requestType & requestUrl defaults
    NewReq-->>User: initialized request with presets
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect updateCollectionPresets for correct draft initialization and immutable patterns.
  • Verify autosave middleware action string and scheduling behavior.
  • Confirm mapping logic for presets.requestType ↔ app request-type ids in NewRequest.
  • Check PresetsSettings save flow and UI state handling (edge cases, empty values).

Possibly related PRs

Suggested reviewers

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

Poem

🌱 A tiny preset finds its place,
Types selected, base URL traced.
Save the choice, defaults align,
New requests start on ready time. 🚀

Pre-merge checks and finishing touches

✅ 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 'add: presets in collection setting' directly relates to the changeset, which introduces a new Presets feature in CollectionSettings with UI components, state management, and integrations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 3

🧹 Nitpick comments (4)
packages/bruno-app/src/components/CollectionSettings/Presets/StyledWrapper.js (1)

10-26: Remove redundant / hardcoded textbox styles (prefer theme-only).

.textbox sets border/box-shadow/border-radius twice and includes a hardcoded #ccc that gets overridden anyway. Consider trimming to the theme-driven declarations and (if possible) drop !important on focus by relying on selector specificity. Based on learnings, prefer theme props for colors.

packages/bruno-app/src/components/Sidebar/NewRequest/index.js (1)

76-102: Request type mapping is clear; consider centralizing the enum mapping later.

This works, but the 'http'/'graphql'/'grpc'/'ws' ↔ app *-request mapping now exists in more than one place conceptually (Presets UI + NewRequest). If it grows, a small shared helper would reduce drift.

Also applies to: 106-113

packages/bruno-app/src/components/CollectionSettings/Presets/index.js (2)

1-7: Prefer lodash/get import style for consistency / bundle size.

Most of this codebase seems to use import get from 'lodash/get'. This file uses import { get } from 'lodash', which can be heavier depending on tooling. Consider:

-import { get } from 'lodash';
+import get from 'lodash/get';

47-85: Presets UI omits WebSocket, but New Request supports it—confirm this is intentional.

NewRequest maps presets.requestType === 'ws'ws-request, but PresetsSettings offers only HTTP/GraphQL/gRPC. If WS presets are supported, add the radio option; if not, consider dropping the WS mapping to avoid “hidden” config states.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6652cca and 2909b6f.

📒 Files selected for processing (6)
  • packages/bruno-app/src/components/CollectionSettings/Presets/StyledWrapper.js (1 hunks)
  • packages/bruno-app/src/components/CollectionSettings/Presets/index.js (1 hunks)
  • packages/bruno-app/src/components/CollectionSettings/index.js (4 hunks)
  • packages/bruno-app/src/components/Sidebar/NewRequest/index.js (3 hunks)
  • packages/bruno-app/src/providers/ReduxStore/middlewares/autosave/middleware.js (1 hunks)
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/providers/ReduxStore/middlewares/autosave/middleware.js
  • packages/bruno-app/src/components/CollectionSettings/Presets/StyledWrapper.js
  • packages/bruno-app/src/components/CollectionSettings/index.js
  • packages/bruno-app/src/components/Sidebar/NewRequest/index.js
  • packages/bruno-app/src/components/CollectionSettings/Presets/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
🧠 Learnings (3)
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.{jsx,tsx} : Styled Components are used as wrappers to define both self and children components style; Tailwind classes are used specifically for layout based styles

Applied to files:

  • packages/bruno-app/src/components/CollectionSettings/Presets/StyledWrapper.js
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.{jsx,tsx} : Styled Component CSS might also change layout but Tailwind classes shouldn't define colors

Applied to files:

  • packages/bruno-app/src/components/CollectionSettings/Presets/StyledWrapper.js
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.{jsx,tsx} : Use styled component's theme prop to manage CSS colors and not CSS variables when in the context of a styled component or any React component using the styled component

Applied to files:

  • packages/bruno-app/src/components/CollectionSettings/Presets/StyledWrapper.js
  • packages/bruno-app/src/components/Sidebar/NewRequest/index.js
🧬 Code graph analysis (3)
packages/bruno-app/src/components/CollectionSettings/index.js (2)
packages/bruno-app/src/components/RunnerResults/ResponsePane/index.js (1)
  • getTabClassname (85-89)
packages/bruno-app/src/components/StatusDot/index.js (1)
  • StatusDot (4-12)
packages/bruno-app/src/components/Sidebar/NewRequest/index.js (2)
packages/bruno-cli/src/runner/prepare-request.js (1)
  • get (1-1)
packages/bruno-app/src/components/Preferences/General/index.js (1)
  • formik (62-90)
packages/bruno-app/src/components/CollectionSettings/Presets/index.js (2)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (2)
  • saveCollectionSettings (2184-2223)
  • saveCollectionSettings (2184-2223)
packages/bruno-app/src/components/CollectionSettings/Presets/StyledWrapper.js (1)
  • StyledWrapper (3-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: Unit Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: CLI Tests
🔇 Additional comments (2)
packages/bruno-app/src/providers/ReduxStore/middlewares/autosave/middleware.js (1)

4-76: Autosave intercept addition looks correct; ensure updateCollectionPresets always carries payload.collectionUid.

This middleware assumes an intercepted action has a payload object (Line 145 destructuring). Please ensure collections/updateCollectionPresets is always dispatched with { collectionUid } (and doesn’t ever dispatch undefined payload), otherwise autosave will throw.

Also applies to: 142-146

packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js (1)

2083-2098: updateCollectionPresets reducer matches existing draft/brunoConfig patterns.

Draft initialization + set(collection, 'draft.brunoConfig.presets', action.payload.presets) is consistent with other collection-level brunoConfig updates.

Also applies to: 3457-3470

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: 2

🧹 Nitpick comments (1)
packages/bruno-app/src/components/CollectionSettings/Presets/index.js (1)

6-16: Optional: drop lodash/get here; optional chaining is enough
This reduces deps/indirection in a simple read path.

-import { get } from 'lodash';
...
-  const currentPresets = collection.draft?.brunoConfig
-    ? get(collection, 'draft.brunoConfig.presets', initialPresets)
-    : get(collection, 'brunoConfig.presets', initialPresets);
+  const currentPresets = collection.draft?.brunoConfig?.presets
+    ?? collection.brunoConfig?.presets
+    ?? initialPresets;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf068d1 and 3b22e6b.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/CollectionSettings/Presets/index.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/components/CollectionSettings/Presets/index.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/CollectionSettings/Presets/index.js (1)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (2)
  • saveCollectionSettings (2184-2223)
  • saveCollectionSettings (2184-2223)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
🔇 Additional comments (1)
packages/bruno-app/src/components/CollectionSettings/Presets/index.js (1)

17-27: Overall structure looks solid (incl. WebSocket option + non-submit Save button)
State updates + save wiring are straightforward.

Also applies to: 47-98, 124-128

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

♻️ Duplicate comments (1)
packages/bruno-app/src/components/CollectionSettings/Presets/index.js (1)

100-122: Fix naming inconsistency: "Base URL" vs "Request URL".

The label says "Base URL" but the placeholder still says "Request URL". This creates UX confusion.

               <input
                 id="request-url"
                 type="text"
                 name="requestUrl"
-                placeholder="Request URL"
+                placeholder="Base URL"
                 className="block textbox"
🧹 Nitpick comments (2)
packages/bruno-app/src/components/CollectionSettings/Presets/index.js (2)

12-15: Consider simplifying preset retrieval.

The ternary is redundant since lodash.get already handles undefined/null paths gracefully. You can simplify to a single call:

-  // Get presets from draft.brunoConfig if it exists, otherwise from brunoConfig
-  const currentPresets = collection.draft?.brunoConfig
-    ? get(collection, 'draft.brunoConfig.presets', initialPresets)
-    : get(collection, 'brunoConfig.presets', initialPresets);
+  // Get presets from draft.brunoConfig if it exists, otherwise from brunoConfig
+  const currentPresets = get(collection, 'draft.brunoConfig.presets') || get(collection, 'brunoConfig.presets', initialPresets);

41-98: Good fixes applied from previous reviews!

The htmlFor now correctly matches the first radio button id, and WebSocket has been added. Nice work addressing the feedback.

Optional: Extract repeated default value.

The expression (currentPresets.requestType || 'http') is repeated in all four checked attributes. Consider extracting it:

+  const requestType = currentPresets.requestType || 'http';
+
   return (
     <StyledWrapper className="h-full w-full">
       ...
             <input
               id="http"
               ...
-              checked={(currentPresets.requestType || 'http') === 'http'}
+              checked={requestType === 'http'}
             />
             ...
-              checked={(currentPresets.requestType || 'http') === 'graphql'}
+              checked={requestType === 'graphql'}
             />
             ...
-              checked={(currentPresets.requestType || 'http') === 'grpc'}
+              checked={requestType === 'grpc'}
             />
             ...
-              checked={(currentPresets.requestType || 'http') === 'ws'}
+              checked={requestType === 'ws'}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b22e6b and a12d940.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/CollectionSettings/Presets/index.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/components/CollectionSettings/Presets/index.js
🧬 Code graph analysis (1)
packages/bruno-app/src/components/CollectionSettings/Presets/index.js (2)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (2)
  • saveCollectionSettings (2184-2223)
  • saveCollectionSettings (2184-2223)
packages/bruno-app/src/components/CollectionSettings/Presets/StyledWrapper.js (1)
  • StyledWrapper (3-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: CLI Tests
  • GitHub Check: Playwright E2E Tests
🔇 Additional comments (4)
packages/bruno-app/src/components/CollectionSettings/Presets/index.js (4)

1-10: LGTM!

Clean imports and sensible default values for presets.


17-34: LGTM!

Clean helper functions with proper Redux dispatch handling.


124-128: LGTM!

Good fix—button is now type="button" as recommended in previous reviews.


130-134: LGTM!

Clean component structure and export.

@sid-bruno sid-bruno merged commit dc111ec into usebruno:main Dec 16, 2025
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.

3 participants