Skip to content

perf(core): Chat's keyboard ride comes with the touch runtime - #11540

Draft
cixzhang wants to merge 10 commits into
perf/defer-touch-wheelsfrom
perf/defer-touch-chat-keyboard
Draft

cixzhang wants to merge 10 commits into
perf/defer-touch-wheelsfrom
perf/defer-touch-chat-keyboard

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Performance, stacked on #11536: Chat stops importing the animator statically. useChatKeyboard places the composer dock and the transcript through a small shared helper, utils/deferredMotionEngine.ts. It writes their translate until the touch runtime loads, then hands the same place to a motion engine from the runtime. The wheels' strip (#11536) moves onto the same helper. No behavior changes after the load, and there's no API change.

User or maintainer impact

  • People loading a page with a ChatLayout download less JavaScript before first paint. Chat now reaches no touch module statically.
  • Before the runtime loads (first paint, then idle, at most 2 s): in Chrome on Android, where the dock rides the on-screen keyboard's slide, a keyboard that opens or closes in that window moves the dock at once with the layout instead of riding the slide. Everywhere else nothing changes, since only that browser publishes the keyboard's slide.

Before-load behavior for the pre-load decision card: "Chat's dock moves with the layout at once instead of riding the on-screen keyboard's slide" (recommended: keep; it's the same result Safari on iOS gives today).

Problem and solution fit

  • useChatKeyboard created two motion engines up front (createMotionEngine) for the dock and the transcript, which put the animator in every ChatLayout page's first load.
  • createDeferredMotionEngine() exposes setY, getY, element, attach and engine(). Before the load, setY writes translate directly (the animator's own format). engine() returns null until the runtime has loaded; at the first call after that, it creates the engine at the place the element shows.
  • The ride: follow rides the keyboard only when both engines exist. Otherwise it takes the existing non-animated path (set at once, commit).
  • Shared helper: wheelStrip used a local copy of the same placement in perf(core): the date and time wheels' drag and spin come with the touch runtime #11536; it now uses this helper, so the concern lives in one module (INV16).

Authority

architecture:react-component-runtime INV13: the before-load sentence adds the Chat clause, a why-line names utils/deferredMotionEngine.ts, and the gap line now names only Slider. spec:AST-099 Gap 13 states the same for Chat's dock. spec:AST-080 DEC-5 (amended).

Change and evidence

  • utils/deferredMotionEngine.ts (new), Chat/useChatKeyboard.ts, DateInput/wheelStrip.ts, the allowlist (2 entries left, both Slider), the boundary test, INV13 and AST-099.

Scope

Components: Chat (ChatLayout's keyboard ride), DateInput (wheelStrip uses the shared helper)

  • This PR has one primary intent.
  • Independently removable deltas were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

Red first, failing on #11536's head:

  • utils/touchRuntime.boundary.test.ts: the Chat entry reaches no touch module statically.
  • The touch-runtime rule's real-tree test, once Chat's entry leaves the allowlist.

Also:

  • useChatKeyboard.test.tsx: "moves the dock at once with no ride before the touch runtime loads". The suite loads the runtime in beforeAll.
  • Chat, DateInput, TimeInput, keyboard and touchRuntime suites: 1,643 passed (after the preload fix). The rule and shared-identity tests pass.
  • Core typecheck, eslint and check:knowledge pass.

Writing rubric results

  • R1 present tense: pass.
  • R2–R7: none in the record.

Owner and land path

Owner: the Astryx fix loop, lane 3. Lands after #8690 merges, in stack order (#11450, #11463, #11466, #11476, #11478, #11508, #11518, #11525, #11530, #11536, #11540, #11544), each after Specs, CodeBunny at its head and green CI; the drain merges.

useChatKeyboard places the dock and the transcript through utils/deferredMotionEngine.ts, which writes their translate until the runtime loads and then hands the same place to a motion engine from the runtime. Before the load a keyboard transition moves the dock at once with the layout instead of riding the keyboard's slide. wheelStrip uses the same helper. Chat reaches no touch module statically; INV13 names the helper and states the before-load ride, AST-099 Gap 13 says the same, and the gap line names only Slider.
@vercel

vercel Bot commented Nov 13, 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 Nov 14, 2026 8:11pm UTC

Request Review

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

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Nov 14, 2026, 8:57 PM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec d2a1200

@cixzhang

Copy link
Copy Markdown
Contributor Author

Decision: D-20261113-316

Records the owner's answer that the touch runtime loads once per page after first paint, never on demand, for Chat's keyboard ride at d2a1200. Until it loads, Chat's dock moves with the layout at once instead of riding the on-screen keyboard's slide (only Chrome on Android reports the slide); this pre-load behavior is also on the owner's queued pre-load card. It waives nothing.

@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: deferring Chat's keyboard ride to the shared touch runtime is sound, and the record changes are approved at this head, but Chat never asks for that runtime to load.

  • Blocking: Nothing ChatLayout mounts calls useTouchRuntime(), so on a page with no other touch component (the Full AI chat story, for one) the runtime never loads and the dock never rides the keyboard in Chrome on Android, not just for the first 2 s (packages/core/src/Chat/useChatKeyboard.ts:276-277); call useTouchRuntime() once in useChatKeyboard and add a test that renders ChatLayout without the beforeAll preload and checks the ride after first paint and idle.

Non-blocking: AST-099 Gap 13 lists the before-load dock behavior as an open gap while FR8 states it as the requirement, so keeping it in FR8 alone would be clearer.

Claims and files checked
  • Claim: Chat no longer reaches a touch module statically: verified (boundary test passes here and fails on the base).
  • Claim: The dock and transcript are placed through the new helper, which writes translate until the load and then hands the same place to an engine: verified (deferredMotionEngine.ts:43-89, useChatKeyboard.ts:276-291).
  • Claim: The wheels' strip uses the same helper and no local copy remains: verified (wheelStrip.ts:311, :336-349).
  • Claim: No behavior change after the load, and no API change: verified (code comparison and ride tests; the API generator lists no rows).
  • Claim: Pages with ChatLayout ship less JavaScript before first paint: verified for the static graph (boundary test); no byte count taken.
  • Claim: The before-load window lasts until first paint, then idle, at most 2 s: false for a ChatLayout page with no other touch component, where the runtime never loads (Chromium and jsdom probes).
  • Claim: Only Chrome on Android is affected, the same result Safari on iOS gives today: verified (useChatKeyboard.ts:331-347).
  • Claim: follow rides only when both engines exist: verified (useChatKeyboard.ts:276-291).
  • Claim: The architecture record names the helper and shrinks the gap line to Slider, and the keyboard record states the same for Chat: verified (diff).
  • Claim: The allowlist keeps two entries, both Slider: verified.
  • Claim: The new tests fail on the base: verified (three failures on the base with these tests and allowlist).
  • Claim: Chat, DateInput, TimeInput, keyboard and touch-runtime suites, typecheck, lint and knowledge checks pass: verified.
  • Claim: Record prose is in the present tense: verified.
  • File: packages/core/src/utils/deferredMotionEngine.ts: clear
  • File: packages/core/src/Chat/useChatKeyboard.ts: blocking finding above
  • File: packages/core/src/Chat/useChatKeyboard.test.tsx: its beforeAll preload hides the blocking finding
  • File: packages/core/src/DateInput/wheelStrip.ts: clear (same behavior; its wheel schedules the load)
  • File: packages/core/src/utils/touchRuntime.boundary.test.ts: clear
  • File: internal/eslint-plugin-astryx/no-static-touch-runtime.allowlist.json: clear
  • File: docs/architecture/react-component-runtime.md: clear
  • File: docs/specs/AST-099-mobile-keyboard/spec.md: non-blocking note above

Automated review (maintainer link)

if (!transition.animated) {
// The ride's motion comes with the shared touch runtime, which loads
// after first paint. Until then the dock moves with the layout at once.
const dockEngine = dock.animator.engine();

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.

Blocking. engine() only reads getTouchRuntime(). The load is scheduled only from useTouchRuntime()'s mount effect, and nothing ChatLayout or ChatComposer mounts calls it. On a page with no other touch component, such as the Full AI chat story, the runtime stays null, and every keyboard show and hide takes the non-animated branch below for good. Calling useTouchRuntime() once in useChatKeyboard, as PickerWheel and Switch do, schedules the page's one load.

Comment on lines +40 to +42
beforeAll(async () => {
await __loadTouchRuntimeForTest();
});

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 preload is why the suite passes while a real ChatLayout page never loads the runtime. Keep it for the ride tests, and add one test without it: render ChatLayout, run the first paint and the idle callback, then check that the next keyboard show rides.

Comment on lines +384 to +385
keyboard, and Chat's dock moves with the layout at once instead of riding
the keyboard's slide.

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.

Non-blocking: FR8's new last sentence states this as the requirement, so listing it here as an open gap leaves a reader unsure whether it is intended. Consider keeping it in FR8 only.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec c17823b

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec d99b2ce

@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: deferring Chat's keyboard ride to the shared touch runtime is sound, and the record changes are approved at this head, but Chat never asks for that runtime to load.

  • Blocking: Nothing ChatLayout mounts calls useTouchRuntime(), so on a page with no other touch component (the Full AI Chat story, for one) the runtime never loads and the dock never rides the keyboard in Chrome on Android, not just for the first 2 s (packages/core/src/Chat/useChatKeyboard.ts:276-277); call useTouchRuntime() once in useChatKeyboard and add a test that renders ChatLayout without the beforeAll preload and checks the ride after first paint and idle.
  • Newly live check: the new shared module utils/deferredMotionEngine.ts needs its first-load gzip deltas, base against head, in the description; measured at this head, the Table, Text and Button entries are unchanged, ChatLayout drops 13,793 B, DateInput grows 3 B and TimeInput 19 B, so those numbers can go in as they are.

Non-blocking: AST-099 Gap 13 lists the before-load dock behavior as an open gap while FR8 states it as the requirement, so keeping it in FR8 alone would be clearer.

Claims and files checked
  • Claim: Chat no longer reaches a touch module statically: verified (boundary test passes here and fails on the base).
  • Claim: The dock and transcript are placed through the new helper, which writes translate until the load and then hands the same place to an engine: verified (deferredMotionEngine.ts:43-89, useChatKeyboard.ts:276-291).
  • Claim: The helper exposes setY, getY, element, attach and engine(), and engine() stays null until the load: verified (deferredMotionEngine.ts:20-35, :47-57).
  • Claim: follow rides only when both engines exist and otherwise sets the place at once and commits: verified (useChatKeyboard.ts:276-291).
  • Claim: The wheels' strip uses the same helper: verified (wheelStrip.ts:139-148, :310).
  • Claim: No behavior change after the load, and no API change: verified (code comparison, the Chat, DateInput and TimeInput suites, and the API generator listing no rows).
  • Claim: Pages with ChatLayout download less JavaScript before first paint: verified (ChatLayout's eager first load drops from 89,611 to 75,818 bytes gzip).
  • Claim: The before-load window lasts until first paint, then idle, at most 2 s: false for a ChatLayout page with no other touch component, where the runtime never loads (Chromium and jsdom probes).
  • Claim: Only Chrome on Android is affected, matching what Safari on iOS gives today: verified (useChatKeyboard.ts:334-337).
  • Claim: The architecture record adds the Chat clause, names the helper and leaves only Slider in its gap line, and the keyboard record states the same for Chat: verified (record diff).
  • Claim: The allowlist keeps two entries, both Slider: verified.
  • Claim: The new tests fail on the base: verified (exactly three failures on the base with these tests and allowlist).
  • Claim: The Chat, DateInput, TimeInput, keyboard and touch-runtime suites, typecheck, lint and knowledge checks pass: verified (1,723 tests in 62 files; Core typecheck, eslint on the changed files and the knowledge check pass).
  • Claim: Record prose is in the present tense: verified.
  • File: packages/core/src/utils/deferredMotionEngine.ts: clear
  • File: packages/core/src/Chat/useChatKeyboard.ts: blocking finding above
  • File: packages/core/src/Chat/useChatKeyboard.test.tsx: its beforeAll preload hides the blocking finding
  • File: packages/core/src/DateInput/wheelStrip.ts: clear
  • File: packages/core/src/utils/touchRuntime.boundary.test.ts: clear
  • File: internal/eslint-plugin-astryx/no-static-touch-runtime.allowlist.json: clear
  • File: docs/architecture/react-component-runtime.md: clear
  • File: docs/specs/AST-099-mobile-keyboard/spec.md: non-blocking note above

Automated review (maintainer link)

# Conflicts:
#	docs/architecture/react-component-runtime.md
# Conflicts:
#	internal/eslint-plugin-astryx/no-static-touch-runtime.allowlist.json
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 70918e4

@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: Chat's keyboard ride now waits for the shared touch runtime, but nothing in Chat asks that runtime to load, and two description claims are out of date.

  • Blocking: Nothing ChatLayout mounts calls useTouchRuntime(), so on a page with no other touch component the runtime never loads and the dock never rides the on-screen keyboard in Chrome on Android, not just for the first 2 s (packages/core/src/Chat/useChatKeyboard.ts:276-277); call useTouchRuntime() once in useChatKeyboard and add a test that renders ChatLayout without the beforeAll preload and checks that the next keyboard show rides after first paint and idle.
  • Regression: The description's "the allowlist (2 entries left, both Slider)" and "the gap line now names only Slider" are false at this head, where the allowlist keeps AlertDialog's entry beside Slider's two and INV13's gap line names AlertDialog and Slider.

The record edits now carry an engineering owner's approval at this head, which also settles the record for the new utils/deferredMotionEngine.ts helper. The fix will be a new commit, so an engineering owner records the decision again by commenting /approve-spec <full head SHA> on that head, which the author may do as an engineering owner. Please also add the new shared module's first-load gzip deltas to the description: ChatLayout −13,803 B, DateInput +4 B and TimeInput −1 B, with the reference-page components unchanged.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: Chat no longer reaches a touch module statically: verified (the boundary case passes; the base imports the animator statically).
  • Claim: the dock and transcript are placed through the new helper, which writes translate until the load and then hands the same place to a motion engine: verified (deferredMotionEngine.ts:43-89, useChatKeyboard.ts:276-291).
  • Claim: the helper exposes setY, getY, element, attach and engine(), and engine() stays null until the load and then creates the engine at the shown place: verified (deferredMotionEngine.ts:20-35, :47-57).
  • Claim: the ride plays only when both engines exist, and otherwise the place is set at once and committed: verified (useChatKeyboard.ts:276-291).
  • Claim: the wheels' strip uses the same helper, so the concern lives in one module: verified (wheelStrip.ts:139-148, :310).
  • Claim: no behavior change after the load and no API change: verified (code comparison, the Chat, DateInput and TimeInput suites, and an API comparison of both builds with no rows).
  • Claim: pages with ChatLayout download less JavaScript before first paint: verified (ChatLayout's eager first load drops from 89,688 to 75,885 bytes gzip).
  • Claim: the before-load window lasts until first paint, then idle, at most 2 s: false for a ChatLayout page with no other touch component, where the runtime never loads.
  • Claim: only Chrome on Android is affected, matching what Safari on iOS already does: verified (useChatKeyboard.ts:334-337).
  • Claim: the architecture record adds the Chat before-load clause and a line naming the helper: verified (react-component-runtime.md:359-360, :368-371).
  • Claim: the architecture record's gap line now names only Slider: false (it names AlertDialog and Slider, react-component-runtime.md:381-382).
  • Claim: the keyboard record states the same for Chat's dock: verified (FR8's new last sentence and Gap 13).
  • Claim: the allowlist keeps two entries, both Slider: false (three entries, including AlertDialog's).
  • Claim: the new boundary case and the rule's real-tree test fail on the base: verified by reading (the base imports the animator statically and still lists Chat's entry).
  • Claim: a test moves the dock at once with no ride before the runtime loads, and the suite loads the runtime up front: verified (useChatKeyboard.test.tsx:40-42, :332-351).
  • Claim: the Chat, DateInput, TimeInput, keyboard and touch-runtime suites pass: verified (1,722 tests at this head; the rule's tests pass too).
  • Claim: core typecheck, eslint and the knowledge check pass: verified.
  • Claim: the record edits have an engineering owner's approval: verified at this head.
  • Claim: record prose is in the present tense: verified.
  • Claim: public text and artifacts contain no internal context: verified.
  • File: packages/core/src/Chat/useChatKeyboard.ts: blocking finding above.
  • File: packages/core/src/Chat/useChatKeyboard.test.tsx: its beforeAll preload hides the blocking finding.
  • File: packages/core/src/utils/deferredMotionEngine.ts: clear.
  • File: packages/core/src/DateInput/wheelStrip.ts: clear.
  • File: packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • File: internal/eslint-plugin-astryx/no-static-touch-runtime.allowlist.json: clear; the description miscounts what it keeps.
  • File: docs/architecture/react-component-runtime.md: clear, approved at this head.
  • File: docs/specs/AST-099-mobile-keyboard/spec.md: clear, approved at this head.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — 70918e41 Deployed Nov 14, 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