Skip to content

fix: fold fragment SSR head and production SEO diagnostics - #1045

Merged
domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-ssr-tooling-issue-1037
Sep 11, 2026
Merged

domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/fix-ssr-tooling-issue-1037

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Why

  • Fragment preambles previously emitted hoisted metadata ahead of their authored <head>.
  • The SEO environment guard kept a development diagnostic in browser production output.
  • The PostCSS type error was in 8.5.27 and is fixed in 8.5.28 (upstream issue #2154); the 8.5.26 smoke override obscured the current consumer result.

Changes

  • Detect a leading fragment <head> after SSR block markers, locate its closing tag past quoted child attributes, comments, and script/style text, and preserve the existing document doctype behavior.
  • Document the SSR preamble and the supported separate-head, body-root hydration route; test buffered, static, prerendered, streamed, nested-head, scoped-style, and hydration behavior.
  • Guard the SEO diagnostic so bundlers eliminate its effect and counter in production, while development browser builds still report misuse and unbundled hosts without process fail safely.
  • Exercise packed consumers with postcss: ^8.5.28 and report the resolved version, without a workspace override.

Validation

  • pnpm sync (no generated diff)
  • Scoped pnpm format:files:check and core/SEO source typechecks
  • SSR and hydration suites in development and production modes: 464 tests; focused SSR regression rerun on the final scanner: 152 tests
  • SEO and SEO SSR suites: 108 tests; production bundle regression passed again after final integration
  • Package-pack canaries: 30 tests; independent strict tsc and tsrx-tsc consumer reproduction fails on PostCSS 8.5.27 and passes on 8.5.28
  • Current-head CI validate publishable packages, including the packed-consumer phase. The local run packed all tarballs but could not install consumers because this host's npm mirror lacks several versions already required by main (@tsrx/[email protected], @tsrx/[email protected], [email protected]).
  • Repository-wide pnpm test, pnpm typecheck, and pnpm format:check (targeted alternatives above)

Risk / follow-ups

  • A fragment <head>/<body> preamble composed into a host-owned <html> is an SSR-only shape; hydrating that fragment as the Document root is not supported. The documented body-root/separate-head path adopts and updates metadata in the hydration regression.
  • Production streaming benchmark output bytes and chunk counts were unchanged. A same-process 100-sample paired comparison measured about 1.9% higher median CPU-800 time, small relative to observed run-order variation; no speed claim is made.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Core SSR head insertion and streaming shell assembly change markup shape for fragment preambles; incorrect </head> detection could misplace title/meta/link, though new edge-case tests mitigate that.

Overview
SSR hoisted metadata now splices into a leading authored <head> on fragment roots (not only full <html> documents), for buffered and streaming renders. Streaming also places leading scoped styles inside that head; fragment preambles still skip the streaming doctype and injection document-tail mode. Closing </head> is found with a quote-aware scan so false matches inside scripts, styles, and comments do not break folding.

@octanejs/seo restructures the stray <Head> diagnostic so useEffect runs only when NODE_ENV !== 'production', letting production browser bundles drop the warning; hosts without process skip safely via try/catch. Docs describe fragment-head SSR vs hydrating with headChannel: 'separate' on a body root.

Packed-consumer tooling drops the PostCSS 8.5.26 pin and relies on ^8.5.28. New SSR, hydration, and esbuild production-bundle tests cover the above.

Reviewed by Cursor Bugbot for commit 006531f. Bugbot is set up for automated code reviews on this repo. Configure here.

@domgan-oai
domgan-oai marked this pull request as ready for review September 10, 2026 23:22
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant