Repository navigation
fix(calendar): the view switch lights an option a phone cannot render - #337
Conversation
Schedule-X rewrites the rendered view by itself below its breakpoint, and emits no callback when it does. `month-grid` and `week` both declare `hasSmallScreenCompat: false`, so `setScreenSizeCompatibleView` moved off them at mount and at each crossing, to the first registered compat view — `list`. The switch never learned, so a phone lit Month over a day list, and clicking Month could not change it: the switch's value was already `month-grid`, so Radix read the click as a deselect. `isResponsive: false` retires that rewrite outright — the resize listener is registered only while the flag is on, and it is the only path into it. A pure resolver in `lib/shape/calendar.ts` is then the one authority: it maps the stored view and a width class to the view to render and the option to light. Below the crossing Month and Week both collapse onto a newly registered `month-agenda`, which keeps a chosen day's own hours in view, and Week is not offered. The store keeps what the viewer picked, so widening restores it. `DrawerStack` sizes the calendar drawer from what renders rather than the stored name, so the month agenda takes the regular width like the list view — and the settings cog, which the same test hides, returns to a phone in month view. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013Sce9tzi3TGe1F7ZNiqtF5
Three findings from the /simplify pass. `ResolvedCalendarView` widened both fields to `string`, so nothing separated "a Schedule-X view name" from "a switch option" — and `CalendarControls` destructured `option` while renaming it `view`, which is the exact mix-up. Both fields now carry literal unions, and `month-agenda` is deliberately absent from the option type: it renders FOR Month and is never lit. `calendarViewIsFullWidth(view)` had one call site and was only ever fed the resolver's own output, which made `DrawerStack` know that a narrow width collapses onto `month-agenda`. It becomes `calendarFillsWidget(stored, isWide)`, resolving internally. The effect driving `controls.setView` on a width crossing was dead code: `DrawerStack` remounts the whole drawer when `isWide` flips, because vaul's `direction` is not hot-swappable, and that remounts the grid with it — so `defaultView` already answers a resize. Measured in a browser at 1280→390 →1280 with Week picked, with the effect removed: the month agenda renders below the crossing and Week is restored above it. That leaves `defaultView` as the single seam, and its comment records what the dependency rests on. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013Sce9tzi3TGe1F7ZNiqtF5
CHANGELOG gets the host-facing entry: what a visitor sees below 768px now, which options the switch offers at which width, and that nothing above it changes. The guide's Calendar row and the state rule name the resolver and why `isResponsive` is off; the responsive decision table gains the row, which is the one entry where the signal decides what a third-party library can draw rather than how much room to give it. docs/embedding.md is unchanged on purpose — no parameter, origin, CSP, sizing or URL-shape change. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013Sce9tzi3TGe1F7ZNiqtF5
Deploying sahajatlas with
|
| Latest commit: |
5c0e2d7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8b242d22.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-fix-331-calendar-view.sahajatlas.pages.dev |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
sahajatlas-design | 5c0e2d7 | Oct 27 2026, 01:09 AM |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The root cause is right and the fix is the small one. I re-derived both claims it rests on in the pinned 2.36.0 build and both hold. One resolver beating five copies of "which view is this?" is right, and nothing host-facing moves.
What is oversized is the prose: 62 of the ~120 added lines are comments, and the isResponsive story now has five homes. One is stale — src/config/store.ts:163 still says "A list view needs the regular width", the rule this PR replaced. Below the crossing no view earns the full width, and that fix belongs here.
Findings
should-fix—calendarFillsWidgetis exactlyisWide && stored !== 'list', and its name says the opposite of what it returns on a phone —src/lib/shape/calendar.ts:279.should-fix— theisResponsiverationale has five homes, andstore.ts:163is the stale one —CalendarView.tsx:337.consider— the resolver's output is typed and its input is not, so the store can still hold'month-agenda'—src/lib/shape/calendar.ts:258.
What was checked
core.js:setScreenSizeCompatibleView(2442) has one caller,handleWindowResize(2461), whose mount call andresizelistener both sit insideif ($app.config.isResponsive)(2542).- Step 5 was rebutted correctly: an agenda day's
handleClickcallssetActiveDateunconditionally (5921), reachingdateSelectionCallback(5434) via theeffectat 3000. <Drawer key={direction}>(DrawerStack:723,833) withdirectionfromisWidealone (:277) — a crossing does remount the grid, sodefaultViewsuffices.- The agenda's unbounded event list scrolls, not clips:
.sx__view-containerisoverflow-y: auto. - Read whole:
calendar.ts,CalendarView.tsx,DrawerStack.tsx,responsive.ts,store.ts, theDrawervariants. Ran the equivalence over all 16 pairs. No preview to open.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`calendarFillsWidget(stored, isWide)` returned exactly `isWide && stored !== 'list'` — proven over every stored name and both widths, including `month-agenda`, `''` and junk. Above the crossing the resolver returns the stored view, and the two it can return there are both full-width; below it, nothing is. So the helper, its JSDoc and its three cases stood in for one `&&` on the line `DrawerStack` already had. The name said the opposite of what it returned, too: below the crossing the bottom sheet does fill the widget. `wide` is a no-op on `direction: 'bottom'` (the Drawer atom's compound variant needs `left`), so its one effect there is whether the settings cog renders. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0111UmECXW42ciGRazy4JhDM
The rationale for turning Schedule-X's own responsiveness off had five homes, and the diff that added it carried 62 comment lines against ~60 of changed code. `docs/rules/i18n-and-state.md` is the maintained one, so the mechanism moves there — the resize listener the flag registers, the compat-view rewrite it is the only path into, and what dropping `isCalendarSmall` costs. The call site keeps the constraint and a breadcrumb. `src/config/store.ts` still stated the rule this branch replaced: "A list view needs the regular width." The wide panel exists only above the crossing now, so below it no view takes it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0111UmECXW42ciGRazy4JhDM
The resolver's output was typed and its input was not, so `setView(view: string)` still accepted `'month-agenda'` — the one name the switch has no item for — and the resolver turned it into Month silently. `useCalendarPosition` now holds `CalendarViewOption | null`, and the toggle group's bare `string` is narrowed by `isCalendarViewOption` at the single place that writes it. That guard also subsumes the empty-value check Radix needs for a deselect, so the one runtime boundary is stated once. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0111UmECXW42ciGRazy4JhDM
|
Adopted all three adversarial findings, one commit each. No behaviour changed. Lean gate green: 1790 tests in 151 files.
Branch was already current with 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
isResponsiveis off, which retires the silent rewrite that caused it rather than racing it.useCalendarPositionis typed to the three options the switch offers, so the one name it must never hold cannot reach it.Change outline
Four seams each held their own copy of "which view is this?". They now read one resolver, with the decision nested under it.
Types
The two names were both
string, and the header destructuredoptionwhile renaming itview— the exact mix-up.type ResolvedCalendarView = { - view: string - option: string + view: CalendarViewName # the four registered SX views + option: CalendarViewOption # the three the switch offers — month-agenda is absent } type CalendarPositionState = { - view: string | null - setView: (view: string) => void + view: CalendarViewOption | null + setView: (view: CalendarViewOption) => void }month-agendarenders for Month and is never lit, so the type refuses a switch value with no matching item — at the store, which is where an untyped'month-agenda'used to get in and be resolved to Month silently. Radix'sonValueChangehands over a barestring, soisCalendarViewOptionis the one runtime boundary.Preview
Preview pending — no alias exists yet on this branch.
⚠ No later run is promised to fill this in, so this line stays as a disclosure. The Workers preview address is produced by this repo's own CI publish step (
wrangler versions upload --preview-alias pr-337), so it has to be read off that step's output rather than derived — the<branch-slug>.sahajatlas.pages.devform earlier PRs carry is the host #283 withdrew, and guessing a slug is how a reviewer opens the wrong branch.To see it without waiting, from this branch:
§ Manual verification below carries the measured result at both widths, so the claim is checkable without either.
Test results
.claude/skills/pr-prep/check.sh— lint, typecheck, 1790 unit tests in 151 filessrc/lib/shape/calendar.test.ts— 6 over the stored-view × width mapping in both directions, 3 over the switch-value guard--fullalso ran the production build,assert:css,assert:mapsand the eager-payload size budget — all within budget (the calendar is a lazy chunk, so the fourth view never reaches it)Watched the new cases fail first. With the resolver returning the stored view regardless of width — today's behaviour — 4 of the mapping cases go red, naming
month-gridagainstmonth-agenda. With the guard relaxed to any non-empty string — the behaviour it replaced — both refusal cases go red.Manual verification
Driven in headless Chromium against the dev server on real SahajCloud data. Reading
.sx__view-container's first child class against the litrole="radio"button:month-agenda-wrapper, Month litmonth-agenda-wrapperlist-wrappermonth-grid-wrapper, Month litmonth-grid-wrapperweek-wrapperlist-wrapperNo two offered options share a body at either size. Also confirmed: Week picked at 1280 → resize to 390 renders the month agenda with Month lit and two options → resize back restores Week over
week-wrapper; a filter apply on a phone in Month keeps the lit button matching the body; the settings cog renders on a phone in month view; at 1280 each view still labels and pages by its own unit (month+year → next month, a date → next week, a date → next day).⚠ That table was measured before the adversarial-review round below, which changed no behaviour: the drawer-width expression is proven equivalent to the helper it replaced over every stored name and both widths, and the switch-value guard refuses only values Radix cannot emit.
Worth a human pass on how the month agenda reads on a real phone — that is a judgement a class list cannot make.
Notes for reviewer
onClickAgendaDate→setDate, on the grounds thatonSelectedDateUpdatefires only from the date picker's own change callback. It also fires for an agenda pick: the agenda'ssetActiveDatewritesdatePickerState.selectedDate.value, andcreateDatePickerStateruns aneffectover that signal which callslisteners.onChange— the samedateSelectionCallback. Measured in the browser: clicking the next agenda day moves the header's date from 2026-10-27 to 2026-10-28 with nothing wired. The callback would have been dead code.DrawerStackremounts the whole drawer whenisWideflips, because vaul'sdirectionis not hot-swappable, and that remounts the grid — sodefaultViewalready answers a resize. Verified by deleting the effect and re-running the 1280→390→1280 pass.defaultViewis now the single seam and its comment records what that rests on.calendarFillsWidgethelper was added, then removed in review as a tautology. It returned exactlyisWide && stored !== 'list'over every input, and its name said the opposite of what it returned below the crossing, where the bottom sheet does fill the widget.wideis a no-op ondirection: 'bottom', so its one effect there is the settings cog.isResponsiverationale now has one home,docs/rules/i18n-and-state.md. The mechanism moved there — the resize listener the flag registers, the compat-view rewrite it is the only path into, and what droppingisCalendarSmallcosts — and the call site keeps the constraint plus a breadcrumb.src/config/store.tshad also kept stating the rule this branch replaced ("A list view needs the regular width").src/config/translations.test.tsfinds keys by matching literalt('…'), so at(LABELS[option])indirection would makecalendar.view_weeklook dead in both directions; auseResolvedCalendarView()hook — it could serve only the two reactive readers, not the threegetState()ones.StackEntrydeclare its own drawer width, soDrawerStackwould ask "does the top view want full width?" and know nothing about calendar view names. It still knows one — it compares the stored view againstCALENDAR_VIEW_LIST. The coupling is pre-existing and this branch neither grows nor shrinks it. I left it alone as a change to the drawer-layout contract well outside this fix — but if you want it, it is a clean follow-up.securityReview.triggerPatternnor its content pattern matches this diff.docs/embedding.mdis deliberately untouched — no parameter, origin, CSP, sizing or URL-shape change. The visible behaviour is inCHANGELOG.md.Detail
Why
isResponsive: falserather than a smaller fix.setScreenSizeCompatibleView(core.js:2442) is reached only fromhandleWindowResize, which is registered only insideif ($app.config.isResponsive)(core.js:2541) — so the flag closes the only path. The shallower options would have left the mechanism armed and the app racing it: supplying a falseisCalendarSmall, or patchinghasSmallScreenCompaton the view objects.isCalendarSmallthen staysundefined, and its only consumers are SX's own view dropdown and thesx__is-calendar-smallclass, whose rules all target the header barglobals.css:532hides — nothing undersrc/keys on either.Why
weekcollapses ontomonth-agendaand notlist. The agenda keeps a chosen day's own hours in view, which is what Week was being read for, and it leaves one answer below the crossing for every non-list view.Why the store keeps the pick, not the resolution. A stored
weekhas to survive a trip through a phone width and light Week again above the crossing. Storing the resolution would lose it, and would also mean a store write on every crossing.Why the drawer-width test is an
&&and not a helper. Above the crossing the resolver returns the stored view, and both views it can return there are full-width. Below it, nothing is. SoisWide && stored !== 'list'is not an approximation of the resolver's answer — it is that answer, for any mapping with those two properties. Verified over all 14 stored-name × width pairs,month-agenda,''and junk included.Rejected for question 2 of the ticket: registering
createViewDay()and mapping Week → Day below the crossing.dayrenderssx__week-wrapper, so Week and Day are indistinguishable by wrapper class, and a button reading "Week" over a single day needs a new label — translations are CMS-owned, so it would have waited on asydevs/SahajCloudissue.Verification method.
?map=0on the standalone shell, with the API key supplied through.env.localfrom the environment's existing read-only key (removed afterwards; the tree is clean). Reads are production-read-only.Closes #331
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_0111UmECXW42ciGRazy4JhDM