Skip to content

Conversation

@adityachoudhari26
Copy link
Contributor

@adityachoudhari26 adityachoudhari26 commented Jul 31, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a Rollout Drawer UI for viewing rollout status and details, accessible from environment tables and policy evaluation cells.
    • Added visual rollout charts, including a rollout curve, version distribution pie chart, and rollout progress percent card.
    • Enabled interactive buttons and links to open rollout details and navigate to related policy pages.
  • Improvements

    • Enhanced environment and version rollout information display with dynamic charts and progress indicators.
    • Updated UI elements for better clarity and user interaction, including improved button styling and contextual tooltips.
  • Bug Fixes

    • Ensured rollout information and charts update in real-time with periodic data refresh.
  • Chores

    • Added centralized color palette for consistent chart visuals.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

This change introduces a comprehensive rollout visualization and management drawer for deployments. It adds new React components for displaying rollout curves, pie charts, and percentage cards, integrates a rollout drawer UI, and updates existing tables and cells to provide rollout triggers. Supporting hooks, utility modules, and API adjustments are also included.

Changes

Cohort / File(s) Change Summary
Rollout Drawer UI & Integration
.../rule-drawers/environment-version-rollout/RolloutDrawer.tsx,
.../rule-drawers/environment-version-rollout/useRolloutDrawer.ts,
.../jobs/page.tsx
Introduces the RolloutDrawer component and a custom hook for rollout drawer state, and integrates the drawer into the main jobs page.
Rollout Chart Visualizations
.../rule-drawers/environment-version-rollout/ChartsSection.tsx,
.../rollout-charts/RolloutCurve.tsx,
.../rollout-charts/RolloutPercentCard.tsx,
.../rollout-charts/RolloutDistributionCard.tsx,
.../rollout-charts/RolloutPieChart.tsx,
.../rollout-charts/useChartData.ts,
.../rollout-charts/colors.ts,
.../rollout-charts/rollout.ts
Adds new components and utilities for rollout curve, percentage, and distribution visualizations, including color palettes and chart data hooks.
Rollout Trigger & Table Integration
.../jobs/_components/EnvironmentTableRow.tsx,
.../jobs/_components/policy-evaluations/PolicyEvaluationsCell.tsx,
.../jobs/_components/ReleaseTargetRow.tsx
Adds rollout drawer trigger buttons to environment and policy evaluation tables, updates cell props, and enhances UI for rollout interaction.
Rollout Policy Parameter Sourcing
.../systems/.../RolloutCurve.tsx
Updates the source of rollout policy parameters to use a nested environmentVersionRollout object within the policy.
Rollout Type & API Adjustments
.../systems/.../rollout.ts,
packages/api/src/router/policy/rollout.ts
Updates type alias for rollout info to be non-nullable and extends API rollout list procedure to include full policy, environment, and version objects.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Table
    participant RolloutDrawerTrigger
    participant useRolloutDrawer
    participant RolloutDrawer
    participant API
    participant ChartsSection

    User->>Table: Clicks "View rollout"
    Table->>RolloutDrawerTrigger: Renders trigger button
    RolloutDrawerTrigger->>useRolloutDrawer: setEnvironmentVersionIds(envId, versionId)
    useRolloutDrawer->>RolloutDrawer: Updates URL, opens drawer
    RolloutDrawer->>API: Fetch rollout data for envId/versionId
    API-->>RolloutDrawer: Returns rollout info
    RolloutDrawer->>ChartsSection: Passes IDs for chart rendering
    ChartsSection->>ChartsSection: Renders charts (curve, percent, pie)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • ctrlplanedev/ctrlplane#587: Refactors rollout policy structure and schema, which directly relates to this PR's extraction of rollout parameters from a nested object.
  • ctrlplanedev/ctrlplane#612: Introduces the initial RolloutCurveChart and related visualization components that this PR further extends and integrates.

Suggested reviewers

  • jsbroks

Poem

In the meadow of code where the carrots grow bright,
A rollout drawer opens—what a dazzling sight!
Charts and curves hop in, with colors so sweet,
Progress and pie slices, a bunny’s treat.
With every deploy, let the rollouts unfurl—
🥕 This rabbit’s quite proud of your rollout swirl!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rollout-drawer

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 generate unit tests to generate unit tests for 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: 1

🧹 Nitpick comments (10)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/(sidebar)/jobs/_components/rule-drawers/environment-version-rollout/rollout-charts/colors.ts (1)

1-16: LGTM! Good centralized color management.

The color palette provides good variety for chart visualizations and uses Tailwind's consistent color system. Consider verifying that the color combinations provide sufficient contrast for accessibility compliance when used together in charts.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/(sidebar)/jobs/_components/rule-drawers/environment-version-rollout/rollout-charts/rollout.ts (1)

3-3: Remove unused lodash import.

The lodash import is not used anywhere in the file and should be removed to keep the code clean.

Apply this diff to remove the unused import:

-import _ from "lodash";
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/(sidebar)/jobs/_components/rule-drawers/environment-version-rollout/rollout-charts/RolloutCurve.tsx (4)

34-54: Consider improving type safety for the props parameter.

The component correctly formats time values for the Y-axis. However, the any type for props could be improved for better type safety.

Consider typing the props more specifically:

-const PrettyYAxisTick = (props: any) => {
+const PrettyYAxisTick = (props: { payload: { value: number } } & any) => {

While not ideal, this pattern is common with recharts custom components where the full prop interface is complex.


34-54: Y-axis tick formatting is well-implemented

The custom tick component properly converts minutes to milliseconds and uses pretty-ms for human-readable formatting. The props typing could be more specific.

-const PrettyYAxisTick = (props: any) => {
+const PrettyYAxisTick = (props: { payload: { value: string } } & any) => {

77-77: Array access could be safer

Using at() with a number that could be out of bounds. Consider adding bounds checking.

-  const releaseTarget = props.rolloutInfoList.at(Number(position));
+  const positionIndex = Number(position);
+  const releaseTarget = positionIndex >= 0 && positionIndex < props.rolloutInfoList.length 
+    ? props.rolloutInfoList[positionIndex] 
+    : null;

162-165: Consider refetch interval configuration

The 10-second refetch interval is hardcoded. Consider making this configurable or using a more strategic refetch strategy based on rollout status.

  const { data: rolloutInfo } = api.policy.rollout.list.useQuery(
    { environmentId, versionId },
-    { refetchInterval: 10_000 },
+    { 
+      refetchInterval: rolloutInfo?.isActive ? 10_000 : 30_000,
+      refetchIntervalInBackground: false 
+    },
  );
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/(sidebar)/jobs/_components/rule-drawers/environment-version-rollout/useRolloutDrawer.ts (1)

9-10: Consider more robust parameter parsing.

The current parameter parsing using split(delimiter) could be more robust. If the URL parameter is malformed or contains unexpected data, it might not handle edge cases gracefully.

Consider adding validation or more defensive parsing:

-  const [environmentId, versionId, releaseTargetId] =
-    paramValue?.split(delimiter) ?? [];
+  const parts = paramValue?.split(delimiter) ?? [];
+  const [environmentId, versionId, releaseTargetId] = [
+    parts[0] || undefined,
+    parts[1] || undefined, 
+    parts[2] || undefined
+  ];
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/(sidebar)/jobs/_components/rule-drawers/environment-version-rollout/rollout-charts/RolloutPieChart.tsx (1)

17-17: Empty config object could be more explicit

The ChartContainer receives an empty config object. Consider making this more explicit or adding a comment explaining why no configuration is needed.

-    <ChartContainer config={{}}>
+    <ChartContainer config={{}} className="h-full w-full">
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/(sidebar)/jobs/_components/rule-drawers/environment-version-rollout/RolloutDrawer.tsx (2)

22-45: Consider adding error handling for URL construction.

The PolicyLink component properly constructs URLs and uses appropriate link attributes. However, consider what happens if workspaceSlug is undefined or if URL construction fails.

const PolicyLink: React.FC<{ policy: { id: string; name: string } }> = ({
  policy,
}) => {
  const { workspaceSlug } = useParams<{ workspaceSlug: string }>();
+  
+  if (!workspaceSlug) {
+    return null;
+  }
+  
  const policyUrl = urls
    .workspace(workspaceSlug)
    .policies()
    .edit(policy.id)
    .rollouts();

69-69: Consider renaming for clarity.

The variable name setIsOpen is misleading since it's actually used to close the drawer by removing environment and version IDs.

- const setIsOpen = removeEnvironmentVersionIds;
+ const closeDrawer = removeEnvironmentVersionIds;

And update the usage:

- <Drawer open={isOpen} onOpenChange={setIsOpen}>
+ <Drawer open={isOpen} onOpenChange={closeDrawer}>

deploymentId: string;
environmentId: string;
}> = ({ deploymentId, environmentId }) => {
const versionCounts = useChartData(deploymentId, environmentId);
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Consider error handling for chart data

The useChartData hook is used without error handling. If the hook can return undefined data or fail, the component should handle these cases gracefully.


🏁 Script executed:

#!/bin/bash
# Check the useChartData hook implementation for error handling
ast-grep --pattern 'export const useChartData = $_'

Length of output: 4565


Add explicit error and loading states for useChartData and handle them in RolloutPieChart

The useChartData hook currently only returns data (falling back to []), so any errors or loading state from the underlying query are swallowed. To surface failures and loading in the UI, update both the hook and the chart component:

• In useChartData.ts

export const useChartData = (deploymentId: string, environmentId: string) => {
-   const { data } =
+   const { data, error, isLoading } =
    api.dashboard.widget.data.deploymentVersionDistribution.useQuery(
      { deploymentId, environmentIds: [environmentId] },
      { refetchInterval: 10_000 },
    );
-  return data ?? [];
+  return {
+    data: data ?? [],
+    error,
+    isLoading,
+  };
};

• In RolloutPieChart.tsx

- const versionCounts = useChartData(deploymentId, environmentId);
+ const { data: versionCounts, error, isLoading } =
+   useChartData(deploymentId, environmentId);

+ if (isLoading) {
+   return <Spinner size="md" />;
+ }
+ if (error) {
+   return <ErrorMessage message={error.message} />;
+ }
// …render chart using versionCounts

This ensures the component can display a loading indicator and surface query errors instead of silently rendering an empty chart.

🤖 Prompt for AI Agents
In
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/(sidebar)/jobs/_components/rule-drawers/environment-version-rollout/rollout-charts/RolloutPieChart.tsx
at line 14, the useChartData hook only returns data without exposing loading or
error states, causing the component to silently render empty charts on failure
or while loading. Update useChartData.ts to return loading and error states
along with data, then modify RolloutPieChart.tsx to handle these states by
displaying a loading indicator when loading and an error message when an error
occurs, ensuring proper UI feedback.

@adityachoudhari26 adityachoudhari26 merged commit bd6325c into main Jul 31, 2025
6 checks passed
@adityachoudhari26 adityachoudhari26 deleted the rollout-drawer branch July 31, 2025 06:11
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