Skip to content

Commit e7ed45a

Browse files
committed
fix(web): expanding stacked notices no longer scrolls a working thread
Hovering the composer's notice stack grows the overlay, and the timeline reserved that growth as footer space. The thread did not move at once, but the next row re-pinned it to the new end, jumping by the expanded height. The reservation now leaves out how far the stack grew past its collapsed height, so working threads behave like idle ones: the expanded notices cover the last rows until the pointer leaves. Fixes #19880
1 parent 4e85a93 commit e7ed45a

4 files changed

Lines changed: 47 additions & 2 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6872,11 +6872,25 @@ export default function ChatView(props: ChatViewProps) {
68726872
modelStrip.offsetHeight + Number.parseFloat(getComputedStyle(modelStrip).marginTop),
68736873
)
68746874
: 0;
6875+
// Expanded notices grow the stack past the minimum height that holds its
6876+
// peek strip. Round once, after removing that growth, so the reservation
6877+
// matches the collapsed overlay exactly.
6878+
const noticeStack = composerOverlayElement?.querySelector<HTMLElement>(
6879+
'[data-composer-banner-stack="true"]',
6880+
);
6881+
const expandedNoticesGrowth = noticeStack
6882+
? Math.max(
6883+
0,
6884+
noticeStack.getBoundingClientRect().height -
6885+
Number.parseFloat(getComputedStyle(noticeStack).minHeight),
6886+
)
6887+
: 0;
68756888
const nextInset = resolveComposerTimelineInset({
68766889
currentInset: composerTimelineInsetRef.current,
68776890
overlayHeight: nextHeight,
68786891
isResting,
68796892
restingOnlyHeight,
6893+
expandedNoticesHeight: nextHeight - Math.ceil(height - expandedNoticesGrowth),
68806894
});
68816895
if (composerTimelineInsetRef.current !== nextInset) {
68826896
composerTimelineInsetRef.current = nextInset;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
123123
{hasStack ? (
124124
<div
125125
ref={noticesRef}
126+
data-composer-banner-stack="true"
126127
data-chat-composer-collapsed-controls="true"
127128
className={cn("relative z-20 min-h-3", stackExpanded && "z-50")}
128129
onPointerEnter={(event) => {

‎apps/web/src/components/composerFooterLayout.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,30 @@ describe("resolveComposerTimelineInset", () => {
142142
resolveComposerTimelineInset({ currentInset: 0, overlayHeight: 60, isResting: true }),
143143
).toBe(60 + COMPOSER_RESTING_EXPANSION_MIN_PX);
144144
});
145+
146+
it("keeps the reservation while notices are expanded from the stack", () => {
147+
const collapsed = resolveComposerTimelineInset({
148+
currentInset: 0,
149+
overlayHeight: 172,
150+
isResting: false,
151+
});
152+
expect(
153+
resolveComposerTimelineInset({
154+
currentInset: collapsed,
155+
overlayHeight: 532,
156+
isResting: false,
157+
expandedNoticesHeight: 360,
158+
}),
159+
).toBe(collapsed);
160+
expect(
161+
resolveComposerTimelineInset({
162+
currentInset: collapsed,
163+
overlayHeight: 470,
164+
isResting: true,
165+
expandedNoticesHeight: 360,
166+
}),
167+
).toBe(collapsed);
168+
});
145169
});
146170

147171
describe("shouldUseRestingComposerLayout", () => {

‎apps/web/src/components/composerFooterLayout.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,28 @@ export const COMPOSER_RESTING_EXPANSION_MIN_PX = 94;
7676
* expansion only before that measurement exists: strip mounting can otherwise
7777
* inflate the estimate mid-transition and move the timeline. An expanded
7878
* measurement is authoritative and may shrink the reservation.
79+
*
80+
* Notices expanded from the stack's peek strip are left out. They cover the
81+
* last rows only while the pointer or focus is on the stack, and reserving
82+
* them would scroll the thread by their height on the next row instead.
7983
*/
8084
export function resolveComposerTimelineInset(input: {
8185
currentInset: number;
8286
overlayHeight: number;
8387
isResting: boolean;
8488
restingOnlyHeight?: number;
89+
expandedNoticesHeight?: number;
8590
}): number {
91+
const overlayHeight = input.overlayHeight - (input.expandedNoticesHeight ?? 0);
8692
return input.isResting
8793
? Math.max(
8894
input.currentInset,
89-
input.overlayHeight +
95+
overlayHeight +
9096
(input.currentInset === 0
9197
? COMPOSER_RESTING_EXPANSION_MIN_PX - (input.restingOnlyHeight ?? 0)
9298
: 0),
9399
)
94-
: input.overlayHeight;
100+
: overlayHeight;
95101
}
96102

97103
/**

0 commit comments

Comments
 (0)