Skip to content

feat: version search input#603

Merged
adityachoudhari26 merged 2 commits intomainfrom
version-search-input
Jun 27, 2025
Merged

feat: version search input#603
adityachoudhari26 merged 2 commits intomainfrom
version-search-input

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Jun 27, 2025

Summary by CodeRabbit

  • New Features

    • Added version filtering and search functionality for deployment versions, allowing users to filter by version name or tag with a combined filter UI and debounced search input.
    • Introduced a new filter button and badge to display current version filter conditions.
  • Improvements

    • Enhanced support for filtering deployment versions by name in both the UI and backend.
    • Expanded condition types for deployment version filters to include name-based queries.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 27, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update implements a combined version filtering and search feature for deployment versions, introducing a new UI component and associated hook in the web application. Backend logic is refactored to replace custom SQL condition builders with a selector-based approach. Schema and validation layers are extended to support filtering by deployment version name.

Changes

File(s) Change Summary
apps/webservice/src/app/.../DeploymentPageContent.tsx Added VersionFilter component, useVersionSearchQuery hook, utility functions for search condition, and updated main component to use new filter/search UI and logic.
packages/api/src/router/deployment-version.ts Replaced schema helper for deployment version filtering with a selector-based SQL fragment in the version listing query.
packages/api/src/router/environment-page/deployments/deployment-stats.ts Updated deployment version filter logic to use selector-based SQL fragment instead of schema helper.
packages/db/src/schema/deployment-version.ts Removed all SQL condition builder functions and the exported deploymentVersionMatchesCondition function.
packages/db/src/selectors/query/deployment-version-selector.ts Added support for filtering deployment versions by name in the selector's condition builder.
packages/validators/src/releases/conditions/comparison-condition.ts Added NameCondition support to the comparison condition validator and type definition.
packages/validators/src/releases/conditions/release-condition.ts Added NameCondition to deployment version condition union, updated schema, and extended enum for condition types.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DeploymentPageContent
    participant VersionFilter
    participant useVersionSearchQuery
    participant API
    participant Selector

    User->>DeploymentPageContent: Types in search/filter UI
    DeploymentPageContent->>useVersionSearchQuery: Update search string (debounced)
    useVersionSearchQuery->>DeploymentPageContent: Provide combined selector condition
    DeploymentPageContent->>API: Request deployment versions (with selector)
    API->>Selector: Build SQL using selector condition (supports name/tag search)
    Selector-->>API: SQL fragment
    API-->>DeploymentPageContent: Return filtered deployment versions
    DeploymentPageContent-->>User: Display filtered results
Loading

Suggested reviewers

  • jsbroks

Poem

In the land of code, a filter appears,
Now search by name—let's give three cheers!
With selector magic and UI delight,
Deployments are filtered, both left and right.
Old helpers retired, new logic in tow,
The rabbit hops forward—onward we go! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0d1986 and 765c2e9.

📒 Files selected for processing (1)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx (5 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.

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
Copy Markdown
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94896d9 and c0d1986.

📒 Files selected for processing (7)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx (5 hunks)
  • packages/api/src/router/deployment-version.ts (1 hunks)
  • packages/api/src/router/environment-page/deployments/deployment-stats.ts (2 hunks)
  • packages/db/src/schema/deployment-version.ts (1 hunks)
  • packages/db/src/selectors/query/deployment-version-selector.ts (1 hunks)
  • packages/validators/src/releases/conditions/comparison-condition.ts (3 hunks)
  • packages/validators/src/releases/conditions/release-condition.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
`**/*.ts`: Use TypeScript with explicit types and prefer interfaces for public A...

**/*.ts: Use TypeScript with explicit types and prefer interfaces for public APIs.
Use named imports and group imports by source: standard library first, then external, then internal.
Use consistent type imports: 'import type { Type } from "module"'.

📄 Source: CodeRabbit Inference Engine (CLAUDE.md)

List of files the instruction was applied to:

  • packages/db/src/selectors/query/deployment-version-selector.ts
  • packages/api/src/router/deployment-version.ts
  • packages/validators/src/releases/conditions/comparison-condition.ts
  • packages/api/src/router/environment-page/deployments/deployment-stats.ts
  • packages/validators/src/releases/conditions/release-condition.ts
  • packages/db/src/schema/deployment-version.ts
`**/*.{js,ts,tsx}`: Formatting must follow Prettier with '@ctrlplane/prettier-config'.

**/*.{js,ts,tsx}: Formatting must follow Prettier with '@ctrlplane/prettier-config'.

📄 Source: CodeRabbit Inference Engine (CLAUDE.md)

List of files the instruction was applied to:

  • packages/db/src/selectors/query/deployment-version-selector.ts
  • packages/api/src/router/deployment-version.ts
  • packages/validators/src/releases/conditions/comparison-condition.ts
  • packages/api/src/router/environment-page/deployments/deployment-stats.ts
  • packages/validators/src/releases/conditions/release-condition.ts
  • packages/db/src/schema/deployment-version.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx
`packages/**`: Adhere to file and directory naming conventions specific to each package.

packages/**: Adhere to file and directory naming conventions specific to each package.

📄 Source: CodeRabbit Inference Engine (CLAUDE.md)

List of files the instruction was applied to:

  • packages/db/src/selectors/query/deployment-version-selector.ts
  • packages/api/src/router/deployment-version.ts
  • packages/validators/src/releases/conditions/comparison-condition.ts
  • packages/api/src/router/environment-page/deployments/deployment-stats.ts
  • packages/validators/src/releases/conditions/release-condition.ts
  • packages/db/src/schema/deployment-version.ts
`**/*.{ts,tsx}`: **Note on Error Handling:** Avoid strict enforcement of try/cat...

**/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • packages/db/src/selectors/query/deployment-version-selector.ts
  • packages/api/src/router/deployment-version.ts
  • packages/validators/src/releases/conditions/comparison-condition.ts
  • packages/api/src/router/environment-page/deployments/deployment-stats.ts
  • packages/validators/src/releases/conditions/release-condition.ts
  • packages/db/src/schema/deployment-version.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx
`apps/**`: Adhere to file and directory naming conventions specific to each package.

apps/**: Adhere to file and directory naming conventions specific to each package.

📄 Source: CodeRabbit Inference Engine (CLAUDE.md)

List of files the instruction was applied to:

  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx
🧠 Learnings (8)
📓 Common learnings
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/webservice/src/app/api/v1/release-targets/[releaseTargetId]/releases/route.ts:103-108
Timestamp: 2025-04-28T18:41:58.813Z
Learning: In this project, full records from the `deployment` and `deployment_version` tables are considered safe for public API consumption, and there's no need to create restricted DTOs for them.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#408
File: apps/webservice/src/components/form/job-agent/JobAgentJenkinsPipelineConfig.tsx:26-31
Timestamp: 2025-04-12T22:08:13.790Z
Learning: For Jenkins job configuration, two approaches are needed: (1) a simple URL input form for airgapped environments (current focus) and (2) a dropdown selection interface for non-airgapped environments where the Jenkins server is accessible. A component similar to DeploymentJobAgentGithubConfig.tsx is preferred.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#408
File: apps/webservice/src/components/form/job-agent/JobAgentJenkinsPipelineConfig.tsx:26-31
Timestamp: 2025-04-12T22:08:13.790Z
Learning: For Jenkins job configuration, two approaches are needed: (1) a simple URL input form for airgapped environments (current focus) and (2) a dropdown selection interface for non-airgapped environments where the Jenkins server is accessible. A component similar to DeploymentJobAgentGithubConfig.tsx is preferred.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#601
File: e2e/tests/api/policies/retry-policy.spec.ts:23-24
Timestamp: 2025-06-24T23:52:50.732Z
Learning: The user adityachoudhari26 prefers not to add null safety checks or defensive programming in test code, particularly in e2e tests, as they prioritize simplicity and focus on the main functionality being tested rather than comprehensive error handling within the test itself.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#601
File: e2e/tests/api/policies/retry-policy.spec.ts:117-130
Timestamp: 2025-06-24T23:53:25.398Z
Learning: User adityachoudhari26 prefers to keep non-null assertions in e2e test code without extensive null safety checks, reasoning that test failures serve the same purpose of catching issues and the extra validation doesn't add much value in test contexts.
packages/db/src/selectors/query/deployment-version-selector.ts (5)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/event-worker/src/workers/compute-systems-release-targets.ts:86-110
Timestamp: 2025-04-28T18:38:21.163Z
Learning: In SQL queries that use `inArray()` with arrays like `deploymentIds` or `environmentIds`, if these arrays are empty, it will generate an invalid `IN ()` clause that PostgreSQL rejects. Adding condition checks (e.g., `if (array.length > 0)`) before executing such queries prevents SQL syntax errors.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: packages/api/src/router/deployment.ts:144-161
Timestamp: 2024-11-01T02:37:25.510Z
Learning: In `packages/api/src/router/deployment.ts`, when using Drizzle ORM, there is a limitation when referencing the same table twice in a relational builder query (rbq), requiring separate queries to avoid issues.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:362-365
Timestamp: 2024-11-27T23:18:42.055Z
Learning: In the file `packages/api/src/router/job.ts`, the function `releaseMatchesCondition` returns undefined if the `filter` parameter is null. This behavior ensures that when constructing the query with `and(...)`, the condition is omitted, allowing the query to function correctly even if there is no release channel associated with the environment.
packages/api/src/router/deployment-version.ts (6)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: packages/api/src/router/deployment.ts:144-161
Timestamp: 2024-11-01T02:37:25.510Z
Learning: In `packages/api/src/router/deployment.ts`, when using Drizzle ORM, there is a limitation when referencing the same table twice in a relational builder query (rbq), requiring separate queries to avoid issues.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:362-365
Timestamp: 2024-11-27T23:18:42.055Z
Learning: In the file `packages/api/src/router/job.ts`, the function `releaseMatchesCondition` returns undefined if the `filter` parameter is null. This behavior ensures that when constructing the query with `and(...)`, the condition is omitted, allowing the query to function correctly even if there is no release channel associated with the environment.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/event-worker/src/workers/compute-systems-release-targets.ts:86-110
Timestamp: 2025-04-28T18:38:21.163Z
Learning: In SQL queries that use `inArray()` with arrays like `deploymentIds` or `environmentIds`, if these arrays are empty, it will generate an invalid `IN ()` clause that PostgreSQL rejects. Adding condition checks (e.g., `if (array.length > 0)`) before executing such queries prevents SQL syntax errors.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/webservice/src/app/api/v1/release-targets/[releaseTargetId]/releases/route.ts:103-108
Timestamp: 2025-04-28T18:41:58.813Z
Learning: In this project, full records from the `deployment` and `deployment_version` tables are considered safe for public API consumption, and there's no need to create restricted DTOs for them.
packages/validators/src/releases/conditions/comparison-condition.ts (1)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#579
File: packages/rule-engine/src/rules/concurrency-rule.ts:8-11
Timestamp: 2025-06-01T19:10:47.122Z
Learning: In packages/rule-engine/src/rules/concurrency-rule.ts, the ConcurrencyRule should remain simple without additional validation since database and Zod schemas already handle concurrency validation. The user prefers this rule to be "dumb" and just perform the comparison check rather than duplicating validation logic.
packages/api/src/router/environment-page/deployments/deployment-stats.ts (10)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: packages/api/src/router/deployment.ts:144-161
Timestamp: 2024-11-01T02:37:25.510Z
Learning: In `packages/api/src/router/deployment.ts`, when using Drizzle ORM, there is a limitation when referencing the same table twice in a relational builder query (rbq), requiring separate queries to avoid issues.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#187
File: apps/jobs/src/ephemeral-env-checker/index.ts:57-0
Timestamp: 2024-10-30T23:10:58.869Z
Learning: In the codebase, deployments are decoupled from environments. When deleting environments (e.g., in `apps/jobs/src/ephemeral-env-checker/index.ts`), associated deployments should not be deleted.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/webservice/src/app/api/v1/release-targets/[releaseTargetId]/releases/route.ts:103-108
Timestamp: 2025-04-28T18:41:58.813Z
Learning: In this project, full records from the `deployment` and `deployment_version` tables are considered safe for public API consumption, and there's no need to create restricted DTOs for them.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/event-worker/src/workers/compute-systems-release-targets.ts:86-110
Timestamp: 2025-04-28T18:38:21.163Z
Learning: In SQL queries that use `inArray()` with arrays like `deploymentIds` or `environmentIds`, if these arrays are empty, it will generate an invalid `IN ()` clause that PostgreSQL rejects. Adding condition checks (e.g., `if (array.length > 0)`) before executing such queries prevents SQL syntax errors.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#395
File: packages/api/src/router/environment-page/resources/router.ts:40-45
Timestamp: 2025-03-24T18:46:38.894Z
Learning: The `takeFirst` utility function in the codebase (from `@ctrlplane/db`) throws an Error with message "Found non unique or inexistent value" if the result array doesn't contain exactly one element, making additional null/undefined checks unnecessary after its use.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#593
File: packages/rule-engine/src/manager/version-manager-rules/version-approval.ts:55-70
Timestamp: 2025-06-18T21:46:51.459Z
Learning: The `takeFirst` utility function from the database layer throws an error if no record is found, rather than returning `undefined`. This means functions using `takeFirst` already have error handling built-in and don't require additional null checks.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#579
File: packages/db/src/schema/rules/concurrency.ts:0-0
Timestamp: 2025-06-01T19:10:11.535Z
Learning: In the ctrlplane codebase, when defining database schemas with Drizzle ORM, it's an intentional pattern to spread base fields (like `basePolicyRuleFields`) and then redefine specific fields to add additional constraints (like unique constraints or foreign key references). The TypeScript field overwriting behavior is deliberately used to override base field definitions with more specific requirements.
packages/validators/src/releases/conditions/release-condition.ts (3)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: CR
PR: ctrlplanedev/ctrlplane#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-24T19:43:23.689Z
Learning: Use 'import type' syntax for importing types in TypeScript to improve clarity and enable better tree-shaking.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
packages/db/src/schema/deployment-version.ts (10)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:362-365
Timestamp: 2024-11-27T23:18:42.055Z
Learning: In the file `packages/api/src/router/job.ts`, the function `releaseMatchesCondition` returns undefined if the `filter` parameter is null. This behavior ensures that when constructing the query with `and(...)`, the condition is omitted, allowing the query to function correctly even if there is no release channel associated with the environment.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#187
File: apps/jobs/src/ephemeral-env-checker/index.ts:57-0
Timestamp: 2024-10-30T23:10:58.869Z
Learning: In the codebase, deployments are decoupled from environments. When deleting environments (e.g., in `apps/jobs/src/ephemeral-env-checker/index.ts`), associated deployments should not be deleted.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/event-worker/src/workers/compute-systems-release-targets.ts:86-110
Timestamp: 2025-04-28T18:38:21.163Z
Learning: In SQL queries that use `inArray()` with arrays like `deploymentIds` or `environmentIds`, if these arrays are empty, it will generate an invalid `IN ()` clause that PostgreSQL rejects. Adding condition checks (e.g., `if (array.length > 0)`) before executing such queries prevents SQL syntax errors.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#515
File: apps/webservice/src/app/api/v1/release-targets/[releaseTargetId]/releases/route.ts:103-108
Timestamp: 2025-04-28T18:41:58.813Z
Learning: In this project, full records from the `deployment` and `deployment_version` tables are considered safe for public API consumption, and there's no need to create restricted DTOs for them.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: packages/api/src/router/deployment.ts:144-161
Timestamp: 2024-11-01T02:37:25.510Z
Learning: In `packages/api/src/router/deployment.ts`, when using Drizzle ORM, there is a limitation when referencing the same table twice in a relational builder query (rbq), requiring separate queries to avoid issues.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#579
File: packages/db/src/schema/rules/concurrency.ts:0-0
Timestamp: 2025-06-01T19:10:11.535Z
Learning: In the ctrlplane codebase, when defining database schemas with Drizzle ORM, it's an intentional pattern to spread base fields (like `basePolicyRuleFields`) and then redefine specific fields to add additional constraints (like unique constraints or foreign key references). The TypeScript field overwriting behavior is deliberately used to override base field definitions with more specific requirements.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#601
File: packages/job-dispatch/src/job-update.ts:264-270
Timestamp: 2025-06-24T23:56:54.799Z
Learning: In this codebase, the `Tx` type is just an alias for the database client type (`Omit<typeof db, "$client">`) and does not necessarily indicate an active transaction context. Functions like `createReleaseJob` need to be called within a transaction, which is why they are wrapped with `db.transaction()` even when the parameter is typed as `Tx`. Drizzle supports nested transactions via breakpoints, so additional transaction wrappers are safe even if already within a transaction.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/auth/src/utils/rbac.ts:102-118
Timestamp: 2024-10-29T02:05:46.185Z
Learning: The `releaseChannel` scope type is included in the `scopeType` enum in `packages/db/src/schema/rbac.ts`.
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx (12)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-01T02:35:07.352Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx:43-50
Timestamp: 2024-11-27T23:16:35.580Z
Learning: In `DeploymentResourceDrawer.tsx`, the `isOpen` variable already checks whether `deploymentId`, `environmentId`, and `resourceId` are non-null, so additional null checks in query `enabled` conditions are not necessary.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#181
File: packages/api/src/router/deployment.ts:116-131
Timestamp: 2024-10-29T02:04:50.312Z
Learning: In `packages/api/src/router/deployment.ts`, the `list.byDeploymentId` procedure requires multiple database queries due to limitations of the `releaseMatchesCondition` function.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#408
File: apps/webservice/src/components/form/job-agent/JobAgentJenkinsPipelineConfig.tsx:26-31
Timestamp: 2025-04-12T22:08:13.790Z
Learning: For Jenkins job configuration, two approaches are needed: (1) a simple URL input form for airgapped environments (current focus) and (2) a dropdown selection interface for non-airgapped environments where the Jenkins server is accessible. A component similar to DeploymentJobAgentGithubConfig.tsx is preferred.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#408
File: apps/webservice/src/components/form/job-agent/JobAgentJenkinsPipelineConfig.tsx:26-31
Timestamp: 2025-04-12T22:08:13.790Z
Learning: For Jenkins job configuration, two approaches are needed: (1) a simple URL input form for airgapped environments (current focus) and (2) a dropdown selection interface for non-airgapped environments where the Jenkins server is accessible. A component similar to DeploymentJobAgentGithubConfig.tsx is preferred.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#578
File: apps/webservice/src/app/[workspaceSlug]/(app)/resources/(sidebar)/providers/integrations/github/GithubDialog.tsx:58-58
Timestamp: 2025-05-30T21:48:48.868Z
Learning: In the ctrlplane codebase, the shadcn form UI version allows initializing forms with `useForm({ schema: formSchema })` directly, without needing to import and use `zodResolver` from '@hookform/resolvers/zod'. This is different from standard react-hook-form usage.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: packages/api/src/router/deployment.ts:144-161
Timestamp: 2024-11-01T02:37:25.510Z
Learning: In `packages/api/src/router/deployment.ts`, when using Drizzle ORM, there is a limitation when referencing the same table twice in a relational builder query (rbq), requiring separate queries to avoid issues.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#363
File: apps/webservice/tsconfig.json:14-15
Timestamp: 2025-03-09T08:56:53.603Z
Learning: In the ctrlplane project, they use Next.js standalone output mode, which means they intentionally exclude `.next/types` in their tsconfig.json despite including `.next/types/**/*.ts` in their include pattern.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#237
File: packages/api/src/router/job.ts:362-365
Timestamp: 2024-11-27T23:18:42.055Z
Learning: In the file `packages/api/src/router/job.ts`, the function `releaseMatchesCondition` returns undefined if the `filter` parameter is null. This behavior ensures that when constructing the query with `and(...)`, the condition is omitted, allowing the query to function correctly even if there is no release channel associated with the environment.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#382
File: apps/webservice/src/app/api/v1/deployments/[deploymentId]/route.ts:82-88
Timestamp: 2025-03-16T19:41:44.129Z
Learning: In Next.js 15, params in dynamic routes must be awaited before accessing their properties in async contexts. For example, `params.deploymentId` should be accessed as `(await params).deploymentId` in async functions.
Learnt from: zacharyblasczyk
PR: ctrlplanedev/ctrlplane#382
File: apps/webservice/src/app/api/v1/deployments/[deploymentId]/route.ts:82-88
Timestamp: 2025-03-16T19:41:44.129Z
Learning: In Next.js 15, dynamic route parameters (params) return Promises instead of direct values in async contexts. When accessing properties like `params.deploymentId` in an async function, use `(await params).deploymentId` to avoid the "params should be awaited before using its properties" error. This applies to API routes, page components, and other async contexts.
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#187
File: apps/jobs/src/ephemeral-env-checker/index.ts:57-0
Timestamp: 2024-10-30T23:10:58.869Z
Learning: In the codebase, deployments are decoupled from environments. When deleting environments (e.g., in `apps/jobs/src/ephemeral-env-checker/index.ts`), associated deployments should not be deleted.
🧬 Code Graph Analysis (3)
packages/db/src/selectors/query/deployment-version-selector.ts (2)
packages/db/src/common.ts (1)
  • ColumnOperatorFn (54-65)
packages/db/src/schema/deployment-version.ts (1)
  • deploymentVersion (80-107)
packages/api/src/router/deployment-version.ts (1)
packages/db/src/selectors/index.ts (1)
  • selector (13-13)
packages/api/src/router/environment-page/deployments/deployment-stats.ts (1)
packages/db/src/selectors/index.ts (1)
  • selector (13-13)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Typecheck
  • GitHub Check: Lint
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
🔇 Additional comments (10)
packages/db/src/selectors/query/deployment-version-selector.ts (1)

135-136: LGTM! Consistent implementation of name-based filtering.

The new condition type follows the established pattern used for Version and Tag conditions, properly applying the ColumnOperatorFn to the deploymentVersion.name column.

packages/api/src/router/deployment-version.ts (1)

99-99: LGTM! Successful migration to selector-based SQL generation.

This change replaces the removed helper function with the new selector approach, which supports the extended condition types including the new name-based filtering.

packages/api/src/router/environment-page/deployments/deployment-stats.ts (2)

6-13: LGTM! Proper import addition for selector functionality.

The selector import is correctly added to support the new SQL generation approach.


144-144: LGTM! Consistent migration to selector-based filtering.

This change aligns with the broader refactor, replacing the helper function with the new selector approach that supports extended condition types.

packages/validators/src/releases/conditions/comparison-condition.ts (1)

6-6: LGTM! Proper integration of NameCondition into comparison conditions.

The changes consistently add NameCondition support to both the Zod schema validation and TypeScript type definitions, following the established pattern for other condition types.

Also applies to: 13-13, 30-30, 46-46

packages/validators/src/releases/conditions/release-condition.ts (1)

6-6: LGTM! Comprehensive integration of name-based filtering support.

The changes properly extend the deployment version condition system with NameCondition support across all necessary layers - type imports, value imports, union types, Zod schemas, and enums. The implementation follows the established pattern and maintains consistency with existing condition types.

Also applies to: 14-14, 26-26, 34-34, 55-55

packages/db/src/schema/deployment-version.ts (1)

1-3: LGTM!

The updated imports align with the refactoring from SQL condition helpers to selector-based query generation.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx (3)

165-188: LGTM!

Clean implementation of the version filter component with proper integration of the condition dialog.


190-219: LGTM!

Well-structured helper functions with clear separation of concerns for search query detection and creation.


271-272: LGTM!

Clean integration of the search functionality with proper state management and UI components.

Also applies to: 285-286

Comment on lines +220 to +256
const useVersionSearchQuery = () => {
const [search, setSearch] = useState("");
const { selector, setSelector } = useDeploymentVersionSelector();

const otherConditions =
selector?.type === DeploymentVersionConditionType.Comparison
? selector.conditions.filter((c) => !isSearchQuery(c))
: [];

useDebounce(
() => {
if (search === "") {
if (selector == null || !isComparisonCondition(selector)) return;
if (otherConditions.length === 0) {
setSelector(null);
return;
}
setSelector({
type: DeploymentVersionConditionType.Comparison,
operator: ComparisonOperator.And,
conditions: otherConditions,
});
return;
}

setSelector({
type: DeploymentVersionConditionType.Comparison,
operator: ComparisonOperator.And,
conditions: [...otherConditions, getSearchCondition(search)],
});
},
500,
[search],
);

return { search, setSearch };
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix potential loss of non-comparison conditions and operator preservation.

The current implementation has two issues:

  1. Non-comparison conditions are lost when adding search
  2. Original operator is not preserved when removing search

Apply this refactor to handle all condition types and preserve operators:

 const useVersionSearchQuery = () => {
   const [search, setSearch] = useState("");
   const { selector, setSelector } = useDeploymentVersionSelector();
 
   const otherConditions =
     selector?.type === DeploymentVersionConditionType.Comparison
       ? selector.conditions.filter((c) => !isSearchQuery(c))
-      : [];
+      : selector ? [selector] : [];
+  
+  const originalOperator =
+    selector?.type === DeploymentVersionConditionType.Comparison
+      ? selector.operator
+      : ComparisonOperator.And;
 
   useDebounce(
     () => {
       if (search === "") {
         if (selector == null || !isComparisonCondition(selector)) return;
         if (otherConditions.length === 0) {
           setSelector(null);
           return;
         }
+        if (otherConditions.length === 1) {
+          setSelector(otherConditions[0]);
+          return;
+        }
         setSelector({
           type: DeploymentVersionConditionType.Comparison,
-          operator: ComparisonOperator.And,
+          operator: originalOperator,
           conditions: otherConditions,
         });
         return;
       }
 
       setSelector({
         type: DeploymentVersionConditionType.Comparison,
         operator: ComparisonOperator.And,
         conditions: [...otherConditions, getSearchCondition(search)],
       });
     },
     500,
     [search],
   );
 
   return { search, setSearch };
 };
📝 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
const useVersionSearchQuery = () => {
const [search, setSearch] = useState("");
const { selector, setSelector } = useDeploymentVersionSelector();
const otherConditions =
selector?.type === DeploymentVersionConditionType.Comparison
? selector.conditions.filter((c) => !isSearchQuery(c))
: [];
useDebounce(
() => {
if (search === "") {
if (selector == null || !isComparisonCondition(selector)) return;
if (otherConditions.length === 0) {
setSelector(null);
return;
}
setSelector({
type: DeploymentVersionConditionType.Comparison,
operator: ComparisonOperator.And,
conditions: otherConditions,
});
return;
}
setSelector({
type: DeploymentVersionConditionType.Comparison,
operator: ComparisonOperator.And,
conditions: [...otherConditions, getSearchCondition(search)],
});
},
500,
[search],
);
return { search, setSearch };
};
const useVersionSearchQuery = () => {
const [search, setSearch] = useState("");
const { selector, setSelector } = useDeploymentVersionSelector();
const otherConditions =
selector?.type === DeploymentVersionConditionType.Comparison
? selector.conditions.filter((c) => !isSearchQuery(c))
: selector
? [selector]
: [];
const originalOperator =
selector?.type === DeploymentVersionConditionType.Comparison
? selector.operator
: ComparisonOperator.And;
useDebounce(
() => {
if (search === "") {
if (selector == null || !isComparisonCondition(selector)) return;
if (otherConditions.length === 0) {
setSelector(null);
return;
}
if (otherConditions.length === 1) {
setSelector(otherConditions[0]);
return;
}
setSelector({
type: DeploymentVersionConditionType.Comparison,
operator: originalOperator,
conditions: otherConditions,
});
return;
}
setSelector({
type: DeploymentVersionConditionType.Comparison,
operator: ComparisonOperator.And,
conditions: [...otherConditions, getSearchCondition(search)],
});
},
500,
[search],
);
return { search, setSearch };
};
🤖 Prompt for AI Agents
In
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx
between lines 220 and 256, the useVersionSearchQuery hook currently loses
non-comparison conditions when adding a search condition and does not preserve
the original operator when removing the search. To fix this, update the logic to
retain all existing conditions that are not search queries regardless of the
selector type, and when modifying the selector, preserve the original operator
instead of defaulting to ComparisonOperator.And. This ensures all condition
types are handled correctly and the operator remains consistent.

@adityachoudhari26 adityachoudhari26 merged commit a04ba7b into main Jun 27, 2025
9 of 10 checks passed
@adityachoudhari26 adityachoudhari26 deleted the version-search-input branch June 27, 2025 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant