mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-07 00:44:49 +00:00
* Keep a disclosure's trigger in place on web Expanding or collapsing a turn summary, tool-call group, tool call details or todo badge now holds the row that owns the trigger. Rows inside the timeline get a disclosure context; each toggle runs its state change through `useDisclosureHold()`, and the viewport's new `holdRow(rowId, apply)` replaces `holdReadingPosition()`. On web the hold pins the reading anchor to that row, stops following output, and resumes following when the change leaves the list at its end. Native keeps its previous behaviour (detach, then apply) until the anchored toggle lands. * Render the native chat timeline with LegendList in forward order The native timeline was an inverted FlatList. Disclosure toggles moved their trigger, and a cold open settled visibly. It is now a forward-order LegendList that stays virtualized, and one owner moves the scroll offset at a time: - Before placement: LegendList's initial scroll, behind its hidden reveal. - While following: the end pin (native-end-pin.tsx). This is a zero-height first child at the bottom of the content, which native maintainVisibleContentPosition keeps in place. A content shrink or growth never scrolls from JS; only a viewport resize or an explicit jump does. - During a disclosure hold and while detached: LegendList MVCP with shouldRestorePosition (native-disclosure-hold.ts), so a toggle keeps its trigger at the same y and paints one layout change. - Every newly mounted row starts at a per-kind estimate (new-row-estimates.ts). PaseoScrollView defers React Native's content clamp while MVCP is set. A shrink below an unmoved anchor no longer draws a frame past the end (RN #58578, PR #58695). VisibleContentPositionClampTest covers this. LegendList 3.7.1 patch, one "Paseo patch" comment per hunk: - The content height comes from React state on the new architecture. - Rows get a per-row size estimate. - The MVCP anchor lock runs on native too. Upstream gated it to web in d24a9d93 without a native reason. Without the lock, the size pass for prepended history re-anchors on a prepended row and moves the rows on screen. Native ends the lock when its row leaves the view, not on the 300 ms clock. - Header and footer reveal together with the rows. - Only lists that keep their end preserve the initial end. - A remeasure within one pixel plus the 1/8 dp floor of the known size is noise. Upstream compares the raw size with the floored one, so the live turn's assistant row (1380 -> 1381 px) read as a resize and moved every row a frame after the reveal. - The Android silent initial scroll retry sends its 1 dp nudge and the return to the target in one task. Upstream returns on the next frame, but its 16 ms check can finish the scroll first and cancel that frame, so the list revealed 3 px short of its end and moved into place a frame later. - The top-padding shrink hold applies on iOS only. Android, emulator. Evidence is in .artifacts/legend-impl. - J1, J2 at the end, J3, J4, J5, J6, J7: pass. - J2 while streaming: not reachable on the Ten second stream fixture; its turns never fold. - J8: no blank frames over 10 fresh flings, at host load 32-37. J4: still. Before these two hunks, 6 of 7 cold opens moved every row one frame after the reveal. After them, 9 valid cold opens show no shift. 5 of those were traced through the nudge path. Runs that hit the dev client's startup SIGSEGV in MountingCoordinator::pullTransaction were left out. That crash is in the emulator's dropbox from before this work. * Revise a history row when its turn summary line changes LegendList renders a row again only when its item changes. The forward-order timeline in d1f2ae352 folds a finished turn into its host user message, but the host's item does not change when the fold appears, so a turn that folded live lost its summary line until something else revised the row. collapseTurns now reports the hosts whose summary line appeared, changed or went away since the previous fold (updatedHostIds), and the history row revision treats them as changed content. * Stop following the end while a user scroll owns the viewport The bottom anchor controller kept sticky-bottom for the whole of a drag and its momentum and only decided at the end. While it is sticky the native list mounts the end pin, so a drag started during a stream had every new line move the rows under the finger: on the iOS simulator the offset jumped by each line's height (+22, +35, +22 pt) mid-drag, and Android does the same with the same code. beginUserScroll now detaches. endUserScroll resumes following when the gesture ends at the end (scrolling there without animation) and otherwise stays detached and drops any pending anchor, as before. The re-stick is not animated: on Android a line that mounts during a smooth scroll cancels it, and the list then followed 40 pt short of the end until the controller detached it. Measured after the change, frame by frame: - iOS and Android, drag up mid-stream: the content tracks the finger and momentum with no line steps; the stream grows below; tapping the pill re-sticks and follows again. - A short drag at the end, mid-stream: following resumes; the release lands on the end in one frame (the drag distance, here 8 pt on iOS and 21 dp on Android). A line already mounting when the drag begins can still move the rows once in its first frame, because the detach reaches native one commit after the touch. * Correct the iOS scroll view under maintainVisibleContentPosition Phase 2 of the LegendList timeline. The native timeline relies on maintainVisibleContentPosition for the end pin and the disclosure hold, and React Native 0.86 on iOS gets two cases wrong. modules/paseo-scroll now registers PaseoScrollViewComponentView, a subclass of RCTScrollViewComponentView, for the iOS scroll view, like PaseoScrollView on Android. - A mount that removes its own anchor: detaching removes the end pin in the same mount that opens the tapped disclosure, and the offset jumped by the removed view's frame. The subclass keeps the offset when the anchor's tag is no longer registered, the check React Native 0.88 adds in https://github.com/react/react-native/pull/57294. That PR's extra superview check is not copied because it skips anchors detached by removeClippedSubviews (https://github.com/react/react-native/issues/58910). - A shrink at the end: UIKit clamps the offset to the new end during the mount, then React Native adds the anchor's movement, so a turn folding while following landed above the end (https://github.com/react/react-native/issues/58578). The subclass restores the pre-mount offset for the adjustment and clamps after it, as https://github.com/react/react-native/pull/58695 does. The dev client was rebuilt with the module. Verified on the iPhone 16 Pro simulator, frame by frame: the summary far up and the latest turn's summary while following each keep the trigger at 0 px with one layout change per toggle, the todo card the same, the cold open lands still, older history pages keep the visible rows in place, and the keyboard, send-time shrink and streaming stay pinned to the end. Freshly mounted markdown on iOS paints one frame after its layout, because enriched-markdown renders asynchronously (https://github.com/software-mansion/enriched-markdown/issues/1131). A synchronous first render removed that frame but raised fling frame time at p90 and p99, so it is not part of this change. docs/agent-stream-disclosure.md now describes the clamp correction on both platforms. * Keep the rows under the finger at a drag's start and its release Two one-frame row movements remained around a user scroll while the timeline streams. A drag's first frames. The end pin stays mounted until JS stops following, one round trip after the drag begins, so a line mounting in those frames scrolled the rows under the finger by its height. Both scroll view subclasses now skip the content-position correction while the user drags and the anchor is the end pin, which they recognise by its native ID ("paseo-end-pin"). Android overrides scrollToPreservingMomentum, the position keeper's only scroll call, from the begin-drag event until the finger lifts; iOS skips the adjustment while the scroll view is dragging. The skip is limited to the pin: LegendList's own anchoring for the detached list also uses the native correction, and a history page landing mid-drag needs it. It starts at the drag rather than at touch-down: a tap or long press while following would otherwise leave the list stranded short of its end, still following, once the finger lifts. The release. A gesture ending within 32 pt of the end re-stuck with an instant scroll, a snap of up to 56 px. Following now resumes only when the finger lifts at or past the end, or momentum stops there, within 1 px, the distance web resumes at (strategy-web.tsx). Anything else stays detached with the pill. The check runs when the gesture is decided, so output that arrived below meanwhile counts. A release past the end counts as at the end: on iOS it bounces back, and a line landing during the bounce scrolls in as following would. endUserScroll takes isAtEnd, like releaseDisclosure. Tests: VisibleContentPositionClampTest gains growth at the end during a drag (red before the change: the offset moved by the 120 px growth, 352 -> 472) and growth without a touch (the pin still follows); the module suite passes on emulator-5558, 11 tests. bottom-anchor-controller.test.ts: a release near but short of the end stays detached. Device, frame scans while streaming (dev clients rebuilt): - Android, 8 slow drags with a pill tap between: no frame moves against the finger once a drag starts; the stream follows between drags. Three short releases 50 px short of the end stay put until the pill; three drags back past the end resume following. - iOS simulator, 6 drags: no line step during any drag or its momentum. Two short releases stay detached with no snap; three drags past the end resume following within 0.5 s of the bounce. * Document the LegendList timeline and remove what the inverted list left The native section of docs/agent-stream-disclosure.md described the FlatList hold (anchor neighbour, native child index, frame spacing, render window). It now covers why the timeline is forward order, who owns the offset in each state, the hold and its sync layout trigger, user scroll and release, draw distance numbers, the LegendList patch and the scroll view corrections. Draw distance stays at 2000. The spike measured it on a chat with a 15,000 px turn expanded: 500 blanked the viewport 1.0 to 1.5 s per fling and 2000 not at all. A re-measure on the collapsed chat (500, 1000, 1500, 2000, interleaved) blanked at no value and its jank followed host load, which stayed between 19 and 40, so it could not separate 1000 or 1500 from 2000. The patch file now opens with a header listing its eight hunks by purpose and linking LegendApp/legend-list#593, which reports each one upstream. The markdown doc records the iOS first-paint delay (software-mansion/enriched-markdown#1131). Removed with the inverted list: PaseoScrollView's child-reveal override (a no-op without the inverting transform) and ScrollSelectionTest, the invertedWrapper style, and the inverted-list passages in android.md, native-text-selection.md, mobile-testing.md, floating-panels.md and agent-stream-performance.md. model.test, layout.test and footer-spacing.test still asserted the inverted native order and failed; they now assert forward order, and footer-spacing uses the real strategies instead of an inverted stub. * fix(app): show a reply's footer when the next prompt arrives on native LegendList re-renders a mounted row only when its item or extraData changes. When a new prompt arrives, the previous reply's footer moves from the live auxiliary slot into that reply's layout item (completedFooter). The reply's StreamItem keeps its identity, and renderItem is a stable event, so the row never rendered its new layout and the footer (copy, timing, fork) disappeared until the row remounted. FlatList had the same gap. The history renderer is now LegendList's extraData. Its identity changes with the history layout map, and StreamRow's memo limits the pass to rows whose layout item changed. * test(app): run the web disclosure hold cases in a real browser The three hold cases simulated layout in jsdom: hand-written row heights, scroll clamping and resize callbacks. They could pass while Chromium paints the trigger somewhere else. They now run in Vitest browser mode with real layout, ResizeObserver and scroll clamping. The two hold cases fail when the hold is bypassed. The browser project pre-bundles @tanstack/react-virtual, so its first import no longer reloads the test mid-run. The lucide stub gains ArrowDown, which pane-find imports. * fix(app): let a drag end a disclosure hold on native A drag detached the bottom controller but kept the disclosure hold. Every item size change restarts the hold's quiet frames, including a streaming row's, so the hold can outlive the toggle. While it lasts, shouldRestorePosition accepts only the held row. Once the drag scrolls that row away, a history page arriving mid-gesture gets no anchor, and the rows the reader was on move by the page's height. The drag now cancels the hold without releasing it. The controller keeps no hold state of its own beyond detached, and the gesture's end decides whether following resumes. * perf(app): keep the scroll-to-bottom button's state out of the timeline Opening a tool call or turn at the end of the chat now holds its trigger in place, so the timeline detaches and the scroll-to-bottom button appears. That visibility was useState in AgentStreamView, so showing the button re-rendered the whole timeline view for a change only the button reads. The viewport now writes near-bottom into a per-agent store that only the button subscribes to. * fix(app): show the scroll-to-bottom button on native whenever following has stopped A gesture now resumes following only when it ends within 1 px of the end, but the button still hid within 32 px. A release 2-32 px short of the end left the list detached with no button to return. While detached the button now hides only at the end; while following it keeps the 32 px tolerance so content growth that the offset trails for a frame does not flash it. The button also updates when following starts or stops without a scroll. * fix(app): stop the timeline jumping when the keyboard opens or closes on native The keyboard's settled height was committed to the list after the motion, as paddingTop on Android and contentInset.top on iOS, to keep the top of the history reachable under the translated dock. While following, the end pin absorbed it in the same mount. While detached or holding a disclosure, nothing did: Android's native anchor is LegendList's ScrollAdjust view, which padding does not move, and LegendList compensates a padding change only on iOS. Every row jumped by the keyboard height 0.2-1 s after the keyboard settled, and back after it closed. On send, the same commit raced the jump to the end. The keyboard now only translates the list with the composer. The cost: while the keyboard is open, the composer viewport clips the top keyboard-height of the list, so the start of a short conversation is hidden until it closes. * chore(app): describe the native timeline as LegendList in stream comments * fix(app): keep a disclosure's trigger in place when its row is cut off at the top on native LegendList's idsInView starts at the first fully visible row. When a turn host's prompt bubble sat above the viewport, a disclosure hold found no anchor in the data pass (shouldRestorePosition rejects every other row), and the size pass anchored on the row below the host instead, so the trigger moved by the host's size change. The patch appends the partly visible rows to idsInView after the fully visible ones, so the held row anchors while every pass that does not restrict the anchor keeps the first fully visible row. The browser test renders the patched native build, which vitest now aliases instead of the package's unpatched web build. * fix(app): let a turn's summary line collapse again after it opens The React Compiler cached StreamRow's `renderStreamItem(layoutItem)` on the layout item and the renderer. The revised item that useRevisedHistoryRows hands a row whose display state changed only fed the row id, so the row reused its cached content. Opening a turn usually inserts its rows directly below the host, which also gives the host a new layout item. When another row sits between them, such as a compaction marker, the host kept its layout item, its summary line stayed collapsed, and every later tap asked to open the turn again. The renderer now takes the item it renders, so the compiler's cache keys on the revision. StreamRow moves to its own module, which the tests compile the way Expo does. * test(app): alias the patched LegendList build in browser tests only Unit tests load @legendapp/list outside Vite, so the native build's react-native import skipped the react-native-web alias and reached React Native's Flow source, failing every unit suite that imports the native strategy. * fix(app): keep a size-only disclosure's trigger in place when its row is cut off at the top on native LegendList's prepareMVCP picks the anchor for a size change with no data change as the first row in view, without asking shouldRestorePosition. A disclosure that only grows its own row (a todo card) while that row's top was above the viewport therefore held the row below it, and the trigger moved by the row's size change. The patch now applies shouldRestorePosition to size changes as it already does to data changes. * test(app): render the timeline row revision test in a real browser The repo's unit tests do not mount components in JSDOM. The test still compiles stream-row.tsx with the React Compiler, so it fails when a revised row ignores the item it was handed.
748 lines
29 KiB
TypeScript
748 lines
29 KiB
TypeScript
import {
|
|
type ReactElement,
|
|
type ReactNode,
|
|
useCallback,
|
|
useEffect,
|
|
useLayoutEffect,
|
|
useMemo,
|
|
useRef,
|
|
useState,
|
|
} from "react";
|
|
import {
|
|
View,
|
|
type LayoutChangeEvent,
|
|
type NativeScrollEvent,
|
|
type NativeSyntheticEvent,
|
|
type ScrollView,
|
|
type ScrollViewProps,
|
|
type ViewStyle,
|
|
} from "react-native";
|
|
import {
|
|
LegendList,
|
|
type LegendListRef,
|
|
type LegendListRenderItemProps,
|
|
useSyncLayout,
|
|
} from "@legendapp/list/react-native";
|
|
import { withUnistyles } from "react-native-unistyles";
|
|
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
|
import type { StreamItem } from "@/types/stream";
|
|
import type { Theme } from "@/styles/theme";
|
|
import { useStableEvent } from "@/hooks/use-stable-event";
|
|
import { shouldAnimateNativeScrollToBottom } from "./native-scroll-animation";
|
|
import { useRevisedHistoryRows } from "./history-row-revision";
|
|
import { useBottomAnchorController } from "./bottom-anchor-controller";
|
|
import { useScrollKeyboardDismiss } from "./scroll-keyboard-dismiss/use-scroll-keyboard-dismiss";
|
|
import { createNativeDisclosureHold } from "./native-disclosure-hold";
|
|
import { EndPinnedScrollView } from "./native-end-pin";
|
|
import { createNewRowEstimates } from "./new-row-estimates";
|
|
import type { StreamRenderInput, StreamStrategy, StreamViewportHandle } from "./strategy";
|
|
import { createStreamStrategy, isNearBottomForStreamRenderStrategy } from "./strategy";
|
|
import {
|
|
abandonHistoryStartPaginationRequest,
|
|
createHistoryStartPaginationState,
|
|
evaluateHistoryStartPagination,
|
|
isHistoryStartLoadingOperation,
|
|
rearmHistoryStartPagination,
|
|
settleHistoryStartPagination,
|
|
type HistoryStartPaginationInput,
|
|
type HistoryStartPaginationTransition,
|
|
} from "./history-start-pagination";
|
|
import { useStreamTopOverlayInset } from "./top-overlay";
|
|
import {
|
|
createHistoryStartSettleScheduler,
|
|
type HistoryStartSettleScheduler,
|
|
} from "./history-start-settle-scheduler";
|
|
|
|
const ThemedLoadingSpinner = withUnistyles(LoadingSpinner);
|
|
const foregroundMutedColorMapping = (theme: Theme) => ({
|
|
color: theme.colors.foregroundMuted,
|
|
});
|
|
const historyStartSlotStyle: ViewStyle = {
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
height: 32,
|
|
flexShrink: 0,
|
|
};
|
|
const HISTORY_START_SETTLE_FRAMES = 2;
|
|
// Rendered distance on each side of the viewport. Smaller values blank the viewport while a fling
|
|
// crosses rows that were never measured (docs/agent-stream-disclosure.md).
|
|
const NATIVE_STREAM_DRAW_DISTANCE = 2000;
|
|
// Following resumes after a disclosure or a user scroll only from the end, so resuming never moves
|
|
// the rows the user is looking at. Web resumes within the same distance (strategy-web.tsx).
|
|
const AT_END_OFFSET_PX = 1;
|
|
// A disclosure settles after this many frames without an item size change.
|
|
const DISCLOSURE_QUIET_FRAMES = 2;
|
|
const BOTTOM_ANCHOR_TRANSPORT_BEHAVIOR = Object.freeze({
|
|
verificationDelayFrames: 2,
|
|
verificationRetryMode: "recheck" as const,
|
|
});
|
|
|
|
type RowLayoutSyncRegistry = Map<string, () => void>;
|
|
|
|
// A disclosure toggle changes a row from the row's own state, so LegendList's container does not
|
|
// re-render and would learn the new height from onLayout a task later, a frame after the change
|
|
// painted. The row's measurement trigger, called next to the toggle, batches the measurement and
|
|
// the corrected positions into the toggle's own commit.
|
|
function RowLayoutSync(props: {
|
|
rowId: string;
|
|
registry: RowLayoutSyncRegistry;
|
|
children: ReactNode;
|
|
}) {
|
|
const { rowId, registry } = props;
|
|
const syncLayout = useSyncLayout();
|
|
useLayoutEffect(() => {
|
|
registry.set(rowId, syncLayout);
|
|
return () => {
|
|
if (registry.get(rowId) === syncLayout) {
|
|
registry.delete(rowId);
|
|
}
|
|
};
|
|
}, [registry, rowId, syncLayout]);
|
|
return props.children;
|
|
}
|
|
|
|
function distanceFromEnd(input: {
|
|
offsetY: number;
|
|
contentHeight: number;
|
|
viewportHeight: number;
|
|
}): number {
|
|
return Math.max(0, input.contentHeight - input.viewportHeight - input.offsetY);
|
|
}
|
|
|
|
function keyExtractor(item: { id: string }): string {
|
|
return item.id;
|
|
}
|
|
|
|
function NativeStreamViewport(props: StreamRenderInput & { strategy: StreamStrategy }) {
|
|
const {
|
|
agentId,
|
|
segments,
|
|
historyRowRevision,
|
|
liveHeadRowRevision,
|
|
boundary,
|
|
renderers,
|
|
listEmptyComponent,
|
|
viewportRef,
|
|
routeBottomAnchorRequest,
|
|
isAuthoritativeHistoryReady,
|
|
onNearBottomChange,
|
|
onNearHistoryStart,
|
|
isLoadingOlderHistory,
|
|
hasOlderHistory,
|
|
olderHistoryProgressKey,
|
|
scrollEnabled,
|
|
listStyle,
|
|
baseListContentContainerStyle,
|
|
strategy,
|
|
} = props;
|
|
const { renderHistoryMountedRow, renderLiveHeadRow, renderLiveAuxiliary } = renderers;
|
|
const listRef = useRef<LegendListRef>(null);
|
|
// LegendList places the rows of each agent once, behind a hidden reveal (`dataKey`).
|
|
const [placedAgentId, setPlacedAgentId] = useState<string | null>(null);
|
|
const isListPlaced = placedAgentId === agentId;
|
|
const isListPlacedRef = useRef(isListPlaced);
|
|
isListPlacedRef.current = isListPlaced;
|
|
const streamViewportMetricsRef = useRef({
|
|
containerKey: "native-virtualized",
|
|
contentHeight: 0,
|
|
viewportWidth: 0,
|
|
viewportHeight: 0,
|
|
offsetY: 0,
|
|
viewportMeasuredForKey: null as string | null,
|
|
contentMeasuredForKey: null as string | null,
|
|
});
|
|
const scrollOffsetYRef = useRef(0);
|
|
const isUserScrollActiveRef = useRef(false);
|
|
const scrollKeyboardDismiss = useScrollKeyboardDismiss();
|
|
const userScrollEndFrameIdRef = useRef<number | null>(null);
|
|
const isReleasedAtEndRef = useRef(false);
|
|
const programmaticScrollEventBudgetRef = useRef(0);
|
|
const historyStartReadyRef = useRef(false);
|
|
const [historyStartPaginationState, setHistoryStartPaginationState] = useState(
|
|
createHistoryStartPaginationState,
|
|
);
|
|
const historyStartPaginationStateRef = useRef(historyStartPaginationState);
|
|
const historyStartSettleSchedulerRef = useRef<HistoryStartSettleScheduler | null>(null);
|
|
|
|
const historyItems = useMemo(() => {
|
|
if (segments.historyVirtualized.length === 0) {
|
|
return segments.historyMounted;
|
|
}
|
|
return [...segments.historyVirtualized, ...segments.historyMounted];
|
|
}, [segments.historyMounted, segments.historyVirtualized]);
|
|
const historyRows = useRevisedHistoryRows(historyItems, historyRowRevision);
|
|
// Live rows are the tail of the list, so a row that finishes keeps its id, container and measured
|
|
// size when it moves into history. A fresh identity per live-head change re-renders every live
|
|
// row, which is how they pick up neighbour and expansion changes (`liveHeadRowRevision`).
|
|
const liveRows = useMemo(() => {
|
|
void liveHeadRowRevision;
|
|
return segments.liveHead.map((item) => ({ ...item }));
|
|
}, [segments.liveHead, liveHeadRowRevision]);
|
|
const liveRowIds = useMemo(() => new Set(liveRows.map((item) => item.id)), [liveRows]);
|
|
const [newRowEstimates] = useState(() => createNewRowEstimates<StreamItem>());
|
|
const rows = useMemo(() => {
|
|
const nextRows = [...historyRows, ...liveRows];
|
|
newRowEstimates.noteRows(nextRows);
|
|
return nextRows;
|
|
}, [newRowEstimates, historyRows, liveRows]);
|
|
const getEstimatedItemSize = useStableEvent((item: StreamItem) => newRowEstimates.estimate(item));
|
|
const getHistoryStartPaginationInput = useStableEvent((): HistoryStartPaginationInput => {
|
|
const metrics = streamViewportMetricsRef.current;
|
|
const hasMeasuredViewport =
|
|
metrics.viewportMeasuredForKey === metrics.containerKey &&
|
|
metrics.contentMeasuredForKey === metrics.containerKey;
|
|
return {
|
|
distanceFromHistoryStart: metrics.offsetY,
|
|
hasOlderHistory,
|
|
isLoadingOlderHistory,
|
|
isReady: historyStartReadyRef.current && hasMeasuredViewport,
|
|
progressKey: olderHistoryProgressKey,
|
|
};
|
|
});
|
|
const applyHistoryStartPaginationTransition = useStableEvent(
|
|
(transition: HistoryStartPaginationTransition) => {
|
|
const previousState = historyStartPaginationStateRef.current;
|
|
historyStartPaginationStateRef.current = transition.state;
|
|
if (transition.state !== previousState) {
|
|
setHistoryStartPaginationState(transition.state);
|
|
}
|
|
if (transition.shouldLoad) {
|
|
const requestedProgressKey = olderHistoryProgressKey;
|
|
if (requestedProgressKey === null) {
|
|
return;
|
|
}
|
|
void (async () => {
|
|
const started = await onNearHistoryStart();
|
|
if (started === true) {
|
|
return;
|
|
}
|
|
applyHistoryStartPaginationTransition({
|
|
state: abandonHistoryStartPaginationRequest(
|
|
historyStartPaginationStateRef.current,
|
|
requestedProgressKey,
|
|
),
|
|
shouldLoad: false,
|
|
});
|
|
})();
|
|
}
|
|
},
|
|
);
|
|
const evaluateHistoryStart = useStableEvent(() => {
|
|
const transition = evaluateHistoryStartPagination(
|
|
historyStartPaginationStateRef.current,
|
|
getHistoryStartPaginationInput(),
|
|
);
|
|
applyHistoryStartPaginationTransition(transition);
|
|
});
|
|
const scheduleHistoryStartSettle = useStableEvent(() => {
|
|
let scheduler = historyStartSettleSchedulerRef.current;
|
|
if (!scheduler) {
|
|
scheduler = createHistoryStartSettleScheduler({
|
|
settleFrames: HISTORY_START_SETTLE_FRAMES,
|
|
requestFrame: requestAnimationFrame,
|
|
cancelFrame: cancelAnimationFrame,
|
|
isSettling: () => historyStartPaginationStateRef.current.status === "settling",
|
|
isLoading: () => getHistoryStartPaginationInput().isLoadingOlderHistory,
|
|
onSettle: () => {
|
|
const transition = settleHistoryStartPagination(
|
|
historyStartPaginationStateRef.current,
|
|
getHistoryStartPaginationInput(),
|
|
);
|
|
applyHistoryStartPaginationTransition(transition);
|
|
},
|
|
});
|
|
historyStartSettleSchedulerRef.current = scheduler;
|
|
}
|
|
scheduler.schedule();
|
|
});
|
|
|
|
const clearPendingUserScrollEnd = useCallback(() => {
|
|
if (userScrollEndFrameIdRef.current !== null) {
|
|
cancelAnimationFrame(userScrollEndFrameIdRef.current);
|
|
userScrollEndFrameIdRef.current = null;
|
|
}
|
|
}, []);
|
|
|
|
const getBottomAnchorTransportBehavior = useCallback(() => BOTTOM_ANCHOR_TRANSPORT_BEHAVIOR, []);
|
|
|
|
const scrollToBottom = useCallback(
|
|
(animated: boolean) => {
|
|
programmaticScrollEventBudgetRef.current = 3;
|
|
const metrics = streamViewportMetricsRef.current;
|
|
// The native scroll view finds its end from the content it has mounted, and the end pin holds
|
|
// it from there. LegendList's own scrollToEnd keeps re-aiming at the end its JS sizes predict
|
|
// until it lands, which runs ahead of the mount and scrolls the end out of view.
|
|
const list = listRef.current;
|
|
list?.cancelScroll();
|
|
// The scroll component is `EndPinnedScrollView`, a ScrollView.
|
|
(list?.getNativeScrollRef() as ScrollView | undefined)?.scrollToEnd({
|
|
animated:
|
|
animated &&
|
|
shouldAnimateNativeScrollToBottom({
|
|
distanceFromEnd: distanceFromEnd(metrics),
|
|
viewportHeight: metrics.viewportHeight,
|
|
drawDistance: NATIVE_STREAM_DRAW_DISTANCE,
|
|
}),
|
|
});
|
|
const endOffsetY = Math.max(0, metrics.contentHeight - metrics.viewportHeight);
|
|
scrollOffsetYRef.current = endOffsetY;
|
|
streamViewportMetricsRef.current = { ...metrics, offsetY: endOffsetY };
|
|
onNearBottomChange(true);
|
|
},
|
|
[onNearBottomChange],
|
|
);
|
|
|
|
const bottomAnchorController = useBottomAnchorController({
|
|
agentId,
|
|
routeRequest: routeBottomAnchorRequest,
|
|
isAuthoritativeHistoryReady,
|
|
renderStrategy: "legend-stream",
|
|
getTransportBehavior: getBottomAnchorTransportBehavior,
|
|
getMeasurementState: () => streamViewportMetricsRef.current,
|
|
isNearBottom: () => {
|
|
const metrics = streamViewportMetricsRef.current;
|
|
return isNearBottomForStreamRenderStrategy({
|
|
strategy,
|
|
offsetY: metrics.offsetY,
|
|
threshold: 32,
|
|
contentHeight: metrics.contentHeight,
|
|
viewportHeight: metrics.viewportHeight,
|
|
});
|
|
},
|
|
scrollToBottom,
|
|
});
|
|
|
|
const [rowLayoutSyncRegistry] = useState<RowLayoutSyncRegistry>(() => new Map());
|
|
const isAtEnd = useStableEvent(
|
|
() => distanceFromEnd(streamViewportMetricsRef.current) <= AT_END_OFFSET_PX,
|
|
);
|
|
const releaseDisclosure = useStableEvent(() => {
|
|
bottomAnchorController.releaseDisclosure({ isAtEnd: isAtEnd() });
|
|
});
|
|
const [disclosureHold] = useState(() =>
|
|
createNativeDisclosureHold({
|
|
quietFrames: DISCLOSURE_QUIET_FRAMES,
|
|
requestFrame: requestAnimationFrame,
|
|
cancelFrame: cancelAnimationFrame,
|
|
onRelease: releaseDisclosure,
|
|
}),
|
|
);
|
|
useEffect(() => () => disclosureHold.cancel(), [disclosureHold]);
|
|
// The hold detaches the controller in the same event as `apply`, so the toggle's commit already
|
|
// has end following off and LegendList anchoring on the held row. The row's measurement trigger
|
|
// makes that same commit carry the row's new height.
|
|
const holdRow = useStableEvent((rowId: string, apply: () => void) => {
|
|
disclosureHold.hold(rowId);
|
|
bottomAnchorController.holdForDisclosure();
|
|
apply();
|
|
rowLayoutSyncRegistry.get(rowId)?.();
|
|
});
|
|
const handleItemSizeChanged = useStableEvent(
|
|
(info: { size: number; previous: number; itemKey: string; itemData: StreamItem }) => {
|
|
newRowEstimates.noteMeasured(info.itemData, info.size);
|
|
disclosureHold.noteItemSizeChanged();
|
|
},
|
|
);
|
|
const shouldRestorePosition = useStableEvent((item: StreamItem) => {
|
|
const heldRowId = disclosureHold.heldRowId();
|
|
return heldRowId === null || item.id === heldRowId;
|
|
});
|
|
// One owner keeps the scroll offset at any moment:
|
|
// - Before the list has placed its rows for the agent: LegendList's initial scroll to the end. It
|
|
// keeps the rows hidden until they are measured and in place, so neither the pin nor the
|
|
// controller acts; the content does not count as measured yet (`handleContentSizeChange`).
|
|
// - Following the end: the end pin. Rows added, rows resized and footer changes never scroll from
|
|
// JS; the pin holds the end in the frame the change mounts. The controller scrolls only for a
|
|
// viewport resize (the composer growing or shrinking), which the pin cannot see, and for an
|
|
// explicit jump, and both go to the native end (`scrollToBottom`). The keyboard does not resize
|
|
// the viewport: it translates the list with the composer. LegendList's end keeping stays off: it
|
|
// scrolls to the end its JS sizes predict, which runs ahead of the native mount, so it lands
|
|
// short of the real end and the controller reads that as the user scrolling away.
|
|
// - A disclosure hold: the held row. The hold detaches the controller, which removes the pin, and
|
|
// LegendList keeps only the held row in place.
|
|
// - A user scroll: the finger. The controller detaches for the gesture, so streamed lines grow below
|
|
// the rows the user is dragging, and resumes following if the gesture ends at the end.
|
|
// - Detached: the visible rows. LegendList keeps the first visible row in place, so history loading
|
|
// above or rows growing below leave what the user is reading where it is.
|
|
const isFollowingEnd = bottomAnchorController.mode === "sticky-bottom";
|
|
const pinsEnd = isFollowingEnd && isListPlaced;
|
|
const maintainVisibleContentPosition = useMemo(
|
|
() => (isFollowingEnd ? false : { data: true, size: true, shouldRestorePosition }),
|
|
[isFollowingEnd, shouldRestorePosition],
|
|
);
|
|
// A new identity re-renders LegendList's scroll component, which is how the pin follows the mode.
|
|
const renderScrollComponent = useCallback(
|
|
(scrollProps: ScrollViewProps) => <EndPinnedScrollView {...scrollProps} pinEnd={pinsEnd} />,
|
|
[pinsEnd],
|
|
);
|
|
const topOverlayInset = useStreamTopOverlayInset();
|
|
// No keyboard inset: one committed after the keyboard settles moves every row when the end pin is
|
|
// not holding the offset (docs/agent-stream-disclosure.md).
|
|
const listContentContainerStyle = useMemo(
|
|
() => [baseListContentContainerStyle, { paddingTop: topOverlayInset }],
|
|
[baseListContentContainerStyle, topOverlayInset],
|
|
);
|
|
|
|
useEffect(() => {
|
|
streamViewportMetricsRef.current = {
|
|
containerKey: "native-virtualized",
|
|
contentHeight: 0,
|
|
viewportWidth: 0,
|
|
viewportHeight: 0,
|
|
offsetY: 0,
|
|
viewportMeasuredForKey: null,
|
|
contentMeasuredForKey: null,
|
|
};
|
|
scrollOffsetYRef.current = 0;
|
|
isUserScrollActiveRef.current = false;
|
|
clearPendingUserScrollEnd();
|
|
disclosureHold.cancel();
|
|
historyStartReadyRef.current = false;
|
|
const initialHistoryStartState = createHistoryStartPaginationState();
|
|
historyStartPaginationStateRef.current = initialHistoryStartState;
|
|
setHistoryStartPaginationState(initialHistoryStartState);
|
|
const frame = requestAnimationFrame(() => {
|
|
historyStartReadyRef.current = true;
|
|
evaluateHistoryStart();
|
|
});
|
|
return () => {
|
|
cancelAnimationFrame(frame);
|
|
clearPendingUserScrollEnd();
|
|
historyStartSettleSchedulerRef.current?.cancel();
|
|
historyStartSettleSchedulerRef.current = null;
|
|
};
|
|
}, [agentId, clearPendingUserScrollEnd, disclosureHold, evaluateHistoryStart]);
|
|
|
|
useEffect(() => {
|
|
const handle: StreamViewportHandle = {
|
|
scrollToBottom: (reason = "jump-to-bottom") => {
|
|
bottomAnchorController.requestLocalAnchor({
|
|
agentId,
|
|
reason,
|
|
});
|
|
},
|
|
prepareForViewportChange: () => {
|
|
bottomAnchorController.prepareForStickyViewportChange();
|
|
},
|
|
holdRow,
|
|
};
|
|
viewportRef.current = handle;
|
|
return () => {
|
|
if (viewportRef.current === handle) {
|
|
viewportRef.current = null;
|
|
}
|
|
};
|
|
}, [agentId, bottomAnchorController, holdRow, viewportRef]);
|
|
|
|
// The scroll-to-bottom button shows whenever following would not resume on its own. A detached
|
|
// list resumes only from the end, so the button shows anywhere short of it. While following, the
|
|
// offset can trail content growth for a frame, so the controller's wider threshold keeps the
|
|
// button from flashing.
|
|
const publishNearBottom = useStableEvent(() => {
|
|
const metrics = streamViewportMetricsRef.current;
|
|
onNearBottomChange(
|
|
bottomAnchorController.mode === "detached"
|
|
? distanceFromEnd(metrics) <= AT_END_OFFSET_PX
|
|
: isNearBottomForStreamRenderStrategy({
|
|
strategy,
|
|
offsetY: metrics.offsetY,
|
|
threshold: 32,
|
|
contentHeight: metrics.contentHeight,
|
|
viewportHeight: metrics.viewportHeight,
|
|
}),
|
|
);
|
|
});
|
|
|
|
// Following starts and stops without a scroll, for example when a disclosure hold begins short of
|
|
// the end, and the button follows it.
|
|
useEffect(() => {
|
|
publishNearBottom();
|
|
}, [isFollowingEnd, publishNearBottom]);
|
|
|
|
const isScrollEventNearBottom = useStableEvent(
|
|
(event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
const { contentOffset, contentSize, layoutMeasurement } = event.nativeEvent;
|
|
return isNearBottomForStreamRenderStrategy({
|
|
strategy,
|
|
offsetY: contentOffset.y,
|
|
threshold: 32,
|
|
contentHeight: contentSize.height,
|
|
viewportHeight: layoutMeasurement.height,
|
|
});
|
|
},
|
|
);
|
|
|
|
const isScrollEventAtEnd = useStableEvent((event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
const { contentOffset, contentSize, layoutMeasurement } = event.nativeEvent;
|
|
return (
|
|
distanceFromEnd({
|
|
offsetY: contentOffset.y,
|
|
contentHeight: contentSize.height,
|
|
viewportHeight: layoutMeasurement.height,
|
|
}) <= AT_END_OFFSET_PX
|
|
);
|
|
});
|
|
|
|
const handleScroll = useStableEvent((event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
const { contentOffset, contentSize, layoutMeasurement } = event.nativeEvent;
|
|
const previousOffsetY = scrollOffsetYRef.current;
|
|
scrollOffsetYRef.current = contentOffset.y;
|
|
scrollKeyboardDismiss.onScroll(event);
|
|
|
|
streamViewportMetricsRef.current = {
|
|
contentHeight: Math.max(0, contentSize.height),
|
|
viewportWidth: Math.max(0, layoutMeasurement.width),
|
|
viewportHeight: Math.max(0, layoutMeasurement.height),
|
|
containerKey: "native-virtualized",
|
|
offsetY: contentOffset.y,
|
|
viewportMeasuredForKey: "native-virtualized",
|
|
contentMeasuredForKey: "native-virtualized",
|
|
};
|
|
|
|
const nearBottom = isScrollEventNearBottom(event);
|
|
publishNearBottom();
|
|
|
|
evaluateHistoryStart();
|
|
|
|
if (
|
|
!isUserScrollActiveRef.current &&
|
|
programmaticScrollEventBudgetRef.current > 0 &&
|
|
distanceFromEnd({
|
|
offsetY: contentOffset.y,
|
|
contentHeight: contentSize.height,
|
|
viewportHeight: layoutMeasurement.height,
|
|
}) <= 8
|
|
) {
|
|
programmaticScrollEventBudgetRef.current -= 1;
|
|
} else {
|
|
programmaticScrollEventBudgetRef.current = 0;
|
|
bottomAnchorController.handleScrollNearBottomChange({
|
|
nextIsNearBottom: nearBottom,
|
|
scrollDelta: contentOffset.y - previousOffsetY,
|
|
});
|
|
}
|
|
});
|
|
|
|
const handleScrollBeginDrag = useStableEvent((event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
clearPendingUserScrollEnd();
|
|
isUserScrollActiveRef.current = true;
|
|
scrollKeyboardDismiss.onScrollBeginDrag(event);
|
|
// The gesture takes the viewport from a disclosure hold. Size changes from a streaming row can
|
|
// keep the hold's quiet frames from ever passing, and a held row that scrolls away would leave
|
|
// no row LegendList may anchor a history page on. The gesture's end decides following.
|
|
disclosureHold.cancel();
|
|
bottomAnchorController.beginUserScroll();
|
|
const rearmed = rearmHistoryStartPagination(historyStartPaginationStateRef.current);
|
|
if (rearmed !== historyStartPaginationStateRef.current) {
|
|
historyStartPaginationStateRef.current = rearmed;
|
|
setHistoryStartPaginationState(rearmed);
|
|
evaluateHistoryStart();
|
|
}
|
|
});
|
|
|
|
// A gesture ends at the end when the finger lifts at or past it, or when its momentum stops there.
|
|
// A release past the end bounces back to it on iOS, and lines that land during the bounce scroll
|
|
// in as they do while following. Momentum stopping short of the end, or output that arrived below
|
|
// the viewport before the decision, leaves the list detached.
|
|
// Drag end is deferred a frame so momentum can take ownership.
|
|
const handleScrollEndDrag = useStableEvent((event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
scrollKeyboardDismiss.onScrollEndDrag(event);
|
|
isReleasedAtEndRef.current = isScrollEventAtEnd(event);
|
|
|
|
clearPendingUserScrollEnd();
|
|
userScrollEndFrameIdRef.current = requestAnimationFrame(() => {
|
|
userScrollEndFrameIdRef.current = null;
|
|
isUserScrollActiveRef.current = false;
|
|
bottomAnchorController.endUserScroll({
|
|
isAtEnd: isReleasedAtEndRef.current || isAtEnd(),
|
|
});
|
|
});
|
|
});
|
|
|
|
const handleMomentumScrollBegin = useStableEvent(() => {
|
|
clearPendingUserScrollEnd();
|
|
});
|
|
|
|
const handleMomentumScrollEnd = useStableEvent(
|
|
(event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
// Android can emit momentum-end after a programmatic anchor correction.
|
|
// Only momentum that still owns the user gesture may settle scroll intent.
|
|
if (!isUserScrollActiveRef.current) {
|
|
return;
|
|
}
|
|
clearPendingUserScrollEnd();
|
|
isUserScrollActiveRef.current = false;
|
|
bottomAnchorController.endUserScroll({
|
|
isAtEnd: isReleasedAtEndRef.current || isScrollEventAtEnd(event),
|
|
});
|
|
},
|
|
);
|
|
|
|
const handleListLayout = useStableEvent((event: LayoutChangeEvent) => {
|
|
const previousViewportWidth = streamViewportMetricsRef.current.viewportWidth;
|
|
const previousViewportHeight = streamViewportMetricsRef.current.viewportHeight;
|
|
const viewportWidth = Math.max(0, event.nativeEvent.layout.width);
|
|
const viewportHeight = Math.max(0, event.nativeEvent.layout.height);
|
|
streamViewportMetricsRef.current = {
|
|
...streamViewportMetricsRef.current,
|
|
containerKey: "native-virtualized",
|
|
viewportWidth,
|
|
viewportHeight,
|
|
viewportMeasuredForKey: "native-virtualized",
|
|
};
|
|
bottomAnchorController.handleViewportMetricsChange({
|
|
previousViewportWidth,
|
|
viewportWidth,
|
|
previousViewportHeight,
|
|
viewportHeight,
|
|
});
|
|
evaluateHistoryStart();
|
|
});
|
|
|
|
const handleContentSizeChange = useStableEvent((_width: number, height: number) => {
|
|
const nextContentHeight = Math.max(0, height);
|
|
streamViewportMetricsRef.current = {
|
|
...streamViewportMetricsRef.current,
|
|
containerKey: "native-virtualized",
|
|
contentHeight: nextContentHeight,
|
|
contentMeasuredForKey: isListPlacedRef.current ? "native-virtualized" : null,
|
|
};
|
|
bottomAnchorController.handleContentSizeChange();
|
|
// Content growing below a detached viewport moves the end away without a scroll event.
|
|
if (
|
|
bottomAnchorController.mode === "detached" &&
|
|
streamViewportMetricsRef.current.viewportHeight > 0
|
|
) {
|
|
publishNearBottom();
|
|
}
|
|
evaluateHistoryStart();
|
|
if (historyStartPaginationStateRef.current.status === "settling") {
|
|
scheduleHistoryStartSettle();
|
|
}
|
|
});
|
|
|
|
const handleListPlaced = useStableEvent(() => {
|
|
isListPlacedRef.current = true;
|
|
setPlacedAgentId(agentId);
|
|
streamViewportMetricsRef.current = {
|
|
...streamViewportMetricsRef.current,
|
|
contentMeasuredForKey: "native-virtualized",
|
|
};
|
|
bottomAnchorController.handleContentSizeChange();
|
|
});
|
|
|
|
useEffect(() => {
|
|
evaluateHistoryStart();
|
|
if (historyStartPaginationStateRef.current.status === "settling") {
|
|
scheduleHistoryStartSettle();
|
|
}
|
|
}, [
|
|
evaluateHistoryStart,
|
|
hasOlderHistory,
|
|
isLoadingOlderHistory,
|
|
olderHistoryProgressKey,
|
|
scheduleHistoryStartSettle,
|
|
]);
|
|
|
|
// LegendList re-renders a mounted row only when its item or `extraData` changes, not when
|
|
// renderItem does. Item identity carries content and display changes (`useRevisedHistoryRows`);
|
|
// `extraData` carries the history renderer, whose identity changes with the history layout (a
|
|
// reply gaining its completed footer when the next prompt arrives) and keeps its row's item.
|
|
// StreamRow's memo limits that pass to the rows whose layout item changed.
|
|
const renderItem = useStableEvent(
|
|
({ item, index }: LegendListRenderItemProps<StreamItem>): ReactElement => (
|
|
<RowLayoutSync rowId={item.id} registry={rowLayoutSyncRegistry}>
|
|
{liveRowIds.has(item.id)
|
|
? renderLiveHeadRow(item, index - historyRows.length, segments.liveHead)
|
|
: renderHistoryMountedRow(item, index, historyItems)}
|
|
</RowLayoutSync>
|
|
),
|
|
);
|
|
|
|
const liveAuxiliaryContent = useMemo(() => {
|
|
const liveAuxiliary = renderLiveAuxiliary();
|
|
if (
|
|
liveRows.length === 0 &&
|
|
!liveAuxiliary &&
|
|
!boundary.hasMountedHistory &&
|
|
!boundary.hasVirtualizedHistory
|
|
) {
|
|
return (listEmptyComponent ?? null) as ReactElement | null;
|
|
}
|
|
return <View>{liveAuxiliary}</View>;
|
|
}, [boundary, listEmptyComponent, liveRows.length, renderLiveAuxiliary]);
|
|
|
|
const historyStartContent = useMemo(() => {
|
|
const isLoadingOperation = isHistoryStartLoadingOperation(historyStartPaginationState);
|
|
return (
|
|
<View style={historyStartSlotStyle} testID="older-history-slot">
|
|
{isLoadingOperation ? (
|
|
<View testID="load-older-history-spinner">
|
|
<ThemedLoadingSpinner size="small" uniProps={foregroundMutedColorMapping} />
|
|
</View>
|
|
) : null}
|
|
</View>
|
|
);
|
|
}, [historyStartPaginationState]);
|
|
|
|
return (
|
|
<LegendList<StreamItem>
|
|
ref={listRef}
|
|
data={rows}
|
|
renderItem={renderItem}
|
|
extraData={renderHistoryMountedRow}
|
|
keyExtractor={keyExtractor}
|
|
testID="agent-chat-scroll"
|
|
nativeID="agent-chat-scroll-native-virtualized"
|
|
ListHeaderComponent={historyStartContent}
|
|
ListFooterComponent={liveAuxiliaryContent ?? undefined}
|
|
contentContainerStyle={listContentContainerStyle}
|
|
automaticallyAdjustContentInsets={false}
|
|
automaticallyAdjustsScrollIndicatorInsets={false}
|
|
contentInsetAdjustmentBehavior="never"
|
|
style={listStyle}
|
|
onLayout={handleListLayout}
|
|
onScroll={handleScroll}
|
|
onScrollBeginDrag={handleScrollBeginDrag}
|
|
onScrollEndDrag={handleScrollEndDrag}
|
|
onMomentumScrollBegin={handleMomentumScrollBegin}
|
|
onMomentumScrollEnd={handleMomentumScrollEnd}
|
|
scrollEventThrottle={16}
|
|
onContentSizeChange={handleContentSizeChange}
|
|
onItemSizeChanged={handleItemSizeChanged}
|
|
onReady={handleListPlaced}
|
|
dataKey={agentId}
|
|
maintainVisibleContentPosition={maintainVisibleContentPosition}
|
|
renderScrollComponent={renderScrollComponent}
|
|
recycleItems={false}
|
|
alignItemsAtEnd
|
|
initialScrollAtEnd
|
|
drawDistance={NATIVE_STREAM_DRAW_DISTANCE}
|
|
getEstimatedItemSize={getEstimatedItemSize}
|
|
scrollEnabled={scrollEnabled}
|
|
showsVerticalScrollIndicator
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function createNativeStreamStrategy(): StreamStrategy {
|
|
const strategy = createStreamStrategy({
|
|
render: (renderInput) => <NativeStreamViewport {...renderInput} strategy={strategy} />,
|
|
orderTailReverse: false,
|
|
orderHeadReverse: false,
|
|
assistantTurnTraversalStep: -1,
|
|
edgeSlot: "footer",
|
|
historyLiveBoundaryEdge: "last",
|
|
liveHeadHistoryBoundaryEdge: "first",
|
|
frameChildOrder: "content-then-footer",
|
|
bottomAnchorTransportBehavior: BOTTOM_ANCHOR_TRANSPORT_BEHAVIOR,
|
|
disableParentScrollOnInlineDetailsExpansion: false,
|
|
anchorBottomOnContentSizeChange: false,
|
|
animateManualScrollToBottom: true,
|
|
useVirtualizedList: true,
|
|
isNearBottom: (input) => distanceFromEnd(input) <= input.threshold,
|
|
getBottomOffset: (metrics) => Math.max(0, metrics.contentHeight - metrics.viewportHeight),
|
|
});
|
|
return strategy;
|
|
}
|