fix(interact): cdp_interact value-injection for Controller inputs (#336)#372
Merged
Conversation
…ler inputs Bug #2: type-match in setFieldValue (coerce number->string only when the field currently holds a string), preserving the intentional number/boolean passthrough. Bug #1: optional value on press (onPress(value) instead of the synthetic event) for value-bearing controls like radios/chips. HELPERS_VERSION 32->33. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… fix harness wording Codex + Gemini reviewed the plan: no blocking/important findings. One unanimous advisory applied — build the press result object imperatively (var + assignment) instead of object-spread, matching the injected-helpers' deliberate ES5 style (safe on older Hermes). Spec wording corrected: tests inline the runInteract VM harness copied from gh-126, not a shared inject-harness.js. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…; HELPERS_VERSION 33 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…oc value/action Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…n patch) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…field holds a string Final-review finding: the setFieldValue string-coercion keys on the field's current value, so string fields want a "" default. Describe now says so. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Closes #336.
Problem
cdp_interactcorrupted react-hook-formController-wrapped inputs two ways:press testID=<radio>calledonPress({nativeEvent:{}}); for a value-bearing control whoseonPressroutes to the Controller'sonChange, the event object became the field value → Zod "received object".setFieldValue value="15112345678"reachedsetValueas the number15112345678→z.string()fails "Expected string, received number".Root cause (verified)
injected-helpers.tspress block passed a synthetic event unconditionally.JSON.stringifypreserves types and the helper forwardsvalueverbatim. The trap is thevalueschema union admittingnumber, so a digit-string is emitted/parsed as a number. The number/boolean passthrough is an intentional feature (gh-126asserts it), so the fix must preserve it.Fix
setFieldValuetype-matches: if the injected value is a number and the field currently holds a string (formReturn.getValues(name)), coerce back to string. Number/boolean fields (current value number/undefined) are untouched; agetValuesthrow → no coercion. Result carriescoercedToString.pressgains optionalvalue: when provided,onPress(value)instead of the synthetic event (built imperatively in ES5 to match the injected-helpers' deliberate no-spread style). Novalue→ byte-identical to before.HELPERS_VERSION32 → 33 (re-inject);index.tsschema descriptions updated.Testing
dist/injected-helpers.jsin a VM against realistic RHF-shaped fiber trees (setFieldValue coerce/preserve/throw-safe/string-unchanged; press with-value/without-value/no-handler). Full suite 2537/2537.Docs
Spec + TDD plan under
docs/superpowers/{specs,plans}/2026-06-30-336-*.🤖 Generated with Claude Code