Skip to content

Conversation

@Abhi1992002
Copy link
Contributor

@Abhi1992002 Abhi1992002 commented Dec 21, 2025

Changes πŸ—οΈ

This PR adds filtering functionality to the new blocks menu, allowing users to filter search results by category and creator.

New Components:

  • BlockMenuFilters: Main filter component displaying active filters and filter chips
  • FilterSheet: Slide-out panel for selecting filters with categories and creators
  • BlockMenuSearchContent: Refactored search results display component

Features Added:

  • Filter by categories: Blocks, Integrations, Marketplace agents, My agents
  • Filter by creator: Shows all available creators from search results
  • Category counts: Display number of results per category
  • Interactive filter chips with animations (using framer-motion)
  • Hover states showing result counts on filter chips
  • "All filters" sheet with apply/clear functionality

State Management:

  • Extended blockMenuStore with filter state management
  • Added filters, creators, creators_list, and categoryCounts to store
  • Integrated filters with search API (filter and by_creator parameters)

Refactoring:

  • Moved search logic from BlockMenuSearch to BlockMenuSearchContent
  • Renamed useBlockMenuSearch to useBlockMenuSearchContent
  • Moved helper functions to BlockMenuSearchContent directory

API Changes:

  • Updated custom-mutator.ts to properly handle query parameter encoding

Checklist πŸ“‹

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • Search for blocks and verify filter chips appear
    • Click "All filters" and verify filter sheet opens with categories
    • Select/deselect category filters and verify results update accordingly
    • Filter by creator and verify only blocks from that creator show
    • Clear all filters and verify reset to default state
    • Verify filter counts display correctly
    • Test filter chip hover animations

- Updated `BlockMenuFilters` to include creator filtering functionality.
- Modified `FilterChip` component to support hover animations and improved visual feedback.
- Integrated `FilterSheet` for better category management.
- Enhanced state management in `blockMenuStore` to handle creators and category counts.
- Added animations using `framer-motion` for a smoother user experience.
@coderabbitai
Copy link

coderabbitai bot commented Dec 21, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch abhimanyuyadav/open-2897-add-filters-to-the-new-blocks-menu

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.

@github-actions github-actions bot added the platform/frontend AutoGPT Platform - Front end label Dec 21, 2025
@AutoGPT-Agent
Copy link

Thank you for your contribution! Before this PR can be merged, there are several issues that need to be addressed:

  1. PR Title: Please update the title to follow the conventional commit format, for example: feat(frontend/library): Add filters to the new blocks menu

  2. PR Description: The description is currently empty. Please:

    • Explain why these changes are needed
    • Provide a concise summary of the changes you've made
  3. Checklist: The checklist in the PR description needs to be completed. Please check off the items that apply to your changes, particularly:

    • Confirming you've listed your changes
    • Creating a test plan
    • Confirming you've tested your changes according to that plan

Your code implementation looks good, adding filtering functionality to the blocks menu, but we need the PR metadata to be properly filled out to understand the context and ensure the changes have been properly tested.

Let me know if you need any clarification or assistance with these updates!

@Abhi1992002 Abhi1992002 changed the title Abhimanyuyadav/open 2897 add filters to the new blocks menu feat(frontend/builder): add filters to blocks menu Dec 21, 2025
@AutoGPT-Agent
Copy link

Thank you for your contribution to add filters to the blocks menu! Your code looks well-structured and implements this feature nicely.

However, before this PR can be merged, you need to complete the PR description:

  1. Please add a clear explanation of these changes under the "Changes πŸ—οΈ" section. What problem does this solve? What functionality are you adding?

  2. The checklist in the description needs to be filled out. Please check the appropriate boxes, especially:

    • Confirming you've clearly listed your changes
    • Confirming you have a test plan
    • Adding details about how you tested these changes

If there are no configuration changes required, you can leave those checklist items as is.

Once you've updated the description with these details, we can proceed with the review.

@Abhi1992002 Abhi1992002 marked this pull request as ready for review December 21, 2025 07:10
@Abhi1992002 Abhi1992002 requested a review from a team as a code owner December 21, 2025 07:10
@Abhi1992002 Abhi1992002 requested review from 0ubbe and kcze and removed request for a team December 21, 2025 07:10
…ype safety

- Replaced instances of GetV2BuilderSearchFilterAnyOfItem with FilterType across BlockMenuFilters, FilterSheet, and blockMenuStore for better type consistency.
- Enhanced state management in useFilterSheet and useBlockMenuSearchContent to align with the new FilterType.
- Updated constants and types to reflect the new filtering structure, ensuring a more robust and maintainable codebase.
- Removed the `params` option from the `customMutator` function, streamlining the request options.
- Updated the construction of the full URL to directly use the provided URL without appending query parameters.
- This change enhances code clarity and reduces complexity in handling request options.
…nyOfItem for improved type consistency

- Replaced instances of FilterType with GetV2BuilderSearchFilterAnyOfItem across BlockMenuFilters, FilterSheet, and blockMenuStore to enhance type safety.
- Adjusted state management in useFilterSheet and useBlockMenuSearchContent to align with the new filtering structure.
- Updated constants and types to reflect the changes, ensuring a more robust and maintainable codebase.
removeCreator,
} = useBlockMenuStore();

const handleFilterClick = (filter: GetV2BuilderSearchFilterAnyOfItem) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe useCallback and for other functions as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0ubbe told me to skip useCallback unless there's a real performance issue. and these are just simple toggle functions with a few filter chips, so the overhead of useCallback probably isn't worth it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the proper way? Can't this just go to types.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yaa... sorry - in hurry I named it constants instead of types - will change it

>
{searchResults.map((item: SearchResponseItemsItem, index: number) => {
const { type, data } = getSearchItemType(item);
// backend give support to these 3 types only [right now] - we need to give support to integration and ai agent types in follow up PRs
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean? Is there something missing? From backend perspective block == integration and I'm unsure what you mean by "ai agent" as in AI suggestion?

Copy link
Contributor Author

@Abhi1992002 Abhi1992002 Dec 22, 2025

Choose a reason for hiding this comment

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

In designs, search blocks come in two more types. I’ve attached an image of them.
In the integration block, I should receive the image URL and a unique name. In the AI block (sorry not the agent), I get the name of the AI when I search for LLM in the search bar.

I’m only receiving these types of responses from the backend.

/**
 * Generated by orval v7.13.0 🍺
 * Do not edit manually.
 * AutoGPT Agent Server
 * This server is used to execute agents that are created by the AutoGPT system.
 * OpenAPI spec version: 0.1
 */
import type { BlockInfo } from "./blockInfo";
import type { LibraryAgent } from "./libraryAgent";
import type { StoreAgent } from "./storeAgent";

export type SearchResponseItemsItem = BlockInfo | LibraryAgent | StoreAgent;

Screenshot 2025-12-22 at 4.36.47β€―PM.pngScreenshot 2025-12-22 at 4.37.08β€―PM.png

INITIAL_CREATORS_TO_SHOW,
);

const handleLocalCategoryChange = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Again imo would be good to use useCallback for these

Copy link
Contributor Author

@Abhi1992002 Abhi1992002 Dec 22, 2025

Choose a reason for hiding this comment

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

I think the same above reason. No need.

@github-project-automation github-project-automation bot moved this from πŸ†• Needs initial review to 🚧 Needs work in AutoGPT development kanban Dec 22, 2025
@diffray-bot
Copy link

Changes Summary

This PR adds filtering functionality to the blocks menu, allowing users to filter search results by category and creator. The changes include new filter components (BlockMenuFilters, FilterSheet), state management updates to blockMenuStore, and a refactoring of the custom-mutator to simplify query parameter handling by removing the separate params option and relying on pre-encoded URLs.

Type: feature

Components Affected: custom-mutator.ts, BlockMenu components, blockMenuStore, BlockMenuSearchContent

Architecture Impact
  • New Patterns: framer-motion animations for filter chips, FilterSheet slide-out panel pattern
  • Dependencies: added: framer-motion (implied by PR description)
  • Coupling: Extended blockMenuStore with filter state (filters, creators, creators_list, categoryCounts). Search API now integrates filter and by_creator parameters.

Risk Areas: Query parameter encoding change - removed URLSearchParams handling in customMutator, now relies on pre-encoded URLs. This could break if any callers still pass params separately, The redirect handling (3xx responses) was added - need to verify this doesn't break existing redirect scenarios, State management complexity increased with new filter state in blockMenuStore

Suggestions
  • Verify all API callers have been updated to pass pre-encoded query params in the URL rather than using the removed params option
  • Consider adding unit tests for the new redirect handling logic in customMutator
  • Ensure the filter state in blockMenuStore is properly reset when navigating away from the blocks menu

Full review in progress... | Powered by diffray

const fullUrl = `${baseUrl}${url}`;

if (environment.isServerSide()) {
try {

Choose a reason for hiding this comment

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

πŸ”΄ CRITICAL - fetch() call missing error handling
Category: bug

Description:
The fetch() call is not wrapped in a try-catch block. Network errors, CORS errors, DNS failures, or other runtime exceptions will cause unhandled promise rejections.

Suggestion:
Wrap the fetch call in a try-catch block and throw an ApiError with appropriate context for network failures.

Confidence: 92%
Rule: bug_missing_try_catch

};

export const customMutator = async <
T extends { data: any; status: number; headers: Headers },

Choose a reason for hiding this comment

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

🟠 HIGH - Generic type parameter uses 'any' which disables type checking
Category: quality

Description:
The type parameter T extends { data: any; status: number; headers: Headers } uses 'any' for the data field, which completely disables type checking for response data.

Suggestion:
Replace 'any' with a generic type parameter. Change the signature to use a separate generic type parameter TData instead of any to allow callers to specify the expected response data type while maintaining type safety.

Confidence: 85%
Rule: ts_prefer_specific_types_over_any_unknown_w

const requestOptions = options;
const method = (requestOptions.method || "GET") as
| "GET"
| "POST"

Choose a reason for hiding this comment

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

🟠 HIGH - Type assertion on headers without runtime validation
Category: quality

Description:
The code uses (requestOptions.headers as Record<string, string>) without validating headers is actually a Record. RequestInit headers can be Headers, string[][], or Record<string, string>.

Suggestion:
Add proper type handling for all possible header types using instanceof Headers check and Array.isArray check before spreading.

Confidence: 72%
Rule: ts_type_assertion_abuse

Comment on lines 41 to +44
T extends { data: any; status: number; headers: Headers },
>(
url: string,
options: RequestInit & {
params?: any;
} = {},
options: RequestInit,

Choose a reason for hiding this comment

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

🟑 MEDIUM - Type assertions without runtime validation for response body
Category: quality

Description:
The getBody function uses type assertions as Promise<T> for blob and text responses without validating that the content matches type T.

Suggestion:
Return Promise<unknown> from getBody and use type guards at call sites to validate response types.

Confidence: 68%
Rule: ts_type_assertion_abuse

const fullUrl = `${baseUrl}${url}`;

if (environment.isServerSide()) {
try {

Choose a reason for hiding this comment

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

🟑 MEDIUM - Console.warn for auth token failure
Category: quality

Description:
Console.warn logs server auth token retrieval failures to production console, potentially leaking security-related information.

Suggestion:
Replace with a proper logging service that supports environment-based log levels.

Confidence: 60%
Rule: fe_console_in_production

@diffray-bot
Copy link

Review Summary

Free public review - Want AI code reviews on your PRs? Check out diffray.ai

Validated 12 issues: 10 kept (bug, quality concerns), 2 filtered (low value console statements)

Issues Found: 10

See 5 individual line comment(s) for details.

πŸ“Š 4 unique issue type(s) across 10 location(s)

πŸ“‹ Full issue list (click to expand)

πŸ”΄ CRITICAL - fetch() call missing error handling (2 occurrences)

Category: bug

πŸ“ View all locations
File Description Suggestion Confidence
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:104-109 The fetch() call is not wrapped in a try-catch block. Network errors, CORS errors, DNS failures, or ... Wrap the fetch call in a try-catch block and throw an ApiError with appropriate context for network ... 92%
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:153 The getBody() function calls c.json() which can throw SyntaxError for malformed JSON. While error re... Wrap the getBody call in a try-catch block similar to the error response handling on line 126-131. 88%

Rule: bug_missing_try_catch


🟠 HIGH - Generic type parameter uses 'any' which disables type checking (2 occurrences)

Category: quality

πŸ“ View all locations
File Description Suggestion Confidence
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:41 The type parameter T extends { data: any; status: number; headers: Headers } uses 'any' for the da... Replace 'any' with a generic type parameter. Change the signature to use a separate generic type par... 85%
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:125-127 The variable responseData is explicitly typed as 'any', which disables type checking. While error ... Use 'unknown' instead of 'any' to maintain type safety. Then use type guards or optional chaining wh... 78%

Rule: ts_prefer_specific_types_over_any_unknown_w


🟠 HIGH - Console.error in production before throwing ApiError (2 occurrences)

Category: quality

πŸ“ View all locations
File Description Suggestion Confidence
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:139-148 Detailed request failure information is logged to console before throwing ApiError, creating duplica... Remove console.error or wrap in development-only conditional. The ApiError already contains all nece... 75%
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:100 Console.warn logs server auth token retrieval failures to production console, potentially leaking se... Replace with a proper logging service that supports environment-based log levels. 60%

Rule: fe_console_in_production


🟠 HIGH - Type assertion on headers without runtime validation (4 occurrences)

Category: quality

πŸ“ View all locations
File Description Suggestion Confidence
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:55 The code uses (requestOptions.headers as Record<string, string>) without validating headers is act... Add proper type handling for all possible header types using instanceof Headers check and Array.isAr... 72%
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:34-37 The getBody function uses type assertions as Promise<T> for blob and text responses without vali... Return Promise<unknown> from getBody and use type guards at call sites to validate response types.... 68%
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:117-121 Returns { data: null } as T for redirects, assuming null is valid for T['data'], but generic const... Use a discriminated union return type that explicitly handles redirect responses with null data. 65%
autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts:158-162 Final return uses as T without guaranteeing transformed data matches T['data']. The transformDates... Properly type the transformDates function to preserve types, or add runtime validation before return... 62%

Rule: ts_type_assertion_abuse


Powered by diffray - Multi-Agent Code Review Agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/frontend AutoGPT Platform - Front end size/xl

Projects

Status: 🚧 Needs work
Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants