Repository navigation
refactor(lynx): bind the native list callbacks through one definition - #111
Merged
Merged
Conversation
The three recycling callbacks Lynx invokes against a live `<list>` — `componentAtIndex`, `enqueueComponent`, `componentAtIndexes` — were closures created inside `createNativeListNode` over that call's `state`, `container` and `listState`. Nothing else could produce them, so nothing else could give a live list a different owner. Adoption needs exactly that. A first tree carrying a `<list>` transfers the list's state from the main-thread source container to the background target, and the callbacks have to follow: left as they are they would keep materializing cells into a container that adoption has already emptied. `updateCallbacks` can retarget a live list — `applyListUpdate` and `disposeNativeListState` both do it — but there was no way to build the replacement trio. `bindNativeListCallbacks(state, container, resolve)` is that way, and `createNativeListNode` now calls it rather than owning the bodies. The list state arrives through `resolve` because creation is circular: `__CreateList` needs the callbacks and the state needs the node it returns. Adoption does not need the indirection, but sharing it keeps one definition of what a live list does instead of two that have to be kept in step. No behavioural change: same closures, same call-time resolution, same bodies. Two deliberate breaks confirm the seam is load-bearing rather than dead — resolving the state once at bind time instead of per call, and never resolving it at all — each turning 21 tests red across 3 files, with all 434 green restored. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
…unadoptable-first-screen
…or/lynx-list-callback-binding
…rst-screen' into perf/lynx-decline-unadoptable-first-screen
…or/lynx-list-callback-binding
1 task done
…t-callback-binding
Huxpro
changed the base branch from
perf/lynx-decline-unadoptable-first-screen
to
new-lynx
August 20, 2026 20:33
7 tasks done
Huxpro
marked this pull request as ready for review
August 21, 2026 20:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #110. Issue #66 Phase C, slice C2a of the C2 design.
The three recycling callbacks Lynx invokes against a live
<list>—componentAtIndex,enqueueComponent,componentAtIndexes— were closurescreated inside
createNativeListNodeover that call'sstate,containerandlistState. Nothing else could produce them, so nothing else could give a livelist a different owner.
bindNativeListCallbacks(state, container, resolve)is now that producer, andcreateNativeListNodecalls it instead of owning the bodies.Why
C2 teaches first-screen adoption to carry a native list. Adoption moves the
list's
LynxNativeListStatefrom the main-thread source container to thebackground target — and the callbacks have to follow, or they keep materializing
cells into a container adoption has already emptied.
updateCallbackscanretarget a live list (
applyListUpdateanddisposeNativeListStateboth do italready), but there was no way to build the replacement trio to hand it.
This PR only supplies that. Nothing calls it yet besides
createNativeListNode; the second caller arrives in C2c.Changes
One function,
packages/lynx/src/core/host-driver.ts. The list state arrivesthrough
resolverather than as a value because creation is circular:__CreateListneeds the callbacks, and the state needs the node that callreturns. Adoption has no such problem — it holds a state that already exists —
but both callers go through the same indirection so what a live list does is
defined once instead of twice.
Behaviour is unchanged: same bodies, same closures, same call-time resolution of
the list state. The one incidental cleanup is a
listState!insidecomponentAtIndexesthat aconstlocal no longer needs.No changeset: nothing exported changes and no behaviour is user-visible.
Validation
pnpm format:files packages/lynx/src/core/host-driver.tspnpm typecheck:files packages/lynx/src/core/host-driver.ts— clean--project lynx— 32 files, 434 passedpnpm test— not run for this diff; the change is confined topackages/lynx/srcand thelynxproject is what reaches it. The fullrun is reported on perf(lynx): decline an unadoptable first screen before painting it #110, which this is stacked on.
A pure extraction has no new behaviour to red/green, so the question is instead
whether the seam is load-bearing or dead. Two deliberate breaks say it is:
() => undefined)Both are the mistakes this shape invites, and
list-recycling.test.tsand itstwo neighbours catch each across 3 files.
Risk / follow-ups
per cell materialization, not per row.
componentAtIndexesresolves once fora whole batch of indexes, as before.
resolvereturningundefinedis still a live state duringcreateNativeListNode:__CreateListmay invoke a callback before theassignment lands. That guard is unchanged and still exercised.
is abandoned, this should be reverted rather than left as an extraction with
one caller.
Provenance
agent-authored)Generated by Claude Code