Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4678,11 +4678,22 @@ export default function ChatView(props: ChatViewProps) {
modelStrip.offsetHeight + Number.parseFloat(getComputedStyle(modelStrip).marginTop),
)
: 0;
const noticeStack = composerOverlayElement?.querySelector<HTMLElement>(
'[data-composer-banner-stack="true"]',
);
const expandedNoticesHeight = noticeStack
? Math.max(
0,
noticeStack.getBoundingClientRect().height -
Number.parseFloat(getComputedStyle(noticeStack).minHeight),
)
: 0;
const nextInset = resolveComposerTimelineInset({
currentInset: composerTimelineInsetRef.current,
overlayHeight: nextHeight,
overlayHeight: height,
isResting,
restingOnlyHeight,
expandedNoticesHeight,
});
if (composerTimelineInsetRef.current !== nextInset) {
composerTimelineInsetRef.current = nextInset;
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/chat/ComposerBannerStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
{hasStack ? (
<div
ref={noticesRef}
data-composer-banner-stack="true"
data-chat-composer-collapsed-controls="true"
className={cn("relative z-20 min-h-3", stackExpanded && "z-50")}
onPointerEnter={(event) => {
Expand Down
29 changes: 29 additions & 0 deletions apps/web/src/components/composerFooterLayout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,35 @@ describe("resolveComposerTimelineInset", () => {
resolveComposerTimelineInset({ currentInset: 0, overlayHeight: 60, isResting: true }),
).toBe(60 + COMPOSER_RESTING_EXPANSION_MIN_PX);
});

it("keeps the timeline reservation stable through notice expansion and collapse", () => {
const collapsed = resolveComposerTimelineInset({
currentInset: 0,
overlayHeight: 172,
isResting: false,
});
const expanded = resolveComposerTimelineInset({
currentInset: collapsed,
overlayHeight: 532,
isResting: false,
expandedNoticesHeight: 360,
});
expect(expanded).toBe(collapsed);
const resting = resolveComposerTimelineInset({
currentInset: expanded,
overlayHeight: 470,
isResting: true,
expandedNoticesHeight: 360,
});
expect(resting).toBe(collapsed);
expect(
resolveComposerTimelineInset({
currentInset: resting,
overlayHeight: 110,
isResting: true,
}),
).toBe(collapsed);
});
});

describe("shouldUseRestingComposerLayout", () => {
Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/components/composerFooterLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@ export function resolveComposerTimelineInset(input: {
overlayHeight: number;
isResting: boolean;
restingOnlyHeight?: number;
expandedNoticesHeight?: number;
}): number {
// Expanded notices temporarily cover the timeline. Remove their growth before
// rounding so fractional measurements reserve exactly the collapsed height.
const overlayHeight = Math.ceil(input.overlayHeight - (input.expandedNoticesHeight ?? 0));
return input.isResting
? Math.max(
input.currentInset,
input.overlayHeight +
overlayHeight +
(input.currentInset === 0
? COMPOSER_RESTING_EXPANSION_MIN_PX - (input.restingOnlyHeight ?? 0)
: 0),
)
: input.overlayHeight;
: overlayHeight;
}

export function overlayComposerIsResting(input: {
Expand Down
Loading