Skip to content

feat: Reject Strong render-time state getter calls - #1031

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:feat/strong-render-state-getter-1027
Sep 10, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:feat/strong-render-state-getter-1027

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Why

The getter can observe scheduled state that differs from the current render snapshot. Rendering should read the tuple's first member; events, effects, and deferred callbacks can use the getter for the latest value.

Changes

  • Track index 2 from useState, useReducer, and useLinkedState through tuple aliases, destructuring, direct indexing, and synchronous helper arguments/defaults.
  • Report a source-located OCTANE_STRONG_RENDER_STATE_GETTER_CALL error only when the known getter is invoked during a Strong render.
  • Add positive and negative compiler tests, Volar mapping coverage, client/server output parity checks, documentation, and patch changesets for octane and @octanejs/mcp-server.

Validation

  • pnpm format:check (scoped formatting check passed)
  • pnpm typecheck
  • pnpm test (full repository CI runs when the PR is ready)
  • Targeted tests: pnpm exec vitest run packages/octane/tests/compiler --reporter=dot --silent=passed-only — 55 files passed, 1,927 tests passed, 14 expected failures.
  • pnpm format:files:check on changed files; pnpm sync; git diff --check.
  • Paired baseline/candidate compiler throughput with explicit GC: output hashes identical; 10/100 component deltas within noise, 1,000 component delta changed sign across repeats (inconclusive; no reproducible regression).

Risk / follow-ups

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
Adds compile-time enforcement in Strong modules for a previously legal Octane API pattern; valid emitted code is unchanged, but apps on Strong may need to stop calling getters during render.

Overview
Strong mode now treats render-time calls to the third-tuple getter from useState, useReducer, and useLinkedState as compile errors (OCTANE_STRONG_RENDER_STATE_GETTER_CALL), alongside the existing ref-read guard. The analyzer tracks index-2 getters through destructuring, tuple indexing/aliases, parameters, and synchronous helper paths, while events, effects, deferred work, and compatibility modules stay unchanged.

Implementation extends strong-mode.js with getter bindings and folds ref-read checks under currentFunctionChecksRenderReads. Docs, MCP skill text, website build-tools page, a patch changeset, and broad compiler/Volar tests document and lock the snapshot-safe pattern (render from tuple index 0; use the getter outside render).

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

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 feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant