feat(injected-helpers): extra fiber roots for portal modal support (closes #126 Gap B)#181
Merged
Conversation
…akeSandbox Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…als / fiber duck-type support Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nts per review - Restore B143 LogBox historical rationale to findAllRootFibers (lost in the original refactor) - Restore Gemini A3 try/catch teardown rationale to iterateAllRoots - Defer the negative-rendererId claim to Task 4 (avoid forward-leaning doc that contradicts the code at this SHA) - Grammar nit: 'Calling cb returning truthy' → 'A truthy return from cb' No behavior change — comments only. 1518/1518 passing.
… + non-function resolver
… coverage (GH #126 Gap B)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes Gap B of #126 —
cdp_interact press testID="..."failing on fields insidereact-native-actions-sheetmodals (and other portal-mounted React subtrees) because their fiber roots are not in React DevTools'getFiberRoots()registry.Gap A (TextField wrapper / RHF Controller) was shipped in #179 via
cdp_interact action="setFieldValue".What changed
iterateAllRoots(cb)primitive ininjected-helpers.ts. Owns the renderer-iteration logic thatforEachRootFiberandfindAllRootFiberswere duplicating, plus the new extra-roots step.extractFiberFromInstance(inst)helper turns user-provided component instances into fibers via three accepted shapes:_reactInternals(modern React),_reactInternalFiber(legacy React), or already-a-fiber duck-type (escape hatch).globalThis.__RN_AGENT_EXTRA_ROOTS__is the user-facing opt-in: set it to a function returning component instances. Called fresh on every fiber-root scan.Architecture
iterateAllRoots) — DRY across both wrappers.rendererId: -1marks extra-roots in the collector path.__NAV_REF__and__ZUSTAND_STORES__(no console warnings on misconfig).Test plan
gh-126-extra-roots.test.jsand +1 drift-guard infind-active-renderer-migration.test.js)extractFiberFromInstancecovers all 3 input shapes + rejection cases (including dual-key duck-type rejecting generator-like objects with only.return)iterateAllRootsextra-roots step covers partial-failure, null-mixing, throwing resolver, non-array return, undefined resolver, sparse-array holes, non-function resolver (typeof guard discrimination)forEachRootFiberdelegation preserves short-circuit through to extra-rootscdp_interact press testIDagainst a component reachable ONLY via extra-roots fires itsonPress(the user-visible fix)iterateAllRoots) verified by full existing-suite pass with NO behavior change before Task 4 wired extra-rootsreact-native-actions-sheetmodal — not blocking merge per spec §11Out of scope
onCommitFiberRoot(rejected in brainstorm — too deep into internals; opt-in is enough)getTree()default path (no filter) does NOT see extra-roots — deliberate, see spec §5/doctorprobe for portal-library deps — rejected in brainstormRefs
docs/superpowers/specs/2026-05-27-gh-126-gap-b-extra-roots-design.md(workspace repo)docs/superpowers/plans/2026-05-27-gh-126-gap-b-extra-roots.md(workspace repo)🤖 Generated with Claude Code