Skip to content
TypeScript

fix(web): keep workspace options when expanding lineage (#16635)

maria847c53df0126
diff --git a/apps/web/src/components/chat/ThreadDetailsCard.tsx b/apps/web/src/components/chat/ThreadDetailsCard.tsx
index dfee1453eda..74cbf60cc9e 100644
--- a/apps/web/src/components/chat/ThreadDetailsCard.tsx
+++ b/apps/web/src/components/chat/ThreadDetailsCard.tsx
@@ -53,6 +53,7 @@ export function ThreadDetailsCard({
const [measurements, setMeasurements] = useState({
key: measurementKey,
heights: { full: 0, compact: 0 },
+ fullContentHeight: 0,
});
const contentHeights =
measurements.key === measurementKey ? measurements.heights : { full: 0, compact: 0 };
@@ -64,8 +65,8 @@ export function ThreadDetailsCard({
? preferredPlacement.x + preferredPlacement.width
: undefined;
const cardBottom =
- preferredPlacement && contentHeights.full > 0
- ? preferredPlacement.y + Math.min(contentHeights.full, preferredPlacement.height)
+ preferredPlacement && measurements.key === measurementKey && measurements.fullContentHeight > 0
+ ? preferredPlacement.y + Math.min(measurements.fullContentHeight, preferredPlacement.height)
: undefined;
useLayoutEffect(() => {
reportDetailsCard?.(
@@ -88,11 +89,27 @@ export function ThreadDetailsCard({
const measure = () => {
const frame = element.closest<HTMLElement>("[data-thread-details-card]");
const next = element.offsetHeight + (frame ? frame.offsetHeight - frame.clientHeight : 0);
+ // Lineage scrolls as it expands. Counting it toward density would hide
+ // the section and workspace controls when the user asks to see more rows.
+ const lineage = element.querySelector<HTMLElement>("[data-thread-relationships-panel]");
+ const fittingHeight = next - (lineage?.offsetHeight ?? 0);
setMeasurements((current) => {
const heights = current.key === measurementKey ? current.heights : { full: 0, compact: 0 };
- return current.key === measurementKey && heights[density] === next
+ const fullContentHeight =
+ density === "full"
+ ? next
+ : current.key === measurementKey
+ ? current.fullContentHeight
+ : 0;
+ return current.key === measurementKey &&
+ heights[density] === fittingHeight &&
+ current.fullContentHeight === fullContentHeight
? current
- : { key: measurementKey, heights: { ...heights, [density]: next } };
+ : {
+ key: measurementKey,
+ heights: { ...heights, [density]: fittingHeight },
+ fullContentHeight,
+ };
});
};
measure();