Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions apps/mobile/src/features/threads/thread-work-log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import Animated, {
FadeOut,
LinearTransition,
ReduceMotion,
useAnimatedScrollHandler,
useAnimatedStyle,
useSharedValue,
withTiming,
Expand Down Expand Up @@ -528,11 +529,13 @@ export function ThreadWorkLog(props: ThreadWorkLogProps) {
props.activities.every((row) => row.projectedItem.item.type === "reasoning")
) {
return (
<ScrollView nestedScrollEnabled className="ml-7 max-h-96 py-1">
{props.activities.map((row) => (
<View key={row.id}>{props.renderReasoning(row.workEntry.detail ?? "")}</View>
))}
</ScrollView>
<WorkLogBlock continues={props.continuesWorkLog}>
<ThreadReasoningGroup
activities={props.activities}
edgeFadeColor={props.edgeFadeColor}
renderReasoning={props.renderReasoning}
/>
</WorkLogBlock>
);
}

Expand All @@ -555,6 +558,55 @@ export function ThreadWorkLog(props: ThreadWorkLogProps) {
);
}

function ThreadReasoningGroup(props: {
readonly activities: ReadonlyArray<ThreadFeedActivity>;
readonly edgeFadeColor: string;
readonly renderReasoning: (text: string) => ReactNode;
}) {
const scrollOffset = useSharedValue(0);
const contentHeight = useSharedValue(0);
const viewportHeight = useSharedValue(0);
const onScroll = useAnimatedScrollHandler((event) => {
scrollOffset.set(event.contentOffset.y);
});
const bottomFadeStyle = useAnimatedStyle(() => ({
opacity: Math.min(
1,
Math.max(0, contentHeight.value - viewportHeight.value - scrollOffset.value) /
WORK_GROUP_EDGE_FADE_HEIGHT,
),
}));

return (
<View className="ml-7">
<Animated.ScrollView
nestedScrollEnabled
className="max-h-96"
contentContainerClassName="py-1"
scrollEventThrottle={16}
onScroll={onScroll}
onLayout={(event) => {
viewportHeight.set(event.nativeEvent.layout.height);
}}
onContentSizeChange={(_width, height) => {
contentHeight.set(height);
}}
>
{props.activities.map((row) => (
<View key={row.id}>{props.renderReasoning(row.workEntry.detail ?? "")}</View>
))}
</Animated.ScrollView>
<Animated.View
pointerEvents="none"
className="absolute inset-x-0 bottom-0"
style={[{ height: WORK_GROUP_EDGE_FADE_HEIGHT }, bottomFadeStyle]}
>
<EdgeFade color={props.edgeFadeColor} direction="up" />
</Animated.View>
</View>
);
}

function ThreadWorkGroupList(props: {
readonly activities: ReadonlyArray<ThreadFeedActivity>;
readonly edgeFadeColor: string;
Expand Down
Loading