Skip to content

feat: opencollection presets#6461

Merged
helloanoop merged 1 commit intomainfrom
feat/opencollection-presets
Dec 18, 2025
Merged

feat: opencollection presets#6461
helloanoop merged 1 commit intomainfrom
feat/opencollection-presets

Conversation

@helloanoop
Copy link
Contributor

@helloanoop helloanoop commented Dec 18, 2025

Opencollection Presets

Summary by CodeRabbit

  • New Features

    • Added support for presets in collection configurations, enabling users to save and load default request settings within their collections.
  • Chores

    • Updated .gitignore configuration.

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

Copilot AI review requested due to automatic review settings December 18, 2025 17:04
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Walkthrough

This PR adds YAML parsing and serialization support for collection presets. Changes enable reading preset request configurations (type and URL) during YAML parsing and writing them back during stringification, with an added .gitignore entry.

Changes

Cohort / File(s) Summary
Configuration
.gitignore
Added CLAUDE.md to Development plan files section.
Presets YAML Support
packages/bruno-filestore/src/formats/yml/parseCollection.ts, packages/bruno-filestore/src/formats/yml/stringifyCollection.ts
Added parseCollection to extract presets (request type and URL) from YAML extensions; added stringifyCollection to serialize presets back with hasPresets helper detection and debug logging.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Straightforward data mapping following existing parsing/serialization patterns
  • Verify presets object structure ({ request: { type, url } }) aligns with consumer expectations
  • Check that debug console.log statement is intentional or should be removed

Possibly related PRs

Suggested labels

size/L

Suggested reviewers

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

Poem

🎨 Presets now flow through YAML streams,
Type and URL in careful schemes,
Parse, stringify, the roundtrip's clean—
Collection config, elegantly seen! ✨

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 accurately describes the main feature addition: opencollection presets support across YAML parsing and stringification.
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
  • Commit unit tests in branch feat/opencollection-presets

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

🧹 Nitpick comments (2)
packages/bruno-filestore/src/formats/yml/parseCollection.ts (1)

29-38: Consider adding proper typing for presets.

The any cast on line 31 bypasses type checking. Define a proper interface for the presets structure to improve type safety and maintainability.

🔎 Suggested approach:

Define an interface at the top of the file:

interface PresetsExtension {
  request?: {
    type?: string[];
    url?: string[];
  };
}

Then update the cast:

-    const presets = oc.extensions.presets as any;
+    const presets = oc.extensions.presets as PresetsExtension;
packages/bruno-filestore/src/formats/yml/stringifyCollection.ts (1)

188-199: Consider adding proper typing for presets serialization.

The any types on lines 189 and 198 reduce type safety. Define proper interfaces for the presets structure to match the OpenCollection types.

🔎 Suggested approach:

Define interfaces for the presets structure:

interface PresetsRequest {
  type?: string[];
  url?: string[];
}

interface PresetsExtension {
  request: PresetsRequest;
}

Then update the code:

-    const presetsRequest: any = {};
+    const presetsRequest: PresetsRequest = {};
     if (brunoConfig.presets.requestType?.length) {
       presetsRequest.type = brunoConfig.presets.requestType;
     }
     if (brunoConfig.presets.requestUrl?.length) {
       presetsRequest.url = brunoConfig.presets.requestUrl;
     }
     oc.extensions.presets = {
       request: presetsRequest
-    } as any;
+    };
📜 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 c5827df and aadbf8c.

📒 Files selected for processing (3)
  • .gitignore (1 hunks)
  • packages/bruno-filestore/src/formats/yml/parseCollection.ts (1 hunks)
  • packages/bruno-filestore/src/formats/yml/stringifyCollection.ts (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-filestore/src/formats/yml/parseCollection.ts
  • packages/bruno-filestore/src/formats/yml/stringifyCollection.ts
🧠 Learnings (2)
📚 Learning: 2025-12-02T07:24:50.311Z
Learnt from: bijin-bruno
Repo: usebruno/bruno PR: 6263
File: packages/bruno-requests/src/auth/oauth2-helper.ts:249-249
Timestamp: 2025-12-02T07:24:50.311Z
Learning: In OAuth2 Basic Auth headers for Bruno, clientSecret is optional and can be omitted. When constructing the Authorization header in `packages/bruno-requests/src/auth/oauth2-helper.ts`, use `clientSecret || ''` instead of `clientSecret!` to properly handle cases where only clientId is provided, per community requests.

Applied to files:

  • packages/bruno-filestore/src/formats/yml/parseCollection.ts
📚 Learning: 2025-12-16T07:16:08.934Z
Learnt from: sanish-bruno
Repo: usebruno/bruno PR: 6090
File: tests/scripting/hooks/init-user-data/ui-state-snapshot.json:1-8
Timestamp: 2025-12-16T07:16:08.934Z
Learning: For e2e tests in the bruno repository: Collections that are shared between CLI and UI tests (comprehensive test suites testing core functionality) should be placed in `packages/bruno-tests/` to avoid duplication. The `tests/**/fixtures/collection` pattern should be used for test-specific collections that test particular UI behaviors or are specific to a single test file.

Applied to files:

  • packages/bruno-filestore/src/formats/yml/stringifyCollection.ts
🧬 Code graph analysis (1)
packages/bruno-filestore/src/formats/yml/parseCollection.ts (4)
packages/bruno-app/src/components/CollectionSettings/index.js (1)
  • presets (62-62)
packages/bruno-electron/src/app/collections.js (1)
  • brunoConfig (103-103)
packages/bruno-electron/src/app/collection-watcher.js (2)
  • brunoConfig (212-212)
  • brunoConfig (453-453)
packages/bruno-electron/src/utils/collection-import.js (1)
  • brunoConfig (100-100)
⏰ 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). (7)
  • GitHub Check: Agent
  • GitHub Check: CLI Tests
  • GitHub Check: Unit Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - macOS
🔇 Additional comments (2)
.gitignore (1)

56-56: LGTM!

Adding CLAUDE.md to the development plan files is appropriate.

packages/bruno-filestore/src/formats/yml/stringifyCollection.ts (1)

49-52: LGTM!

The hasPresets helper correctly detects preset configuration by checking for non-empty requestType or requestUrl arrays.

};

const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => {
console.log('brunoConfig', brunoConfig);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Remove debug console.log statement.

This debug statement should not be in production code.

🔎 Apply this diff:
-  console.log('brunoConfig', brunoConfig);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log('brunoConfig', brunoConfig);
🤖 Prompt for AI Agents
In packages/bruno-filestore/src/formats/yml/stringifyCollection.ts around line
55 there is a leftover debug console.log('brunoConfig', brunoConfig); — remove
this console.log statement from the file so no debug output occurs in
production, and replace with no-op or use logger.debug if structured logging is
required; after removal run lint/tests to ensure no formatting or
unused-variable issues are introduced.

@github-actions
Copy link

CLI Test Results

  1 files  ±0  140 suites  ±0   53s ⏱️ -25s
235 tests ±0  235 ✅ ±0  0 💤 ±0  0 ❌ ±0 
301 runs  ±0  300 ✅ ±0  1 💤 ±0  0 ❌ ±0 

Results for commit aadbf8c. ± Comparison against base commit c5827df.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces preset functionality for opencollection format, allowing configuration of default request types and URLs. The changes enable parsing and stringifying of preset configurations through the opencollection YAML format.

  • Adds hasPresets helper function to check for preset configuration
  • Implements preset serialization and deserialization in opencollection YAML format
  • Updates .gitignore to exclude Claude development file

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 5 comments.

File Description
packages/bruno-filestore/src/formats/yml/stringifyCollection.ts Adds preset serialization logic, hasPresets helper function, and reorders opencollection version assignment
packages/bruno-filestore/src/formats/yml/parseCollection.ts Implements preset parsing from opencollection extensions
.gitignore Adds CLAUDE.md to ignored development files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

};

const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => {
console.log('brunoConfig', brunoConfig);
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statement should be removed before merging to production. This will log potentially sensitive collection configuration data to the console.

Suggested change
console.log('brunoConfig', brunoConfig);

Copilot uses AI. Check for mistakes.
Comment on lines +50 to +51
return brunoConfig?.presets?.requestType?.length
|| brunoConfig?.presets?.requestUrl?.length;
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hasPresets function should use explicit comparison with greater than 0 for consistency with other similar helper functions in this file (e.g., hasCollectionConfig checks length > 0). This makes the intent clearer and follows the established pattern.

Suggested change
return brunoConfig?.presets?.requestType?.length
|| brunoConfig?.presets?.requestUrl?.length;
return (brunoConfig?.presets?.requestType?.length ?? 0) > 0
|| (brunoConfig?.presets?.requestUrl?.length ?? 0) > 0;

Copilot uses AI. Check for mistakes.
oc.extensions.ignore = ignoreList;
}
if (hasPresets(brunoConfig)) {
const presetsRequest: any = {};
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable presetsRequest uses 'any' type. Consider defining a more specific type for better type safety, similar to how other parts of this file use specific types from '@opencollection/types'.

Suggested change
const presetsRequest: any = {};
type PresetsRequest = {
type?: string;
url?: string;
};
const presetsRequest: PresetsRequest = {};

Copilot uses AI. Check for mistakes.
Comment on lines +196 to +198
oc.extensions.presets = {
request: presetsRequest
} as any;
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'as any' type assertion could be avoided by properly typing the presets structure. Consider defining a proper type for extensions.presets instead of using type assertion.

Copilot uses AI. Check for mistakes.

// presets
if (oc.extensions?.presets) {
const presets = oc.extensions.presets as any;
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable presets uses 'any' type. Consider defining a more specific type for the extensions.presets structure for better type safety.

Copilot uses AI. Check for mistakes.
@helloanoop helloanoop merged commit 336496a into main Dec 18, 2025
15 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