Skip to content

Conversation

@JivusAyrus
Copy link
Member

@JivusAyrus JivusAyrus commented Jun 19, 2025

Motivation and Context

This PR fixes the toggle ui logic and search to account for all the operations affected rather than just the first page of the paginated operations list.

Checklist

  • I have discussed my proposed changes in an issue and have received approval to proceed.
  • I have followed the coding standards of the project.
  • Tests or benchmarks have been added or updated.
  • Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
  • I have read the Contributors Guide.
Screen.Recording.2025-06-23.at.4.14.41.PM.mov

Summary by CodeRabbit

  • New Features

    • Added the ability to search and filter operations by name or hash in the operations list.
    • Introduced a toggle to apply overrides only to filtered operations based on the current search.
  • Enhancements

    • Operations list and override actions now reflect server-side filtering, improving accuracy and performance.
    • Added indicators showing if all operations have ignore-all overrides or all changes are marked safe, based on filtered results.
  • User Interface

    • Added a search input and a new switch in the "Override All" dropdown for more granular control.

@github-actions
Copy link

github-actions bot commented Jun 19, 2025

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-78f39cf13374e6ad78752ad7ff3eabe05f484408

Copy link
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

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

LGTM

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 30, 2025

Walkthrough

This change introduces new optional search fields to several protobuf request and response messages and propagates these fields through backend repositories, service logic, and the UI. The backend now supports server-side filtering of operations by search term, and the frontend provides a search input and a toggle to limit overrides to filtered operations, removing previous client-side filtering.

Changes

Files/Paths Change Summary
proto/wg/cosmo/platform/v1/platform.proto
connect/src/wg/cosmo/platform/v1/platform_pb.ts
Added optional search string fields to three request messages and two boolean fields to a response message for aggregated override status.
controlplane/src/core/repositories/SchemaCheckRepository.ts Added optional search parameter to methods for fetching/counting affected operations, applying server-side filtering by operation name or hash.
controlplane/src/core/bufservices/check/getCheckOperations.ts Integrated search into affected operations queries and response; added logic to compute and return new boolean override status flags.
controlplane/src/core/bufservices/check/createIgnoreOverridesForAllOperations.ts
controlplane/src/core/bufservices/check/toggleChangeOverridesForAllOperations.ts
Passed search parameter from request into affected operations queries, enabling filtered override application.
controlplane/src/core/repositories/OperationsRepository.ts Added new types for overrides, updated method signatures for type safety, and introduced a method to compute override status flags for operations.
controlplane/src/db/models.ts Added new type alias DBSchemaChangeType for schema change type enum values.
studio/src/components/checks/operations.tsx Replaced client-side Fuse.js filtering with server-side search; added debounced search input and toggle to apply overrides only to filtered operations; updated UI and mutation logic to use new backend capabilities and flags.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 (2)
controlplane/src/core/repositories/SchemaCheckRepository.ts (1)

340-349: Consider performance optimization for search queries.

The search implementation is functionally correct but may have performance implications with wildcard patterns (%${search}%) on large datasets. As discussed in previous comments, consider implementing pg_trgm indexes for better performance with pattern matching queries.

Consider adding GIN indexes with pg_trgm extension:

CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX CONCURRENTLY idx_operation_usage_name_trgm ON schema_check_change_action_operation_usage USING GIN (name gin_trgm_ops);
CREATE INDEX CONCURRENTLY idx_operation_usage_hash_trgm ON schema_check_change_action_operation_usage USING GIN (hash gin_trgm_ops);

Also applies to: 404-413

proto/wg/cosmo/platform/v1/platform.proto (1)

573-575: Field names violate protobuf style & are excessively verbose

Buf already flags these as non-snake_case. In addition, the names are so long that they harm readability and increase boilerplate in generated code.

-  bool doAllOperationsHaveIgnoreAllOverride = 7;
-  bool doAllOperationsHaveAllTheirChangesMarkedSafe = 8;
+  bool all_operations_have_ignore_all_override = 7;
+  bool all_operations_have_all_changes_marked_safe = 8;

Because these fields are brand-new, renaming now avoids a locked-in breaking change later.

🧹 Nitpick comments (2)
studio/src/components/checks/operations.tsx (1)

72-74: Initialize search state more safely from router query.

The search state initialization should handle undefined values more explicitly to avoid potential TypeScript issues.

Apply this diff to make the initialization more explicit:

-  const [search, setSearch] = useState(router.query.search as string);
+  const [search, setSearch] = useState((router.query.search as string) || "");
controlplane/src/core/repositories/OperationsRepository.ts (1)

371-408: Add performance benchmarks and consider optimizing getOperationOverrideStatusOfCheck

I didn’t find any existing performance tests or benchmarks for this method—adding them will help catch regressions and guide future optimizations.

• File: controlplane/src/core/repositories/OperationsRepository.ts (lines 371–408)
• Function: getOperationOverrideStatusOfCheck

Suggested next steps:

  1. Offload aggregate logic to the database (SQL‐level computation)
  2. Replace Array.prototype.every with manual loops for early exits
  3. Process large operation sets in batches
  4. Add benchmark tests (e.g., using [your preferred testing/benchmarking tool]) and monitor under realistic load
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53a4b93 and db647e8.

⛔ Files ignored due to path filters (1)
  • connect-go/gen/proto/wg/cosmo/platform/v1/platform.pb.go is excluded by !**/*.pb.go, !**/gen/**
📒 Files selected for processing (9)
  • connect/src/wg/cosmo/platform/v1/platform_pb.ts (8 hunks)
  • controlplane/src/core/bufservices/check/createIgnoreOverridesForAllOperations.ts (1 hunks)
  • controlplane/src/core/bufservices/check/getCheckOperations.ts (5 hunks)
  • controlplane/src/core/bufservices/check/toggleChangeOverridesForAllOperations.ts (1 hunks)
  • controlplane/src/core/repositories/OperationsRepository.ts (4 hunks)
  • controlplane/src/core/repositories/SchemaCheckRepository.ts (6 hunks)
  • controlplane/src/db/models.ts (2 hunks)
  • proto/wg/cosmo/platform/v1/platform.proto (4 hunks)
  • studio/src/components/checks/operations.tsx (8 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
controlplane/src/db/models.ts (1)
controlplane/src/db/schema.ts (1)
  • schemaChangeTypeEnum (634-711)
studio/src/components/checks/operations.tsx (5)
studio/src/components/ui/dropdown-menu.tsx (1)
  • DropdownMenuSeparator (196-196)
connect/src/wg/cosmo/platform/v1/platform_pb.ts (1)
  • Label (340-378)
connect-go/gen/proto/wg/cosmo/platform/v1/platform.pb.go (3)
  • Label (562-569)
  • Label (584-584)
  • Label (599-601)
controlplane/src/types/index.ts (1)
  • Label (55-58)
studio/src/components/ui/switch.tsx (1)
  • Switch (27-27)
🪛 Buf (1.54.0)
proto/wg/cosmo/platform/v1/platform.proto

573-573: Field name "doAllOperationsHaveIgnoreAllOverride" should be lower_snake_case, such as "do_all_operations_have_ignore_all_override".

(FIELD_LOWER_SNAKE_CASE)


574-574: Field name "doAllOperationsHaveAllTheirChangesMarkedSafe" should be lower_snake_case, such as "do_all_operations_have_all_their_changes_marked_safe".

(FIELD_LOWER_SNAKE_CASE)

⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: build-router
  • GitHub Check: build_test
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_push_image
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: build_test
  • GitHub Check: Analyze (go)
  • GitHub Check: build_push_image
🔇 Additional comments (26)
controlplane/src/db/models.ts (1)

19-19: LGTM! Clean type definition for schema change enum.

The import and type definition follow the established patterns in this file and provide proper type safety for schema change types.

Also applies to: 39-39

controlplane/src/core/bufservices/check/toggleChangeOverridesForAllOperations.ts (1)

57-57: LGTM! Clean parameter propagation for search functionality.

The search parameter is properly propagated from the request to the repository method, enabling search filtering for affected operations.

controlplane/src/core/bufservices/check/createIgnoreOverridesForAllOperations.ts (1)

54-54: LGTM! Consistent search parameter propagation.

The search parameter is properly propagated, maintaining consistency with other similar service methods.

controlplane/src/core/bufservices/check/getCheckOperations.ts (4)

44-45: LGTM! Proper initialization of new boolean flags in early returns.

The new override status flags are correctly initialized to false in all early return scenarios, ensuring consistent response structure.

Also applies to: 71-72, 88-89


97-97: LGTM! Consistent search parameter propagation.

The search parameter is properly propagated to both repository methods, enabling filtering of affected operations and their counts.

Also applies to: 114-114


117-123: LGTM! Well-structured override status calculation.

The new method call properly aggregates override status information using the check details and existing overrides, enhancing the response with useful metadata.


145-146: LGTM! Complete response structure enhancement.

The new boolean flags are properly included in the final response, completing the enhancement to provide override status information to clients.

controlplane/src/core/repositories/SchemaCheckRepository.ts (3)

14-14: LGTM! Proper import addition for search functionality.

The ilike import is correctly added to support case-insensitive pattern matching.


320-320: LGTM! Clean method signature extension.

The optional search parameter is properly added to both method signatures, maintaining backwards compatibility.

Also applies to: 325-325, 390-390


368-373: LGTM! Proper condition integration in where clauses.

The search conditions are correctly combined with existing filters using proper logical operators, maintaining query correctness.

Also applies to: 422-427

proto/wg/cosmo/platform/v1/platform.proto (3)

548-553: 👍 Search filter addition looks correct

search is appended with tag 6, preserving field-number stability and marked optional, matching the other request DTOs. No concerns here.


1568-1574: Consistent filter field addition – looks good

search = 5 is appended at the end, so wire compatibility is preserved.


1580-1585: Consistent filter field addition – looks good

Same comment as above; the tag number is appended safely.

connect/src/wg/cosmo/platform/v1/platform_pb.ts (4)

4259-4262: LGTM! Consistent addition of search field to GetCheckOperationsRequest.

The optional search field (field 6) is properly defined with correct TypeScript and protobuf schema definitions. The optional modifier ensures backward compatibility.

Also applies to: 4277-4277


4331-4339: LGTM! Well-structured addition of aggregate status fields.

The two new boolean fields provide useful aggregate information about operation override statuses:

  • doAllOperationsHaveIgnoreAllOverride (field 7)
  • doAllOperationsHaveAllTheirChangesMarkedSafe (field 8)

The field names are descriptive and the boolean type is appropriate for these status indicators.

Also applies to: 4355-4356


12077-12080: LGTM! Consistent search field addition to ToggleChangeOverridesForAllOperationsRequest.

The optional search field (field 5) follows the same pattern as other request messages, maintaining consistency across the API.

Also applies to: 12094-12094


12170-12173: LGTM! Consistent search field addition to CreateIgnoreOverridesForAllOperationsRequest.

The optional search field (field 4) completes the consistent addition of search capability across all related request messages.

Also applies to: 12186-12186

studio/src/components/checks/operations.tsx (6)

57-59: LGTM! Good library choices for the new functionality.

The new imports for debounced search, Switch component, and Label component are appropriate for the added functionality.


84-84: LGTM! Debounced search parameter implementation.

Using debouncedSearch instead of the raw search value is a good practice to avoid excessive API calls during typing.


253-258: LGTM! Simplified operations handling with server-side data.

The removal of client-side filtering and direct use of server-provided boolean flags simplifies the component logic and improves performance.


339-339: LGTM! Conditional search parameter for filtered operations.

The logic correctly passes the search parameter only when applyOnlyFiltered is enabled, allowing users to choose the scope of override operations.

Also applies to: 364-364


381-390: LGTM! Well-implemented toggle switch for filtered operations.

The new toggle switch is properly integrated into the dropdown menu with clear labeling and appropriate state management. The UI provides good control over the scope of override operations.


400-400: LGTM! Direct use of server-filtered operations.

Using operations directly instead of applying client-side filtering is correct since the server now handles the filtering based on the search parameter.

controlplane/src/core/repositories/OperationsRepository.ts (3)

5-5: LGTM! Appropriate imports for the new functionality.

The additional imports for database models, schema check details DTO, and the SchemaCheckRepository are necessary for the new method implementation.

Also applies to: 13-13, 16-16


18-30: LGTM! Well-defined type definitions.

The ChangeOverride and IgnoreAllOverride types provide better type safety for the repository methods. The structure is appropriate for the data being handled.


348-348: LGTM! Explicit return types improve type safety.

Adding explicit return types for getChangeOverrides and getIgnoreAllOverrides methods improves type safety and code documentation.

Also applies to: 360-360

@JivusAyrus JivusAyrus merged commit e6264bd into main Jul 1, 2025
45 of 46 checks passed
@JivusAyrus JivusAyrus deleted the suvij/eng-7372-fix-check-override-errors branch July 1, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants