Skip to content

Commit 847c53d

Browse files
authored
fix(web): keep workspace options when expanding lineage (#16635)
1 parent 2991331 commit 847c53d

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

‎apps/web/src/components/chat/ThreadDetailsCard.tsx‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function ThreadDetailsCard({
5353
const [measurements, setMeasurements] = useState({
5454
key: measurementKey,
5555
heights: { full: 0, compact: 0 },
56+
fullContentHeight: 0,
5657
});
5758
const contentHeights =
5859
measurements.key === measurementKey ? measurements.heights : { full: 0, compact: 0 };
@@ -64,8 +65,8 @@ export function ThreadDetailsCard({
6465
? preferredPlacement.x + preferredPlacement.width
6566
: undefined;
6667
const cardBottom =
67-
preferredPlacement && contentHeights.full > 0
68-
? preferredPlacement.y + Math.min(contentHeights.full, preferredPlacement.height)
68+
preferredPlacement && measurements.key === measurementKey && measurements.fullContentHeight > 0
69+
? preferredPlacement.y + Math.min(measurements.fullContentHeight, preferredPlacement.height)
6970
: undefined;
7071
useLayoutEffect(() => {
7172
reportDetailsCard?.(
@@ -88,11 +89,27 @@ export function ThreadDetailsCard({
8889
const measure = () => {
8990
const frame = element.closest<HTMLElement>("[data-thread-details-card]");
9091
const next = element.offsetHeight + (frame ? frame.offsetHeight - frame.clientHeight : 0);
92+
// Lineage scrolls as it expands. Counting it toward density would hide
93+
// the section and workspace controls when the user asks to see more rows.
94+
const lineage = element.querySelector<HTMLElement>("[data-thread-relationships-panel]");
95+
const fittingHeight = next - (lineage?.offsetHeight ?? 0);
9196
setMeasurements((current) => {
9297
const heights = current.key === measurementKey ? current.heights : { full: 0, compact: 0 };
93-
return current.key === measurementKey && heights[density] === next
98+
const fullContentHeight =
99+
density === "full"
100+
? next
101+
: current.key === measurementKey
102+
? current.fullContentHeight
103+
: 0;
104+
return current.key === measurementKey &&
105+
heights[density] === fittingHeight &&
106+
current.fullContentHeight === fullContentHeight
94107
? current
95-
: { key: measurementKey, heights: { ...heights, [density]: next } };
108+
: {
109+
key: measurementKey,
110+
heights: { ...heights, [density]: fittingHeight },
111+
fullContentHeight,
112+
};
96113
});
97114
};
98115
measure();

0 commit comments

Comments
 (0)