Skip to content

spec(react-component-runtime): a shared concern is extended in its hook, and components call it once - #9139

Merged
cixzhang merged 5 commits into
mainfrom
spec/shared-concern-one-call
Oct 31, 2026
Merged

cixzhang merged 5 commits into
mainfrom
spec/shared-concern-one-call

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Behavior Core owns in one shared hook or utility, such as focus-ring modality, should be the same in every component and frame. This rule keeps that logic in the shared owner, so a component does not split it between the hook and an effect of its own.

Change

architecture:react-component-runtime gains INV16: in @astryxdesign/core, a concern Core already owns in a shared hook or utility is extended there; a component calls it once and adds no effect, listener, or tracker of its own for that concern. INV16 names known implementation gaps (not exhaustive): Dialog keeps its own modality Effect for a second document beside the shared modality hook; MobileNav keeps its own page scroll lock Effect instead of useScrollLock; BottomSheet's gestures and mobile keyboard, DateInput's month scroller, DropdownMenu's overflow check, Layer positioning, Popover, and Table's sticky columns each keep their own ResizeObserver beside sharedResizeObserver; and other Core sites keep their own MutationObserver beside sharedMutationObserver. The verification table gains one INV16 review row: a Core component that keeps its own effect, listener, or tracker for such a concern fails, whether or not it also calls the shared owner. INV16 is added to the record's react-runtime review routing.

Writing rubric results

R1 narration: none; INV16, its gap list, and its row are present-tense statements about the system.
R2 research: none.
R3 evidence: the INV16 row names a review check, not a pull request, issue, or commit.
R4 rejected alternatives: none.
R5 change references: none.
R6 open questions: none.

@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Error Error Oct 31, 2026 3:56pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 31, 2026
@astracat-bot

astracat-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 31, 2026, 5:04 PM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Oct 31, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec a1562d4

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Oct 31, 2026
@cixzhang cixzhang closed this Oct 31, 2026
@cixzhang cixzhang reopened this Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Preview: the links below open this branch's latest Vercel deployment, which can trail a new push until that push's deployment is ready.

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: The accessibility audit did not run on this pull request. It runs after merges to main and before each release; pull requests that touch components run it with the ci:heavy-lanes label.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

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.

Changes requested: the direction of INV16 is approved, but its wording conflicts with other claims in the same record and needs three small edits before merging.

  • INV16 reaches Lab through applies_to, yet INV10 and INV11 tell components outside Core to keep their own Effect or listener (Lab's ChatTypingIndicator calls useAnnounce and keeps one Effect), so scope INV16 to Core or carve those cases out.
  • Dialog already calls useInteractionModalityTracking() and runs its own trackInteractionModalityIn Effect, so INV16 needs an implementation-gap note, and the description should not say modality already lives in one place.
  • The INV16 row reviews only components that call the shared owner; widen it so a component that keeps its own listener without calling the owner also fails.

[Automated review]

Comment on lines +260 to +263
- **INV16 — A shared concern is extended in its owner and called once.** A
concern Core already owns in a shared hook or utility is extended there; a
component calls it once and adds no effect, listener, or tracker of its own
for that concern.

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.

As worded this reaches Lab too (applies_to includes packages/lab/src/), but INV10 tells packages outside Core to "keep one well-behaved Effect per adopter" and INV11 tells a component outside Core to keep one keyboard listener. Lab's ChatTypingIndicator (calls useAnnounce, keeps its own Effect) would fail INV16 while following INV10. Suggest scoping it like INV10-INV12 ("In @astryxdesign/core, …") or adding "A component outside Core that cannot import the owner follows that concern's own invariant (INV10, INV11)." Dialog also fails this today (useInteractionModalityTracking() plus its own trackInteractionModalityIn Effect), so an implementation-gap note would keep the record honest.

| INV12 | Source boundary check plus real-browser tests on a throttled phone profile over a 10-level by 50-sibling tree and two changes in one frame | A per-frame height or layout, a walk past the area or into a subtree other than `display: contents`, an element moved twice for one frame, an added element other than a swap's one transient copy, that copy left after the swap ends, or an exported reporting function fails |
| INV13 | Source boundary check plus bundle analysis of a page with several touch components, and real-browser tests on a throttled phone profile, under a fine pointer, and on a hybrid device | A second copy of a touch module on one page, a component bundling its own copy of a module's primitive, an `import()` of a module in a component, a public export or doc entry for the modules, an install call or installed check in the public API, a gesture listener in a component that uses no gesture, or an idle document listener outside a press other than the one shared press controller and the one stray-click swallower, an import of `@astryxdesign/core/internal/*` outside Core and Lab, a class outside the recognizer family, an `instanceof` check on a recognizer, an internal factory with a public factory's name, or a direct module import for a job the public layer covers fails |
| INV15 | Unit tests of the animator's value mode and real-browser proofs of its adopters | A value off its motion role, a count past the component's swap size, a count or cross-fade under reduced motion with a coarse or a fine pointer, an intermediate value announced, or a public export fails |
| INV16 | Review of each component that calls a shared concern's hook or utility | A component that calls a shared concern's hook or utility and also registers its own effect, listener, or tracker for that concern fails |

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 row only reviews components that call the owner and only fails one that calls it and also adds its own effect. A component that keeps its own listener for the concern without calling the owner passes, though INV16 forbids it. Suggest: evidence "Review of each component that handles a concern a shared hook or utility owns", failure "…registers its own effect, listener, or tracker for that concern, whether or not it also calls the owner, fails".

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec ba0fa14

@astracat-bot astracat-bot Bot left a comment

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.

Changes requested: INV16 is now scoped to Core, records the Dialog gap and catches a component that skips the shared owner, but its implementation-gap note still reads as if Dialog were the only Core component that fails it. At this head MobileNav locks page scroll in its own Effect (MobileNav.tsx:588) instead of the shared useScrollLock, and DateInput's month scroller (MonthScroller.tsx:418), DropdownMenu's overflow check, Layer positioning and Table's sticky columns each create their own ResizeObserver beside sharedResizeObserver. Please add these to INV16's gap note and to the description's "one implementation gap", or name the concerns INV16 covers so they fall outside it.

[Automated review]

Comment on lines +263 to +265
tracker of its own for that concern. (Implementation gap: Dialog calls
`useInteractionModalityTracking()` and also keeps its own Effect that tracks
modality in a second document.)

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 note names only Dialog, but the widened row at line 417 also fails MobileNav, which locks page scroll in its own Effect (MobileNav.tsx:588) instead of useScrollLock, and the per-instance ResizeObservers in DateInput's MonthScroller.tsx:418, DropdownMenu's useMenuOverflow.ts:47, useLayer.tsx:810 and useTableStickyColumns.tsx:581, beside sharedResizeObserver (line 378). Suggest listing them here, e.g. "(Implementation gaps: Dialog …; MobileNav locks page scroll in its own Effect beside useScrollLock; DateInput's month scroller, DropdownMenu's overflow check, Layer positioning and Table sticky columns create their own ResizeObserver beside sharedResizeObserver.)"

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Oct 31, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec bdaf2d3

@astracat-bot astracat-bot Bot left a comment

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.

Changes requested: INV16's gap note now names Dialog, MobileNav and four ResizeObserver sites, but the note and the description still present that list as complete. BottomSheet (useSheetGestures.ts:738, useMobileKeyboard.ts:380) and Popover (Popover.tsx:751) also keep their own ResizeObserver beside sharedResizeObserver, and ten Core sites keep their own MutationObserver beside sharedMutationObserver. Please reword the note as non-exhaustive ("Known implementation gaps include: …"), add the BottomSheet and Popover observers to the ResizeObserver gap, and change the description's "lists the known implementation gaps" to match.

[Automated review]

Comment on lines +263 to +268
tracker of its own for that concern. (Implementation gaps: Dialog calls
`useInteractionModalityTracking()` and also keeps its own Effect that tracks
modality in a second document; MobileNav keeps its own page scroll lock
Effect instead of `useScrollLock`; and DateInput's month scroller,
DropdownMenu's overflow check, Layer positioning, and Table's sticky columns
each keep their own `ResizeObserver` beside `sharedResizeObserver`.)

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 list reads as complete, but BottomSheet (useSheetGestures.ts:738, useMobileKeyboard.ts:380) and Popover (Popover.tsx:751) also keep their own ResizeObserver beside sharedResizeObserver. Ten Core sites keep their own MutationObserver beside sharedMutationObserver (for example useMenuOverflow.ts:51, Popover.tsx:755, useToast.tsx:54). Suggest "(Known implementation gaps include: …; BottomSheet's sheet height and keyboard reveal, DateInput's month scroller, DropdownMenu's overflow check, Layer positioning, Popover's overflow check, and Table's sticky columns each keep their own ResizeObserver beside sharedResizeObserver.)"

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Oct 31, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec e36e28a

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Oct 31, 2026

@astracat-bot astracat-bot Bot left a comment

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.

Recommending approval: INV16 is owner-approved at this head, and the gap note now reads as non-exhaustive and covers the BottomSheet and Popover observers raised earlier. Knowledge validation passes, and no other change is needed before merge.

[Automated review]

@cixzhang
cixzhang merged commit f29e90e into main Oct 31, 2026
49 of 50 checks passed
cixzhang added a commit that referenced this pull request Oct 31, 2026
…ce and modality tracking

With #9139's INV16 on main, the runtime record owns two more concerns:
slot-presence (isRenderable, or a typeof ... !== 'boolean' check) and
modality-tracking (useInteractionModalityTracking, or a pointerdown or
keydown listener) both route INV16, beside interaction-modality's own
INV1-INV3 for modality.

Tests: #8236's Badge check routes INV16 naming isRenderable; #8381's diff
now also routes INV16.
@github-actions
github-actions Bot deleted the spec/shared-concern-one-call branch November 1, 2026 06:05

This branch had an error being deployed

1 failed deployment
Preview — e36e28a4 Deployed Oct 31, 2026 by vercel[bot]
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 Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant