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
26 changes: 24 additions & 2 deletions apps/web/src/components/chat/MessagesTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3161,6 +3161,9 @@ function WorkingTimer({ createdAt }: { createdAt: string }) {
);
}

// Matches the grouped WorkLog row's min-h-6.
const compactWorkEntryHeight = 24;

function ExpandedWorkGroupEntries({
anchorKey,
disclosureAnchorKey,
Expand All @@ -3178,6 +3181,7 @@ function ExpandedWorkGroupEntries({
);
const [restoringPosition, setRestoringPosition] = useState(initialScrollIndex !== undefined);
const listRef = useRef<LegendListRef>(null);
const [expandedContentHeight, setExpandedContentHeight] = useState(0);
const [fades, setFades] = useState({ top: false, bottom: false, viewportHeight: 0 });
const [appendState, setAppendState] = useState({ entries, follow: false });
// Capture the pre-change edge once per incoming array, before new layout
Expand Down Expand Up @@ -3260,6 +3264,22 @@ function ExpandedWorkGroupEntries({
[workspaceRoot],
);

const updateExpandedContentHeight = useCallback(() => {
const state = listRef.current?.getState();
let height = 0;
for (const entryId of viewState.expandedEntries) {
if (state?.indexByKey(entryId) === undefined) continue;
// Each open row adds room for its details, including while scrolled out of view.
height += Math.max(
0,
(state.sizes.get(entryId) ?? compactWorkEntryHeight) - compactWorkEntryHeight,
);
}
setExpandedContentHeight(height);
}, [viewState]);

useLayoutEffect(updateExpandedContentHeight, [entries, updateExpandedContentHeight]);

return (
<WorkGroupViewCtx value={groupView}>
<WorkLogList>
Expand All @@ -3269,7 +3289,7 @@ function ExpandedWorkGroupEntries({
extraData={workspaceRoot}
keyExtractor={workEntryKey}
renderItem={renderEntry}
estimatedItemSize={24}
estimatedItemSize={compactWorkEntryHeight}
drawDistance={240}
recycleItems
{...(initialScrollIndex ? { initialScrollIndex } : {})}
Expand All @@ -3286,12 +3306,14 @@ function ExpandedWorkGroupEntries({
onLoad={handleLoad}
onScroll={handleScroll}
onLayout={updateScrollFades}
onItemSizeChanged={updateExpandedContentHeight}
tabIndex={0}
role="region"
aria-label="Tool calls"
data-tool-group-scroll
style={{ maxHeight: `calc(min(18rem, 50dvh) + ${expandedContentHeight}px)` }}
className={cn(
"scrollbar-gutter-stable max-h-[min(18rem,50dvh)] scroll-py-6 overflow-x-hidden rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70",
"scrollbar-gutter-stable scroll-py-6 overflow-x-hidden rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70",
getVirtualizedScrollFadeClassName(fades),
)}
/>
Expand Down
Loading