Skip to content

perf(keyboard): the keyboard height no longer loads the selection lock - #14289

Merged
cixzhang merged 4 commits into
meta:mainfrom
vjeux:keyboard-caret-own-module
Dec 4, 2026
Merged

cixzhang merged 4 commits into
meta:mainfrom
vjeux:keyboard-caret-own-module

Conversation

@vjeux

@vjeux vjeux commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

The keyboard height reads one function of the selection lock: caretAt, the caret query that returns the caret position, a node and an offset, under a client point. It imports that function from utils/selectionLock.ts. The gesture host uses the lock for a drag's selection hold and its press reads, and a few recognizers and controls use it while they hold a press. A page whose lazily loaded code also uses the lock, as a page with a DropdownMenu or a Table does, therefore carries the whole lock in its first load.

The cost grows with code splitting. A bundler puts a module that the page and a lazy chunk share into the page's first load, whole. On #8217's branch at 53239f61, ChatLayout's drag dismissal loads at the first touch, and its gesture code uses the lock. There, before this move, about 5 KB of the lock, minified, stays in the chat page's first load, and this move takes about 1.6 KB gzip off that page (test).

Intended invariant

No behavior change. caretAt's statements are main's, byte for byte; only its comments differ. The keyboard height and the selection lock each import it from its new module, so both read the same function.

Change

  • caretAt moves from utils/selectionLock.ts to a new utils/caretAt.ts, which imports nothing.
  • selectionLock.ts imports caretAt from there for its own press reads, and no longer exports it.
  • keyboard/keyboardHeight.ts imports caretAt from utils/caretAt.ts.
  • architecture:react-component-runtime's Owning code names utils/selectionLock.ts and utils/caretAt.ts.
  • A bundle check in scripts/touch-support-bundle.test.mjs: what DropdownMenu loads at once holds no code of utils/selectionLock.ts.
  • scripts/snap-paging-bundle.test.mjs counts utils/caretAt.ts with the selection lock as the pager's gesture support: the snap-paging hook's gesture host imports the selection lock, which reads the caret with caretAt.
  • A [perf] changeset.

This is maintenance: the change moves the existing caretAt unchanged, apart from its comments, between two internal modules; its record names the new path, and no product behavior changes.

Internal module

utils/caretAt.ts is a new internal module that other modules import, so it is shown here as architecture:knowledge-contracts DEC-22 asks.

  • Usage: caretAt(doc, x, y, shadowRoots) returns the caret position the engine puts at a client point, as {node, offset}, or null when the engine has no caret query or its query finds no caret at that point. Where the engine has caretPositionFromPoint, it looks into the given shadow roots. caretRangeFromPoint, the fallback, takes no shadow roots, so over shadow text it answers at the shadow host. keyboard/keyboardHeight.ts and utils/selectionLock.ts import it.
  • Why it is needed: the keyboard height needs only this caret query. While the query lives in selectionLock.ts, a page that loads the keyboard height and lazily loads code that uses the selection lock carries the whole lock in its first load.
  • Why existing modules are not enough: no other Core module holds a caret query. Considered: keeping it in selectionLock.ts, whose import keeps the whole lock in the first load (about 1.6 to 1.8 KB gzip) of such a page, where no other control on it uses the lock at once; and moving it into keyboardHeight.ts, which would make the selection lock import the keyboard height.
  • Its record: no record named utils/selectionLock.ts by path, so the new Owning code line in architecture:react-component-runtime names both modules.

Evidence

  • Failure before the change: with main's selectionLock.ts and keyboardHeight.ts, the new bundle check fails, because DropdownMenu's first load holds packages/core/src/utils/selectionLock.ts (test).
  • Success after the change: the check passes (test).
  • Product/runtime behavior verified unchanged: the unit suites of the folders that use the keyboard height or the selection lock pass, and so does the Core typecheck (Testing).
  • CI impact: none. No workflow, action or CI script changes.

First-load JavaScript per page: the figures as pnpm size:pages prints them, with base main d2e198b and head 4e16aae54c (this head's code), in bytes minified / gzip (test). The chat and bottomsheet pages are added with --page.

esbuild:

Page (components) Base Head Change
docs (Text, Heading, Link, Card, Divider, List) 217,222 / 71,553 211,961 / 69,781 −5,261 / −1,772
form (Button, IconButton, TextInput, CheckboxInput, Text, Heading, Card) 331,830 / 112,242 331,841 / 112,321 +11 / +79
menu (DropdownMenu, ContextMenu, Button, Text) 404,512 / 138,600 399,223 / 136,928 −5,289 / −1,672
table (Table, Text, Button) 373,921 / 127,281 368,633 / 125,588 −5,288 / −1,693
chat (ChatLayout, ChatComposer, ChatMessageList, Button, Text) 339,810 / 116,679 339,768 / 116,635 −42 / −44
bottomsheet (BottomSheet, Button, Text) 393,514 / 132,890 393,478 / 132,859 −36 / −31

Rolldown (--bundler rolldown):

Page Base Head Change
docs 195,961 / 62,986 195,965 / 62,988 +4 / +2
form 319,327 / 105,961 319,326 / 105,998 −1 / +37
menu 395,217 / 132,285 390,043 / 130,682 −5,174 / −1,603
table 352,198 / 118,387 347,006 / 116,729 −5,192 / −1,658
chat 328,123 / 110,365 328,104 / 110,344 −19 / −21
bottomsheet 381,891 / 125,489 381,857 / 125,463 −34 / −26

Pages with one component, in a second run (--page), base against the same head: DropdownMenu −5,289 / −1,764 with esbuild and −5,174 / −1,595 with Rolldown; Table −5,288 / −1,695 and −5,192 / −1,657; TextInput −42 / −34 and −25 / −131; ChatLayout −42 / −23 and −48 / −46; BottomSheet −42 / −58 and −34 / −12 (test). The gzip figures of one build move by a few bytes between runs.

The move saves bytes only where the bundler kept the selection lock in the page's first load. On docs, esbuild's split build (four first-load chunks) carried the lock at base, and the move takes it out. Rolldown builds docs as one chunk and already tree-shakes the lock out of it at base, so its docs figure barely changes. The form page uses the selection lock itself, so it keeps the lock and pays for one more module: +79 B gzip with esbuild and +37 B with Rolldown.

Scope

Components: utils (selectionLock, caretAt), keyboard (keyboardHeight); records: architecture:react-component-runtime (Owning code)

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Writing rubric results

Over architecture:react-component-runtime: its Owning code gains one line naming utils/selectionLock.ts, the selection lock during a gesture, and utils/caretAt.ts, its caret query, with the two modules that import it, so the keyboard height does not bring the selection lock into a page.

  • R1 narration, R2 research, R3 evidence, R4 rejected alternatives, R5 change references, R6 open questions, R7 project status: none.

Testing

This round, from review, at 7ec7797, on ed56d5e:

  • The changeset says the saving holds only where no other control on the page uses the selection lock at once. Beside a control that does, such as CheckboxInput, NumberInput or Slider, the lock stays in the first load, and the page changes by under 200 bytes.
  • pnpm size:pages --base d2e198be5f --head ed56d5e527, in bytes minified / gzip, for a DropdownMenu with CheckboxInput, NumberInput and Slider, then a Table with the same three: esbuild +58 / −13, +58 / +28, +87 / −8, +125 / +74, +97 / +54 and +133 / +64; Rolldown +52 / +67, +17 / +25, +85 / +130, +48 / −76, +51 / −38 and +100 / +167 (test).
  • Prettier on the changeset and pnpm check:changesets pass. Only the changeset's text changes, so no bundle changes.

This round, from CI, at ed56d5e, on e84b7a7:

  • scripts/snap-paging-bundle.test.mjs listed utils/caretAt.ts as a module that the snap-paging hook adds over Carousel alone and that is not pager code. The hook brings the gesture host, which imports the selection lock, and the lock reads the caret with caretAt: 415 bytes of esbuild's minified output, which sat inside utils/selectionLock.ts before the move. The test now counts caretAt with the selection lock.
  • Red first: at e84b7a7, pnpm exec vitest run --project node scripts/snap-paging-bundle.test.mjs fails 1 of 4, as CI's test-node (2/5) does. At ed56d5e it passes 4 of 4 (test).
  • At ed56d5e: pnpm exec vitest run --project node passes 1,367 files (14 skipped) and 23,678 tests (3 expected fail, 108 skipped), and Prettier on the test file passes. pnpm size:pages --base e84b7a7090 --head ed56d5e527 is +0 / +0 on docs, form, menu and table, so the size figures above stand (test).

The review round at e84b7a7, on b98e7d7:

  • The changeset scopes the saving to a page whose lazily loaded code also uses the selection lock, as a DropdownMenu or a Table page, where no other control on the page uses the selection lock at once; other pages that load the keyboard height change by under 50 bytes minified (the one-component figures above).
  • caretAt.ts: its @position says the keyboard height imports it from here, so it does not load the selection lock; its @input and a comment at the fallback say that only caretPositionFromPoint looks into the shadow roots, and that caretRangeFromPoint answers at the shadow host. Its statements do not change.
  • The record line now reads "so the keyboard height does not bring the selection lock into a page": a page can load the lock for another use, as CheckboxInput's box hold does.
  • This description: the lock's users, the one caret query in Core, and the fallback's shadow roots are now stated exactly.
  • Checks at e84b7a7: Prettier on the three changed files, ESLint (--max-warnings=0) on caretAt.ts, pnpm check:knowledge and pnpm check:changesets pass. The three bundle tests pass 24 of 24. pnpm size:pages --base b98e7d7d04 --head e84b7a7090 is +0 / +0 on docs, form, menu and table, so the size figures above stand (test).

b98e7d7 is 4e16aae54c plus that record line; the code, bundle and size runs at 4e16aae54c stand for both heads.

  1. Red first: pnpm exec vitest run --project node scripts/touch-support-bundle.test.mjs -t 'selection lock' with main's utils/selectionLock.ts and keyboard/keyboardHeight.ts fails 1 of 1. The selection lock's bytes are in DropdownMenu's first load (test).
  2. At 4e16aae54c the same case passes. scripts/touch-support-bundle.test.mjs, scripts/lazy-sheet-bundle.test.mjs and scripts/core-single-bundle.test.mjs pass 24 of 24 (test).
  3. At 4e16aae54c: pnpm exec vitest run --project ui over utils, keyboard and gestures passes 119 files, 2,477 of 2,477 tests; pnpm -F @astryxdesign/core typecheck, ESLint (--max-warnings=0) on the three changed source files and Prettier on the five changed files pass (test). At this head, Prettier on the record and pnpm check:knowledge pass.
  4. At 0676d46c4a, which differs from 4e16aae54c only by the dropped re-export and a comment's wording in caretAt.ts: the same --project ui run over utils, keyboard, gestures, Layer, Tooltip, Chat, List, NumberInput, Swipe, hooks, TextInput, TextArea, BottomSheet and DropdownMenu passes 316 files, 7,339 of 7,339 tests (test). pnpm check:changesets and pnpm review:pre (0 findings) pass.
  5. pnpm size:pages --base d2e198be5f --head 4e16aae54c, with esbuild and with --bundler rolldown, gives the table above (test).

Drafted with an AI coding agent; the tests were run as described.

@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Dec 4, 2026 4:53am UTC

Request Review

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

astracat-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Dec 4, 2026, 6:19 AM UTC

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

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 7ec7797

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC
lab/AudioPlayer 242.0 kB (+163 B) · 1.8 kB CSS (0) —
lab/VideoPlayer 240.0 kB (+136 B) · 2.1 kB CSS (0) —
SegmentedControl 105.9 kB (+135 B) · 7.7 kB CSS (0) —
149 more components
Component Size LoC
lab/CommentThread 377.1 kB (+134 B) · 2.4 kB CSS (0) —
lab/MediaPlaybackRate 231.6 kB (+127 B) · 1.5 kB CSS (0) —
lab/MediaCaptionsButton 231.6 kB (+126 B) · 1.5 kB CSS (0) —
lab/MediaFullscreenButton 231.6 kB (+126 B) · 1.5 kB CSS (0) —
lab/MediaTime 231.6 kB (+126 B) · 1.5 kB CSS (0) —
lab/MediaTimeSlider 231.6 kB (+126 B) · 1.5 kB CSS (0) —
lab/MediaPlayButton 231.6 kB (+124 B) · 1.5 kB CSS (0) —
lab/MediaSeekButton 231.6 kB (+123 B) · 1.5 kB CSS (0) —
lab/MediaVolume 231.6 kB (+123 B) · 1.5 kB CSS (0) —
charts/ChartTooltip 237.1 kB (+117 B) · 451 B CSS (0) —
ButtonGroup 45.4 kB (+116 B) · 3.7 kB CSS (0) —
lab/Comments 384.0 kB (+105 B) · 2.5 kB CSS (0) —
MultiSelector 110.8 kB (+95 B) · 19.4 kB CSS (0) —
richtext/RichTextView 291.6 kB (+91 B) · 2.4 kB CSS (0) —
Toast 111.2 kB (+83 B) · 11.7 kB CSS (0) —
lab/TransferListSelector 147.5 kB (+81 B) · 1.6 kB CSS (0) —
AlertDialog 138.5 kB (+67 B) · 16.4 kB CSS (0) —
Switch 114.6 kB (+63 B) · 10.9 kB CSS (0) —
lab/TabBarMoreList 98.8 kB (+60 B) · 1.8 kB CSS (0) —
CheckboxInput 74.1 kB (+58 B) · 11.0 kB CSS (0) —
NumberInput 110.4 kB (+55 B) · 13.4 kB CSS (0) —
Pagination 155.9 kB (+52 B) · 20.4 kB CSS (0) —
ListItem 84.9 kB (+43 B) · 13.0 kB CSS (0) —
RadioListItem 81.9 kB (+38 B) · 11.6 kB CSS (0) —
Slider 119.9 kB (+37 B) · 9.6 kB CSS (0) —
CheckboxListItem 85.8 kB (+33 B) · 13.0 kB CSS (0) —
richtext/RichTextEditor 314.9 kB (+32 B) · 2.7 kB CSS (0) —
lab/TransferList 134.6 kB (+30 B) · 1.4 kB CSS (0) —
lab/TabBar 85.1 kB (+29 B) · 1.8 kB CSS (0) —
Lightbox 155.8 kB (+28 B) · 12.5 kB CSS (0) —
InfoTip 54.0 kB (+17 B) · 6.1 kB CSS (0) —
charts/Chart 261.3 kB (+16 B) · 529 B CSS (0) —
CheckboxList 69.2 kB (+12 B) · 8.5 kB CSS (0) —
MobileNav 83.9 kB (+12 B) · 12.0 kB CSS (0) —
Button 71.1 kB (+11 B) · 11.3 kB CSS (0) —
lab/ListInput 102.7 kB (+11 B) · 1.3 kB CSS (0) —
TableSelectionToolbar 81.7 kB (+10 B) · 14.7 kB CSS (0) —
ToggleButton 71.8 kB (+10 B) · 11.4 kB CSS (0) —
AppShell 95.5 kB (+9 B) · 15.1 kB CSS (0) —
Banner 73.2 kB (+9 B) · 11.8 kB CSS (0) —
ChatDictationButton 71.7 kB (+9 B) · 11.4 kB CSS (0) —
ChatSendButton 71.5 kB (+9 B) · 11.3 kB CSS (0) —
IconButton 71.1 kB (+9 B) · 11.3 kB CSS (0) —
lab/Schedule 123.0 kB (+9 B) · 3.9 kB CSS (0) —
Calendar 82.3 kB (+8 B) · 11.9 kB CSS (0) —
ChatLayoutScrollButton 71.6 kB (+7 B) · 11.5 kB CSS (0) —
DialogHeader 74.4 kB (+7 B) · 13.0 kB CSS (0) —
DrawerHeader 74.5 kB (+7 B) · 14.4 kB CSS (0) —
SideNavCollapseButton 72.0 kB (+7 B) · 11.4 kB CSS (0) —
Markdown 202.3 kB (+6 B) · 23.9 kB CSS (0) —
Field 63.9 kB (+5 B) · 8.0 kB CSS (0) —
FileInput 81.5 kB (+5 B) · 13.1 kB CSS (0) —
TopNavMegaMenuItem 15.5 kB (+5 B) · 4.2 kB CSS (0) —
lab/DialogHeroHeader 95.9 kB (+5 B) · 372 B CSS (0) —
InputGroup 66.1 kB (+4 B) · 9.4 kB CSS (0) —
Link 61.2 kB (+4 B) · 7.8 kB CSS (0) —
Stepper 72.8 kB (+4 B) · 11.4 kB CSS (0) —
RadioList 65.4 kB (+3 B) · 8.0 kB CSS (0) —
ToggleButtonGroup 42.5 kB (+3 B) · 3.7 kB CSS (0) —
Toolbar 49.1 kB (+2 B) · 8.7 kB CSS (0) —
charts/ChartLegend 44.6 kB (+1 B) · 224 B CSS (0) —
ChatToolCalls 34.0 kB (+1 B) · 9.2 kB CSS (0) —
ProgressBar 12.5 kB (+1 B) · 7.1 kB CSS (0) —
AvatarGroup 51.6 kB (0) · 6.4 kB CSS (0) —
BottomSheetSwitcher 20.1 kB (0) · 3.5 kB CSS (0) —
ChatMessageList 29.4 kB (0) · 7.8 kB CSS (0) —
Collapsible 30.1 kB (0) · 4.6 kB CSS (0) —
CommandPaletteInput 35.1 kB (0) · 8.3 kB CSS (0) —
Dialog 29.7 kB (0) · 7.4 kB CSS (0) —
Item 21.7 kB (0) · 6.3 kB CSS (0) —
LayoutPanel 22.4 kB (0) · 5.1 kB CSS (0) —
NavHeadingMenu 19.9 kB (0) · 3.5 kB CSS (0) —
NavHeadingMenuItem 20.3 kB (0) · 7.1 kB CSS (0) —
ResizeHandle 22.5 kB (0) · 4.4 kB CSS (0) —
SelectorOption 25.7 kB (0) · 6.8 kB CSS (0) —
StatusDot 36.9 kB (0) · 6.0 kB CSS (0) —
TabList 49.4 kB (0) · 6.9 kB CSS (0) —
Text 12.3 kB (0) · 6.2 kB CSS (0) —
Timer 14.8 kB (0) · 6.7 kB CSS (0) —
TopNavMegaMenuFeaturedCard 8.6 kB (0) · 3.7 kB CSS (0) —
TreeList 48.2 kB (0) · 6.1 kB CSS (0) —
lab/MediaPlayer 31.5 kB (0) · 165 B CSS (0) —
lab/PageControl 79.6 kB (0) · 716 B CSS (0) —
lab/TabBarItem 3.9 kB (0) · 1.8 kB CSS (0) —
Heading 13.2 kB (−1 B) · 6.2 kB CSS (0) —
HoverCard 31.6 kB (−1 B) · 4.8 kB CSS (0) —
MobileNavToggle 73.3 kB (−1 B) · 12.0 kB CSS (0) —
Timestamp 28.7 kB (−1 B) · 11.5 kB CSS (0) —
TopNav 75.1 kB (−1 B) · 12.3 kB CSS (0) —
lab/LineClamp 15.0 kB (−1 B) · 168 B CSS (0) —
Spinner 26.0 kB (−2 B) · 7.0 kB CSS (0) —
Tooltip 35.1 kB (−3 B) · 5.1 kB CSS (0) —
ComplexSelector 88.4 kB (−4 B) · 13.7 kB CSS (0) —
TimeInput 187.0 kB (−4 B) · 18.2 kB CSS (0) —
SideNav 120.0 kB (−5 B) · 12.8 kB CSS (0) —
Thumbnail 75.9 kB (−5 B) · 12.8 kB CSS (0) —
lab/NavigationStack 87.1 kB (−5 B) · 1.5 kB CSS (0) —
CodeBlock 87.4 kB (−6 B) · 13.0 kB CSS (0) —
lab/NavigationScreen 87.1 kB (−6 B) · 1.5 kB CSS (0) —
lab/DiffViewer 100.3 kB (−8 B) · 2.3 kB CSS (0) —
TopNavHeading 93.2 kB (−9 B) · 12.6 kB CSS (0) —
FieldLabel 59.3 kB (−11 B) · 6.5 kB CSS (0) —
Avatar 48.8 kB (−12 B) · 6.3 kB CSS (0) —
ChatLayout 94.8 kB (−12 B) · 11.8 kB CSS (0) —
TopNavMenu 92.4 kB (−12 B) · 12.7 kB CSS (0) —
SideNavHeading 94.1 kB (−13 B) · 12.7 kB CSS (0) —
lab/SelectableCardGroup 74.4 kB (−13 B) · 162 B CSS (0) —
AvatarGroupOverflow 54.9 kB (−14 B) · 6.4 kB CSS (0) —
SideNavItem 87.4 kB (−15 B) · 12.6 kB CSS (0) —
lab/CommentPin 63.9 kB (−16 B) · 1.2 kB CSS (0) —
ChatComposer 95.5 kB (−17 B) · 13.9 kB CSS (0) —
Drawer 61.4 kB (−17 B) · 9.1 kB CSS (0) —
TabMenu 89.4 kB (−19 B) · 12.6 kB CSS (0) —
TextInput 105.0 kB (−19 B) · 13.2 kB CSS (0) —
Typeahead 100.2 kB (−20 B) · 14.8 kB CSS (0) —
lab/ChatEmojiPicker 133.9 kB (−21 B) · 773 B CSS (0) —
lab/EmojiPicker 125.0 kB (−21 B) · 751 B CSS (0) —
ChatComposerInput 92.6 kB (−22 B) · 12.7 kB CSS (0) —
ChatComposerTokenElement 92.6 kB (−23 B) · 12.7 kB CSS (0) —
DateInput 214.8 kB (−25 B) · 19.4 kB CSS (0) —
TopNavMegaMenu 86.3 kB (−26 B) · 13.3 kB CSS (0) —
Carousel 82.9 kB (−28 B) · 12.3 kB CSS (0) —
BaseTypeahead 88.6 kB (−30 B) · 12.3 kB CSS (0) —
DateTimeInput 238.7 kB (−31 B) · 21.1 kB CSS (0) —
BottomSheet 78.1 kB (−33 B) · 7.9 kB CSS (0) —
DateRangeInput 101.6 kB (−33 B) · 14.6 kB CSS (0) —
PowerSearch 327.8 kB (−34 B) · 27.8 kB CSS (0) —
Tokenizer 118.9 kB (−34 B) · 22.5 kB CSS (0) —
lab/Tour 112.6 kB (−35 B) · 1.0 kB CSS (0) —
lab/ChatReactionBar 135.4 kB (−37 B) · 1.1 kB CSS (0) —
TextArea 97.9 kB (−38 B) · 10.5 kB CSS (0) —
Popover 110.3 kB (−42 B) · 15.8 kB CSS (0) —
lab/ChatVirtualizer 58.3 kB (−70 B) · 223 B CSS (0) —
MoreMenu 137.2 kB (−1.6 kB) · 20.1 kB CSS (0) —
DropdownMenu 136.9 kB (−1.7 kB) · 20.1 kB CSS (0) —
lab/CommentComposer 191.3 kB (−1.7 kB) · 1.9 kB CSS (0) —
TableCell 110.8 kB (−1.7 kB) · 20.6 kB CSS (0) —
richtext/RichTextEditorToolbar 297.6 kB (−1.7 kB) · 454 B CSS (0) —
Table 125.4 kB (−1.7 kB) · 21.6 kB CSS (0) —
Selector 120.9 kB (−1.7 kB) · 20.1 kB CSS (0) —
ContextMenu 109.6 kB (−1.7 kB) · 19.9 kB CSS (0) —
TableHeaderCell 110.6 kB (−1.7 kB) · 20.4 kB CSS (0) —
CommandPalette 86.3 kB (−1.7 kB) · 14.0 kB CSS (0) —
DropdownMenuRadioItem 28.7 kB (−1.7 kB) · 7.7 kB CSS (0) —
DropdownMenuCheckboxItem 28.7 kB (−1.7 kB) · 7.7 kB CSS (0) —
DropdownMenuSubMenu 82.1 kB (−1.7 kB) · 11.5 kB CSS (0) —
DropdownMenuItem 27.9 kB (−1.7 kB) · 7.2 kB CSS (0) —
BreadcrumbItem 106.1 kB (−1.7 kB) · 14.3 kB CSS (0) —
ContextMenuItem 40.4 kB (−1.9 kB) · 7.4 kB CSS (0) —

Package size: @astryxdesign/core 8.18 MB packed (+506 B); no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@cixzhang

cixzhang commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec b98e7d7

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Dec 3, 2026
@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Dec 3, 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.

Changes requested: moving caretAt into its own module is behavior-neutral, and the new bundle check holds (it fails on main and passes on this branch, reproduced locally), but the changeset and the description claim more than the change does.

  • Changeset overstates the saving: the changeset promises about 1.6 KB gzip on every page that loads the keyboard height, but in a local build the chat and bottomsheet pages save only 21–44 bytes and the form page grows by 37–79 bytes, so limit the figure to pages whose lazy code also imports the selection lock (the DropdownMenu and Table pages) and reword the matching description sentences ("every page that loads the keyboard height also loads the selection lock", "every page that loads the keyboard height loads the whole selection lock" and "whose import loads the lock (about 1.6 KB gzip)").
  • Changeset misnames the 1.7 KB page: the "text-only page" that drops about 1.7 KB with esbuild is the docs reference page, which also renders List and Link, while a page that renders only Text changes by 1 byte in a local build.
  • Selection lock users misstated: the description says only gestures that hold a finger use the selection lock, but the gesture host also imports its mouse and pen drag hold and its press reads (packages/core/src/gestures/GestureHost.ts:189-196).
  • Caret query uniqueness misstated: the description says only caretAt calls caretPositionFromPoint or caretRangeFromPoint, but the RichTextEditor image-plugin story's rangeFromPoint calls both (apps/storybook/stories/RichTextEditor.imagePlugin.tsx:715-733), so say that no other Core module holds a caret query.
  • Shadow root behavior misstated: the description says caretAt looks into the given shadow roots, but its caretRangeFromPoint fallback ignores them and answers at the shadow host (packages/core/src/utils/caretAt.ts:38-43).
  • Miss: Caret query described as a text-field line lookup: the description calls caretAt the query that finds the line under a point in a text field, but it returns a node and character offset for any point, and the selection lock calls it over any page text (packages/core/src/utils/caretAt.ts:11-17, packages/core/src/utils/selectionLock.ts:313-316).
  • Owning code sentence is broader than the change (optional): the record's "a page that loads the keyboard height does not load the selection lock" is false for a page that also renders CheckboxInput, so "the keyboard height does not bring the selection lock into a page" fits better.
  • Header comment ties loading to locking (optional): the caretAt.ts header says a page that locks no selection does not load the lock, but loading follows imports; "The keyboard height imports it from here, so it does not load the selection lock" says it plainly.

The changeset fix is a new commit, so an engineering owner (you can, as one) needs to comment /approve-spec with the new head SHA again for the Owning code line.

Claims and files checked

Review mode: full; reason: requested

  • Title, the keyboard height no longer loads the selection lock: verified (import graph; the new bundle check passes locally).
  • The keyboard height read only the caret query from the lock module: verified.
  • Every page that loads the keyboard height also loads the lock: false (Button and Link pages carried none of it; chat, sheet and text-input pages carried only the caret query).
  • Only gestures that hold a finger use the lock: false (the gesture host's mouse and pen drag hold and press reads).
  • DropdownMenu and Table pages carried the whole lock in their first load: verified (5,633 bytes before, built locally).
  • A module that a page and a lazy chunk share lands whole in the first load: verified on the menu and table pages with both bundlers.
  • Figures from another pull request's branch: reported.
  • No behavior change, the function body byte for byte, both callers on the new module: verified.
  • The new module imports nothing, the lock imports it for its press reads and stops exporting it, and the keyboard height imports it: verified.
  • The record's Owning code names both modules: verified, approved by an engineering owner for this head.
  • A DropdownMenu bundle check and a perf changeset: verified.
  • Maintenance only, with no product behavior change: verified.
  • Usage, a caret position or null: verified; looks into the given shadow roots: false (the fallback query ignores them); imported by the keyboard height and the lock: verified.
  • The caret query finds the line under a point in a text field: false (it returns a node and offset for any point).
  • The keyboard height needs only this query: verified.
  • Keeping it in the lock module loads the whole lock (about 1.6 KB): false for the chat, sheet and text-input pages.
  • No other module calls the browser caret queries: false (a Storybook story calls both).
  • Moving it into the keyboard height would make the lock import the keyboard height: verified.
  • No record names the lock module by path: verified.
  • Red-first failure and pass after the change: verified, reproduced locally.
  • Unit suites and the Core typecheck pass: reported; 138 unit files and the Core typecheck pass locally.
  • No CI impact (no workflow, action or CI script change): verified.
  • Size table: reported; all six rows reproduced locally within 1 byte.
  • The form page keeps the lock for another use: verified (the checkbox hold imports it).
  • No public API, behavior, visual or policy change, and no internal context: verified (the API surface generator reports no change).
  • Product changes split out during the work: reported.
  • Writing rubric results and test runs at earlier commits: reported; the knowledge check and Prettier pass locally.
  • Changeset, the keyboard height reads the caret from a module of its own: verified.
  • Changeset, keyboard-height pages no longer load the lock with it: verified.
  • Changeset, about 1.6 KB gzip less on such a page with both bundlers: false.
  • Changeset, a text-only page drops about 1.7 KB with esbuild: false.
  • Changeset, a page that keeps the lock loads up to 80 bytes more: reported (79 bytes on the form page locally).
  • Changeset, the same caret as before: verified.
  • Files: .changeset/keyboard-height-caret-own-module.md findings; docs/architecture/react-component-runtime.md wording note; packages/core/src/keyboard/keyboardHeight.ts clear; packages/core/src/utils/caretAt.ts comment note; packages/core/src/utils/selectionLock.ts clear; scripts/touch-support-bundle.test.mjs clear.

Automated review (maintainer link)

Comment thread packages/core/src/utils/caretAt.ts Resolved
Comment thread packages/core/src/utils/caretAt.ts Resolved
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 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.

Changes requested: moving caretAt into its own module is behavior-neutral, the changeset now matches the savings measured locally, and the new bundle check fails on main and passes on this branch (reproduced locally), but the new module needs an owner's approval at this head and two description sentences misstate what caretAt returns.

  • New internal module lacks owner approval at this head: packages/core/src/utils/caretAt.ts is a new internal module that the keyboard height imports, and the only record line naming it is this pull request's own Owning code entry, whose /approve-spec covered the previous head, so an engineering owner (you can, as one) needs to comment /approve-spec with this head's full SHA.
  • Caret query described as a text-field line lookup: the description calls caretAt "the caret query that finds the line under a point in a text field", but it returns a node and a character offset for any point and the selection lock calls it over any page text (packages/core/src/utils/caretAt.ts:12-18, packages/core/src/utils/selectionLock.ts:313-316), so say that it finds the caret position under a point.
  • Null result described too narrowly: the Usage line says caretAt returns null when the engine has no caret query, but it also returns null when the engine's query finds no caret at the point (packages/core/src/utils/caretAt.ts:35-37, :43-45), so name that case too.

Fixing the description needs no new commit, so an approval for this head stays valid after it.

Claims and files checked

Review mode: full; reason: spec-record

  • Title, the keyboard height no longer loads the selection lock: verified (its import graph holds no lock; the new bundle check passes locally).
  • The keyboard height read one function of the lock module: verified.
  • The caret query finds the line under a point in a text field: false (it returns a node and offset for any point).
  • The gesture host uses the lock for its drag hold and press reads, and a few recognizers and controls while they hold a press: verified (all 13 importers read).
  • A page whose lazy code also uses the lock carried the whole lock in its first load: verified on the menu, table, Selector and ContextMenu pages with both bundlers and the docs page with esbuild (built locally; Rolldown builds the docs page with no lazy chunk).
  • A module that a page and a lazy chunk share lands in the first load whole: verified on those pages.
  • Figures from another pull request's branch: reported.
  • No behavior change, the statements main's byte for byte with only comments changed, both callers on the same function: verified.
  • The new module imports nothing; the lock imports it for its press reads and stops exporting it; the keyboard height imports it: verified.
  • The record's Owning code names both modules: verified; not yet approved for this head.
  • A DropdownMenu bundle check and a perf changeset: verified.
  • Maintenance only, with no product behavior change: verified.
  • The new module is shown with usage, need and alternatives: verified.
  • Usage, a caret position or null when the engine has no caret query: false (null also when a query finds no caret at the point).
  • Shadow roots are looked into only with the newer query, and the fallback answers at the host: verified.
  • Imported by the keyboard height and the lock: verified (the only importers).
  • The keyboard height needs only this query: verified (its only import from the lock module before the change).
  • Keeping it in the lock keeps the whole lock in such pages, about 1.6 to 1.8 KB: verified (measured locally).
  • No other Core module holds a caret query: verified.
  • Moving it into the keyboard height would make the lock import the keyboard height: verified.
  • No record names the lock module by path: verified.
  • Red-first failure and pass after the change: verified, reproduced locally.
  • Unit suites and the Core typecheck pass: reported; 160 unit files and the Core typecheck pass locally.
  • No CI impact (no workflow, action or CI script change): verified.
  • Size tables and one-component figures: reported; reproduced locally within 3 bytes gzip.
  • Rolldown builds the docs page as one chunk, and the form page keeps the lock: verified.
  • No public API, behavior, visual or policy change, and no internal context: verified (the API surface generator reports no change).
  • Product changes split out during the work: reported.
  • Writing rubric results and test runs at earlier commits: reported.
  • This round's notes on the changeset, the module's comments, the record line and the description: verified; this round's check runs: reported, and the knowledge, changeset, Prettier and ESLint checks pass locally.
  • Changeset, the keyboard height reads the caret from a module of its own: verified.
  • Changeset, pages whose lazy code also uses the lock drop about 1.6 to 1.8 KB gzip with both bundlers: verified on the menu, table, Selector and ContextMenu pages (built locally).
  • Changeset, other pages that load the keyboard height change by under 50 bytes minified: reported; consistent locally for the TextInput, ChatLayout, BottomSheet, Popover and Tokenizer pages.
  • Changeset, a page that uses the lock itself loads up to 80 bytes more: reported (79 bytes gzip on the form page locally).
  • Changeset, the same caret as before: verified.
  • Files: .changeset/keyboard-height-caret-own-module.md clear; docs/architecture/react-component-runtime.md clear, needs an owner approval for this head; packages/core/src/keyboard/keyboardHeight.ts clear; packages/core/src/utils/caretAt.ts findings (owner approval, null contract); packages/core/src/utils/selectionLock.ts clear; scripts/touch-support-bundle.test.mjs clear.

Automated review (maintainer link)

Comment thread packages/core/src/utils/caretAt.ts Resolved
Comment thread packages/core/src/utils/caretAt.ts Resolved
@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

/approve-spec e84b7a7

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 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.

Approved pending CI: moving caretAt into its own module is behavior-neutral, the new bundle check fails on main and passes on this branch (reproduced locally), and the description's account of what caretAt returns now matches the code. The record line naming utils/caretAt.ts carries an engineering owner's approval for this head. This is a draft, so CI has not run on this head yet; it runs once the pull request is marked ready for review.

Claims and files checked

Review mode: same-head; reason: none

  • Changed rules (0): none.
  • Title, the keyboard height no longer loads the selection lock: verified (its static imports no longer reach the lock module; the new bundle check passes locally).
  • The keyboard height read one function of the lock module, a caret query returning the node and offset under a point: verified (its only import from that module).
  • The gesture host uses the lock for its drag hold and press reads, and a few recognizers and controls while they hold a press: verified (all importers read).
  • A page whose lazy code also uses the lock carried the whole lock in its first load, as DropdownMenu and Table pages do: verified for DropdownMenu (5,633 bytes on main, run locally); the Table figure is reported.
  • A module that a page and a lazy chunk share lands whole in the first load: verified on the DropdownMenu page.
  • Figures from another pull request's branch: reported.
  • No behavior change; the statements are main's byte for byte with only comments changed; both callers read the same function: verified.
  • The new module imports nothing; the lock imports it for its press reads and stops exporting it; the keyboard height imports it: verified.
  • The record's Owning code names both modules: verified, owner-approved for this head.
  • A DropdownMenu bundle check and a perf changeset: verified.
  • Maintenance only, moving the function unchanged apart from comments: verified.
  • The new module is shown with usage, need and alternatives: verified.
  • Usage, a caret position as node and offset, or null when the engine has no caret query or finds no caret there: verified (both null paths and the no-query return).
  • The newer query looks into the given shadow roots, and the fallback takes none and answers at the host: verified in code (the fallback receives no roots); the host answer is the engine's, reported.
  • Only the keyboard height and the lock import it: verified (repository search).
  • The keyboard height needs only this query: verified.
  • No other Core module holds a caret query: verified (search of Core source for both engine queries).
  • Keeping it in the lock keeps the whole lock in such pages, about 1.6 to 1.8 KB gzip: reported.
  • Moving it into the keyboard height would make the lock import the keyboard height: verified.
  • No record names the lock module by path: verified (search of the records).
  • Red-first failure and the pass after the change: verified, reproduced locally.
  • Unit suites and the Core typecheck pass: reported; the keyboard and utils suites and the Core typecheck pass locally.
  • No CI impact (no workflow, action or CI script changes): verified.
  • Size tables, single-component figures and run-to-run gzip drift: reported.
  • The docs saving comes from esbuild's split build, Rolldown already drops the lock from its single docs chunk, and the form page keeps the lock and grows by one module: reported.
  • No public API, behavior, visual or policy change, and no internal context: verified (no package entry reaches either module).
  • Product changes split out during the work, writing rubric results and runs at earlier commits: reported.
  • This round's notes on the changeset, the module comments, the record line and the description: verified; this round's check runs: reported.
  • Changeset, the keyboard height reads the caret from a module of its own: verified.
  • Changeset, pages whose lazy code also uses the lock drop about 1.6 to 1.8 KB gzip with both bundlers: verified by earlier local size runs on this same code.
  • Changeset, other keyboard-height pages change by under 50 bytes minified: reported.
  • Changeset, a page that uses the lock itself loads up to 80 bytes more: reported.
  • Changeset, the same caret as before: verified.
  • Files: .changeset/keyboard-height-caret-own-module.md clear; docs/architecture/react-component-runtime.md clear; packages/core/src/keyboard/keyboardHeight.ts clear; packages/core/src/utils/caretAt.ts clear; packages/core/src/utils/selectionLock.ts clear; scripts/touch-support-bundle.test.mjs clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review December 4, 2026 01:38
…election lock

The snap-paging hook brings the gesture host, which imports the selection
lock. The selection lock reads the caret with caretAt. Now that caretAt has
a module of its own, the test sees it as a module the hook adds. Its bytes
are the ones the selection lock carried before. The test counts caretAt
with the selection lock.
@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

/approve-spec ed56d5e

@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: moving caretAt into its own module is behavior-neutral, both bundle checks fail without this change and pass with it (reproduced locally), and the record line naming the new module carries an engineering owner's approval for this head. The changeset, though, promises a saving that some DropdownMenu and Table pages do not get.

  • Changeset promises the saving on every DropdownMenu or Table page: next to a CheckboxInput, NumberInput or Slider the selection lock stays in the first load, and locally pnpm size:pages measures +58 / −14, +58 / +22 and +133 / +60 bytes (minified / gzip, esbuild) for DropdownMenu with CheckboxInput, DropdownMenu with NumberInput and Table with Slider instead of about 1.6 to 1.8 KB gzip less, so bound the first sentence to pages that use the lock only in lazily loaded code, give the next sentence's "up to 80 bytes" in gzip, and apply the same bound to the description's Testing and Internal module lines.

CI's build and test jobs run once review passes.

Claims and files checked

Review mode: same-head; reason: none

  • Changed rules (0): none.
  • Title, "perf(keyboard): the keyboard height no longer loads the selection lock": verified (the keyboard height's static import graph holds no lock module, checked locally).
  • The keyboard height read one function of the lock module, a caret query returning the node and offset under a point, and imported it from there: verified.
  • The gesture host uses the lock for drag holds and press reads, and a few recognizers and controls use it while they hold a press: verified (every importer read).
  • A page whose lazily loaded code also uses the lock, as DropdownMenu and Table pages, carried the whole lock in its first load: verified for DropdownMenu (the new check fails on the base, locally) and Table (measured locally); a general statement about the base otherwise.
  • A module that a page and a lazy chunk share lands whole in the first load: verified on the DropdownMenu and Table pages with both bundlers.
  • Figures on another pull request's branch: reported.
  • No behavior change; the statements are main's with only comments changed; both callers read the same function: verified.
  • The new module imports nothing; the lock imports it for its press reads and stops exporting it; the keyboard height imports it: verified.
  • The record's Owning code names both modules: verified, owner-approved for this head.
  • A DropdownMenu bundle check and a perf changeset: verified.
  • The snap-paging bundle test counts the new module with the lock: verified (with its previous pattern it fails on this code, locally).
  • Maintenance only, moving the function unchanged apart from comments: verified.
  • The new module is shown with usage, need and alternatives: verified.
  • Usage, a caret position as node and offset, or null when the engine has no caret query or finds no caret: verified.
  • The newer query looks into the given shadow roots; the fallback takes none and answers at the host: verified in code; the host answer is the engine's, reported.
  • Only the keyboard height and the lock import it: verified (repository search).
  • The keyboard height needs only this query, and while it lives in the lock such pages carry the whole lock: verified.
  • No other Core module holds a caret query: verified (search of Core source).
  • Keeping it in the lock keeps the whole lock in such a page's first load, about 1.6 to 1.8 KB gzip: false for pages that also use the lock at once (the finding above).
  • Moving it into the keyboard height would make the lock import the keyboard height: verified.
  • No record names the lock module by path: verified (search of the records).
  • Red-first failure and the pass after the change: verified, reproduced locally.
  • Unit suites and the Core typecheck pass: the keyboard and utils suites pass locally and CI's typecheck passes on this head; the rest reported.
  • No CI impact (no workflow, action or CI script changes): verified.
  • Size tables, single-component figures, run-to-run drift and the docs and form explanations: the four reference pages reproduce locally within 3 bytes gzip with esbuild and exactly with Rolldown, as do the DropdownMenu, Table and TextInput figures; the rest reported.
  • No public API, behavior, visual or policy change, and no internal context: verified.
  • Product changes split out, writing rubric results and earlier-round runs: reported.
  • The changeset scopes the saving to pages whose lazy code uses the lock, as DropdownMenu or Table pages: false for such pages that also use the lock at once (the finding above); other keyboard-height pages under 50 bytes minified: reported, TextInput measured locally.
  • This head's round, the snap-paging test failing one case before and passing after, the full node project and the size rerun: the red and green verified locally; the rest reported.
  • The module comments and the record line wording from the earlier round: verified.
  • Changeset, the keyboard height reads the caret from a module of its own: verified.
  • Changeset, pages whose lazy code uses the lock, as DropdownMenu or Table pages, drop the lock and about 1.6 to 1.8 KB gzip with both bundlers: false for such pages beside a CheckboxInput, NumberInput or Slider (the finding above); verified for DropdownMenu and Table alone with both bundlers.
  • Changeset, other keyboard-height pages change by under 50 bytes minified: reported, TextInput measured locally.
  • Changeset, a page that uses the lock itself loads up to 80 bytes more: holds in gzip in every page measured locally; Table with Slider grows 133 bytes minified (the finding above asks for the unit).
  • Changeset, the same caret as before: verified.
  • Files: .changeset/keyboard-height-caret-own-module.md finding above; docs/architecture/react-component-runtime.md clear; packages/core/src/keyboard/keyboardHeight.ts clear; packages/core/src/utils/caretAt.ts clear; packages/core/src/utils/selectionLock.ts clear; scripts/snap-paging-bundle.test.mjs clear; scripts/touch-support-bundle.test.mjs clear.

Automated review (maintainer link)

…ontrol on the lock

Beside a control that uses the selection lock at once, such as
CheckboxInput, NumberInput or Slider, the lock stays in the first load.
The changeset says so, and that such a page changes by under 200 bytes.
@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 7ec7797

@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: moving caretAt into its own module is behavior-neutral, its record entry is owner-approved for this head, and the new bundle check fails on main and passes here (reproduced locally); two description sentences still need fixing.

  • Internal module line drops the lazy-load bound: the Internal module section now says keeping caretAt in selectionLock.ts "keeps the whole lock in the first load (about 1.6 to 1.8 KB gzip) of a page where no other control uses the lock", but a TextInput, ChatLayout or BottomSheet page has no lock user and only ever carried caretAt's 428 bytes of the lock (reproduced locally, and your one-component figures and the changeset agree), so keep the new bound and restore the old one, for example "of such a page, where no other control on it uses the lock at once".
  • Miss: Caret query described as returning a character offset: the Maintainer impact calls caretAt the query "that returns the node and character offset under a client point", but over an element that holds no text, such as an empty contenteditable, it returns that element and a child index (which is why startsOnSelectableText rejects non-text nodes at utils/selectionLock.ts:321), so say it returns the caret position, a node and an offset, as your Usage line does.

No code change is needed; CI's build and test jobs run once review passes.

Claims and files checked

Review mode: same-head; reason: none

  • Changed rules (0): none.
  • Title, the keyboard height no longer loads the selection lock: verified (its static import graph at this head holds no lock module; the lock's bytes leave the TextInput, ChatLayout, BottomSheet, DropdownMenu and Table first loads, reproduced locally).
  • The keyboard height read one function of the lock and imported it from the lock module: verified (its only import from that module).
  • That function returns the node and a character offset under a point: false (finding above).
  • The gesture host uses the lock for drag holds and press reads, and a few recognizers and controls use it while they hold a press: verified (every importer read).
  • A page whose lazily loaded code also uses the lock, as DropdownMenu and Table pages, carried the whole lock in its first load: verified (all of the lock's bytes, reproduced locally).
  • A module that a page and a lazy chunk using it share lands whole in the first load: verified for the lock on the DropdownMenu and Table pages.
  • The saving on another pull request's branch: reported.
  • No behavior change; the statements are main's with only comments changed; both callers read the same function: verified (comment-stripped comparison with main).
  • The new module imports nothing; the lock imports it for its press reads and stops exporting it; the keyboard height imports it: verified.
  • The record's Owning code names both modules: verified, owner-approved for this head.
  • A DropdownMenu bundle check and a perf changeset: verified.
  • The snap-paging check counts the new module with the lock, which the snap-paging hook reaches through the gesture host: verified (passes locally).
  • Maintenance only, moving the function unchanged apart from comments: verified.
  • The new module is shown with usage, need and alternatives: verified.
  • Usage, a caret position as node and offset, or null when the engine has no caret query or finds no caret: verified.
  • The newer query looks into the given shadow roots; the fallback takes none and answers at the host: verified for the code; the host answer is the engine's behavior.
  • Only the keyboard height and the lock import the new module: verified (whole-repository search).
  • The keyboard height needs only this query, and while it lives in the lock module a page with lazy lock code carries the whole lock: verified.
  • No other Core module holds a caret query: verified (search of Core's source).
  • Keeping it in the lock module costs the whole lock, about 1.6 to 1.8 KB gzip, on a page where no other control uses the lock: false for pages with no lazy lock code (finding above).
  • Moving it into the keyboard height would make the lock import the keyboard height: verified.
  • No record named the lock module by path: verified (search of the records on main).
  • The new check fails before the change and passes after it: verified (reproduced locally on the base and this branch).
  • The unit suites of the folders that use the keyboard height or the lock, and the Core typecheck, pass: typecheck verified in CI's typecheck job; unit suites reported (CI's test job runs once review passes).
  • No workflow, action or CI script changes: verified.
  • Size tables for both bundlers and the one-component pages: reported; the esbuild menu, table, TextInput, ChatLayout and BottomSheet figures agree with a local build within a few bytes.
  • Docs saves only with esbuild, and the form page keeps the lock: reported for docs; form verified for the lock (CheckboxInput's eager import).
  • No public API, behavior or policy change, and no internal context in public text: verified.
  • Writing rubric results for the record line: verified.
  • Testing section runs: reported; the bundle tests and the DropdownMenu with CheckboxInput, NumberInput and Slider sizes reproduced locally.
  • Changeset, the keyboard height reads the caret from its own module: verified.
  • Changeset, about 1.6 to 1.8 KB gzip less on a page whose lazy code uses the lock, with both bundlers, only where no other control uses it at once: verified for esbuild on the DropdownMenu and Table pages, locally; Rolldown reported.
  • Changeset, beside CheckboxInput, NumberInput or Slider the lock stays and the page changes by under 200 bytes: verified for DropdownMenu with each, locally; Table pairs reported.
  • Changeset, other pages that load the keyboard height change by under 50 bytes minified: verified for TextInput, ChatLayout and BottomSheet, locally.
  • Changeset, the keyboard height reads the same caret as before: verified.
  • Files: .changeset/keyboard-height-caret-own-module.md clear; docs/architecture/react-component-runtime.md clear; packages/core/src/keyboard/keyboardHeight.ts clear; packages/core/src/utils/caretAt.ts clear; packages/core/src/utils/selectionLock.ts clear; scripts/snap-paging-bundle.test.mjs clear; scripts/touch-support-bundle.test.mjs clear; the description: two findings.

Automated review (maintainer link)

@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.

Approved pending CI: moving caretAt into its own module is behavior-neutral, its record entry is owner-approved for this head, and every claim in the title, description and changeset holds. Reproduced locally: the new DropdownMenu bundle check fails on main and passes here, main's snap-paging check fails here until it counts caretAt with the lock, and the size tables match a rebuild with esbuild and Rolldown. CI's deferred build and test jobs still have to pass on this head before merge.

Claims and files checked

Review mode: full; reason: requested

  • Claim: the keyboard height no longer loads the selection lock (title, change list, changeset first sentence): verified, nothing the keyboard height imports reaches the lock, and DropdownMenu's first load holds none of it (bundle check, run locally).
  • Claim: the keyboard height read only caretAt from the lock, and a page whose lazily loaded code uses the lock carried all of it in its first load: verified on every such page measured.
  • Claim: the gesture host and a few recognizers and controls use the lock: verified by listing its importers.
  • Claim: no behavior change; caretAt's statements match main and only its comments differ: verified by comparing the function and running the utils, keyboard and gesture unit suites locally.
  • Claim: the selection lock imports caretAt and no longer exports it; nothing else imported it: verified.
  • Claim: the Owning code entry names both modules, and the lock is one of the known public-API gaps: verified against the record.
  • Claim: the snap-paging check must count caretAt with the lock: verified, main's version fails on this branch.
  • Claim: caretAt's usage, its null results and its shadow-root behavior, including the fallback answering at the shadow host: verified by reading the code and a Chromium probe.
  • Claim: no other Core module holds a caret query, and no record named the lock by path: verified by search.
  • Claim: the changeset's saving of about 1.6 to 1.8 KB gzip with esbuild and Rolldown where lazily loaded code uses the lock and no control uses it at once: verified on every one-component page and the reference pages (1,595 to 1,799 bytes gzip).
  • Claim: beside a control that uses the lock at once the lock stays and the page changes by under 200 bytes, and other pages that load the keyboard height change by under 50 bytes minified: verified (at most 199 and 48 bytes).
  • Claim: the size tables, the docs and form explanations, and CI impact none: reported figures reproduced locally; no workflow changes.
  • Claim: earlier-head test runs, the other pull request's chat-page figures and the writing rubric results: reported.
  • .changeset/keyboard-height-caret-own-module.md: clear.
  • docs/architecture/react-component-runtime.md: clear.
  • packages/core/src/keyboard/keyboardHeight.ts: clear.
  • packages/core/src/utils/caretAt.ts: clear.
  • packages/core/src/utils/selectionLock.ts: clear.
  • scripts/snap-paging-bundle.test.mjs: clear.
  • scripts/touch-support-bundle.test.mjs: clear.

Automated review (maintainer link)

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Dec 4, 2026
@cixzhang cixzhang closed this Dec 4, 2026
@cixzhang cixzhang reopened this Dec 4, 2026

@cixzhang cixzhang 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.

Approved at this exact head.

@cixzhang
cixzhang merged commit 8894de4 into meta:main Dec 4, 2026
289 of 295 checks passed

This branch was successfully deployed

1 active deployment
Preview — 7ec77972 Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) 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.

2 participants