1+ import {
2+ WorktreeWorkingHeader ,
3+ WorktreeSetupCard ,
4+ type WorktreeSetupCardProps ,
5+ } from "./worktree-setup-card" ;
16import * as Haptics from "expo-haptics" ;
27import { KeyboardAwareLegendList } from "@legendapp/list/keyboard" ;
38import { useViewabilityAmount , type LegendListRef } from "@legendapp/list/react-native" ;
@@ -240,6 +245,8 @@ function isFreshTimestamp(input: string): boolean {
240245}
241246
242247export interface ThreadFeedProps {
248+ readonly worktreeSetup ?: WorktreeSetupCardProps | null ;
249+ readonly setupWorkingStartedAt ?: string | null ;
243250 readonly queuedMessages : ReadonlyArray < QueuedThreadMessage > ;
244251 readonly dispatchingMessageId : MessageId | null ;
245252 readonly onEditPendingMessage : ( message : QueuedThreadMessage ) => void ;
@@ -2273,6 +2280,8 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
22732280 // even when the final message update arrives before the turn settles.
22742281 const listAppearanceData = useMemo (
22752282 ( ) => ( {
2283+ worktreeSetup : props . worktreeSetup ,
2284+ setupWorkingStartedAt : props . setupWorkingStartedAt ,
22762285 dispatchingMessageId : props . dispatchingMessageId ,
22772286 unsettledTurnId,
22782287 copiedRowId,
@@ -2287,6 +2296,8 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
22872296 viewportWidth,
22882297 } ) ,
22892298 [
2299+ props . worktreeSetup ,
2300+ props . setupWorkingStartedAt ,
22902301 props . dispatchingMessageId ,
22912302 unsettledTurnId ,
22922303 copiedRowId ,
@@ -2454,6 +2465,9 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
24542465 props . latestTurn ,
24552466 ] ,
24562467 ) ;
2468+ const setupAnchorIndex = presentedFeed . findIndex (
2469+ ( entry ) => entry . type === "message" && entry . message . role === "user" ,
2470+ ) ;
24572471 // The empty↔filled key below remounts the list and resets its imperative
24582472 // content-inset override. Seed the fresh instance synchronously with the
24592473 // current overlay height before the scroll integration's next reaction;
@@ -2765,10 +2779,19 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
27652779 skills : props . skills ,
27662780 onUseArtifactTemplate : props . onUseArtifactTemplate ,
27672781 } ) }
2782+ { props . worktreeSetup && info . index === setupAnchorIndex ? (
2783+ < WorktreeSetupCard key = { props . threadId } { ...props . worktreeSetup } />
2784+ ) : props . setupWorkingStartedAt && info . index === setupAnchorIndex ? (
2785+ < WorktreeWorkingHeader startedAt = { props . setupWorkingStartedAt } />
2786+ ) : null }
27682787 </ ThreadMediaVisibility >
27692788 </ Animated . View >
27702789 ) ,
27712790 [
2791+ props . worktreeSetup ,
2792+ props . setupWorkingStartedAt ,
2793+ props . threadId ,
2794+ setupAnchorIndex ,
27722795 props . dispatchingMessageId ,
27732796 props . onEditPendingMessage ,
27742797 copiedRowId ,
@@ -2944,6 +2967,9 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29442967 ListHeaderComponent = {
29452968 < >
29462969 { usesNativeAutomaticInsets ? null : < View style = { { height : topContentInset } } /> }
2970+ { setupAnchorIndex < 0 && props . worktreeSetup ? (
2971+ < WorktreeSetupCard key = { props . threadId } { ...props . worktreeSetup } />
2972+ ) : null }
29472973 { props . loadEarlier != null ? (
29482974 < Pressable
29492975 onPress = { props . loadEarlier . onLoadEarlier }
@@ -2964,6 +2990,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29642990 />
29652991 </ View >
29662992 { presentedFeed . length === 0 &&
2993+ ! props . worktreeSetup &&
29672994 props . activeWorkStartedAt === null &&
29682995 props . contentPresentation . kind === "ready" ? (
29692996 < View pointerEvents = "none" style = { StyleSheet . absoluteFill } >
0 commit comments