Skip to content

fix(web): update the wrapper's refs before layout effects - #33

Merged
SectionTN merged 1 commit into
mainfrom
fix/web-handlers-before-layout
Nov 18, 2026
Merged

SectionTN merged 1 commit into
mainfrom
fix/web-handlers-before-layout

Conversation

@SectionTN

@SectionTN SectionTN commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

#32 moved the wrapper's handler and prop refs to a layout effect. layout effects run in tree order, so a component earlier in the tree that focused the editor from its own layout effect still got the onFocus from the commit before. both refs are written in an insertion effect now, React runs those before any layout effect, so the refs are current for every layout effect and still never hold a dropped render's values.

The handler and prop refs were written in a layout effect, which runs in tree
order. A component earlier in the tree that focused the editor from its own
layout effect reached the onFocus of the previous commit. The refs are now
written in an insertion effect, which React runs before every layout effect.
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

CodeEditor now updates callback-handler and editor-props refs with useInsertionEffect instead of useLayoutEffect. A regression test checks that a sibling layout effect can focus the editor and trigger its onFocus callback during the same commit.

Changes: Editor ref timing

Layer / File(s) Summary
Insertion-effect ref updates and focus test
src/web/CodeEditor.tsx, src/web/__tests__/CodeEditor.test.tsx
Callback-handler and editor-props refs now update with useInsertionEffect. The test checks that focusing the editor from a sibling layout effect triggers onFocus for that update.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to bb5bb

The change makes the editor's focus and callback handlers current when another component focuses it during the same update. No concrete merge risk was found.

Security architecture risk: Minimal · up to bb5bb

The update corrects callback timing without expanding the editor’s permissions or public API. The inspected change establishes no introduced or worsened risk to security, ownership, or failure containment.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed behavior is bounded to publication of application-supplied callbacks and editor props within existing web wrapper instances. The inspected path adds no new caller, credential access, service connection, or privileged operation.

Trust Boundaries and Controls

  • inferred — Focus events continue to invoke callbacks supplied by the embedding application through the existing view and handler-ref chain. Earlier ref publication changes callback freshness, not who can register callbacks or the authority under which they execute.

Resilience and Maintainability Implications

  • observed — The changed effects only overwrite refs; they acquire no resources and introduce no cleanup or asynchronous transition. Existing loading, queued-operation settlement, and unmount cleanup remain unchanged by the timing adjustment.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the wrapper's handler and prop refs are now updated before layout effects run. The raw summary confirms CodeEditor.tsx switches from useLayoutEffect to useInsertionEff…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the wrapper's handler and prop refs are now updated before layout effects run. The raw summary confirms CodeEditor.tsx switches from useLayoutEffect to useInsertionEffect for these ref updates, and the objectives describe the same fix for a stale onFocus call. The title is specific and matches the changeset, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6704fe62-b24c-4ed0-8f1f-99ca173f6523
Commits

Reviewing files that changed from the base of the PR and between 2e064a3 and bb5bb38.

Files selected for processing: 2

  • src/web/CodeEditor.tsx
  • src/web/__tests__/CodeEditor.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@SectionTN
SectionTN merged commit bb5bb38 into main Nov 18, 2026
10 checks passed
@SectionTN
SectionTN deleted the fix/web-handlers-before-layout branch November 18, 2026 15:13
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.

1 participant