Repository navigation
Conversation
Four lifecycles were spread across booleans, refs, module lets and timers, with their rules held only in comments. Each is now an XState 5 machine in a pure module with a node-lane table spec, read from React through useSyncExternalStore: - lib/ownership.ts: which <sahaj-atlas> owns the page, and the 1s teardown grace window (was `owner` + `pendingTeardown` in Widget.tsx). The embed report is now cancelled on release instead of relying on 500ms < 1s, so a different-key replacement can no longer send the old owner's report unauthenticated or under the new key. - lib/locate-machine.ts: one request phase shared by the map's find-me and the filters' Near me, owned by the locator, with the 35s backstop as a delayed transition. A Near me fix now lights find-me; each control still acts on, and raises a failure alert for, only its own presses. The duplicate `failed` boolean and `waiting` ref are gone. - lib/challenge-machine.ts: one Turnstile frame's token, click prompt and blocked state. The frame's `interactive`/`settled` events (SahajCloud#1090) now drive the line under Register, replacing the 4s `checkIsSlow` guess; a reset with no frame window remounts instead of keeping a spent token. - views/DrawerStack/sheet-machine.ts: the phone sheet's stop plus the intents a dismissal leaves. Escape and the header now read one `isCollapsed` predicate, and a "Show N classes" intent no longer outlives a collapse. Also: both forms hold a submit with a ref, so two submits that clear validation together cannot send one single-use token twice (isPending reads false in both callbacks); first unit spec for atlas-history; a browser-lane scenario for the sheet; the lifecycle convention in i18n-and-state.md. xstate joins both eager graphs: +11.6/+11.8 KiB gzipped, so the standalone and embed budgets move to 349/350, keeping the ~1 KiB each had spare. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Near me kept a boolean for its own last refusal and joined it to the shared phase, so a later refusal from the map's button brought Near me's alert back for a press it never made. The machine now numbers each request it starts; a control remembers the id it asked under and shows 'failed' only for that one, which also keeps a refusal from before a remount off the alert. The locator's own pending-promise memo goes: the machine already ignores a request while one is out, so a second ask simply waits on the first. MapControls reads the phase itself, so a phase change no longer re-renders the whole map, and every actor read goes through one useActorSelector hook (with a server snapshot, which SSR needs). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The two forms each held a `sending` ref to stop two same-tick submits sending one single-use token twice, with the reason written out in each. The machine already owns the token, so it now owns that rule too: a new `solved.spent` state, entered through `spend`, and `useTurnstile().take()`, which reads the actor rather than the render and hands the token to one submit only. Leaving `solved` drops the token, in one exit action. The hook reads its actor through useActorSelector and clears it when the frame is torn down, so a stopped machine's last token is never handed out before the next frame mounts. The two submit specs pin React Query's scheduler to a microtask instead of waiting out its 0ms timer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The sheet's "Show N classes" intent no longer depends on effect order: VIEW_CHANGED and LOCATION_SETTLED both carry the view, and a settle spends the intent only when its move changed none. - The sheet's actor reads through useActorSelector, and its long-lived landing callback is built at module scope, holding the navigate ref rather than the first render's whole scope. `Stop` has one declaration. - Ownership: the duplicated docblocks between Widget.tsx and lib/ownership.ts are one; unused type exports are private. - The history spec's hand-written fake window is gone: its four new cases run on jsdom's own session history beside the router spec that already pinned the rest. - The size budget's row names the right eager paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mpt (#556) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Four genuine lifecycles, and the table specs earn their keep — ownership's grace window and the challenge's non-latching blocked read in one place now. The refactor sits where the diff works, so none of it is smuggled.
The price is what I would not take as written. xstate reaches both eager graphs solely for ownership and challenge, and the eager budgets rise 336→349 and 338→350 KiB on the payload host pages load. locate and sheet get the library free from the lazy interface. With no ticket, "XState was the chosen approach" is not yet an answer.
Contracts held: SahajCloud's challenge protocol is identical; nothing new is fetched or framed. No preview links or question threads.
Findings
- should-fix · 13 KiB of eager budget for two of the four machines —
check-bundle-size.mjs:142 - should-fix · the #556 ledger row matches neither
pnpm sizenor its own spare-KiB claim —:95 - should-fix · Streamline
isCollapsed+escapeGoesOutward—sheet-machine.ts:74 - should-fix · Streamline
sheetStoreFor—DrawerStack.tsx:123 - should-fix · Streamline
LocatePhase—locate-machine.ts:6 - should-fix · Streamline
LocatorApi—use-locator.tsx:30 - consider · Streamline
challengeView—challenge-machine.ts:114
What was checked
Read whole on the branch: the four machines, use-actor-selector, use-locator, use-locate, use-near-me, use-turnstile, embed-announce, both forms, Widget.tsx, DrawerStack, config/embed. Streamliner: 43 pieces, 33 kept, 5 of 6 held.
Dropped after checking: the ownership table against main's connectedCallback, cell by cell — equivalent; ReportIssueForm losing its isPending guard, which Button's disabled={disabled || isLoading} covers; the waiting AbortController, which fixes a race main had.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`sheetStoreFor` was a module-level layer with one call site. The reason it existed — the long-lived rewrite callback must hold the ref, not a render scope — is a property of the callback, so it moves onto the callback. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVwrUoHZT8qUrVTuA8
`isCollapsed` and `escapeGoesOutward` were one-expression predicates in the machine module, though neither is machine state: one reads the sheet's live top, the other the step back. Both had one caller. The spec pinned them to agree. One `collapsed` local, read by the header's control and by the Escape ladder, makes that agreement structural instead; `sheet.spec.ts` holds Escape in a browser. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVwrUoHZT8qUrVTuA8
`LocatePhase` re-declared the four state names the machine config already holds, so the union could drift from the states it names. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVwrUoHZT8qUrVTuA8
`LocatorApi` annotated one local that was immediately spread into the return, while the exported `Locator` is already `ReturnType<typeof createLocator>`. The JSDoc moves onto each property, and the three casts go with the derived phase union. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVwrUoHZT8qUrVTuA8
`Widget.tsx` reaches this module before anything renders, so XState here was ~12 KiB gzipped on every host page. Three states, one timer and no invoked actor fit a plain table. Every one of the 14 table cells the spec pins — the grace window, the refusal, the key comparison and the documented insert-first failure — passes against the rewrite unchanged. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVwrUoHZT8qUrVTuA8
…ection `use-turnstile.ts` rides in both eager graphs through the app-wide report form, so XState here was the other ~12 KiB. The `solved` region flattens to three state names, which leaves a seven-row transition table and one timer. Flat names also make the projection one expression per field, so `challengeView`, `ChallengeView` and `UNMOUNTED_CHALLENGE` give way to three `useActorSelector` reads with their own absent values. The hook no longer subscribes to whole-snapshot identity. The spec keeps all 21 cells and gains the handshake clock's survival of an ignored event, `canSpend` as a closed set, and the store's notification. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVwrUoHZT8qUrVTuA8
With xstate out of both eager graphs the payload measures 334.8/336.0 KiB again — `main`'s own figure — so neither budget moves and the ledger gains no row. `Widget.standalone.test.ts` drops `xstate` from the eager packages, which is what proves the library left rather than the figures. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVwrUoHZT8qUrVTuA8
The convention this PR added read as "every lifecycle is an XState machine". Two of the four are plain tables now, because they ride in the eager graph, and the rule that decides between the two shapes is the part worth writing down: xstate is in neither eager graph and must stay out. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVwrUoHZT8qUrVTuA8
|
All seven threads adopted and resolved, each answered in place. Pushed as The big one: xstate is now in neither eager graph. Streamlines: the two predicates are one Gates: lean gate ✓ · browser lane ✓ 40 · 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
sahajatlas-design | 19431ec | Nov 28 2026, 08:49 PM |
There was a problem hiding this comment.
Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. Enable auto-merge when you want it merged: the queue tests it against its base. 🤖 Written by the sydevs autonomous loop — see what this is
The owner chose XState for all four lifecycles and accepted the eager budget raise it costs (+11.6/+11.8 KiB gzipped, budgets 349/350), so this restores the ownership and challenge machines on XState, the budget row and the eager-package pin, and the state rule's wording. It reverts 8c40577, 02d7821, 2cc1af2 and 6570be3; the sheet and locate streamlines pushed with them stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Owner decision: keep XState for all four lifecycles, |
Both sides added a Changed entry and its link definition to CHANGELOG.md; both are kept, newest PR first as the file orders them. The per-edit selection-width pin went red on the merge alone. #556's use-locate.test.tsx and #555's shared.search-pick.test.tsx each took a slot on src/hooks/use-locale.ts, measured at 24 on either side and 25 together, which is the two-PR interaction docs/testing.md describes. The hook measures 8.8s for that edit on 4 cores against a 12s budget, and 8.8s for src/config/i18n.ts, so the ceiling is ratcheted to 25 rather than a spec dropped from the selection. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW4W5etXifdPPHPNAJ
|
Merged
The one failure was the merge's own. Lean gate green: lint, typecheck, 2887 passed, 1 skipped. Nothing here asks a question. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Not required, so not blocking: 🤖 sydevs dispatcher |
Summary
lets and timers are now XState 5 machines with table specsChange outline
Types — the four machines
Each is a pure module, with no React and no DOM, and a node-lane spec over its transition table. React reads each one through one hook,
useActorSelector.All four are XState 5, by the owner's decision (see Notes): one formalism for every lifecycle, at +11.6/+11.8 KiB on the eager payload.
docs/rules/i18n-and-state.mdcarries the rule.Flow — page ownership and the embed report
The element passes its lifecycle callbacks to the machine and does nothing else. On release, a report still waiting for idle is cancelled, so the 500 ms < 1 s coincidence no longer decides whose key sends it.
Flow — one location request, two controls
The map's find-me and the filters' Near me share one request phase. A control shows a refusal only for the request it asked under.
Flow — a submit takes the token
Both forms used to guard on
tokenfrom the render, which two submits that clear validation in the same tick both pass.Components — DrawerStack's sheet
Escape and the header now read one
collapsedlocal. The "Show N classes" intent and the landing rewrite live in the machine, not in refs.Files
Preview
Preview pending: the Workers alias is not posted yet. On a phone-width viewport:
full-map.html— press Escape on the sheet, then Show moreTest results
pnpm size: standalone 347.7 of 349 KiB, embed 349.1 of 350 KiB, loader 3.5 of 3.6sheet.spec.ts. With four workers, two first-boot cases timed out at 5 s on a machine at load average 25, and each passed aloneManual verification
Notes for reviewer
Visible behaviour changes. Everything else is meant to be unchanged:
Dismissed review findings:
waitingnot cleared ifwhenIdlethrows. Unreachable:whenIdleonly resolves, and its executor catches the one call that can throw.refusegoes throughreportIntegrationWarning, which swallows a throwing console.releaseis assignments and idempotent DOM writes. A ⚠ comment records the rule.vacantintoowned. Not taken: they are the named states this PR exists to add.Owner decision, not open for review: XState for all four lifecycles, and the eager budget raise it costs. The adversarial review proposed plain tables for
ownershipandchallenge, to keep xstate out of the eager graphs. That was pushed and then reverted in f274fbb at the owner's request: one formalism, with its visualiser and devtools, was the explicit choice over saving 11.6/11.8 KiB. The sheet and locate streamlines from the same push are kept.The security review ran, triggered by
package.jsonandWidget.tsx. It found nothing.Detail
Widget.tsx— for +11.6/+11.8 KiB gzipped, so the budgets go 336 → 349 and 338 → 350, keeping the ~1 KiB each had spare.Widget.standalone.test.tslistsxstateamong the eager packages. The locate and sheet machines reuse it from the lazy interface.@xstate/react:useActorSelectoris about 10 lines, with a server snapshot sorenderToStaticMarkupspecs do not throw.act, failing about 15/30 with the new hook and 1/30 onmain.routing.router.test.tsx, on jsdom's real session history. There is no hand-written fake window.🤖 Generated with Claude Code