Skip to content

Commit a4fe62e

Browse files
refactor(web): composer overlay re-measures from one layout effect (pingdotgg#25915)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent c39a115 commit a4fe62e

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,6 @@ export default function ChatView(props: ChatViewProps) {
708708
const composerReservedHeightRef = useRef(0);
709709
const composerExpandedHeightRef = useRef(0);
710710
const composerRestingRef = useRef(false);
711-
const composerMountedRef = useRef(true);
712711
const [scrollToEndClearance, setScrollToEndClearance] = useState(0);
713712
const [timelineOverflows, setTimelineOverflows] = useState(false);
714713
const fanoutSelectionsAtom = draftFanoutSelectionsAtom(routeThreadKey);
@@ -2127,7 +2126,7 @@ export default function ChatView(props: ChatViewProps) {
21272126
const nextHeight = Math.ceil(height);
21282127
if (nextHeight <= 0) return;
21292128
const isResting = overlayComposerIsResting({
2130-
composerMounted: composerMountedRef.current,
2129+
composerMounted,
21312130
composerReportedResting: composerRestingRef.current,
21322131
});
21332132
const modelStrip = composerOverlayElement?.querySelector<HTMLElement>(
@@ -2200,8 +2199,13 @@ export default function ChatView(props: ChatViewProps) {
22002199
composerReservedHeightRef.current = 0;
22012200
composerExpandedHeightRef.current = 0;
22022201
publishComposerOverlayHeightStable(composerOverlayElement.getBoundingClientRect().height);
2203-
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- A thread switch must re-measure the overlay for the new timeline.
2204-
}, [activeThreadKey, composerOverlayElement, publishComposerOverlayHeightStable]);
2202+
}, [
2203+
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- A thread switch or a composer mount/unmount must re-measure the overlay for the new timeline.
2204+
activeThreadKey,
2205+
composerMounted,
2206+
composerOverlayElement,
2207+
publishComposerOverlayHeightStable,
2208+
]);
22052209

22062210
useLayoutEffect(() => {
22072211
if (!composerOverlayElement) return;
@@ -2226,15 +2230,6 @@ export default function ChatView(props: ChatViewProps) {
22262230
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- The scroll-to-bottom button changes the overlay's height without resizing the observed node first.
22272231
showScrollToBottom,
22282232
]);
2229-
useLayoutEffect(() => {
2230-
if (composerMountedRef.current === composerMounted) return;
2231-
composerMountedRef.current = composerMounted;
2232-
if (!composerOverlayElement) return;
2233-
composerTimelineInsetRef.current = 0;
2234-
composerReservedHeightRef.current = 0;
2235-
composerExpandedHeightRef.current = 0;
2236-
publishComposerOverlayHeightStable(composerOverlayElement.getBoundingClientRect().height);
2237-
}, [composerMounted, composerOverlayElement, publishComposerOverlayHeightStable]);
22382233
const openPanelPullRequestUrl = useOpenPanelPullRequestUrl(activeThreadRef);
22392234
const activeThreadReferenceCopyTarget =
22402235
activeThreadId === null || !isServerThread

0 commit comments

Comments
 (0)