Skip to content

fix(page): the Atlas page breaks when another template renders it, unnoticed - #52

Merged
sydevs-bot merged 9 commits into
mainfrom
claude/fix-39-template-fallback
Oct 2, 2026
Merged

sydevs-bot merged 9 commits into
mainfrom
claude/fix-39-template-fallback

Conversation

@sydevs-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • The widget now renders in the page's content area when a template this plugin did not supply claims the Atlas page, with the theme's own footer below it.
  • wp_footer stays as the last resort, and diagnostics turns red on it instead of reporting the page healthy.
  • Two new status rows read the live page back over loopback: which print rendered the element, and whether the loader's script tag survived.
  • The readme's page-builder section now describes what actually happens; its old advice could not work.

Phases

  • The the_content print, the render marker, the readme, and both render runs
  • The diagnostics loopback probe and its two rows
  • Browser-lane coverage: the Elementor Full Width cell and the status panel
  • /code-review high findings
  • The adversarial review's findings

Changes

  • includes/embed.php — sahaj_atlas_content_element() on the_content at priority 99; sahaj_atlas_render_element_fallback() splits the wp_footer print from the template print; data-sahaj-atlas-render names which ran; is_feed() added to the resolver's early return
  • includes/diagnostics.php — sahaj_atlas_page_probe() / sahaj_atlas_read_page() and checks for placement and the loader; sahaj_atlas_client_slot() so a lane can seed the client record; sahaj_atlas_tag_attr() reads one attribute quoted, single-quoted or bare; sahaj_atlas_probe_unavailable() is the row both loopback checks fall back to
  • tests/fixture-template.php — takes the Atlas page over the way each theme kind really loses it
  • tests/probe.php — the loopback checks, with stubbed answers

Test results

  • Lean gate: ✓ pnpm test:all — syntax lint, 292 PHP assertions, both render runs, 0 failures (against f02df15, this branch's base)
  • Contract step: ✓ tests/atlas-url-contract.json byte-identical to SahajCloud's copy
  • Security review: ✓ run (includes/ matched securityReview.triggerPattern) — no findings
  • Review: /code-review high plus comment-lint.mjs (no banned comment). The adversarial review's three findings are answered — two adopted, one rebutted with the module-script spec. /simplify did not run — the lease ran out; worth a pass on the next session.
  • Browser lane: not run — it needs the network and SAHAJ_ATLAS_TEST_KEY

Manual verification

  1. This branch needs origin/main merged in before CI can run. main moved to 0540aa8 while this was building (fix(page): a fixed header covers the map on the Atlas page #47 and fix(seo): robots.txt and title paths fail on part of the fleet #49 landed), and the merge conflicts in includes/diagnostics.php, AGENTS.md and tests/render-classic.json. Every conflict is two independent additions in one region — main's new check 6 (sitemap discovery) beside this branch's two rows, which become 7 and 8 — plus AGENTS.md line anchors that both sides moved. A partial resolution was written and then discarded rather than pushed unvalidated.
  2. pnpm test:browser --only elementor-full-width,strip-module,astra — the three cells this PR touches. elementor-full-width is new and has never run.
  3. On a real site: set the Atlas page to Elementor Full Width, confirm the map renders above the footer, and confirm Settings → Sahaj Atlas names the content-area path.

Notes for reviewer

  • The new host-facing attribute is settled, and leaves one gap upstream. data-sahaj-atlas-render on <sahaj-atlas> collides with nothing: the widget's only element-level attribute is data-sy-atlas-loaded (src/loader/index.ts:152), data-sahaj-atlas-ready goes on <html>, and docs/embedding.md retired all nine element attributes. What is missing is a line in that doc reserving data-sahaj-atlas-* on the element for the host — a SahajAtlasWeb change this session could not write. Worth carrying over.
  • Dismissed, from /code-review high: a theme-builder hero can still push the content-area element's top past the viewport and clamp its height to zero, and the placement row stays green. That is chore(page): check the fleet's other themes for a header hero #37's defect reached by a new path, and turning the row red there would contradict this ticket's own criterion — red only for the footer fallback or no element.
  • Diagnostics went from five checks to seven on this branch, and to eight once main's check 6 merges. Principle 4 caps settings, not checks, and the ticket asks for both rows; say if the panel is now too long for the volunteer it is for.
Detail

Why the_content and not an earlier hook. The Atlas page's content is empty, so a theme's or builder's page template that runs the_content is exactly the place the element belongs. Priority 99 is load-bearing: at the default priority wpautop() wraps the element in a <p>, whose margins push the contained map's bottom edge — where the mobile drag handle sits — below the fold. Pinned by an assertion in both tests/run.php and tests/render.mjs; verified by moving the filter to priority 5 and watching both fail.

Two callers run the_content without rendering the page body, and either would spend the single print on a string nobody shows, leaving the page with no element and the footer fallback no-opping behind it. wp_trim_excerpt() is one — get_the_excerpt() on a page with no excerpt runs the content through this filter to build one. An SEO plugin asking for a description inside <head> is the other. Both are refused, and the suite asserts on the print flag rather than only the returned string, because the string assertion passes while the flag is already spent.

Fixture pre-mortem. tests/fixture-template.php assumes two things, both read from the real mechanism rather than from the plugin: a classic theme loses the page to a later template_include filter (priority 99, past the plugin's 10), and a block theme loses it when _wp_page_template stops naming the plugin's template, which is what the Site Editor leaves behind. Never both at once — get_page_template() on a block theme falls through to index.php. tests/probe.php assumes the loader tag core prints for wp_enqueue_script_module(): type, src, id="<handle>-js-module", from WP_Script_Modules::print_enqueued_script_modules() via wp_print_script_tag(); verified against those, and the render lane asserts the real thing too.

Four /code-review high findings fixed in d3b3364: the new panel cells made an unstubbed clients/me call that failed every cell's SahajCloud invariant; a transport failure is deliberately uncached, so two checks each calling the probe spent two ten-second timeouts (now one probe, handed to both rows, the way the client record already is); \bsahaj-atlas-page\b also matched core's page-template-sahaj-atlas-page, collapsing the two no-element diagnoses into the wrong one on every page whose meta still names our template; and a volunteer who changed the page's template still saw the red row for five minutes (save_post now drops the probe).

Three adversarial-review findings, answered. Every reader in sahaj_atlas_read_page() required double-quoted attributes, and an HTML minifier drops optional quotes from any value with no spaces — which is the whole set this probe reads. The marker then read as absent and check 6 told the volunteer their working page had no map. One reader, sahaj_atlas_tag_attr(), now handles ", ' and none (c444eba). sahaj_atlas_probe_excuse() became sahaj_atlas_probe_unavailable() (cc4dcaa). The third — match defer beside async — is rebutted: defer is a no-op on a module script, since the HTML spec defers module scripts already and document.currentScript is null for a module either way, so SahajAtlasWeb's loader reaches its tag through script[src*="auto.js"] regardless (src/loader/index.ts:346). async is honoured on a module and does break it, so it stays alone. embedding.md:87's "No async or defer" is the rule for a host's classic snippet, not for the module tag core prints here. 81406e2 pins the distinction.

sslverify is off on the loopback, as core's own Site Health loopback test has it. A server that cannot verify its own host's certificate is common on this fleet, and a red row a volunteer cannot act on is the shape that sends them to us about a working site. The probe stores a flag for the loader, not the tag — the tag carries the key in its src, and the array goes into a transient.

tests/no-network.php now lets a request to the instance's own host through. That is not a way out of the instance, and refusing it would make the loopback check report "could not reach the page" in every lane — the one answer that tells a lane nothing. Calls to SahajCloud and to third parties stay refused, and the per-cell invariant still proves it.

Every assertion here failed once first. Without the the_content filter, both render runs put the element below the footer. Without each guard, the excerpt and <head> cases spend the print. With the naive \basync\b match, an optimiser's data-async-ignore marker reports a working page broken. With \b on the body class, core's own template class reads as ours. With the quote-only attribute pattern, a minified page reads as a page with no map. With defer folded into the async match, a working page reads as broken.

Closes #39

🤖 Generated with Claude Code

https://claude.ai/code/session_016qsV5T5e7fJsFwNSBfzztt

claude added 5 commits October 1, 2026 21:12
…e wins

The plugin owns the Atlas page's template, but anything can take it: a page
builder's canvas template, a theme-builder layout, a maintenance-mode plugin, or
a volunteer switching the template in Page Attributes or the Site Editor. The
theme then renders header, empty content and footer, and the only print left was
the `wp_footer` fallback — which lands after the footer, where
`assets/atlas-page.js` measures the element's top at the document's full height
and the map computes to zero.

`the_content` is now the second print, so the element lands in the page's content
area with the theme's footer below it, sized exactly as before. The footer
fallback stays as the last resort, for a template that runs neither path.

Two callers run `the_content` without rendering the page body, and either would
spend the single print on a string nobody shows: `wp_trim_excerpt()`, and an SEO
plugin asking for a description while `<head>` is built. Both are refused, and
the suite pins both — asserting on the print flag, not only the string, because
the string assertion passes while the flag is already spent.

`data-sahaj-atlas-render` names which print ran. Nothing else in the page can
answer that: a theme's footer markup varies too much to locate, and the plugin
knows the answer only while it renders. The diagnostics loopback check reads it.

`tests/fixture-template.php` takes the page over the way each theme kind really
loses it — a later `template_include` filter on a classic theme, a cleared
`_wp_page_template` on a block theme — and both render runs assert the element
sits above the theme's footer. Verified by reintroducing the defect: without the
filter the element lands below the footer in both runs.

Refs #39

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012fWGENvNLWJsmWFAfXQ5ey
Check 2 reads the template meta, so it called a page healthy while a page
builder's template rendered it and the element landed after the footer. Nothing
server-side can tell the difference: the meta still names this plugin's
template.

Two new rows read the live page instead, from one fetch. "Map placement" names
which of the three prints rendered the element, and is red only for the footer
fallback or no element at all. "Map script" reads the loader's own tag, and is
red when it lost `type="module"`, gained `async`, or its address lost the key —
the detection SahajAtlasWeb#239 handed to the plugin, because a module cannot
report on a tag that never ran.

A page with no element gets two different diagnoses, on the body class: the
Atlas page rendered without its map, or something else answered the address
entirely. The second sends the volunteer to their caching and maintenance-mode
plugins rather than to us.

Neither row turns red on anything a volunteer cannot act on. A server that
cannot reach itself is a warning, and `sslverify` is off as core's own Site
Health loopback test has it, because a host whose certificate its own server
rejects is common here. The probe stores a flag for the loader, not the tag: the
tag carries the key in its `src` and this array goes into a transient.

`tests/probe.php` covers each render path, a tag stripped of `type="module"`,
`async`, a key-less address, no tag, an unreachable page and an unset key.
Verified by reintroducing four defects, the naive `\basync\b` match among them —
it reads an optimiser's own `data-async-ignore` marker as `async` and reports a
working page broken.

Refs #39

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012fWGENvNLWJsmWFAfXQ5ey
An `elementor-full-width` cell sets the Atlas page to Elementor's own
`elementor_header_footer` template, so the builder renders the page and the
element must come from the content area with the theme's footer below it. Every
cell now asserts which print rendered the element, read from the served HTML
before a browser runs any of it, so a cell that silently fell back to the footer
is no longer indistinguishable from one that did not.

Two cells also read the status panel as the volunteer sees it.
`elementor-full-width` expects both loopback rows green and the content-area path
named. `strip-module` expects the script row red — that cell's page is still
broken, and the panel saying so is the whole fix, so its `known` mark now points
at #39 rather than the closed SahajAtlasWeb#239. A panel where both rows warn
means this server could not fetch its own page, which is a harness condition and
reports as info rather than a red the code did not earn.

`tests/no-network.php` lets a request to the instance's own host through. That is
not a way out of the instance, and refusing it would make the loopback check
report "could not reach the page" in every lane — the one answer that says
nothing. Calls to SahajCloud and to third parties stay refused.

Not run here: the browser lane needs the network and `SAHAJ_ATLAS_TEST_KEY`.

Refs #39

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012fWGENvNLWJsmWFAfXQ5ey
Four findings from `/code-review high` on this branch:

The two new `panel` cells load the settings screen, which fetches `clients/me`
from PHP. That request is unstubbed in the browser lane, so `no-network.php`
recorded it and every cell's SahajCloud invariant went red — an `ok` failure,
which counts even for a `known` cell. The cells now seed the record through
`sahaj_atlas_client_slot()`, a named slot builder beside `sahaj_atlas_seo_slot()`
so no lane copies the key rule.

A transport failure is deliberately not cached, so two checks each calling
`sahaj_atlas_page_probe()` spent two ten-second timeouts on the host that
produced it — the case `tests/probe.php` claimed to prevent while only covering
the cached HTTP-code path. `sahaj_atlas_checks()` now asks once and hands the
answer to both rows, the way it already hands the client record to three.

`\bsahaj-atlas-page\b` also matched core's `page-template-sahaj-atlas-page`, so
the body-class flag no longer proved this plugin's own filter ran — and on every
page whose template meta still names our template, which is every page this fix
is about, the two diagnoses collapsed into the wrong one. Exact membership now.

A volunteer who did what the row asked — change the page's template — still saw
the red row for five minutes. `save_post` on the Atlas page now drops the cached
probe.

Not fixed, with reasons: a theme-builder hero can still push the content-area
element's top past the viewport and clamp its height to zero, and the placement
row stays green. That is #37's defect reached by a new path, and red there would
contradict this ticket's own criterion that the row is red only for the footer
fallback or no element.

Refs #39

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012fWGENvNLWJsmWFAfXQ5ey
@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
  • 23:48Z resolve-conflicts · attempt 1 · session · done
  • 23:48Z resolve-conflicts · attempt 1 · session
  • 23:29Z address-review · attempt 1 · session · done
  • 23:29Z address-review · attempt 1 · session
  • 23:19Z 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

The diff is the size of #39: four approach items, four sets of changes, nothing smuggled in, and 600 of its 1016 added lines are tests. the_content at 99 is the platform's own hook for this, and the three prints stay one function with a parameter. The body's data-sahaj-atlas-render question is answerable from SahajAtlasWeb — no collision, evidence on embed.php:360. All three findings sit in sahaj_atlas_read_page(), the one place this PR parses output it did not print. mergeable_state is dirty, so CI has not run this against its base.

Findings

  • should-fix — diagnostics.php:691: check 7 misses defer, which breaks the loader as async does
  • consider — diagnostics.php:672: quoted attributes are assumed; a minifier turns check 6 red on a working page.
  • consider — diagnostics.php:566: sahaj_atlas_probe_excuse() invents a word for a row.

What was checked

#39, the PR body, the diff at beb37ac, and whole: embed.php, diagnostics.php, probe.php. Plus SahajAtlasWeb loader/index.ts, embedding.md

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


Generated by Claude Code

Comment thread includes/diagnostics.php Resolved
Comment thread includes/diagnostics.php Resolved
Comment thread includes/diagnostics.php Resolved
Comment thread includes/embed.php 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
claude added 3 commits October 1, 2026 23:42
Every reader in `sahaj_atlas_read_page()` required double-quoted attributes.
An HTML minifier drops optional quotes from any value with no spaces in it,
which is the whole set this probe reads: the render marker, the loader's type
and address, and a body carrying one class. The marker then read as absent and
check 6 told the volunteer their working page had no map, and to send us the
address — the false red the `data-async` guard beside it already refuses.

One reader for all four, handling both quotings and none. Its four assertions
each failed first, against the quote-only pattern.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qsV5T5e7fJsFwNSBfzztt
Check 7 reads `async` and not `defer`, deliberately. `defer` is a no-op on a
module script — the HTML spec defers module scripts already — and
`document.currentScript` is null for one whatever the attributes say, so
SahajAtlasWeb's loader reaches its own tag through `script[src*="auto.js"]`
either way. Matching `defer` would turn the row red on a working page.

Nothing said so, so the next reader of the contract's "No async or defer" line
would add it. The assertion fails against `/\s(?:async|defer)[\s=>]/`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qsV5T5e7fJsFwNSBfzztt
`sahaj_atlas_probe_excuse()` invented a second word for what this file already
calls a row, and `$excuse = …; if ( null !== $excuse )` read as an apology
rather than a value. `sahaj_atlas_check_idle()` returns the same shape under the
same conditions. The new name says what comes back.

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

Copy link
Copy Markdown
Contributor Author

Three findings answered, pushed as cc4dcaa.

  • Adopted — unquoted attributes: one reader for all four (c444eba).
  • Adopted — the row's name: sahaj_atlas_probe_unavailable() (cc4dcaa).
  • Rebutted, left open — defer: it is a no-op on a module script, so matching it reddens a working page. 81406e2 pins that.
  • Answered — the render attribute: no collision. The line reserving data-sahaj-atlas-* belongs in SahajAtlasWeb's docs/embedding.md.

Lean gate: pnpm test:all green, 292 assertions.

Still blocking CI: the branch is dirty against main (0540aa8), conflicting in includes/diagnostics.php, AGENTS.md and tests/render-classic.json.

🤖 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 23:48
@sydevs-bot
sydevs-bot requested a review from Ardnived October 1, 2026 23:48
@sydevs-bot
sydevs-bot enabled auto-merge October 1, 2026 23:48
@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 diagnostics checks in one region. Main's sitemap
discovery check stays 6, this branch's placement and loader rows become
7 and 8, and the five comments that named the placement check "check 6"
follow it. Main's two new mu-plugin steps and this branch's fixture
template are independent blueprint steps, so the classic render run
writes both.

AGENTS.md line anchors are re-derived against the merged files rather
than taken from either side: trap 5 and trap 14 both pointed into files
the other side had moved.

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

Copy link
Copy Markdown
Contributor Author

Merged main in at 1127bdf. pnpm test:all passes on the result — 308 assertions, 0 failures.

Three conflicts, each two independent additions in one region:

  • includes/diagnostics.php — both sides added checks. Main's sitemap discovery stays 6; this branch's placement and loader rows become 7 and 8. Five comments in diagnostics.php and tests/probe.php named the placement check "check 6" and now name 7.
  • tests/render-classic.json — main's fake-Yoast mu-plugin and this branch's fixture template are separate blueprint steps, so the classic run now writes both.
  • AGENTS.md — main's traps 22 and 23 kept. Trap 5 and trap 14 anchors are re-derived against the merged files, because both sides had moved the lines they pointed at: embed.php:399, render.mjs:396, run.php:143, and diagnostics.php:296,928.

Manual-verification note 1 is now done. The body's "292 assertions" predates the merge.

🤖 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 2, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit 7649ec7 Oct 2, 2026
22 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-39-template-fallback branch October 2, 2026 00:28
sydevs-bot pushed a commit that referenced this pull request Oct 2, 2026
Only AGENTS.md conflicted, and only on a line-number breadcrumb. Both
sides shifted includes/diagnostics.php, so trap 14's anchors were stale
on both and neither side's numbers were right for the merged file.
Recomputed from the merged file instead of taking a side, and trap 24's
breadcrumb — this branch's own, untouched by main and so unconflicted —
moved by the same amount.

#52 added checks 7 and 8 while this branch changed check 6, which git
merged cleanly; verified both survive.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01W59UqW1sLWMePpX8ZYaxy2
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): the Atlas page breaks when another template renders it, unnoticed

3 participants