Skip to content

Improve sheduling algorithm #3151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 22, 2025
Merged

Improve sheduling algorithm #3151

merged 5 commits into from
Jun 22, 2025

Conversation

datnguyen-en
Copy link
Collaborator

@datnguyen-en datnguyen-en commented Jun 21, 2025

Summary by CodeRabbit

  • New Features

    • Added support for locked events in the scheduler, including a dedicated UI for managing and displaying locked time blocks.
    • Introduced a toggle to allow tasks to be split into multiple sessions, available in both the task list and task creation modal.
    • Enhanced schedule display with a lock icon and tooltip for locked events.
  • Improvements

    • Refined scheduling logic to respect locked events and support both splittable and non-splittable tasks, with better handling of deadlines and durations.
    • Updated task and event forms with a reorganized, more intuitive layout.
  • Bug Fixes

    • Improved validation and error handling for event and task creation.
  • Tests

    • Added comprehensive tests for scheduling behavior, particularly around task splitting and locked events.
  • Documentation

    • Updated tooltips and labels for improved clarity in the UI.

Copy link

graphite-app bot commented Jun 21, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

coderabbitai bot commented Jun 21, 2025

Walkthrough

This update introduces support for "locked events" and task splitting in the scheduling system. It modifies scheduling algorithms, UI components, and type definitions to handle locked events, allow toggling task splitting, and improve scheduling flexibility. The changes include new UI controls, state management, and enhanced scheduling test coverage.

Changes

File(s) Change Summary
.../scheduler/components/ScheduleDisplay.tsx Added support for a locked property on events, applying distinct styling and a lock icon with tooltip for locked events.
.../scheduler/components/TaskList.tsx Introduced a toggle switch UI to control the allowSplit property for each task, with a tooltip and icon, updating state via callback.
.../scheduler/components/TaskModal.tsx Refactored prop names (onCloseonCloseAction, onAddTaskonAddTaskAction), added allowSplit field to form state, included a toggle switch for it in a redesigned two-column layout, and updated form submission logic.
.../scheduler/page.tsx Added locked event management: state, add/remove functions, modal UI for input, validation, and integration into scheduling. Updated TaskModal prop names for consistency.
packages/ai/src/scheduling/algorithm.test.ts Added comprehensive tests for the scheduleTasks function, covering non-splittable tasks, error handling when no slot is available, and splitting behavior for splittable tasks. Minor test data adjustments.
packages/ai/src/scheduling/algorithm.ts Refactored scheduleTasks to support locked events, iterative scheduling, improved handling of splittable/non-splittable tasks, min/max durations, deadlines, and event part numbering. Updated function signature to accept locked events.
packages/ai/src/scheduling/default.ts Added allowSplit: true to the default task object.
packages/ai/src/scheduling/templates.ts Added allowSplit property to tasks in template scenarios, set to false or true as appropriate.
packages/ai/src/scheduling/types.ts Extended Event interface with locked and category properties; added optional allowSplit property to Task interface.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SchedulerPage
    participant LockedEventForm
    participant ScheduleAlgorithm

    User->>SchedulerPage: Click "Add Locked Event"
    SchedulerPage->>LockedEventForm: Open modal
    User->>LockedEventForm: Submit locked event details
    LockedEventForm->>SchedulerPage: onAdd(newLockedEvent)
    SchedulerPage->>SchedulerPage: Add to lockedEvents state
    User->>SchedulerPage: Click "Schedule"
    SchedulerPage->>ScheduleAlgorithm: scheduleTasks(tasks, activeHours, lockedEvents)
    ScheduleAlgorithm->>SchedulerPage: Returns scheduled events (including locked)
    SchedulerPage->>User: Display updated schedule
Loading
sequenceDiagram
    participant User
    participant TaskList
    participant TaskModal
    participant SchedulerPage
    participant ScheduleAlgorithm

    User->>TaskList: Toggle "Allow Split" switch
    TaskList->>SchedulerPage: onUpdateTask (updates allowSplit)
    User->>TaskModal: Toggle "Allow Split" in task creation
    TaskModal->>SchedulerPage: onAddTaskAction (with allowSplit)
    User->>SchedulerPage: Click "Schedule"
    SchedulerPage->>ScheduleAlgorithm: scheduleTasks(tasks with allowSplit, ...)
    ScheduleAlgorithm->>SchedulerPage: Returns scheduled events (split as needed)
    SchedulerPage->>User: Display scheduled tasks (split or not)
Loading

Suggested labels

enhancement, calendar

Suggested reviewers

  • vhpx

Poem

🐇✨
Split or lock, the calendar grows,
With toggles and tasks in tidy rows.
Locked events now block the way,
While splittable work can save the day.
The schedule’s smarter, tests abound—
Hopping forward, progress found!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@typescript-eslint/parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ddf9e2 and e8e6fef.

📒 Files selected for processing (1)
  • apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Prettier Check (23)
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Verify generated types
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch fix/fix-CI/CD-for-algorithm-branch

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @datnguyen-en, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces significant new features to the task scheduling application, allowing users greater control over how tasks are scheduled. It enables the definition of fixed time blocks that the scheduler must respect and provides granular control over whether individual tasks can be split into multiple sessions. The underlying scheduling algorithm has been updated to incorporate these new constraints, and the user interface has been enhanced to expose and manage these capabilities.

Highlights

  • Enhanced Scheduling Algorithm: The core task scheduling algorithm has been significantly refactored to support new constraints, including respecting pre-defined 'locked events' and handling tasks that are explicitly marked as non-splittable.
  • Task Splitting Control: Introduced a new allowSplit property for tasks, enabling users to specify whether a task can be broken down into multiple sessions. This is exposed via new UI toggles in the task list and the task creation modal.
  • Locked Events Feature: Added the ability to define 'locked events' – fixed time blocks that the scheduling algorithm must avoid. Users can add and manage these events through a new dedicated section and modal in the scheduler interface.
  • Improved Task Modal UI: The task creation/editing modal has been redesigned with a more organized two-column layout, enhancing user experience for defining task properties.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

codecov bot commented Jun 21, 2025

Codecov Report

Attention: Patch coverage is 21.12903% with 489 lines in your changes missing coverage. Please review.

Project coverage is 0.87%. Comparing base (04a406a) to head (3652e7e).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...alendar/src/app/[locale]/(root)/scheduler/page.tsx 0.00% 204 Missing ⚠️
...[locale]/(root)/scheduler/components/TaskModal.tsx 0.00% 170 Missing ⚠️
packages/ai/src/scheduling/algorithm.ts 66.32% 66 Missing ⚠️
.../[locale]/(root)/scheduler/components/TaskList.tsx 0.00% 25 Missing ⚠️
[...e]/(root)/scheduler/components/ScheduleDisplay.tsx](https://app.codecov.io/gh/tutur3u/platform/pull/3151?src=pr&el=tree&filepath=apps%2Fcalendar%2Fsrc%2Fapp%2F%5Blocale%5D%2F%28root%29%2Fscheduler%2Fcomponents%2FScheduleDisplay.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tutur3u#diff-YXBwcy9jYWxlbmRhci9zcmMvYXBwL1tsb2NhbGVdLyhyb290KS9zY2hlZHVsZXIvY29tcG9uZW50cy9TY2hlZHVsZURpc3BsYXkudHN4) 0.00% 18 Missing ⚠️
packages/ai/src/scheduling/templates.ts 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3151      +/-   ##
==========================================
+ Coverage    0.80%    0.87%   +0.07%     
==========================================
  Files        2572     2572              
  Lines      328251   328578     +327     
  Branches     3074     3126      +52     
==========================================
+ Hits         2626     2877     +251     
- Misses     323430   323507      +77     
+ Partials     2195     2194       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces significant new features related to task scheduling, specifically the ability to mark events as 'locked' and control whether tasks can be 'split' into multiple sessions. The core scheduling algorithm has been refactored to accommodate these features, and the UI has been updated accordingly. While the new functionalities are valuable additions, the pull request title 'Fix/fix ci/cd for algorithm branch' is misleading, as the changes are primarily feature development and UI refactoring rather than CI/CD fixes. This discrepancy in scope should be addressed. Overall, the implementation of the new features appears to be correct, but there are areas for improvement in terms of UI consistency, maintainability (magic numbers/strings), and code clarity in the algorithm.

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

🔭 Outside diff range comments (1)
packages/ai/src/scheduling/templates.ts (1)

17-74: Consider adding allowSplit property to all template tasks for consistency.

While the semantic choices for allowSplit values are appropriate (false for "Basic Work Day", true for "Task Splitting Challenge"), several other template scenarios in this file are missing the allowSplit property entirely. This inconsistency could lead to undefined behavior.

Consider adding explicit allowSplit values to all tasks in remaining scenarios (Mixed Categories, Deadline Pressure, Overloaded Schedule, etc.) to ensure predictable behavior across all templates.

For example, add to each task object:

+ allowSplit: true, // or false based on the scenario's intent
🧹 Nitpick comments (5)
apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx (1)

229-233: Consider improving conditional styling priority for locked events.

The current logic prioritizes locked events over past deadline styling, which might hide important deadline information. A locked event that's also past deadline should probably show both visual indicators.

Consider combining the styles or showing both states:

-                                event.locked
-                                  ? 'border-dynamic-blue/30 bg-dynamic-blue/10'
-                                  : event.isPastDeadline
-                                    ? 'border-destructive/30 bg-destructive/5'
-                                    : 'hover:bg-accent/5'
+                                event.locked && event.isPastDeadline
+                                  ? 'border-destructive/50 bg-dynamic-blue/10 ring-1 ring-destructive/30'
+                                  : event.locked
+                                    ? 'border-dynamic-blue/30 bg-dynamic-blue/10'
+                                    : event.isPastDeadline
+                                      ? 'border-destructive/30 bg-destructive/5'
+                                      : 'hover:bg-accent/5'
apps/calendar/src/app/[locale]/(root)/scheduler/page.tsx (1)

428-541: Consider adding validation for end time being after start time.

The form validation checks for valid dates but doesn't explicitly validate that end time is after start time when they're on the same date.

Add this validation in the handleSubmit function:

     if (!start.isValid() || !end.isValid() || end.isBefore(start)) {
-      setError('Invalid date or time');
+      setError(end.isBefore(start) ? 'End time must be after start time' : 'Invalid date or time');
       return;
     }
apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx (1)

1-359: Consider adding unit tests for TaskModal component.

Static analysis indicates this component lacks test coverage. Given the complex form validation and state management logic, adding tests would help prevent regressions.

Would you like me to help generate comprehensive unit tests for this component covering form validation, state updates, and user interactions?

packages/ai/src/scheduling/algorithm.ts (2)

106-163: Non-splittable task scheduling logic is comprehensive.

The implementation correctly ensures non-splittable tasks are scheduled as single continuous blocks with appropriate retry logic and error handling.

Consider making the retry limit configurable:

+        const MAX_BLOCK_ATTEMPTS = 50;
         let blockAttempts = 0;
-        while (!scheduled && blockAttempts < 50) {
+        while (!scheduled && blockAttempts < MAX_BLOCK_ATTEMPTS) {

165-279: Splittable task logic handles edge cases well.

The implementation comprehensively handles task splitting with respect to duration constraints, deadlines, and slot availability. The part numbering provides clear visibility of split tasks.

Consider extracting the complex part duration calculation logic (lines 203-240) into a separate helper function to improve readability and testability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0dbe249 and 8ddf9e2.

📒 Files selected for processing (9)
  • apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx (2 hunks)
  • apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx (3 hunks)
  • apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx (8 hunks)
  • apps/calendar/src/app/[locale]/(root)/scheduler/page.tsx (7 hunks)
  • packages/ai/src/scheduling/algorithm.test.ts (4 hunks)
  • packages/ai/src/scheduling/algorithm.ts (2 hunks)
  • packages/ai/src/scheduling/default.ts (1 hunks)
  • packages/ai/src/scheduling/templates.ts (6 hunks)
  • packages/ai/src/scheduling/types.ts (2 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx

[warning] 16-16: apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx#L16
Added line #L16 was not covered by tests


[warning] 229-233: apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx#L229-L233
Added lines #L229 - L233 were not covered by tests


[warning] 240-251: apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx#L240-L251
Added lines #L240 - L251 were not covered by tests

apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx

[warning] 21-21: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx#L21
Added line #L21 was not covered by tests


[warning] 32-32: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx#L32
Added line #L32 was not covered by tests


[warning] 250-272: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx#L250-L272
Added lines #L250 - L272 were not covered by tests

apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx

[warning] 14-14: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L14
Added line #L14 was not covered by tests


[warning] 25-25: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L25
Added line #L25 was not covered by tests


[warning] 32-33: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L32-L33
Added lines #L32 - L33 were not covered by tests


[warning] 57-61: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L57-L61
Added lines #L57 - L61 were not covered by tests


[warning] 71-71: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L71
Added line #L71 was not covered by tests


[warning] 125-125: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L125
Added line #L125 was not covered by tests


[warning] 128-128: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L128
Added line #L128 was not covered by tests


[warning] 142-142: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L142
Added line #L142 was not covered by tests


[warning] 145-145: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L145
Added line #L145 was not covered by tests


[warning] 148-148: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L148
Added line #L148 was not covered by tests


[warning] 157-157: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L157
Added line #L157 was not covered by tests


[warning] 168-172: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L168-L172
Added lines #L168 - L172 were not covered by tests


[warning] 174-175: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L174-L175
Added lines #L174 - L175 were not covered by tests


[warning] 178-182: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L178-L182
Added lines #L178 - L182 were not covered by tests


[warning] 184-185: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L184-L185
Added lines #L184 - L185 were not covered by tests


[warning] 189-193: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L189-L193
Added lines #L189 - L193 were not covered by tests


[warning] 195-195: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L195
Added line #L195 was not covered by tests


[warning] 197-197: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L197
Added line #L197 was not covered by tests


[warning] 201-208: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L201-L208
Added lines #L201 - L208 were not covered by tests


[warning] 210-244: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L210-L244
Added lines #L210 - L244 were not covered by tests


[warning] 246-247: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L246-L247
Added lines #L246 - L247 were not covered by tests


[warning] 252-253: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L252-L253
Added lines #L252 - L253 were not covered by tests


[warning] 255-256: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L255-L256
Added lines #L255 - L256 were not covered by tests


[warning] 258-337: apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L258-L337
Added lines #L258 - L337 were not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Verify generated types
🔇 Additional comments (19)
packages/ai/src/scheduling/default.ts (1)

34-34: LGTM! Consistent addition of allowSplit property.

The addition of allowSplit: true to the default task aligns with the new Task interface and enables task splitting functionality by default, which is a reasonable choice.

packages/ai/src/scheduling/types.ts (2)

16-17: LGTM! Well-designed type extensions for new features.

The addition of optional locked and category properties to the Event interface provides the necessary type support for locked events while maintaining backward compatibility.


29-29: LGTM! Consistent type addition for task splitting.

The optional allowSplit property on the Task interface properly supports the task splitting feature while maintaining backward compatibility.

apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx (2)

21-21: LGTM! Proper imports added for new functionality.

The imports for SplitIcon and Switch components are correctly added to support the new task splitting toggle feature.

Also applies to: 32-32


250-272: ```shell
#!/bin/bash

Locate TaskList component file

COMP_PATH=$(fd TaskList.tsx | head -n1)
echo "Component Path: $COMP_PATH"
DIR=$(dirname "$COMP_PATH")
echo "Component Directory: $DIR"

List files in component directory

echo "Files in component directory:"
ls "$DIR"

Search for any test files in the same directory

echo "Looking for tests in $DIR:"
fd -e test.tsx -e test.ts -e spec.tsx -e spec.ts "$DIR"

Search globally for test files referencing TaskList

echo "Global search for TaskList in test files:"
rg -l "TaskList" -g ".test.tsx" -g ".test.ts" -g ".spec.tsx" -g ".spec.ts"


</details>
<details>
<summary>apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx (2)</summary>

`16-16`: **LGTM! Proper import added for locked event visualization.**

The `LockIcon` import is correctly added to support the new locked events display functionality.

---

`240-251`: **Well-implemented locked event indicator with clear UX.**

The lock icon and tooltip provide clear visual feedback for locked events. The positioning before the deadline warning maintains good information hierarchy.



Static analysis indicates this new functionality lacks test coverage. Consider adding tests for locked event display behavior.

</details>
<details>
<summary>packages/ai/src/scheduling/algorithm.test.ts (3)</summary>

`1-1`: **LGTM! Import statement correctly added.**

The import of `scheduleTasks` function is appropriate for the new test cases.

---

`180-197`: **Well-structured test for non-splittable task scheduling.**

The test correctly validates that a non-splittable task is scheduled as a single continuous block when possible, with appropriate assertions for event count, name, and absence of part numbering.

---

`217-233`: **Good test coverage for task splitting functionality.**

The test appropriately validates that splittable tasks are divided into multiple parts when needed, with correct part numbering in event names.

</details>
<details>
<summary>apps/calendar/src/app/[locale]/(root)/scheduler/page.tsx (4)</summary>

`21-60`: **Imports and state management correctly implemented.**

The new imports and state variables for locked events functionality are properly structured and follow React best practices.

---

`104-118`: **Locked event management functions are well-implemented.**

The functions correctly handle adding and removing locked events with proper type safety and immutable state updates.

---

`120-132`: **Scheduling function correctly updated to include locked events.**

The `handleSchedule` function properly passes locked events to the scheduling algorithm.

---

`212-277`: **Locked events UI section is well-designed and functional.**

The UI provides clear visual distinction for locked events with appropriate icons, displays essential information, and includes intuitive controls for adding and removing events.

</details>
<details>
<summary>apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx (2)</summary>

`30-34`: **Props renamed consistently for better clarity.**

The renaming from `onClose`/`onAddTask` to `onCloseAction`/`onAddTaskAction` better indicates these are action handlers and is applied consistently throughout the component.



Also applies to: 57-61

---

`71-71`: **Task splitting toggle correctly implemented.**

The `allowSplit` field is properly integrated with appropriate default value, form state management, and intuitive UI controls.



Also applies to: 125-125, 142-142, 327-342

</details>
<details>
<summary>packages/ai/src/scheduling/algorithm.ts (3)</summary>

`47-68`: **Function signature and initialization properly updated.**

The addition of `lockedEvents` parameter and the task pool initialization with normalized durations and tracking fields are well-implemented.

---

`87-92`: **Iterative scheduling approach with proper safeguards.**

The implementation includes appropriate safeguards against infinite loops with a maximum attempt limit and early exit when no progress is made.



Also applies to: 282-284

---

`286-300`: **Comprehensive logging for scheduling outcomes.**

The final logging section provides valuable insights into task splitting and any unscheduled portions, helping users understand the scheduling results.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@vhpx vhpx changed the title Fix/fix ci/cd for algorithm branch Improve sheduling algorithm (new) Jun 21, 2025
@vhpx vhpx marked this pull request as draft June 21, 2025 21:27
@vhpx vhpx changed the title Improve sheduling algorithm (new) Improve sheduling algorithm Jun 22, 2025
@vhpx vhpx marked this pull request as ready for review June 22, 2025 10:07
Copy link
Member

@vhpx vhpx left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @datnguyen-en.

@vhpx vhpx enabled auto-merge June 22, 2025 10:10
@vhpx vhpx merged commit dbe064a into main Jun 22, 2025
19 checks passed
@vhpx vhpx deleted the fix/fix-CI/CD-for-algorithm-branch branch June 22, 2025 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants