Skip to content
TypeScript

fix(web): keep the composer chin below the input (#21345)

Theo Browneb72740852ffb
diff --git a/apps/web/src/components/chat/ComposerSurface.browser.test.tsx b/apps/web/src/components/chat/ComposerSurface.browser.test.tsx
new file mode 100644
index 00000000000..18414f8ee59
--- /dev/null
+++ b/apps/web/src/components/chat/ComposerSurface.browser.test.tsx
@@ -0,0 +1,33 @@
+import "~/index.css";
+
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { expect, it, vi } from "vite-plus/test";
+
+import { ComposerSurface } from "./ComposerSurface";
+
+it("masks the toolbar overlap and reveals its surface one pixel before the input edge", async () => {
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
+ const container = document.createElement("div");
+ document.body.append(container);
+ const root = createRoot(container);
+
+ try {
+ await act(async () => {
+ root.render(
+ <ComposerSurface.Shell contextStrip>
+ <ComposerSurface.Host>Message</ComposerSurface.Host>
+ <ComposerSurface.ContextStrip>Workspace</ComposerSurface.ContextStrip>
+ </ComposerSurface.Shell>,
+ );
+ });
+
+ const strip = container.querySelector('[data-slot="composer-context-strip"]')!;
+ const mask = getComputedStyle(strip, "::before").maskImage;
+ expect(mask).toContain("rgba(0, 0, 0, 0) 15px, rgb(0, 0, 0) 15px");
+ } finally {
+ await act(async () => root.unmount());
+ container.remove();
+ vi.unstubAllGlobals();
+ }
+});
diff --git a/apps/web/src/components/chat/ComposerSurface.tsx b/apps/web/src/components/chat/ComposerSurface.tsx
index e5ae2770b6c..3889bbb1be8 100644
--- a/apps/web/src/components/chat/ComposerSurface.tsx
+++ b/apps/web/src/components/chat/ComposerSurface.tsx
@@ -79,14 +79,14 @@ function Main({ className, ...props }: ComponentProps<"div">) {
);
}
-/** Extends the composer outline below the input, masking its overlap up to one pixel above the shared edge so no seam shows. */
+/** Mask offsets use the position hint so class merging preserves the transparent and black stops. */
function ContextStrip({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="composer-context-strip"
className={cn(
"group/composer-context relative isolate mx-auto -mt-4 flex w-[calc(100%-2*var(--chat-composer-drawer-inset))] items-center gap-2 overflow-x-clip overflow-y-visible px-2 pt-5 pb-1",
- "before:absolute before:inset-0 before:-z-1 before:rounded-b-2xl before:border before:border-(--chat-composer-outline) before:mask-b-from-transparent before:mask-b-from-(length:--spacing-composer-seam) before:mask-b-to-black before:mask-b-to-(length:--spacing-composer-seam) before:shadow-composer",
+ "before:absolute before:inset-0 before:-z-1 before:rounded-b-2xl before:border before:border-(--chat-composer-outline) before:mask-b-from-transparent before:mask-b-from-(position:--spacing-composer-seam) before:mask-b-to-black before:mask-b-to-(position:--spacing-composer-seam) before:shadow-composer",
"dark:before:border-white/7 dark:before:bg-composer-seam-below dark:before:shadow-composer-dark",
"group-has-data-[composer-banner-surface=attached]/composer-surface:before:bg-(--chat-composer-glass-surface)/(--glass-opacity) group-has-data-[composer-banner-surface=attached]/composer-surface:before:backdrop-blur-(--glass-blur) group-has-data-[composer-banner-surface=attached]/composer-surface:before:backdrop-saturate-(--glass-saturation)",
"not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:bg-(--chat-composer-glass-surface)/(--glass-opacity) not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:backdrop-blur-(--glass-blur) not-supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:before:backdrop-saturate-(--glass-saturation)",