Skip to content

chore(deps): upgrade Schedule-X to 4.9.1 with Temporal dates - #450

Merged
sydevs-bot merged 12 commits into
mainfrom
chore/schedule-x-4
Nov 20, 2026
Merged

sydevs-bot merged 12 commits into
mainfrom
chore/schedule-x-4

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This moves the calendar's grid library, Schedule-X, from 2.36.0 to 4.9.1, its current major:

  • @schedule-x/calendar, calendar-controls and theme-default go to 4.9.1, and @schedule-x/react to 4.1.0.
  • temporal-polyfill 0.3.2 is a new exact peer. @preact/signals ^2 was already a peer of 2.36.

Schedule-X 4 takes and returns Temporal objects and draws everything in a single timezone. The shadow-DOM patch is re-derived for 4.9.1. It now also binds the core to the polyfill module, so the widget never installs or reads a page-wide Temporal.

The first version of this upgrade made the calendar 2–8× slower on a production-size feed. This PR also fixes the two root causes inside Schedule-X 4 and memoizes our conversion. What remains is a modest slowdown on very large feeds, measured below. Whether that, and the +26 KiB gz lazy calendar chunk, are acceptable is a maintainer decision.

What changed and why it matters

Dates and time zones (src/views/CalendarView/timeline.ts)

  • lib/shape still produces wall-clock strings. scheduleXTimeline converts them at the Schedule-X boundary:
    • It passes the viewer's zone as timezone, so "today" is the viewer's. Schedule-X's default is UTC: a Los Angeles visitor at 23:30 saw tomorrow lit as today, and every class shifted 8 h.
    • It anchors each entry in that zone at its own wall clock, so an in-person class keeps its local time.
  • A class whose start falls in the viewer's spring-forward gap keeps its length. Before, it could end before it started. The remaining limit is a shortcut:: such a class shows an hour late.
  • The conversion is memoized. Otherwise each route change (opening Filters, for example) re-ran it over the whole feed.
  • selectedDate, the controls' setDate, onSelectedDateUpdate and onClickPlusEvents all use Temporal.PlainDate.
  • src/types/temporal.d.ts aliases the polyfill's own Temporal namespace onto the global name Schedule-X's own types use and never declare, so what it takes and hands back is typed rather than any. The alias is type-only, so Temporal.Now stays a compile error: there is no global at runtime.

The Schedule-X patch (patches/@[email protected], all three builds). The register in src/components/AGENTS.md lists every change.

  • The 2.36 shadow-DOM changes are re-derived: 15 lookups through the rendered root and 5 variable writes onto the element instead of <html>. That includes two lookups new in 4.x, the month-agenda dots and the week agenda. Upstream schedule-x#1223 is still open.
  • Temporal is bound to the temporal-polyfill module. The polyfill's documented global install would overwrite the host page's Temporal, Intl.DateTimeFormat and Date.prototype.toTemporalInstant.
  • New: an event already in the calendar's zone is read as is. Schedule-X 4 called withTimeZone on every read of start/end, and sorting and layout read each event thousands of times. That was the larger half of the slowdown.

String memo. scheduleXTimeline is the file's one function, and each entry's start and end are a ZonedDateTime subclass that keeps its own toString(). Schedule-X sorts and groups events through toString(), and the polyfill formats afresh on every call. That was most of the rest of the slowdown.

Visible to visitors (CHANGELOG entry under [Unreleased]):

  • Upstream 4.x lays out staggered overlapping classes differently in the week view. A later class reuses a freed column, drawn beneath the classes still running, so its time can be hidden.
  • The lazy calendar chunk is 26 KiB gzipped larger.
  • A very large feed draws somewhat more slowly.
  • No parameter, origin, CSP, Permissions-Policy or page-global change, so docs/embedding.md is unchanged.

Verification

Graph Before (measured / shipped) After (measured / shipped) Budget
standalone 333.5 / 334.7 KiB 333.5 / 334.7 KiB 336 KiB
embed 334.6 / 335.8 KiB 334.6 / 335.8 KiB 336 KiB
loader 2.8 / 3.3 KiB 2.8 / 3.3 KiB 3.6 KiB
  • Size, lazy calendar chunk: 184.0 KiB raw / 49.5 KiB gz → 273.7 KiB raw / 75.6 KiB gz (+26.1 KiB gz, gzip at its default level).
  • New specs, each watched failing against its defect:
    • Viewer's clock (jsdom, LA at 23:30): failed with timezone removed (got 3:00 AM) and with the zone forced to UTC (today was the 20th).
    • Gap start: failed against independent anchoring.
    • Exact anchoring: failed against "always start + length".
    • Getter shortcut (same object on re-read; another zone still re-zoned) plus its pins: failed with the hunk removed from all three builds, and with the shortcut forced on.
    • toString memo: failed with the memo removed.
    • The calendar specs also pass under TZ=America/Los_Angeles and TZ=Asia/Kolkata.
    • The earlier implementer's checks still hold: the whole patch reversed fails 5 Schedule-X specs, and each shadow hunk fails its own pin.
  • Browser, base vs this branch: built Ladle, Chromium, 13 scenarios / 38 steps (desktop and phone, light and dark, Grid failure, LA 23:30, Kolkata, Auckland, London and New York DST weeks).
    • DOM facts are identical at every step.
    • 33 of 38 screenshots are pixel-identical. The other 5 differ by 4–16 anti-aliasing pixels inside our toggle group.
    • The only console errors are the expected Grid-failure ones, the same on both sides.
    • The shadow-root transplant of the live React root matches on both sides.
    • Event clicks (month, week, list, agenda, Enter key), the native date input, the width crossing, DST week positions, the now-indicator and the "+2 events" flow all match.
  • Performance: 450 weekly classes (1,800 entries) injected into the built Calendar story; Chromium, median of 3.
Scenario 2.36 Upgrade before fixes This PR
4× CPU, 1280px: first grid 3.6 s 6.9 s 4.1 s
4× CPU, 1280px: Week 0.55 s 2.0 s 0.78 s
4× CPU, 1280px: List 2.4 s 4.9 s 2.3 s
4× CPU, 1280px: month-paging long tasks 0.14 s 0.91 s 0.28 s
4× CPU, 1280px: Filters-click long tasks 0 0.14 s 0
4× CPU, 390px: first grid 3.0 s 6.1 s 3.9 s
4× CPU, 390px: paging long tasks 0 0.95 s 0.11 s
1× CPU, 1280px: first grid 1.25 s 2.46 s 1.57 s
1× CPU, 1280px: Week 0.11 s 0.43 s 0.18 s

Not done / not verified

  • Residual slowdown. It is not fully closed: the first grid is about 1.2–1.3× and month paging adds 50 ms at 1× CPU, at 1,800 entries.
  • fetchEvents windowing was rejected. The review suggested it. In a jsdom A/B it doubled Week and List times, because Schedule-X renders the old list for the new range before the async fetch resolves.
  • Perf runs are noisy. They ran on a shared machine (load average 2–7), with each side's runs back to back rather than interleaved. The "before fixes" column comes from an earlier run of the same script, in which 2.36 measured 3.2 s for the first grid.
  • One-frame layout shift (CLS 0.0007) when Week first mounts: accepted, not fixed. 4.x paints the hour labels before it sets their spacing variable. Fixing it needs another patch hunk or duplicating Schedule-X's grid-step arithmetic.
  • The config spread is not guarded. No spec renders CalendarGrid itself, so deleting ...timeline from CalendarView's config would not fail a test. The helper is guarded.
  • Not checked in a browser:
    • pnpm review:embed (hard-wired to port 5174 and needs a backend).
    • Non-English locales (Ladle ships English only).
    • RTL. getDirection still reads the host's <html dir>, unpatched as on 2.36.
    • A class actually scheduled inside a DST gap (unit-tested only).
    • The UMD build's global branch.
    • v3's compact title-and-time layout for short time-grid events: no story event is short enough to trigger it.
  • The browser comparison and the performance table predate both the rebase onto 775dcea and the 049ff3c merge and were not re-run. The gate, the Ladle build, the Wrangler check and both size measurements were.

Follow-ups for the maintainer

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjY8jstKnZva2Ji2skM

Moves @schedule-x/calendar, calendar-controls and theme-default from
2.36.0 to 4.9.1 and @schedule-x/react to 4.1.0, and adds temporal-polyfill
0.3.2, the exact version the calendar now declares as a peer.

Since 3.0 the calendar takes Temporal objects: events, selectedDate,
the controls' setDate and the date callbacks. CalendarView keeps the
wall-clock entries lib/shape builds and anchors them in the calendar's
`timezone`, set to the viewer's zone. Left at Schedule-X's UTC default,
"today" and every wall clock moved for anyone off UTC.

The patch is re-derived against 4.9.1. Every 2.36.0 change is still
needed (schedule-x#1223 is open, no fix linked), plus two lookups 4.x
added (the month-agenda dots slot, the week-agenda wrapper). One new
change binds the core to the temporal-polyfill module: it reads a global
`Temporal`, and the polyfill's own global install overwrites the host
page's `Temporal`, `Intl.DateTimeFormat` and `Date.prototype`.

shadow-patches.test.ts pins the binding and the month agenda's lookup,
and a new spec renders under a foreign global `Temporal`. Each spec was
watched failing against pristine 4.9.1, against the binding alone, and
against the shadow changes alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
Schedule-X's declarations name a global `Temporal` namespace this
project's `lib` does not declare, so every date it takes or returns was
`any`: the 2.x call `setDate('2026-11-19')` still compiled, and would have
thrown at runtime. A types-only alias to the polyfill's own types makes
those resolve. Tried before the specs were migrated, it flagged exactly
the ones still on the old string API. It declares no value, so a bare
`Temporal.Now` stays a compile error, matching a runtime with no global.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
The root guide's Calendar row names the new pins and warns off
`temporal-polyfill/global`. The patch register row is rewritten for
4.9.1, the Temporal binding included, and a list beside it names every
change the patch makes, what is new against 2.36.0, and what still reads
`document`. The state guide's isCalendarSmall note gains the year grid,
the one 4.x rule on that class that is not the header's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
…lock

The `timezone` option and the wall-clock anchoring move into
`scheduleXTimeline` (views/CalendarView/timeline.ts), which CalendarView
spreads into its config. A jsdom spec renders a Los Angeles viewer at
23:30 and checks today and the class time; it failed with `timezone`
removed and with the zone forced to UTC, which CI's own UTC clock could
not catch before.

A wall clock inside the viewer's spring-forward gap moved the start an
hour later but anchored the end on its own, so a class could end before
it started. The end now keeps the entry's length when the start moves.

The conversion is memoized: the grid re-renders on every route change,
and with 1,800 entries it cost 110-150 ms of long tasks per Filters
click at 4x CPU throttling.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
Schedule-X 4's `start` and `end` getters call `withTimeZone` on every
read, even when the event is already in the calendar's zone. Sorting and
laying out a full feed reads each event thousands of times, so with
1,800 entries at 4x CPU throttling the week view took 2.0 s against
0.6 s on 2.36. The patch returns such an event as is, in all three
builds; CalendarView anchors every entry in that zone.

A spec reads one event twice and expects the same object, and expects an
event in another zone to come back re-zoned. It failed with the hunk
removed and with the shortcut forced on for every zone. The register
records the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
…file

The note described the state before the declaration existed. It now
says what the declaration prevents.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
Schedule-X sorts, groups and labels events through `toString()`, and the
polyfill formats afresh on every call. Each entry's start and end are now
a `ZonedDateTime` subclass that keeps its own string; any call with
options still formats. This relies on the patched getters handing the
same object back.

A spec counts the prototype's `toString` calls: it failed with two
calls once the memo was removed.

Measured on a built Ladle story with 450 weekly classes (1,800 entries),
Chromium, median of 3, against 2.36 / the branch before these fixes /
now:
- 4x CPU, 1280px: first grid 3.6 / 6.9 / 4.1 s; Week 0.55 / 2.0 /
  0.78 s; List 2.4 / 4.9 / 2.3 s; month paging long tasks 0.14 / 0.91 /
  0.28 s.
- 4x CPU, 390px: first grid 3.0 / 6.1 / 3.9 s; paging 0 / 0.95 /
  0.11 s.
- 1x CPU, 1280px: first grid 1.25 / 2.46 / 1.57 s; Week 0.11 / 0.43 /
  0.18 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
Schedule-X 4 reuses a freed column for a staggered class, so a busy
evening's week view can hide a class's time behind its neighbours. The
calendar chunk grows by about 26 KiB gzipped and draws a large feed
somewhat more slowly. No host contract changes.

The entry carries no PR reference yet: the number does not exist.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVeNzer8ue5c7JRsZk
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot

sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 00:15Z address-review · attempt 1 · session · done
  • 00:15Z address-review · attempt 1 · session
  • 23:39Z resolve-conflicts · attempt 1 · session · done
  • 23:39Z resolve-conflicts · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 7b70887 Nov 20 2026, 12:33 AM

Resolves the conflict #443 and #445 created under way.

CHANGELOG.md, [Unreleased] § Changed: both bullets kept. The calendar's
week-layout entry and #445's map-library entry describe different changes
and neither replaces the other.

src/lib/shadow-patches.test.ts: #443's new `patch` field on the Schedule-X
entry points at 4.9.1, the version this branch pins and patches, instead of
2.36.0. The register spec compares those paths with
`pnpm.patchedDependencies`, so the textual merge left it naming a patch file
that no longer exists.

pnpm-lock.yaml: regenerated from origin/main's rather than kept as the
textual merge of two dependency upgrades.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYx5SsxtLkQPCFYyTF
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged origin/main in. Three resolutions, none of them a choice between sides.

CHANGELOG.md — kept both [Unreleased] bullets. The calendar entry and #445's map-library entry describe different changes.

src/lib/shadow-patches.test.ts — #443's new patch field on the Schedule-X entry now names patches/@[email protected]. Git merged both sides cleanly and left it pointing at the 2.36.0 file, which this branch deletes. The register spec compares those paths with pnpm.patchedDependencies.

pnpm-lock.yaml — regenerated from origin/main's, rather than kept as the textual merge of two dependency upgrades. pnpm install --frozen-lockfile is clean afterwards.

.claude/skills/pr-prep/check.sh --full passes on the merge: 178 files / 2148 tests, build, and the eager payload unchanged at 333.5 / 334.6 / 2.8 KiB gz.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot sydevs-bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 19, 2026
@sydevs-bot
sydevs-bot enabled auto-merge November 19, 2026 23:48
Comment thread src/types/temporal.d.ts Resolved
Comment thread src/views/CalendarView/timeline.ts Resolved
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 20, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 20, 2026
`export import Temporal = Polyfill` inside `declare global` aliases the
whole namespace the polyfill publishes, instead of re-declaring two of its
types by hand. Every type Schedule-X names is covered now, including ones
its signatures reach but ours do not, and the next version needs no edit
here.

The alias stays type-only, so `Temporal.Now` is still a compile error —
there is no global at runtime, and binding one is what the patch avoids.
`temporal-polyfill/global` would declare it, along with `Intl.DateTimeFormat`
overloads and `Date.prototype.toTemporalInstant`, all three of which only
exist once the global install runs.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjY8jstKnZva2Ji2skM
Two of the file's four declarations only named a step. `memoized` adapted a
`ZonedDateTime` into the memoizing subclass, so that is the subclass's own
constructor now; `toScheduleXEvent` had one call site and existed to avoid a
nested block, at the cost of threading the zone through a parameter.

What is left is the class, whose `toString` memo each of its specs still
fails without, and the exported function. The polyfill never reconstructs an
instance through `this.constructor`, `new.target` or `Symbol.species`, so
narrowing the subclass constructor is safe.

`DateTime.local().zoneName` stays: it is how this repo reads the viewer's
zone (`src/lib/shape/event.ts`), and CalendarView labels this same grid with
it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjY8jstKnZva2Ji2skM
The file's own header says entries reference the pull request that landed
them, and the week-layout entry had none.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjY8jstKnZva2Ji2skM
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both review threads answered, each with a commit. Lean gate green on 7b70887: lint, typecheck, 178 files / 2148 tests.

src/types/temporal.d.ts — 327c35c. Schedule-X's own types name a global Temporal 66 times and declare none; the polyfill is already a direct dependency. The file aliases the polyfill's whole namespace now, instead of re-declaring two types.

timeline.ts — 1f6f519. Two of four declarations gone: memoized is the subclass's constructor, toScheduleXEvent had one call site. The subclass stays; its toString memo spec fails without it.

Both threads left open.

7b70887 also gives the CHANGELOG entry its PR reference, which the body listed as outstanding. The body's stale base, #443 and #445 notes are refreshed.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 20, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 20, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 20, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 20, 2026
Merged via the queue into main with commit d7f3dea Nov 20, 2026
20 checks passed
@sydevs-bot
sydevs-bot deleted the chore/schedule-x-4 branch November 20, 2026 22:29
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 20, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 20, 2026
#450 rewrote the Calendar row this branch had trimmed. The merged row keeps
main's Temporal sentence and its `temporal-polyfill/global` gotcha, and keeps
this branch's removal of the copied version numbers.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYDSPiLMRgvZD3Jsx5
Ardnived added a commit that referenced this pull request Nov 20, 2026
…hunk by hunk (#454)

#450 re-derived the patch for 4.9.1 and rewrote its walkthrough: a count of
lookups, an inventory of every one, and a list of what changed since 2.36.
Each upgrade would rewrite all three. The guide keeps what each hunk is for,
the ⚠ instanceof trap, and what is deliberately left unpatched; the pin spec
holds the built files.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants