TypeScript
fix(web): reconnecting notice no longer shifts the new thread composer (#26958)
Theo Browne88ab83e8bcf0
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsxindex de76f47844b..665bb2fc5f5 100644--- a/apps/web/src/components/ChatView.tsx+++ b/apps/web/src/components/ChatView.tsx@@ -306,7 +306,7 @@ import { useThreadLinkedPullRequest } from "./pullRequest/useThreadLinkedPullReqimport { useProactivePanels } from "../hooks/useProactivePanels";import { useIncrementalTimelineEntries } from "../hooks/useIncrementalTimelineEntries";import { useRightPanelSurfaceClose } from "../hooks/useRightPanelSurfaceClose";-import type { ComposerBannerStackItem } from "./chat/ComposerBannerStack";+import { ComposerBannerStack, type ComposerBannerStackItem } from "./chat/ComposerBannerStack";import { modelFallbackBannerItem } from "./chat/ComposerUsageLimits";import { ComposerSurface } from "./chat/ComposerSurface";import { resolveThreadSyncPhase } from "../threadSync";@@ -3516,7 +3516,7 @@ export default function ChatView(props: ChatViewProps) {: projectCloneSendBlockReason}isPreparingWorktree={isPreparingWorktree && !sendQueuesBehindSetup}- bannerItems={composerBannerItems}+ bannerItems={isDraftHeroState ? [] : composerBannerItems}resumeCompactionTokens={resumeCompactionTokens}keepFullHistory={keepFullHistory}onToggleKeepFullHistory={toggleKeepFullHistoryStable}@@ -3682,6 +3682,12 @@ export default function ChatView(props: ChatViewProps) {)}</div></div>+ {isDraftHeroState && composerBannerItems.length > 0 ? (+ // Out of flow, like the headline, so a notice never moves the centered composer.+ <div className="absolute inset-x-0 top-full flex flex-col gap-1 pt-4">+ <ComposerBannerStack items={composerBannerItems} detached />+ </div>+ ) : null}</ComposerSurface.Shell><divaria-hiddendiff --git a/apps/web/src/components/chat/ComposerBanner.tsx b/apps/web/src/components/chat/ComposerBanner.tsxindex ef07497171e..0710f2534da 100644--- a/apps/web/src/components/chat/ComposerBanner.tsx+++ b/apps/web/src/components/chat/ComposerBanner.tsx@@ -33,27 +33,36 @@ const variantColors: Record<ComposerBannerVariant, string> = {"[--chat-composer-attached-outline:color-mix(in_srgb,var(--warning)_28%,transparent)] [--chat-composer-attached-tint:color-mix(in_srgb,var(--warning)_8%,transparent)]",};+/**+ * An attached surface tucks its bottom under the card below it. A detached one is a whole card+ * of its own, for a notice that sits apart from the composer.+ */function Surface({variant = "default",+ detached = false,className,...props}: ComponentProps<"div"> & {variant?: ComposerBannerVariant;+ detached?: boolean;}) {return (<div- data-composer-banner-surface="attached"+ data-composer-banner-surface={detached ? "detached" : "attached"}data-variant={variant}className={cn(surfaceColors,"relative isolate border-0 bg-transparent shadow-none [--chat-composer-attached-tint:transparent]",variantColors[variant],- // Bleed the mask 1px past the seam to cover Chromium's fractional-pixel backdrop loss.- "[--chat-composer-attachment-overlap:calc(1rem+1px)] before:rounded-t-2xl before:mask-t-from-transparent before:mask-t-from-4 before:mask-t-to-black before:mask-t-to-4",+ detached+ ? "[--chat-composer-attachment-overlap:0px] before:rounded-2xl"+ : // Bleed the mask 1px past the seam to cover Chromium's fractional-pixel backdrop loss.+ "[--chat-composer-attachment-overlap:calc(1rem+1px)] before:rounded-t-2xl before:mask-t-from-transparent before:mask-t-from-4 before:mask-t-to-black before:mask-t-to-4","before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:border before:border-(--chat-composer-attached-outline)","before:bg-(--chat-composer-attached-surface)/(--glass-opacity) before:bg-linear-to-b before:from-(--chat-composer-attached-tint) before:to-(--chat-composer-attached-tint) before:backdrop-blur-(--glass-blur) before:backdrop-saturate-(--glass-saturation)","before:shadow-composer dark:before:shadow-composer-dark",- "dark:supports-[(backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px))]:before:bg-composer-seam-above",+ !detached &&+ "dark:supports-[(backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px))]:before:bg-composer-seam-above","not-supports-[((backdrop-filter:blur(1px))_or_(-webkit-backdrop-filter:blur(1px)))]:before:bg-(--chat-composer-attached-surface)",className,)}@@ -108,9 +117,8 @@ function Root({variant = "default",width = "fill",...props-}: ComponentProps<"div"> & {+}: ComponentProps<typeof Surface> & {density?: "default" | "comfortable" | "spacious";- variant?: ComposerBannerVariant;width?: "fill" | "content";}) {return (diff --git a/apps/web/src/components/chat/ComposerBannerStack.tsx b/apps/web/src/components/chat/ComposerBannerStack.tsxindex 086826cde86..755d20ba8c6 100644--- a/apps/web/src/components/chat/ComposerBannerStack.tsx+++ b/apps/web/src/components/chat/ComposerBannerStack.tsx@@ -7,7 +7,7 @@ import { ComposerBanner, type ComposerBannerVariant } from "./ComposerBanner";import { observeResize } from "~/lib/observeResize";/**- * Where a notice sits above the composer. The machine comes first, then what needs you; the+ * Where a notice sits in the stack. The machine comes first, then what needs you; the* order is fixed so rows never trade places as notices come and go.*/export type ComposerBannerGroup = "environment" | "attention";@@ -27,23 +27,33 @@ export interface ComposerBannerStackItem {const GROUPS = ["environment", "attention"] as const;+const FADE_IN =+ "transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none";+/*** Notices about sending from this composer, each its own attached card. Consecutive cards join- * edge to edge, and the last joins the composer or the drawer below it.+ * edge to edge, and the last joins the composer or the drawer below it. Detached cards stand+ * apart instead, for layouts where the composer must not move when a notice appears.*/export function ComposerBannerStack({items,+ detached = false,}: {readonly items: ReadonlyArray<ComposerBannerStackItem>;+ readonly detached?: boolean;}) {- return GROUPS.flatMap((group) =>+ const ordered = GROUPS.flatMap((group) =>items.filter((item) => (item.group ?? "attention") === group),- ).map((item) => (- <ComposerBanner.Attachment- key={item.id}- data-composer-banner-stack="true"- className="transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none"- >+ );+ if (detached) {+ return ordered.map((item) => (+ <div key={item.id} data-composer-banner-stack="true" className={FADE_IN}>+ <NoticeCard item={item} detached />+ </div>+ ));+ }+ return ordered.map((item) => (+ <ComposerBanner.Attachment key={item.id} data-composer-banner-stack="true" className={FADE_IN}><NoticeCard item={item} /></ComposerBanner.Attachment>));@@ -125,11 +135,18 @@ export function NoticeText({);}-function NoticeCard({ item }: { readonly item: ComposerBannerStackItem }) {+function NoticeCard({+ item,+ detached = false,+}: {+ readonly item: ComposerBannerStackItem;+ readonly detached?: boolean;+}) {return (<ComposerBanner.Rootrole={item.variant === "error" || item.variant === "warning" ? "alert" : undefined}variant={item.variant}+ detached={detached}density="comfortable"data-chat-composer-collapsed-controls="true">diff --git a/apps/web/src/components/chat/ComposerSurface.tsx b/apps/web/src/components/chat/ComposerSurface.tsxindex 13614b8c9bd..213189064ee 100644--- a/apps/web/src/components/chat/ComposerSurface.tsx+++ b/apps/web/src/components/chat/ComposerSurface.tsx@@ -41,7 +41,7 @@ function Host({ className, ...props }: ComponentProps<"div">) {"relative z-10 w-full rounded-2xl shadow-composer after:z-1 dark:shadow-none","group-data-context-row/composer-surface:before:pointer-events-none group-data-context-row/composer-surface:before:absolute group-data-context-row/composer-surface:before:inset-0 group-data-context-row/composer-surface:before:-z-1 group-data-context-row/composer-surface:before:rounded-2xl group-data-context-row/composer-surface:before:bg-(--chat-composer-glass-surface)/(--glass-opacity) group-data-context-row/composer-surface:before:backdrop-blur-(--glass-blur) group-data-context-row/composer-surface:before:backdrop-saturate-(--glass-saturation)",outlineClasses,- "group-has-data-[composer-banner-surface=attached]/composer-surface:shadow-none group-has-data-[composer-banner-surface=attached]/composer-surface:after:hidden",+ "group-has-data-[composer-banner-surface=attached]/composer-surface:shadow-none group-has-data-[composer-banner-surface=attached]/composer-surface:before:hidden group-has-data-[composer-banner-surface=attached]/composer-surface:after:hidden",className,)}{...props}