Skip to content

Capture forwarded React Native button identity in AutoLogging - #313

Merged
schwartzmx merged 2 commits into
meta:mainfrom
schwartzmx:fix/react-native-descendant-identity
Nov 16, 2026
Merged

schwartzmx merged 2 commits into
meta:mainfrom
schwartzmx:fix/react-native-descendant-identity

Conversation

@schwartzmx

Copy link
Copy Markdown
Member

Composite controls often receive an intercepted handler before forwarding it to an inner Pressable. Previously, Hyperion skipped that already-instrumented handler on the inner element, missing its explicit testID and accessibility label. Events could therefore identify only the outer component name despite meaningful identity being available inside.

  • 7fc40dc6 — Use forwarded element identity for React Native UI events
  • 3d2e3a0c — Tighten forwarded UI labels and mixed-handler identity

--

  • npm test --workspace hyperion-react-native -- --watchman=false --runInBand --coverage=false — 130 passed; 3 benchmark tests skipped in the ordinary run.
  • npm test --workspace hyperion-autologging -- --watchman=false --runInBand --coverage=false — 72 passed.
  • npm run benchmark:runtime --workspace hyperion-react-native — all 3 benchmark tests passed within existing budgets.
  • npm run build:mobile — passed, including workspace TypeScript checks and artifact validation.
  • Targeted ESLint and Prettier checks — passed.

- Track wrapped handlers in a WeakMap associated with their owner runtime state.
- Capture missing testID and element text from the first eligible forwarded descendant.
- Prefer explicit outer identity and preserve label provenance and sensitivity annotations.
- Refresh descendant identity on owner rerenders and independently for keyed descendants.
- Preserve stable handler wrappers, application callbacks, and sibling isolation.
- Accept stringifiable labels while isolating conversion failures.
- Add forwarding regressions, test-app controls, and render/heap benchmarks.
- Document the independent-update limitation for unkeyed same-type descendants.
- Preserve public APIs and existing web implementation.

Validation:
- React Native tests: 121 passed.
- Web AutoLogging tests: 72 passed.
- React Native test-app API tests: 26 passed.
- TypeScript, targeted ESLint/Prettier, build:mobile, and runtime benchmarks passed.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 16, 2026
@schwartzmx
schwartzmx requested a review from reshadi November 16, 2026 17:40
Comment on lines +155 to +171
if (value == null) return undefined;
if (typeof value === 'string') return value;
try {
if (typeof value !== 'number') {
if (typeof value !== 'object') return undefined;
const toString = value.toString;
if (
typeof toString !== 'function' ||
toString === Object.prototype.toString
)
return undefined;
}
const text = String(value);
return text.length === 0 ? undefined : text;
} catch {
return undefined;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This might be much more readable if you use a switch (typeof value). It also means you compute typeof value only once.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call. Updated in latest push

- Accept strings, numbers, and custom-stringifiable objects without logging plain objects as labels.
- Isolate failed label conversions and preserve provenance and sensitivity annotations.
- Observe forwarded handlers independently of raw handler ordering in mixed controls.
- Add rejection, numeric-label, and mixed-handler ordering regressions.
- Document unresolved descendant lifecycle and independent unkeyed update limitations.
- Preserve public APIs and web implementation.

Validation: 130 React Native tests and 72 web AutoLogging tests passed; TypeScript, targeted ESLint/Prettier, mobile build, and all three runtime/heap benchmarks passed.
@schwartzmx
schwartzmx force-pushed the fix/react-native-descendant-identity branch from 3d2e3a0 to acfa50b Compare November 16, 2026 20:07
default:
return undefined;
}
const text = String(value);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

String(x) does a bunch of coercion by itself (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion).

I just noticed you're calling it here, so check if you're doing extra work that the function does anyways.

@schwartzmx
schwartzmx merged commit f7c7132 into meta:main Nov 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants