@@ -7,7 +7,7 @@ import { ComposerBanner, type ComposerBannerVariant } from "./ComposerBanner";
77import { observeResize } from "~/lib/observeResize" ;
88
99/**
10- * Where a notice sits above the composer . The machine comes first, then what needs you; the
10+ * Where a notice sits in the stack . The machine comes first, then what needs you; the
1111 * order is fixed so rows never trade places as notices come and go.
1212 */
1313export type ComposerBannerGroup = "environment" | "attention" ;
@@ -27,23 +27,33 @@ export interface ComposerBannerStackItem {
2727
2828const GROUPS = [ "environment" , "attention" ] as const ;
2929
30+ const FADE_IN =
31+ "transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none" ;
32+
3033/**
3134 * Notices about sending from this composer, each its own attached card. Consecutive cards join
32- * edge to edge, and the last joins the composer or the drawer below it.
35+ * edge to edge, and the last joins the composer or the drawer below it. Detached cards stand
36+ * apart instead, for layouts where the composer must not move when a notice appears.
3337 */
3438export function ComposerBannerStack ( {
3539 items,
40+ detached = false ,
3641} : {
3742 readonly items : ReadonlyArray < ComposerBannerStackItem > ;
43+ readonly detached ?: boolean ;
3844} ) {
39- return GROUPS . flatMap ( ( group ) =>
45+ const ordered = GROUPS . flatMap ( ( group ) =>
4046 items . filter ( ( item ) => ( item . group ?? "attention" ) === group ) ,
41- ) . map ( ( item ) => (
42- < ComposerBanner . Attachment
43- key = { item . id }
44- data-composer-banner-stack = "true"
45- className = "transition-opacity duration-150 ease-out starting:opacity-0 motion-reduce:transition-none"
46- >
47+ ) ;
48+ if ( detached ) {
49+ return ordered . map ( ( item ) => (
50+ < div key = { item . id } data-composer-banner-stack = "true" className = { FADE_IN } >
51+ < NoticeCard item = { item } detached />
52+ </ div >
53+ ) ) ;
54+ }
55+ return ordered . map ( ( item ) => (
56+ < ComposerBanner . Attachment key = { item . id } data-composer-banner-stack = "true" className = { FADE_IN } >
4757 < NoticeCard item = { item } />
4858 </ ComposerBanner . Attachment >
4959 ) ) ;
@@ -125,11 +135,18 @@ export function NoticeText({
125135 ) ;
126136}
127137
128- function NoticeCard ( { item } : { readonly item : ComposerBannerStackItem } ) {
138+ function NoticeCard ( {
139+ item,
140+ detached = false ,
141+ } : {
142+ readonly item : ComposerBannerStackItem ;
143+ readonly detached ?: boolean ;
144+ } ) {
129145 return (
130146 < ComposerBanner . Root
131147 role = { item . variant === "error" || item . variant === "warning" ? "alert" : undefined }
132148 variant = { item . variant }
149+ detached = { detached }
133150 density = "comfortable"
134151 data-chat-composer-collapsed-controls = "true"
135152 >
0 commit comments