Skip to content

fix: preserve context across control boundaries - #152

Merged
smiggleworth merged 1 commit into
mainfrom
fix/for-scope-context-propagation
Jul 27, 2026
Merged

fix: preserve context across control boundaries#152
smiggleworth merged 1 commit into
mainfrom
fix/for-scope-context-propagation

Conversation

@smiggleworth

@smiggleworth smiggleworth commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve component scope context across For, Show, and Case in DOM rendering, synchronous SSR, and hydration verification
  • refresh existing For-owned item scopes transactionally when provider context changes while rendering empty-list fallbacks exactly once
  • preserve nested provider precedence while rebasing reused vnode frames away from stale outer providers
  • avoid traversing and stamping plain user objects in array-valued vnode props
  • preserve every node in component-owned multi-node ranges during full parent reconciliation
  • accept readonly arrays and readonly-array accessors in For
  • compare context frames semantically so unrelated parent updates keep stable keyed rows stable
  • bump @askrjs/askr to 0.0.75

This supplies the owning runtime fix for askrjs/askr-ui#14. The UI issue remains open until its downstream regression PR and package release complete.

Validation

  • npm run check (35 repository checks, 151 unit tests, 1,257 jsdom tests, 40 browser tests, build and artifact validation)
  • npm run bench:tier1
  • packed patched core installed into askr-ui; focused ToggleGroup behavior passes

Regression coverage

  • initial and updated provider context through For
  • empty For fallback renders once per provider update and updates live DOM text
  • initial provider context through Show and Case
  • SSR and hydration verification through For, Show, and Case
  • nested provider precedence inside For child scopes
  • stale outer frame rebasing retains nested provider values
  • stable keyed For rows do not rerender for unrelated parent state
  • plain objects in array-valued component props remain unmodified
  • component-owned multi-node ranges survive parent reconciliation
  • direct and accessor readonly For sources, including frozen arrays
  • keyed computed-array children remain supported

Copilot AI review requested due to automatic review settings July 27, 2026 14:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes context propagation across control-boundary primitives (For/Show/Case) so child scopes preserve the correct provider frame, including transactional refresh of stable keyed For rows when provider context changes. It also updates regression coverage and bumps the package version to 0.0.75.

Changes:

  • Propagate and semantically compare context frames for control boundaries so stable keyed For rows stay stable on unrelated parent updates.
  • Refresh For-owned child scopes transactionally when the provider context frame changes.
  • Add jsdom regression tests covering For/Show/Case context preservation and stability; bump version + docs.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/jsdom/renderer/context-frame-invariants.test.tsx Adds regression coverage for context frames across For/Show/Case and stable keyed behavior.
src/runtime/for-scopes.ts Assigns For-owned child scopes an explicit ownerFrame and adds refreshForContextScopes.
src/runtime/for-internal.ts Tracks _contextFrame/_contextFrameChanged on For state and triggers transactional refresh when needed.
src/runtime/control.ts Ensures Show/Case branch scopes inherit the boundary’s context frame when created.
src/runtime/context.ts Adds haveEquivalentContextFrames for semantic context-frame comparison.
src/runtime/child-scope.ts Marks rendered vnode trees with the scope’s ownerFrame to preserve context metadata.
src/renderer/reconcile-resolution.ts Uses getControlBoundaryState() (frame-aware) for control-boundary resolution.
src/renderer/evaluate-reconcile.ts Centralizes control-boundary evaluation/state access via boundary helpers.
src/renderer/boundary-state.ts Propagates vnode context frames into control boundary state/scopes and detects For frame changes.
package.json Bumps package version to 0.0.75.
package-lock.json Updates lockfile version metadata to 0.0.75.
docs/guides/platform-recipes.md Updates documented version contract to 0.0.75.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/renderer/boundary-state.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Comment thread src/runtime/child-scope.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Comment thread src/runtime/context.ts
Comment thread src/runtime/for-scopes.ts
@smiggleworth
smiggleworth force-pushed the fix/for-scope-context-propagation branch from b5077c8 to a74c3c1 Compare July 27, 2026 15:13
@smiggleworth

Copy link
Copy Markdown
Contributor Author

@copilot review

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@copilot review

Reviewed the latest commit set on this branch; I don’t have additional code changes to request at this time.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 24 changed files in this pull request and generated no new comments.

@smiggleworth
smiggleworth merged commit 2033126 into main Jul 27, 2026
5 checks passed
@smiggleworth
smiggleworth deleted the fix/for-scope-context-propagation branch July 27, 2026 15:21
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.

3 participants