Skip to content

fix(page): a header that grows after load is never re-measured - #45

Merged
sydevs-bot merged 6 commits into
mainfrom
claude/fix-41-header-remeasure
Oct 1, 2026
Merged

sydevs-bot merged 6 commits into
mainfrom
claude/fix-41-header-remeasure

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • assets/atlas-page.js now loads in the footer, where the element it measures and the body it observes both exist.
  • A header that grows after load — a cookie banner, a late logo, a wrapping menu — re-measures, so the map keeps its bottom edge on screen.
  • The observer also attaches on the first call that finds a body, so a cache plugin hoisting footer scripts into <head> no longer loses it silently.

Test results

  • Lean gate: ✓ pnpm test:all — syntax lint, 243 PHP assertions / 0 failures, render lane 0 failures
  • Targeted specs: 2 new assertions, both watched fail with in_footer restored to false
  • Build: N/A

Manual 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 by DOMContentLoaded or load. On origin/main the same probe never attaches it at all.

  1. On a site with a cookie-consent banner that injects into the flow, open the Atlas page and dismiss nothing. The map's bottom edge, with the mobile drag handle, should stay at the viewport bottom once the banner appears.

Notes for reviewer

The ticket offered the footer move or a DOMContentLoaded attach. This does both. includes/embed.php:377 alone 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 ⚠ in assets/atlas-page.js carries 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-time measure() always returned early on ! element, so the first real offset arrived at DOMContentLoaded. On a classic theme core prints the widget's script module at wp_footer priority 10 and ours at 20, but a module is deferred and ours executes at parse — so --sahaj-atlas-top is now written before auto.js boots, instead of racing it. Previously the widget could boot against a full-100dvh element, the over-tall box assets/atlas-page.css warns pushes the bottom sheet below the fold.

The element is always above the script, on all three print paths: templates/atlas-page.php prints it before wp_footer(), the block template's wp:sahaj-atlas/page sits in the content, and the fallback hooks wp_footer at priority 1 against core's script printing at 20.

No feedback loop. --sahaj-atlas-top drives 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. The top === last guard stops the second pass.

Why not observe document.documentElement. It would work mechanically — neither html nor body is given a height — but the custom property is written onto root, so observing it invites "ResizeObserver loop completed with undelivered notifications", and a theme setting html { height: 100% } would pin the root box to the viewport and miss a growing header entirely. body keeps 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.php opens 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-top value is Math.round() of a getBoundingClientRect() read, and wp_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. 0ccb468 cuts trap 21 to the index line the list is for. 35b35f2 cuts the ⚠ in assets/atlas-page.js to why the attach retries, leaving the enqueue to own why the footer. Nothing moved line 65, so trap 21's atlas-page.js:65 reference still lands on it. No code changed, and the critic's one open exposure — the widget never re-reading container height after mount, useIsWide observing 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

claude added 3 commits October 1, 2026 17:08
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
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 1, 2026
@sydevs-bot

sydevs-bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 18:56Z resolve-conflicts · attempt 1 · session · done
  • 18:56Z resolve-conflicts · attempt 1 · session
  • 17:32Z address-review · attempt 1 · session · done
  • 17:32Z address-review · attempt 1 · session
  • 17:21Z adversarial-review · attempt 1 · session · done

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

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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

  • consider assets/atlas-page.js:72 — the retry is the entire JS diff. Keep it, for the reason in the thread.
  • consider AGENTS.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

Comment thread assets/atlas-page.js Resolved
Comment thread AGENTS.md Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 1, 2026
sydevs-bot and others added 2 commits October 1, 2026 17:35
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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both critic findings adopted. No code changed — the premise stood in three places, and now stands once.

  • assets/atlas-page.js:72 — the ⚠ keeps only why the attach retries. The enqueue owns why the footer. 35b35f2
  • AGENTS.md:141 — trap 21 cut to your replacement, verbatim. 0ccb468

Line 65 did not move, so trap 21's atlas-page.js:65 still lands on the ⚠.

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

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 1, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 1, 2026 17:42
@sydevs-bot
sydevs-bot requested a review from Ardnived October 1, 2026 17:42
@sydevs-bot
sydevs-bot enabled auto-merge October 1, 2026 17:42
sydevs-bot pushed a commit that referenced this pull request Oct 1, 2026
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
sydevs-bot pushed a commit that referenced this pull request Oct 1, 2026
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
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Oct 1, 2026
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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged origin/main in. Two conflicts, both kept from both sides.

tests/render.mjs — #51's headerless block and this branch's script-ordering assertion landed on the same line. Both kept, ordering first, because it reads elementAt from the assertion above it.

AGENTS.md — both sides had repointed trap 5's render.mjs reference, so neither number survived the merge. Re-derived against the merged file: render.mjs:321, the ⚠ line #51's side had moved it onto.

Gate green: lint 12 files, 243 PHP assertions, render lane 0 failures. Both sides' new assertions run — with the script below both and the four headerless: ones. The branch's own diff against the new base is unchanged at +59/−11 across the same 5 files, so the merge took nothing out of the fix.

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


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 1, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit f02df15 Oct 1, 2026
22 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-41-header-remeasure branch October 1, 2026 20:51
sydevs-bot pushed a commit that referenced this pull request Oct 1, 2026
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
@Ardnived Ardnived mentioned this pull request Oct 2, 2026
3 tasks done
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.

fix(page): a header that grows after load is never re-measured

3 participants