Skip to content

fix(calendar): make calendar time zone tests independent of today - #1005

Merged
Quick104 merged 1 commit into
mainfrom
fix/ci-failure
Nov 4, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/ci-failure

Conversation

@Quick104

@Quick104 Quick104 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Apple regression has failed on every main and PR run since 2 November, on both iOS and tvOS. Only one test fails: CalendarTimeZoneTests.testLoadAfterATimeZoneChangeRequestsTheSameWeekInTheNewZone. The test hardcodes the week of 2–8 November 2026, but CalendarViewModel checks the real clock to decide whether that week contains today. Now that today falls in that week, selectedDay gets set to the current time instead of the week's first day, so the assertion fails. The test would start passing again on 9 November and break again the next time the real date and the hardcoded week overlap.

This PR lets callers pass in the view model's clock and pins "today" in the tests.

Approach

  • CalendarViewModel now takes a now: () -> Date parameter that defaults to Date.init, and every Date() call in the view model goes through it. The app uses the default, so its behavior doesn't change.
  • The existing test sets "today" to 1 June 2026. That date is outside the week the test shows, which is the case the test was written for.
  • A new test covers the other case: today is inside the shown week, and today stays selected after a time zone change.

Only the Apple client changes. The server and Android are not affected.

Validation

  • CalendarTimeZoneTests on a tvOS 27.0 simulator with Xcode 27.0: both tests pass.
  • I did not run the iOS SiloTests copy locally because no iOS simulator was available. The iOS and tvOS targets share the test file and the view model, but iOS stays unconfirmed until CI runs it.
  • I did not run the full suite locally. In every failed CI run, this was the only failing test.

Evidence

Evidence: none, no user-visible change

Risks

None identified. The new now parameter has a default, so existing call sites don't change.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: n/a

Note

Make calendar time zone tests independent of today via injectable now clock

  • Adds an injectable now closure to the CalendarViewModel initializer, defaulting to Date.init, so initial selectedDay, week, isCurrentWeek, goToToday, and rebuildWeekIfTimeZoneChanged all read from one fixed clock value
  • Reworks the existing time zone change test to use a fixed date outside the displayed week, making the fallback to the week's start day deterministic
  • Adds a new test covering a time zone change during the current week: the week rebuilds in the new zone but the selected day stays the fixed date
  • Behavioral Change: after a time zone change, rebuildWeekIfTimeZoneChanged in CalendarViewModel.swift now selects the current date if it is in the rebuilt week, otherwise the week's start date

Macroscope summarized 52bb2e7.

- Inject a `now` clock into CalendarViewModel and use it for the initial week, selected day, Go to Today, and the time zone rebuild
- Pin the existing time zone test to a date outside the shown week
- Add a test that a time zone change during the current week keeps today selected
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 4, 2026
@silo-kody

silo-kody Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T16:44:39.318691Z 52bb2e7 PR opened
🔒 Security Review ✅ Completed 2026-11-04T16:45:43.103241Z 52bb2e7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

CalendarViewModel now uses an injectable clock for calendar date state. Timezone tests use fixed dates and check that a timezone change during the current week keeps the selected day set to today.

Changes: Calendar timezone date handling

Layer / File(s) Summary
Clock-driven calendar state and timezone coverage
iosApp/iosApp/Screens/Calendar/CalendarViewModel.swift, iosApp/Tests/CalendarTimeZoneTests.swift
The view model uses one injected clock reading when it initializes or updates calendar dates. Tests use fixed dates and verify that a timezone change during the current week updates the week timezone while keeping selectedDay set to today.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related issues

  • Issue 989 reports a date-selection failure in CalendarTimeZoneTests after a timezone change. This PR adds deterministic clock input and coverage for that case.

Possibly related PRs

  • Silo-Server/silo-apple#990: Changes the same timezone test behavior; this PR also adds an injectable clock and current-week coverage.

Suggested reviewers: timmyconnect

Merge Risk: Low · up to 52bb2

Calendar headings can be inconsistent under a fixed clock, but the app’s default clock path remains usable. This is a small follow-up rather than a merge blocker.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added bug Something isn't working priority: P2 Limited scope, workaround exists, or polish labels Nov 4, 2026
@Quick104
Quick104 merged commit ffa6e51 into main Nov 4, 2026
4 of 9 checks passed
@Quick104
Quick104 deleted the fix/ci-failure branch November 4, 2026 16:46
@macroscopeapp

macroscopeapp Bot commented Nov 4, 2026

Copy link
Copy Markdown

The Calendar week-strip selection can differ when view-model initialization crosses the start of a new week: CalendarViewModel.swift now uses one clock sample for both the selected day and displayed week, where separate samples could leave the selection outside that week. This reaches iPhone, iPhone Duo folded and open, iPad, Mac, and Apple TV. The Evidence section has no captures; please add before-and-after screenshots of the same Calendar screen and data for each device, including the Duo folded and open, and identify the device and build or commit for each capture.

No diff: add the requested captures under the PR’s Evidence section.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

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

Labels

bug Something isn't working priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant