Skip to content

Conversation

@JayashTripathy
Copy link
Member

@JayashTripathy JayashTripathy commented Dec 19, 2025

Description

This PR refactors the logic of cycle updation to only validate the date when dates are changed.

Type of Change

  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • Bug Fixes
    • Optimized cycle update performance by validating dates only when start or end dates have actually changed, reducing unnecessary validation checks. New cycle creation validation behavior remains unchanged.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 19, 2025 09:15
@makeplane
Copy link

makeplane bot commented Dec 19, 2025

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Walkthrough

Updated date validation logic in the cycle modal component to conditionally check dates during updates only when start_date or end_date values have changed compared to the original data. Creation behavior for new cycles remains unchanged, with validation always performed.

Changes

Cohort / File(s) Summary
Cycle Date Validation Optimization
apps/web/core/components/cycles/modal.tsx
Refactored date validation logic to skip validation on cycle updates when neither start_date nor end_date has changed; validation remains unconditional for new cycle creation

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Validation logic correctness: Verify the date change detection logic properly compares against original values
  • Update vs. create path: Ensure the conditional branching correctly handles both creation and update scenarios without introducing edge cases
  • Cycle state consistency: Confirm that skipping validation on unchanged dates doesn't create inconsistencies in cycle state management

Poem

A rabbit hops through code so clean, ✨
Skips validation when dates stay serene,
No change? No check! A clever sight,
Creation still validates, as it should be right,
Efficiency wins with every bound! 🐰

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: optimizing date validation logic in the CycleCreateUpdateModal component, with a specific ticket reference.
Description check ✅ Passed The description covers the main purpose and includes type of change selections, but lacks test scenarios and references as specified in the template.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/cycle-update

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 465c99f and 7aa4df0.

📒 Files selected for processing (1)
  • apps/web/core/components/cycles/modal.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,mts,cts}

📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)

**/*.{ts,tsx,mts,cts}: Use const type parameters for more precise literal inference in TypeScript 5.0+
Use the satisfies operator to validate types without widening them
Leverage inferred type predicates to reduce the need for explicit is return types in filter/check functions
Use NoInfer<T> utility to block inference for specific type arguments when they should be determined by other arguments
Utilize narrowing in switch(true) blocks for control flow analysis (TypeScript 5.3+)
Rely on narrowing from direct boolean comparisons for type guards
Trust preserved narrowing in closures when variables aren't modified after the check (TypeScript 5.4+)
Use constant indices to narrow object/array properties (TypeScript 5.5+)
Use standard ECMAScript decorators (Stage 3) instead of legacy experimentalDecorators
Use using declarations for explicit resource management with Disposable pattern instead of manual cleanup (TypeScript 5.2+)
Use with { type: "json" } for import attributes; avoid deprecated assert syntax (TypeScript 5.3/5.8+)
Use import type explicitly when importing types to ensure they are erased during compilation, respecting verbatimModuleSyntax flag
Use .ts, .mts, .cts extensions in import type statements (TypeScript 5.2+)
Use import type { Type } from "mod" with { "resolution-mode": "import" } for specific module resolution contexts (TypeScript 5.3+)
Use new iterator methods (map, filter, etc.) if targeting modern environments (TypeScript 5.6+)
Utilize new Set methods like union, intersection, etc., when available (TypeScript 5.5+)
Use Object.groupBy / Map.groupBy standard methods for grouping instead of external libraries (TypeScript 5.4+)
Use Promise.withResolvers() for creating promises with exposed resolve/reject functions (TypeScript 5.7+)
Use copying array methods (toSorted, toSpliced, with) for immutable array operations (TypeScript 5.2+)
Avoid accessing instance fields via super in classes (TypeScript 5....

Files:

  • apps/web/core/components/cycles/modal.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Enable TypeScript strict mode and ensure all files are fully typed

Files:

  • apps/web/core/components/cycles/modal.tsx
**/*.{js,jsx,ts,tsx,json,css}

📄 CodeRabbit inference engine (AGENTS.md)

Use Prettier with Tailwind plugin for code formatting, run pnpm fix:format

Files:

  • apps/web/core/components/cycles/modal.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,jsx,ts,tsx}: Use ESLint with shared config across packages, adhering to max warnings limits per package
Use camelCase for variable and function names, PascalCase for components and types
Use try-catch with proper error types and log errors appropriately

Files:

  • apps/web/core/components/cycles/modal.tsx
🧠 Learnings (1)
📓 Common learnings
Learnt from: NarayanBavisetti
Repo: makeplane/plane PR: 7969
File: apps/api/plane/api/views/cycle.py:1218-1228
Timestamp: 2025-10-17T10:46:13.825Z
Learning: In the cycle transfer functionality in apps/api/plane/api/views/cycle.py, transfers should only be allowed from completed cycles (end_date < timezone.now()), not from active or draft cycles. The guard should block when end_date is None or end_date >= timezone.now().
🧬 Code graph analysis (1)
apps/web/core/components/cycles/modal.tsx (1)
packages/utils/src/datetime.ts (1)
  • renderFormattedPayloadDate (58-68)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: CodeQL analysis (javascript-typescript)
  • GitHub Check: Agent
  • GitHub Check: Build packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
apps/web/core/components/cycles/modal.tsx (1)

138-157: LGTM! Well-implemented optimization.

The conditional date validation logic correctly handles all scenarios:

  • Updates with date changes: Validation runs when either start_date or end_date differs from the original
  • Updates without date changes: Validation skipped, reducing unnecessary API calls
  • Creation: Always validates (unchanged behavior)
  • Edge cases: Properly handles adding dates to a dateless cycle (null !== "date" triggers validation) and removing dates (outer condition at line 137 prevents validation)

Using renderFormattedPayloadDate for both original and new dates ensures consistent formatting before comparison, making the strict equality check at line 142 reliable.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the date validation logic in the cycle update flow to avoid unnecessary API calls. Previously, every cycle update would validate dates even when they hadn't changed. Now, date validation only occurs when dates are actually modified.

Key changes:

  • Added date comparison logic to detect if start_date or end_date have changed
  • Skips dateChecker API call when updating a cycle with unchanged dates
  • Maintains existing validation behavior for new cycle creation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pushya22 pushya22 merged commit f3d5e7d into preview Dec 19, 2025
17 of 18 checks passed
@pushya22 pushya22 deleted the refactor/cycle-update branch December 19, 2025 10: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.

4 participants