Skip to content

feat(app-deployments): add server-side sorting by created, activated, and last used#7700

Open
adambenhassen wants to merge 13 commits intomainfrom
adam/sorted-paginated-app-deployments
Open

feat(app-deployments): add server-side sorting by created, activated, and last used#7700
adambenhassen wants to merge 13 commits intomainfrom
adam/sorted-paginated-app-deployments

Conversation

@adambenhassen
Copy link
Collaborator

Background

The app deployments table has no sorting capability, deployments were always listed by creation date descending. Users need to sort by different columns (created, activated, last used) to find relevant deployments quickly, especially in targets with many deployments.

Description

Adds server-side sorting to the app deployments table.

@adambenhassen adambenhassen marked this pull request as draft February 16, 2026 21:32
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @adambenhassen, 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 crucial feature for managing app deployments: server-side sorting. Previously, deployments were only sortable by creation date. Now, users can efficiently sort deployments by their creation time, activation time, or last usage, which significantly improves the ability to locate and manage relevant deployments, especially in environments with numerous entries. The changes span across the GraphQL API, backend data retrieval logic, and the frontend user interface to provide a seamless sorting experience.

Highlights

  • Server-Side Sorting for App Deployments: Implemented server-side sorting capabilities for app deployments by 'created at', 'activated at', and 'last used' fields, enhancing user experience for navigating large lists of deployments.
  • GraphQL API Extension: Extended the GraphQL API with new AppDeploymentsSortField enum and AppDeploymentsSortInput type, allowing clients to specify sorting criteria for app deployment queries.
  • Advanced Pagination and Sorting Logic: Developed sophisticated pagination and sorting logic within the backend, including a dedicated method for 'last used' sorting that integrates data from both PostgreSQL and ClickHouse, and introduced new cursor encoding/decoding for sort-aware pagination.
  • User Interface Integration: Integrated interactive sorting controls into the app deployments table on the frontend, enabling users to sort by various columns and persisting sorting preferences via URL search parameters.
Changelog
  • packages/services/api/src/modules/app-deployments/module.graphql.ts
    • Added AppDeploymentsSortField enum to define sortable fields.
    • Introduced AppDeploymentsSortInput input type for sort configuration.
    • Updated appDeployments query to accept a sort argument.
  • packages/services/api/src/modules/app-deployments/providers/app-deployments-manager.ts
    • Modified getPaginatedAppDeploymentsForTarget to accept and process sorting arguments.
    • Implemented conditional logic to delegate 'LAST_USED' sorting to a new dedicated method.
  • packages/services/api/src/modules/app-deployments/providers/app-deployments.ts
    • Imported new cursor encoding/decoding utilities.
    • Updated getPaginatedAppDeployments to apply sorting logic for 'CREATED_AT' and 'ACTIVATED_AT' fields, including cursor validation and SQL query adjustments.
    • Added getPaginatedAppDeploymentsSortedByLastUsed method to handle complex sorting by 'LAST_USED' using data from ClickHouse and PostgreSQL.
  • packages/services/api/src/modules/app-deployments/resolvers/Target.ts
    • Updated the appDeployments resolver to parse and pass the sort argument to the AppDeploymentsManager.
  • packages/services/storage/src/index.ts
    • Added encodeAppDeploymentSortCursor to create sort-aware pagination cursors.
    • Added decodeAppDeploymentSortCursor to parse sort-aware pagination cursors.
  • packages/web/app/src/components/v2/sortable.tsx
    • Simplified tooltip text for sorting actions.
    • Updated sort icon color to text-neutral-10.
  • packages/web/app/src/pages/target-apps.tsx
    • Imported z and Sortable components.
    • Defined TargetAppsSortSchema and SortState for client-side sorting state management.
    • Updated GraphQL queries (TargetAppsViewQuery, TargetAppsViewFetchMoreQuery) to include a $sort variable.
    • Implemented handleSortClick and getSortOrder functions for managing sorting state and UI.
    • Integrated Sortable components into table headers for 'Created', 'Activated', and 'Last used' columns.
    • Passed the sorting prop to the TargetAppsView component.
  • packages/web/app/src/router.tsx
    • Imported TargetAppsSortSchema and SortState.
    • Defined TargetAppsRouteSearch for validating URL search parameters related to sorting.
    • Updated targetAppsRoute to read and provide default sorting state from URL search parameters.
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 16, 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.4.2-alpha-20260220112236-c355931146b2bbacacc95cc1e67695ffb69a89ab 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 server-side sorting for the app deployments table, allowing users to sort by creation date, activation date, and last used date. The backend changes are significant, especially the logic for sorting by 'last used' which involves querying both PostgreSQL and ClickHouse. I've identified a potential issue with how different sort fields are handled and suggested improvements for maintainability and type safety in the complex sorting logic. The frontend changes to support this new functionality look good.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

💻 Website Preview

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

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

Targets: build

Platforms: linux/amd64

Image Tag: c355931146b2bbacacc95cc1e67695ffb69a89ab

"""
appDeployments(first: Int, after: String): AppDeploymentConnection
appDeployments(
first: Int
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
first: Int
first: Int! = 20

Minor: I like to set the default in the SDL so that it's clearly visible to API consumer and so that although the argument doesnt need passed, youll always get a value in the resolver.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree but, there's already a code check for this that clamps and sets it to 20 when null. If there's any needed change, it has to also change all fields that utilize the (nullable, no default) first parameter pattern and not just appDeployments. For consistency, this should be a codebase-wide decision, not a one-off on this field.

This is based on the project patterns document: https://www.notion.so/theguildoss/Hive-Console-GraphQL-API-Design-Patterns-18ab6b71848a80678939c669699fe8e6#18ab6b71848a80d5a1b1d16abd881d32

const { sort, cursor, first } = args;

const pagePromise =
sort?.field === 'LAST_USED'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have an exported enum from codegen we could use?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope. codegen produces string union types, not typescript enums, so there's no enum member to reference

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.

2 participants