Skip to content

Conversation

@adityachoudhari26
Copy link
Contributor

@adityachoudhari26 adityachoudhari26 commented Jun 18, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a dedicated deployments table with detailed rows for each deployment, including status, version, resources, duration, success rate, deployer, and timestamp.
    • Added a user-friendly search and filter interface for deployments, allowing filtering by status and sorting by various criteria.
    • Implemented loading skeletons for a smoother experience while data is being fetched.
  • Refactor

    • Simplified the deployment page by delegating table rendering and search/filter controls to new modular components for improved maintainability and clarity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

Walkthrough

This update refactors the deployment environment page by extracting all inline table rendering and search/filter UI into dedicated components. New components—DeploymentsTable, DeploymentRow, SearchAndFilters, SkeletonRow, and supporting type definitions—are introduced, streamlining the main page's logic and improving code organization.

Changes

File(s) Change Summary
.../deployments/EnvironmentDeploymentsPageContent.tsx Refactored: Removed inline table and filter UI, now delegates to new components for table and search/filter logic.
.../deployments/_components/DeploymentRow.tsx New: Adds DeploymentRow component to render a single deployment row with navigation and status display.
.../deployments/_components/DeploymentsTable.tsx New: Adds DeploymentsTable component to render the deployments table with loading state and rows.
.../deployments/_components/SearchAndFilters.tsx New: Adds SearchAndFilters component for search input, status filter, and order-by dropdown UI.
.../deployments/_components/SkeletonRow.tsx New: Adds SkeletonRow component to show loading placeholders in the table.
.../deployments/_components/types.ts New: Adds TypeScript types for deployment stats, status filter, and version.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EnvironmentDeploymentsPageContent
    participant SearchAndFilters
    participant DeploymentsTable
    participant API

    User->>SearchAndFilters: Types search/filter/order
    SearchAndFilters->>EnvironmentDeploymentsPageContent: Updates state via props
    EnvironmentDeploymentsPageContent->>API: Fetch deployment stats (with filters)
    API-->>EnvironmentDeploymentsPageContent: Returns deployment stats
    EnvironmentDeploymentsPageContent->>DeploymentsTable: Passes deployment stats and loading state
    DeploymentsTable->>User: Renders table (with DeploymentRow or SkeletonRow)
Loading

Possibly related PRs

  • ctrlplanedev/ctrlplane#299: Introduces similar DeploymentTable and DeploymentRow abstractions for deployment listings in a different context, reflecting a parallel approach to UI componentization.

Suggested reviewers

  • jsbroks

Poem

In the warren of code, we hop and we play,
Extracting components to brighten the day.
Tables and filters now neat and apart,
Each with a purpose, a role, and a heart.
With rows that can shimmer and filters that gleam,
This refactor’s a rabbit’s spring-cleaning dream!
🐇✨

✨ 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
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: 2

🧹 Nitpick comments (2)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentRow.tsx (2)

30-38: Consider memoizing the condition and URL construction.

The environment condition and URL compression are recalculated on every render. Since these depend only on stable route parameters, consider using useMemo for optimization:

+ const environmentCondition = useMemo(() => ({
+   type: JobConditionType.Environment,
+   value: environmentId,
+   operator: ColumnOperator.Equals,
+ }), [environmentId]);

+ const conditionHash = useMemo(() => 
+   LZString.compressToEncodedURIComponent(JSON.stringify(environmentCondition)),
+   [environmentCondition]
+ );

76-82: Simplify repeated success rate calculations.

The success rate percentage is calculated multiple times. Consider extracting it to a variable for better readability and performance:

+ const successPercentage = deploymentStat.successRate * 100;
  className={`h-full rounded-full ${
-   deploymentStat.successRate * 100 > 90
+   successPercentage > 90
      ? "bg-green-500"
-     : deploymentStat.successRate * 100 > 70
+     : successPercentage > 70
        ? "bg-amber-500"
        : "bg-red-500"
  }`}
- style={{ width: `${Number(deploymentStat.successRate * 100)}%` }}
+ style={{ width: `${successPercentage}%` }}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b33fea4 and ab4ae9e.

📒 Files selected for processing (6)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/EnvironmentDeploymentsPageContent.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentRow.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentsTable.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SearchAndFilters.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SkeletonRow.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/types.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{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...

**/*.{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.

  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SkeletonRow.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentsTable.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SearchAndFilters.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentRow.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/types.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/EnvironmentDeploymentsPageContent.tsx
🧬 Code Graph Analysis (5)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SkeletonRow.tsx (2)
packages/ui/src/table.tsx (2)
  • TableRow (117-117)
  • TableCell (118-118)
packages/ui/src/skeleton.tsx (1)
  • Skeleton (15-15)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentsTable.tsx (4)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/types.ts (1)
  • DeploymentStat (6-14)
packages/ui/src/table.tsx (5)
  • Table (112-112)
  • TableHeader (113-113)
  • TableRow (117-117)
  • TableHead (116-116)
  • TableBody (114-114)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SkeletonRow.tsx (1)
  • SkeletonRow (6-14)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentRow.tsx (1)
  • DeploymentRow (20-100)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SearchAndFilters.tsx (3)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/types.ts (1)
  • StatusFilter (16-21)
packages/ui/src/input.tsx (1)
  • Input (24-24)
packages/ui/src/select.tsx (5)
  • Select (154-154)
  • SelectTrigger (157-157)
  • SelectValue (156-156)
  • SelectContent (158-158)
  • SelectItem (160-160)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentRow.tsx (5)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/types.ts (1)
  • DeploymentStat (6-14)
packages/validators/src/jobs/conditions/job-condition.ts (1)
  • JobCondition (30-39)
apps/webservice/src/app/urls.ts (1)
  • urls (262-262)
packages/ui/src/table.tsx (2)
  • TableRow (117-117)
  • TableCell (118-118)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/StatusBadge.tsx (1)
  • StatusBadge (3-58)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/EnvironmentDeploymentsPageContent.tsx (2)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SearchAndFilters.tsx (1)
  • SearchAndFilters (26-81)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentsTable.tsx (1)
  • DeploymentsTable (20-70)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Typecheck
  • GitHub Check: Lint
🔇 Additional comments (7)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/types.ts (1)

1-22: Well-structured type definitions.

The type definitions are comprehensive and provide excellent type safety for the deployment components. The DeploymentStat type captures all necessary deployment information, and the StatusFilter union type properly handles all filtering states.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SkeletonRow.tsx (1)

6-14: Clean loading state implementation.

The skeleton row component is well-implemented with consistent styling and proper key handling for the mapped cells.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentsTable.tsx (1)

44-44: Verify Tailwind class validity.

The classes w-1/8 may not be standard Tailwind CSS classes. Tailwind typically includes fractions like 1/2, 1/3, 1/4, 1/5, 1/6, and 1/12, but w-1/8 might need to be defined in your Tailwind config or replaced with a standard class.

#!/bin/bash
# Check if custom width classes are defined in Tailwind config
fd -e js -e ts -e json tailwind.config | xargs grep -l "1/8\|custom.*width" || echo "No custom width configurations found"

Also applies to: 47-47

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/SearchAndFilters.tsx (1)

15-81: Excellent component design and implementation.

The component is well-structured with proper TypeScript typing, responsive design, and clean separation of concerns. The controlled inputs and proper change handlers follow React best practices.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/EnvironmentDeploymentsPageContent.tsx (1)

6-9: Excellent refactoring that improves code organization.

The extraction of inline UI into dedicated components significantly improves maintainability and follows the single responsibility principle. The component props are properly typed and passed correctly.

Also applies to: 46-59

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentRow.tsx (2)

1-14: LGTM: Clean import organization.

The imports are well-organized with external libraries first, followed by UI components, and then local imports. All imported modules are properly used in the component.


49-99: LGTM: Well-structured table row component.

The component effectively renders deployment information with proper styling, hover effects, and click navigation. The use of formatting libraries (prettyMilliseconds, formatDistanceToNow) and the StatusBadge component maintains consistency with the application's design system.

Comment on lines +56 to +65
{isLoading &&
Array.from({ length: 3 }).map((_, index) => (
<SkeletonRow key={index} />
))}
{deploymentStats.map((deploymentStat) => (
<DeploymentRow
key={deploymentStat.deployment.id}
deploymentStat={deploymentStat}
/>
))}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix rendering logic to prevent simultaneous skeleton and data rows.

Both skeleton rows and actual deployment rows will render when isLoading is true and deploymentStats has data, creating visual confusion.

Apply this diff to fix the conditional rendering:

        <TableBody>
-          {isLoading &&
-            Array.from({ length: 3 }).map((_, index) => (
-              <SkeletonRow key={index} />
-            ))}
-          {deploymentStats.map((deploymentStat) => (
-            <DeploymentRow
-              key={deploymentStat.deployment.id}
-              deploymentStat={deploymentStat}
-            />
-          ))}
+          {isLoading ? (
+            Array.from({ length: 3 }).map((_, index) => (
+              <SkeletonRow key={index} />
+            ))
+          ) : (
+            deploymentStats.map((deploymentStat) => (
+              <DeploymentRow
+                key={deploymentStat.deployment.id}
+                deploymentStat={deploymentStat}
+              />
+            ))
+          )}
        </TableBody>
📝 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
{isLoading &&
Array.from({ length: 3 }).map((_, index) => (
<SkeletonRow key={index} />
))}
{deploymentStats.map((deploymentStat) => (
<DeploymentRow
key={deploymentStat.deployment.id}
deploymentStat={deploymentStat}
/>
))}
<TableBody>
{isLoading ? (
Array.from({ length: 3 }).map((_, index) => (
<SkeletonRow key={index} />
))
) : (
deploymentStats.map((deploymentStat) => (
<DeploymentRow
key={deploymentStat.deployment.id}
deploymentStat={deploymentStat}
/>
))
)}
</TableBody>
🤖 Prompt for AI Agents
In
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentsTable.tsx
around lines 56 to 65, the rendering logic currently shows both skeleton loading
rows and actual deployment rows simultaneously when isLoading is true and
deploymentStats has data. To fix this, update the rendering condition so that
skeleton rows are only shown when isLoading is true and deployment rows are only
rendered when isLoading is false, preventing overlap and visual confusion.

Comment on lines +90 to +92
<TableCell className="truncate py-3 text-neutral-300">
{deploymentStat.deployedBy}
</TableCell>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential null value for deployedBy.

According to the DeploymentStat type definition, deployedBy can be null, but it's rendered directly without null handling. This could display "null" in the UI:

- {deploymentStat.deployedBy}
+ {deploymentStat.deployedBy ?? "Unknown"}
📝 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
<TableCell className="truncate py-3 text-neutral-300">
{deploymentStat.deployedBy}
</TableCell>
<TableCell className="truncate py-3 text-neutral-300">
{deploymentStat.deployedBy ?? "Unknown"}
</TableCell>
🤖 Prompt for AI Agents
In
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/environments/[environmentId]/deployments/_components/DeploymentRow.tsx
around lines 90 to 92, the deploymentStat.deployedBy value can be null but is
rendered directly, which may show "null" in the UI. Update the rendering logic
to check if deployedBy is null and display an empty string or a placeholder
instead to avoid showing "null" text.

@adityachoudhari26 adityachoudhari26 merged commit 6a87315 into main Jun 20, 2025
6 checks passed
@adityachoudhari26 adityachoudhari26 deleted the cursor-environment-deployments-refactor branch June 20, 2025 03:32
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.

2 participants