Repository navigation
fix(page): a header that grows after load is never re-measured - #45
Conversation
assets/atlas-page.js was enqueued in <head>, where document.body is still null, so its ResizeObserver never attached. A cookie banner pushed into the flow, a late logo, or a menu that wraps moves the atlas down without firing a resize event, so the offset kept its load-time value and the element's bottom edge — where the mobile bottom sheet's drag handle lives — ended below the fold. The script now loads in the footer, where both the element it measures and the body it observes already exist. Its first measure stops being a no-op, and the observer attaches. The attach also retries on each measure, so the observer no longer depends silently on an enqueue argument in another file. Two assertions cover it. The behaviour suite pins the footer group, and the render lane pins the script tag below the element in both theme kinds. Both were watched fail with in_footer restored to false. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sy9SkbHFFPaSejMjXsJEM2
One `start()` instead of `observe()` plus a single-caller wrapper, and a boolean rather than a handle nothing disconnects. The same four-sentence story was written out four times; it stays whole at the enqueue, where the decision lives, and the other three carry their own one fact plus a pointer. The comments now state the rule in the present tense instead of narrating what `<head>` used to do. The suite block restores the previous `$GLOBALS['wp_query']` the way tests/contract.php does, and drops a `the_post()` and `wp_reset_postdata()` that `sahaj_atlas_is_atlas_page()` never reads. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sy9SkbHFFPaSejMjXsJEM2
Four inline ⚠ comments and no entry in the trap list is the one shape this repo's own convention says not to leave: the next person to touch the enqueue has no reason to read the comment before changing it back. render.mjs:298 moved to 305 under this branch. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sy9SkbHFFPaSejMjXsJEM2
|
🤖 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
Right fix, right size. includes/embed.php:377 is the whole of #41. The body's boot-order claim holds from the consumer side: decideSlot runs once at mount (SahajAtlasWeb src/main.tsx:81), so in <head> the widget mounted against a full 100dvh box.
One exposure stays, and it is not this PR's to close: nothing in the widget re-reads container height after mount — useIsWide observes width only — so a header growing past MIN_INTERFACE_HEIGHT_PX (420) leaves a full interface in a short box. Pre-existing, and narrower now.
Findings
considerassets/atlas-page.js:72— the retry is the entire JS diff. Keep it, for the reason in the thread.considerAGENTS.md:141— trap 21 tells the story its two inline⚠comments already carry.
What was checked
Read whole: atlas-page.js, embed.php, the new run.php group. Consumer side: embed-slot.ts, decideSlot callers, responsive.ts, docs/embedding.md. One enqueue site, and sahaj-atlas-editor was already footer. No contract file touched.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The list indexes traps. Trap 21 told the story its two inline ⚠ comments already carry, so it keeps the instruction and the failure mode and drops the retelling. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XJuPJvvz5mH2QahhenF9Ys
The `<head>`-loses-both reasoning stood in three places: the enqueue, this ⚠, and AGENTS.md trap 21. Nobody has counted a hoisting optimiser across the 13 sites. The enqueue owns why the footer; this comment now owns only why the attach retries. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XJuPJvvz5mH2QahhenF9Ys
|
Both critic findings adopted. No code changed — the premise stood in three places, and now stands once.
Line 65 did not move, so trap 21's Lean gate green after both: 0 syntax errors, 243 PHP assertions, render lane 0 failures. Nothing rebutted, nothing asked. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
PR #45 already adds `observing`, `start()` and the three entry points, and moves the enqueue to the footer, which reverses the premise the ⚠ here stated. Keeping a second copy conflicted with it in `assets/atlas-page.js` and in `AGENTS.md`, so the lifecycle goes back to what `main` has and #41 owns it. The offset still needs frames to walk its additive sum to the header's bottom edge, and it now asks for them itself. Nothing else supplies them: no resize event fires for a margin this script wrote, and the body observer is exactly the thing that is not reliably attached. The clamp already ends the walk, so the loop is bounded by the same guard as before. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015QGDLmYDuvjPYCqBRejoAz
The fixture modelled a `<head>` load and asserted it. PR #45 moves this script to the footer, after which the lane would have kept passing while modelling a page the plugin no longer serves, and nothing would have said so. The position now comes out of `includes/embed.php`, so every scene follows the enqueue, and both positions are run explicitly. A rename of the handle, or an enqueue the regex cannot read, exits 2 rather than falling back to a guess. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015QGDLmYDuvjPYCqBRejoAz
Both sides added to the same two places. tests/render.mjs: #51's headerless-theme block and this branch's script ordering assertion landed at the same line. Both kept, the ordering one first, since it reads `elementAt` from the assertion above it. AGENTS.md: both sides repointed trap 5's render.mjs reference, so neither number survives the merge. Re-derived against the merged file: 321, on the ⚠ line #51's side had moved it to. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01C4H64tVputWUuN3kZXmKMb
|
Merged
Gate green: lint 12 files, 243 PHP assertions, render lane 0 failures. Both sides' new assertions run — 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Two text conflicts, both from #45. Each side keeps its own behaviour. assets/atlas-page.js, the file's doc comment. This branch reads two offsets rather than one; #45 widened what re-triggers a measure. The merged sentence states both. The lifecycle below it is #45's unchanged: this branch reverted its own entry-point rewrite before pushing, so start() and the observing flag arrive only from main, and measure() is this branch's. AGENTS.md, two traps both numbered 21. Both are real and unrelated, so both stay. Main's footer-enqueue trap keeps 21, since nothing cites either number and main's is already published; the out-of-flow header trap becomes 22. Line citations in both are recomputed against the merged files. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NaktyxKC7XZbRVbDNjsS86
Summary
assets/atlas-page.jsnow loads in the footer, where the element it measures and the body it observes both exist.<head>no longer loses it silently.Test results
pnpm test:all— syntax lint, 243 PHP assertions / 0 failures, render lane 0 failuresin_footerrestored tofalseManual verification
The retry half of the fix has no lane that can reach it — no test lane here runs a DOM, which is what #38 exists to build. Verified instead against a stub DOM: with the body absent at load the observer attaches on
DOMContentLoaded(0 → 1), and in the footer it attaches once at load and is not duplicated byDOMContentLoadedorload. Onorigin/mainthe same probe never attaches it at all.Notes for reviewer
The ticket offered the footer move or a
DOMContentLoadedattach. This does both.includes/embed.php:377alone closes #41; the retry is there because optimiser plugins (Autoptimize, LiteSpeed) really do relocate footer scripts on self-hosted sites, and the failure is invisible to the visitor and the admin alike. The critic kept it and cut its documentation instead: the<head>-loses-both reasoning now stands once, at the enqueue, and the ⚠ inassets/atlas-page.jscarries only why the attach retries. Say the word and the retry still comes out in six lines.Detail
Why the footer is correct rather than merely sufficient. In
<head>the parse-timemeasure()always returned early on! element, so the first real offset arrived atDOMContentLoaded. On a classic theme core prints the widget's script module atwp_footerpriority 10 and ours at 20, but a module is deferred and ours executes at parse — so--sahaj-atlas-topis now written beforeauto.jsboots, instead of racing it. Previously the widget could boot against a full-100dvhelement, the over-tall boxassets/atlas-page.csswarns pushes the bottom sheet below the fold.The element is always above the script, on all three print paths:
templates/atlas-page.phpprints it beforewp_footer(), the block template'swp:sahaj-atlas/pagesits in the content, and the fallback hookswp_footerat priority 1 against core's script printing at 20.No feedback loop.
--sahaj-atlas-topdrives only the element's own height, and the element cannot move its own top edge from below. Document height is invariant under it:top + (100dvh - top)is constant, so there is no scrollbar oscillation to drive one. Thetop === lastguard stops the second pass.Why not observe
document.documentElement. It would work mechanically — neitherhtmlnorbodyis given a height — but the custom property is written ontoroot, so observing it invites "ResizeObserver loop completed with undelivered notifications", and a theme settinghtml { height: 100% }would pin the root box to the viewport and miss a growing header entirely.bodykeeps the mutation target and the observed target distinct.No CSS-only path exists. On a block theme the header part and the element are siblings and flex would do it, but a classic theme's
header.phpopens wrappers this page never closes, so the element sits at an unknown depth and no flex container reaches it. A CSS path would mean two layout mechanisms for two theme kinds.Security review: ran, no findings. The diff adds no input source or sink; the
--sahaj-atlas-topvalue isMath.round()of agetBoundingClientRect()read, andwp_enqueue_script's 5th argument is all that changed in PHP.Contract step: not run — the diff does not touch
tests/atlas-url-contract.json.Adversarial review, adopted. Both findings were about one thing: the
<head>-loses-both premise stood in three places at once.0ccb468cuts trap 21 to the index line the list is for.35b35f2cuts the ⚠ inassets/atlas-page.jsto why the attach retries, leaving the enqueue to own why the footer. Nothing moved line 65, so trap 21'satlas-page.js:65reference still lands on it. No code changed, and the critic's one open exposure — the widget never re-reading container height after mount,useIsWideobserving width only — stays out of scope here.Review findings dismissed, from the pre-push pass: the suggestion to drop the retry entirely, for the reason above. The suggestion to fold
tests/render.mjs's existing "and the measurement script" assertion into the new ordering one — the repo keeps paired assertions on purpose there, and the existing one gives the clearer message when the file is missing outright.Tooling: one of the four review lenses took four times the others' runtime to return; its conclusions arrived after I had acted on the other three and are reflected above.
Closes #41
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_01XJuPJvvz5mH2QahhenF9Ys