Skip to content
TypeScript

fix(web): collapsed composer reserves room for wide send actions (#17016)

maria48b71f0eb323
diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx
index cfdb03d0f05..4a92c9efa88 100644
--- a/apps/web/src/components/chat/ChatComposer.tsx
+++ b/apps/web/src/components/chat/ChatComposer.tsx
@@ -5220,6 +5220,19 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
useLayoutEffect(() => {
onRestingChange(isComposerResting);
}, [isComposerResting, onRestingChange]);
+ // The resting footer floats over the prompt row, so the row reserves its
+ // measured width. Wide actions like the compact-before-send chip vary too much for a fixed inset.
+ const [restingActionsElement, setRestingActionsElement] = useState<HTMLDivElement | null>(null);
+ const [restingActionsWidth, setRestingActionsWidth] = useState<number | null>(null);
+ useLayoutEffect(() => {
+ if (!isComposerResting || !restingActionsElement) return;
+ const measure = () => setRestingActionsWidth(restingActionsElement.offsetWidth);
+ measure();
+ if (typeof ResizeObserver === "undefined") return;
+ const observer = new ResizeObserver(measure);
+ observer.observe(restingActionsElement);
+ return () => observer.disconnect();
+ }, [isComposerResting, restingActionsElement]);
const restingImagePreviewCounts = getRestingComposerImagePreviewCounts(
standaloneComposerImages.length,
);
@@ -7376,17 +7389,12 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
)}
<div
- className={cn(
- "relative",
- isComposerResting && "flex min-w-0 items-center gap-1",
- isComposerResting &&
- ((settings.contextWindowMeterEnabled && activeContextWindow) ||
- reserveContextWindowMeter
- ? "pr-28"
- : showComposerAttachAction
- ? "pr-20"
- : "pr-12"),
- )}
+ className={cn("relative", isComposerResting && "flex min-w-0 items-center gap-1")}
+ style={
+ isComposerResting && restingActionsWidth !== null
+ ? { paddingRight: `calc(${restingActionsWidth}px + 1rem)` }
+ : undefined
+ }
>
{previewFile ? (
<Dialog
@@ -7565,6 +7573,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
{/* Right side: send / stop button */}
<div
+ ref={setRestingActionsElement}
data-chat-composer-actions="right"
data-chat-composer-transition-actions="true"
data-chat-composer-primary-actions-compact={