Skip to content

Comments

Feature/insights filters [CONSOLE-1607]#7662

Merged
n1ru4l merged 97 commits intomainfrom
feature/insights-filters
Feb 25, 2026
Merged

Feature/insights filters [CONSOLE-1607]#7662
n1ru4l merged 97 commits intomainfrom
feature/insights-filters

Conversation

@jonathanawesome
Copy link
Member

@jonathanawesome jonathanawesome commented Feb 9, 2026

This PR implements a saved filters feature for Insights.

The feature has the following requirements as per internal and external stakeholders:

  • Permissions
    • All users should be able to save filters that are scoped for their own use
    • Users with appropriate permissions should also be able to save filters to a project, making them available across targets
  • Users must be able to manage saved filters
    • rename saved filters
    • delete saved filters
    • update saved filters in a similar way that a user would generate a new filter (all filter options available)
    • updating saved filters must be context aware (UI should notify users when modified filters will produce unintended results)
  • The existing UI does not allow for filtering client versions
    • Users should be able to filter for versions within a given client
    • This addition should work seamlessly within the current search param pattern

As a reminder, we decided early on in this discussion that we should invest in this opportunity to improve our filtering UI. This resulted in significant UI changes with the following implications:

  • Introduce new/replacement components that demonstrate alternative patterns with the goal of making feature implementation faster and more consistent
    • new components in components/base
    • introduce @base-ui/react as an alternative to headless/radix/etc
    • we restrict the component APIs from allowing className in favor of providing strict style variants
  • Replace the existing Insights operations/clients filter Sheets with a Linear-like approach to filtering
    • Include DateRange filtering as a core/default filter

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jonathanawesome, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new 'Saved Filters' feature, enabling users to persist and reuse filter configurations for insights. It includes GraphQL API endpoints for managing these filters, database schema changes, integration tests, and audit logging to ensure proper tracking and security. The feature enhances user experience by allowing quick access to frequently used filter settings.

Highlights

  • Saved Filters Feature: Introduces the ability to create, update, delete, and track views for saved filters within the application. This allows users to save specific filter configurations for later use.
  • GraphQL API: Adds new GraphQL queries and mutations for managing saved filters, including fetching single filters, listing filters with pagination and filtering options, creating new filters, updating existing ones, deleting filters, and tracking filter views.
  • Database Migration: Includes a database migration script to create the saved_filters table, which stores the filter configurations, visibility settings, and usage statistics.
  • Integration Tests: Adds integration tests to verify the functionality of the saved filters feature, including CRUD operations, visibility and permission checks, and validation of input data.
  • Audit Logging: Implements audit logging for saved filter creation, updates, and deletions to track changes and maintain a history of filter modifications.
Changelog
  • integration-tests/testkit/saved-filters.ts
    • Adds GraphQL queries and mutations for saved filters to the testkit.
  • integration-tests/testkit/seed.ts
    • Adds methods to the seed function for creating, retrieving, updating, and deleting saved filters, as well as tracking views.
  • integration-tests/tests/api/saved-filters/saved-filters.spec.ts
    • Adds integration tests for saved filters, covering CRUD operations, visibility and permissions, and validation.
  • packages/migrations/src/actions/2026.02.07T00-00-00.saved-filters.ts
    • Creates the saved_filters table in the database.
  • packages/migrations/src/run-pg-migrations.ts
    • Includes the new saved filters migration in the migration runner.
  • packages/services/api/src/create.ts
    • Adds the savedFiltersModule to the API.
  • packages/services/api/src/modules/audit-logs/providers/audit-logs-types.ts
    • Adds audit log event types for saved filter creation, updates, and deletions.
  • packages/services/api/src/modules/operations/module.graphql.mappers.ts
    • Adds clientVersionFilters to OperationsStatsMapper interface.
  • packages/services/api/src/modules/operations/module.graphql.ts
    • Adds ClientVersionFilterInput input type and clientVersionFilters field to OperationStatsFilterInput.
  • packages/services/api/src/modules/operations/providers/operations-manager.ts
    • Updates OperationsManager to include clientVersionFilters in various methods.
  • packages/services/api/src/modules/operations/providers/operations-reader.ts
    • Updates OperationsReader to include clientVersionFilters in various methods and queries.
  • packages/services/api/src/modules/operations/resolvers/OperationsStats.ts
    • Updates OperationsStats resolvers to include clientVersionFilters.
  • packages/services/api/src/modules/operations/resolvers/Target.ts
    • Updates Target resolver to include clientVersionFilters.
  • packages/services/api/src/modules/saved-filters/index.ts
    • Creates the savedFiltersModule.
  • packages/services/api/src/modules/saved-filters/module.graphql.mappers.ts
    • Adds SavedFilterMapper type.
  • packages/services/api/src/modules/saved-filters/module.graphql.ts
    • Defines the GraphQL schema for saved filters.
  • packages/services/api/src/modules/saved-filters/providers/saved-filters.provider.ts
    • Creates the SavedFiltersProvider with methods for managing saved filters.
  • packages/services/api/src/modules/saved-filters/resolvers/Mutation/createSavedFilter.ts
    • Creates the createSavedFilter mutation resolver.
  • packages/services/api/src/modules/saved-filters/resolvers/Mutation/deleteSavedFilter.ts
    • Creates the deleteSavedFilter mutation resolver.
  • packages/services/api/src/modules/saved-filters/resolvers/Mutation/trackSavedFilterView.ts
    • Creates the trackSavedFilterView mutation resolver.
  • packages/services/api/src/modules/saved-filters/resolvers/Mutation/updateSavedFilter.ts
    • Creates the updateSavedFilter mutation resolver.
  • packages/services/api/src/modules/saved-filters/resolvers/SavedFilter.ts
    • Creates the SavedFilter resolver.
  • packages/services/api/src/modules/saved-filters/resolvers/SavedFilterConnection.ts
    • Creates the SavedFilterConnection resolver.
  • packages/services/api/src/modules/saved-filters/resolvers/Target.ts
    • Creates the Target resolver for saved filters.
  • packages/services/api/src/modules/shared/providers/storage.ts
    • Adds methods for managing saved filters to the Storage interface.
  • packages/services/api/src/shared/entities.ts
    • Adds types and interfaces for saved filters.
  • packages/services/storage/src/db/types.ts
    • Adds types for saved filters to the database schema.
  • packages/services/storage/src/index.ts
    • Implements the storage methods for saved filters.
Activity
  • Added GraphQL API endpoints for saved filters
  • Implemented database migration for saved filters
  • Added integration tests for saved filters
  • Implemented audit logging for saved filters
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

📚 Storybook Deployment

The latest changes are available as preview in: https://pr-7662.hive-storybook.pages.dev

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
hive 9.5.0-alpha-20260224172743-0a8bac7d387234747e5ac235bc6f6b6a11077a31 npm ↗︎ unpkg ↗︎

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new feature for saved filters, including database migrations, storage logic, GraphQL schema, and resolvers, and extends operations filtering with client version support. A critical security concern has been identified: a lack of input validation on array sizes could lead to a Denial of Service (DoS) attack by providing excessively large arrays of operation IDs or client versions, causing resource exhaustion. Additionally, while the implementation is comprehensive with good test coverage, there are areas for improvement regarding adherence to architectural guidelines, query performance, and input validation consistency.

I am having trouble creating individual review comments. Click here to see my feedback.

packages/services/storage/src/index.ts (3973-4202)

high

Adding new data access logic for the saved_filters table directly into packages/services/storage/src/index.ts appears to deviate from the repository's architectural guidelines. According to the style guide (lines 60-66), new database logic should be encapsulated in smaller, dedicated classes within the corresponding GraphQL module to avoid bloating the legacy storage package.

To align with the preferred architecture, consider refactoring this new data access logic into a separate SavedFiltersStorage class within the packages/services/api/src/modules/saved-filters/ directory.

References
  1. The repository style guide discourages adding new logic for new database tables to the legacy /packages/services/storage module. Instead, it recommends encapsulating database interactions in smaller classes within the relevant GraphQL module. (link)
  2. New database interaction logic should be encapsulated in smaller classes within the corresponding GraphQL modules, not added to the legacy /packages/services/storage module.

packages/services/api/src/modules/saved-filters/providers/saved-filters.provider.ts (22)

security-medium medium

The versions array within clientFilters lacks a maximum size limit in the Zod validation model. An attacker could provide an extremely large array of versions, leading to resource exhaustion (DoS) when the filter is processed or used to construct database queries. It is recommended to enforce a reasonable limit (e.g., 100 elements) on this array.

packages/services/api/src/modules/operations/resolvers/Target.ts (67-71)

security-medium medium

The clientVersionFilters input is mapped and passed to the operations manager without any validation of the array sizes (both the number of filters and the number of versions per filter). This data eventually reaches the OperationsReader where it is used to build complex SQL queries with large IN clauses. This can be exploited to cause a Denial of Service on the database or the API service. Please implement size limits for these arrays.

packages/services/api/src/modules/saved-filters/providers/saved-filters.provider.ts (39)

medium

The name field is defined as nullable in the UpdateSavedFilterInputModel, but the corresponding database column saved_filters.name is NOT NULL. This inconsistency can lead to unexpected behavior where providing name: null in a mutation silently does nothing instead of raising an error. To ensure data integrity and provide clear feedback to the user, the validation should not allow null for the name.

  name: zod.string().min(1).max(100).optional(),

packages/services/storage/src/index.ts (4032-4035)

medium

The OR condition used to handle filter visibility ("visibility" = 'shared' OR ("visibility" = 'private' AND ...)), combined with pagination, can lead to suboptimal query performance, especially as the number of saved filters grows. The database might struggle to use the saved_filters_project_type_visibility_pagination index effectively with this OR logic.

A more performant approach would be to refactor this query using UNION ALL to handle the two visibility cases separately. This allows the database to use the index efficiently for both parts of the query, which should improve performance.

@jonathanawesome jonathanawesome changed the title Feature/insights filters Feature/insights filters [CONSOLE-1607] Feb 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

🐋 This PR was built and pushed to the following Docker images:

Targets: build

Platforms: linux/amd64

Image Tag: 0a8bac7d387234747e5ac235bc6f6b6a11077a31

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

💻 Website Preview

The latest changes are available as preview in: https://pr-7662.hive-landing-page.pages.dev

Copy link
Contributor

@n1ru4l n1ru4l left a comment

Choose a reason for hiding this comment

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

Nice 💯

@n1ru4l
Copy link
Contributor

n1ru4l commented Feb 25, 2026

Some additional feedback, nothing that should be part of this PR though.

I am spoiled from the linear "type to search" feature in the context menu and would love to see the same in ours. 😁

I could see that happen in several ways.

E.g. when I am in a context submenu menu with a search field, startign typing would automatically focus and populate the Search... input 🤔
image

Or more like linear "AI Filters", where on the top level context menu, we already had a search input that can find operations, clients, filters etc.
image

@n1ru4l n1ru4l merged commit cefdb60 into main Feb 25, 2026
27 checks passed
@n1ru4l n1ru4l deleted the feature/insights-filters branch February 25, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants