Skip to content

Fix: schedule updates only touch selected days#20

Merged
ng merged 1 commit intomainfrom
fix/schedule-per-day
Mar 19, 2026
Merged

Fix: schedule updates only touch selected days#20
ng merged 1 commit intomainfrom
fix/schedule-per-day

Conversation

@ng
Copy link
Copy Markdown
Contributor

@ng ng commented Mar 19, 2026

Summary

Selecting Monday and applying a schedule was modifying all 7 days. Now only the selected days are updated.

Root cause

updateSchedules iterated DayOfWeek.allCases regardless of which days the caller actually modified. A Monday-only edit would delete and recreate entries for every day of the week.

Fix

Added days: Set<DayOfWeek>? parameter to updateSchedules. All callers now pass their specific days:

Caller Days passed
SmartCurveView (apply curve) scheduleManager.selectedDays (multi-select)
ScheduleScreen (clear) scheduleManager.selectedDays (multi-select)
ScheduleManager (single-day edits) [selectedDay]

When days is nil (default), all days are updated (backward compatible).

Test plan

  • Select Monday only, apply smart curve → verify Tuesday–Sunday untouched
  • Select Mon+Tue, apply curve → verify only those 2 days updated
  • Clear schedule for Wednesday → verify other days preserved
  • Edit single phase temperature → verify only that day changes

🤖 Generated with Claude Code

Summary by CodeRabbit

Improvements

  • Schedule updates now support day-specific modifications. Apply changes to selected days only rather than updating all days simultaneously
  • Users gain enhanced control when updating temperature, power, alarm, and bedtime schedules with flexible day selection options
  • Improved schedule management with more granular, day-based customization capabilities

updateSchedules now takes a `days` parameter specifying which days to
modify. Callers pass their specific days:
- SmartCurveView: passes scheduleManager.selectedDays
- ScheduleScreen (clear): passes scheduleManager.selectedDays
- ScheduleManager: passes [selectedDay] for single-day edits

Previously, updateSchedules iterated DayOfWeek.allCases regardless of
which days were actually modified, causing a Monday-only change to
delete and recreate entries for all 7 days.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The updateSchedules method signature is enhanced across the protocol, clients, services, and views to accept an optional days: Set<DayOfWeek>? parameter, enabling selective updates to schedules for specific days. Call sites now pass the currently selected day(s) to scope API requests accordingly.

Changes

Cohort / File(s) Summary
API Protocol & Clients
Sleepypod/Networking/SleepypodProtocol.swift, Sleepypod/Networking/FreeSleepClient.swift, Sleepypod/Networking/SleepypodCoreClient.swift
Method signature updated to include optional days: Set<DayOfWeek>? = nil parameter. SleepypodCoreClient now computes daysToUpdate as days ?? Set(DayOfWeek.allCases) and iterates only over those days when updating schedules.
Schedule Services
Sleepypod/Services/ScheduleManager.swift
All schedule-modifying methods (togglePowerSchedule, updateAlarmTime, updateBedtime, updatePhaseTemperature, applyProfile) now pass days: [selectedDay] to api.updateSchedules calls.
UI Views
Sleepypod/Views/Schedule/ScheduleScreen.swift, Sleepypod/Views/Schedule/SmartCurveView.swift
Schedule update calls now include days: scheduleManager.selectedDays parameter when invoking api.updateSchedules.
Test Mocks
SleepypodTests/MockAPIClient.swift
Mock implementation updated with optional days: Set<DayOfWeek>? = nil parameter to match protocol signature.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A day-scoped dance, so neat and tight,
No need to shuffle all in sight—
Just update this day, let others rest,
Smart scheduling at its very best! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: schedule updates now only touch selected days instead of all seven days, addressing the root cause bug.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/schedule-per-day
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@ng ng merged commit 3cb789f into main Mar 19, 2026
1 of 2 checks passed
@ng ng deleted the fix/schedule-per-day branch March 19, 2026 06:40
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant