Skip to content

Hooks parity fixes, SSR render options, user-facing MCP rework - #6

Closed
WebEferen wants to merge 5 commits into
mainfrom
hooks-parity-ssr-mcp
Closed

WebEferen wants to merge 5 commits into
mainfrom
hooks-parity-ssr-mcp

Conversation

@WebEferen

@WebEferen WebEferen commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three streams of work: React-parity fixes and new conformance coverage for useState/useReducer/useEffect (including render-phase derived state and the ReactHooks eager-bailout edge cases), an SSR options/cleanup pass, and a rework of the MCP server around Octane users.

Runtime fixes (React parity)

  • useReducer no longer eagerly bails. React only eager-bails useState's setter; a dispatch whose reducer returns Object.is-equal state still renders the component once (children then bail). Per ReactHooksWithNoopRenderer-test.js:3889, listed as a High gap in the parity plan. The old test that encoded the eager bail as parity is corrected.
  • Render-phase update cap. An unguarded setState during render used to grow the queue forever and hang the flush. drainQueue now counts per-block renders per drain and throws Too many re-renders. Octane limits the number of renders to prevent an infinite loop. at 25 (React's cap), routed through @try/ErrorBoundary like any render error. Guarded derived-state patterns are unaffected.

New conformance coverage

  • conformance/derived-state.test.ts (+ fixture): derived state from props during render (converged before commit, exact body-run counts), multi-step convergence, the new re-render cap (bare and caught by @try), initial value is mount-only, same-value sets skip renders and [state]-keyed effects, NaN bail then real change, chained updaters observing pending state, set-then-revert renders once, cleanup sees the previous closure while setup sees the fresh one.
  • conformance/eager-bailout.test.ts (+ fixture), ported from ReactHooks-test.internal.js: same-state sets do not re-render children, re-fire deps-less layout effects, or commit; bail repeatedly; a later real change still renders; a context change in the same batch defeats the bailout; no-op reducer actions apply in order when batched with real ones. One benign divergence is documented inline: React re-enters the render phase once more after the last real update (fiber double-buffering) before bailing; Octane skips that extra parent-body run. Rebase-of-skipped-updates cases are concurrent-only and N/A to the sync scheduler.
  • tests/_helpers.ts: a throwing initial mount now detaches its container; a leaked duplicate id was breaking jsdom's #id selector fast path for later tests in the same file.
  • Parity plan updated: the two hook rows are marked Done with pointers to the pinning tests.

SSR

  • render(component, props?, options?) gains a RenderOptions third argument (an earlier commit on this branch renamed the entry to renderToString; that rename was reverted per review, render stays the public name): signal (AbortSignal; rejects a suspended render when the request dies), nonce (CSP nonce stamped on the inline <style> tags and the suspense seed script, attribute-escaped), timeoutMs (per-render suspense settle deadline). Covered by ssr-render-api.test.ts.
  • Fixed stale docstrings claiming head is always empty (head hoisting shipped long ago); octane/server now documents which exports are the compiler's private ABI.
  • Fixed the vite plugin dev RPC path: it loads executeServerFunction via ssrLoadModule('octane/server') (the intended architecture, mirroring ripple/server), but octane/server never exported it, so any module server call crashed. The executor is now implemented in octane/server with the devalue wire format @ripple-ts/adapter's client stub defines (devalue-encoded argument array in, devalue-encoded { value } envelope out), pinned by server-rpc.test.ts including a guard that the encoding is devalue, not plain JSON.
  • New docs/ssr.md: full server API guide plus the honest roadmap of missing pieces (streaming, out-of-order Suspense flushing, selective hydration, framework-level data serialization, production server build, error hooks).

MCP server (0.2.0)

The published package was broken outside the monorepo (it shipped only src/ but read skills from .ai/ at the repo root) and everything it served was maintainer-facing. Reworked around Octane users:

  • Bundled skills ship in the package: bridge-react-package (full porting workflow incl. the subSlot pattern), migrate-react-component (JSX to .tsrx conversion table), react-divergences, setup-ssr.
  • octane_bridge_react_package: statically scans an installed React package (or any source dir) and returns a compatibility report: per-API mapping (same / rewrite / unsupported), class-component detection, vanilla-core detection, whether an official @octanejs/* binding exists, a verdict, and a step-by-step plan. octane_bindings lists the eight official ports.
  • Maintainer tools (project map, triage, validate plan, scaffold, benchmarks, issue context) register only when an octane monorepo checkout is detected.
  • Staleness fixes throughout: radix in path triage/project map/skills/root README.

Validation

  • pnpm test: full workspace green (all bindings included)
  • pnpm typecheck, pnpm format:check: clean
  • Changesets added (octane, @octanejs/vite-plugin: patch; @octanejs/mcp-server: minor)

WebEferen added 2 commits July 3, 2026 21:56
Runtime (React parity):
- useReducer dispatch no longer eagerly bails on Object.is-equal state; a
  no-op action renders the component once, per
  ReactHooksWithNoopRenderer-test.js:3889.
- Unguarded render-phase setState now throws "Too many re-renders" after 25
  same-block re-renders in one drain (catchable by @try/ErrorBoundary)
  instead of hanging the flush.

Conformance tests:
- conformance/derived-state.test.ts: guarded render-phase updates (derived
  state from props, multi-step convergence), the new re-render cap, initial
  value is mount-only, same-value sets skip renders and effects,
  bail-then-change, updater queues observe pending state, set-then-revert,
  cleanup/setup closure freshness.
- conformance/eager-bailout.test.ts: ReactHooks-test.internal.js edges:
  same-state sets skip child renders/effects/commit and bail repeatedly,
  context change defeats the bailout, no-op reducer actions apply in order
  within a batch. React's extra post-update render (double-buffering
  artifact) is documented as a benign divergence.
- tests/_helpers.ts: a throwing initial mount detaches its container so
  leaked duplicate ids cannot break later #id selector queries.

SSR:
- renderToString(component, props?, options?) is the public entry (render
  kept as deprecated alias) with RenderOptions: signal (AbortSignal), nonce
  (CSP nonce on inline style/seed tags), timeoutMs (per-render suspense
  deadline). Covered in ssr-render-api.test.ts.
- Fixed stale "head is empty" docstrings, marked the ssr* exports as the
  compiler's private ABI, fixed the vite plugin dev RPC handler referencing
  a nonexistent executeServerFunction export, new docs/ssr.md with the
  missing-features roadmap (streaming, selective hydration, production
  build).

MCP server (0.2.0):
- Skills now ship inside the npm package (bridge-react-package,
  migrate-react-component, react-divergences, setup-ssr) so the server
  works outside the monorepo checkout.
- New octane_bridge_react_package tool: scans a React package or source dir
  for React API usage and returns an Octane compatibility report (verdict,
  vanilla-core detection, existing @octanejs binding, step-by-step plan);
  octane_bindings lists the official ports.
- Maintainer tools (project map, triage, validate plan, benchmarks, issue
  context) register only when an octane monorepo checkout is detected.
- Staleness fixes: radix binding in path triage, project map, skills, and
  the root README package list.
The interim executeServerFunction used JSON, but the RPC stack is built on
@ripple-ts/adapter, whose client stub encodes the argument array with
devalue and reads the response as a devalue-encoded { value } envelope.
The formats are silently incompatible (devalue's indexed-graph output is
itself valid JSON, so JSON.parse would produce wrong arguments instead of
throwing). Mirror ripple's server implementation with devalue so rich
values (Dates, Maps, undefined, cycles) round-trip and the future compiler
client stub stays compatible.
@WebEferen
WebEferen force-pushed the hooks-parity-ssr-mcp branch from e68e04d to c4c8ad2 Compare July 3, 2026 19:57
Revert the renderToString rename from earlier in this branch: render(
component, props?, options?) stays the single public name, per review
decision. The RenderOptions additions (signal, nonce, timeoutMs) and the
docs/ssr.md guide are unchanged apart from the name; the deprecated alias
and its tests are dropped, and the hacker-news examples return to their
original local `render as renderToString` import.
@WebEferen WebEferen changed the title Hooks parity fixes, SSR renderToString API, user-facing MCP rework Hooks parity fixes, SSR render options, user-facing MCP rework Jul 3, 2026
The vite plugin's original ssrLoadModule('octane/server') wiring was the
intended architecture (mirroring ripple/server, which exports the executor
from the framework so it runs inside the SSR module graph); the bug was
only the missing export on the octane side. Restore the plugin's original
line, implement executeServerFunction in octane/server with the devalue
wire format ripple's client stub defines, move the devalue dependency from
the plugin to octane, and pin the executor with tests including a
client-stub round-trip of Dates/Maps/Sets/undefined and a guard that the
encoding really is devalue, not plain JSON.
@trueadm

trueadm commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Mind fixing the conflicts please?

Brings PR #6 up to date with main. All of this PR's content (module-server RPC,
SSR RenderOptions, render-phase cap + useReducer parity, MCP rework) already
landed on main via PR #7 (the reconciliation onto the new renderToString/
prerender SSR API), so the merged tree equals main and the branch is now
conflict-free. Dropped the stale ssr-render-api.test.ts (superseded on main by
ssr-render-options.test.ts, ported to the new API).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@WebEferen WebEferen closed this Jul 4, 2026
@WebEferen
WebEferen deleted the hooks-parity-ssr-mcp branch July 4, 2026 09:01
@cursor cursor Bot mentioned this pull request Jul 14, 2026
@mrdiyorbek-juraev mrdiyorbek-juraev mentioned this pull request Jul 20, 2026
3 of 5 tasks
@leonidaz leonidaz mentioned this pull request Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants