Skip to content

Commit 87aa849

Browse files
fix(web): keep the compaction notice visible above monitoring
1 parent cb9a694 commit 87aa849

2 files changed

Lines changed: 34 additions & 12 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5555,6 +5555,7 @@ export default function ChatView(props: ChatViewProps) {
55555555
return {
55565556
id: `resume-compaction:${resumeCompactionKey}`,
55575557
variant: "info",
5558+
alwaysVisible: true,
55585559
icon: <Minimize2Icon />,
55595560
title: "Resume with less context",
55605561
description: `${formatContextWindowTokens(activeContextWindow.usedTokens)} tokens from earlier`,

‎apps/web/src/components/chat/ComposerBannerStack.tsx‎

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface ComposerBannerStackItem {
1313
readonly id: string;
1414
readonly variant: ComposerBannerVariant;
1515
readonly priority?: "urgent" | "activity" | "notice";
16+
readonly alwaysVisible?: boolean;
1617
readonly icon: ReactNode;
1718
readonly title: ReactNode;
1819
readonly description?: ReactNode;
@@ -24,7 +25,7 @@ export interface ComposerBannerStackItem {
2425

2526
export type ComposerBannerStackContent = Pick<
2627
ComposerBannerStackItem,
27-
"id" | "variant" | "priority"
28+
"id" | "variant" | "priority" | "alwaysVisible"
2829
> & { readonly content: ReactNode };
2930

3031
type ComposerBannerStackEntry = ComposerBannerStackItem | ComposerBannerStackContent;
@@ -57,6 +58,13 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
5758
requestedExitingItemId !== null && items.some((item) => item.id === requestedExitingItemId)
5859
? requestedExitingItemId
5960
: null;
61+
// Activity stays attached. Persistent actions remain above it without changing notice priority.
62+
const orderedItems = items.toSorted((a, b) => bannerPriority(a) - bannerPriority(b));
63+
const frontItem = orderedItems[0];
64+
const remainingItems = orderedItems.slice(1);
65+
const visibleItems = remainingItems.filter((item) => item.alwaysVisible);
66+
const stackedItems = remainingItems.filter((item) => !item.alwaysVisible);
67+
const hasStack = stackedItems.length > 0;
6068

6169
useEffect(() => {
6270
return () => {
@@ -67,8 +75,8 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
6775
}, []);
6876

6977
useEffect(() => {
70-
if (items.length < 2) setStackExpanded(false);
71-
}, [items.length]);
78+
if (!hasStack) setStackExpanded(false);
79+
}, [hasStack]);
7280

7381
useLayoutEffect(() => {
7482
if (stackExpanded && pendingFocusRef.current === "notice") {
@@ -83,18 +91,9 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
8391
}
8492
}, [stackExpanded]);
8593

86-
if (items.length === 0) {
87-
return null;
88-
}
89-
90-
// Activity stays attached. Urgency and severity only order the notices behind it.
91-
const orderedItems = items.toSorted((a, b) => bannerPriority(a) - bannerPriority(b));
92-
const frontItem = orderedItems[0];
9394
if (!frontItem) {
9495
return null;
9596
}
96-
const stackedItems = orderedItems.slice(1);
97-
const hasStack = stackedItems.length > 0;
9897
const showCollapsedStackCap = hasStack && exitingItemId !== frontItem.id;
9998
const firstStackedItem = stackedItems[0];
10099

@@ -144,6 +143,28 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
144143
onDismissRequest={() => requestDismiss(frontItem)}
145144
/>
146145
</div>
146+
{visibleItems.length > 0 ? (
147+
<div className="space-y-2 pb-2">
148+
{visibleItems.map((item) => (
149+
<div
150+
key={item.id}
151+
className={cn(
152+
"transition-[translate,opacity] duration-220 ease-in",
153+
exitingItemId === item.id
154+
? "pointer-events-none translate-y-28 opacity-0"
155+
: "opacity-100",
156+
)}
157+
>
158+
<ComposerBannerStackAlert
159+
item={item}
160+
attached={false}
161+
exiting={exitingItemId === item.id}
162+
onDismissRequest={() => requestDismiss(item)}
163+
/>
164+
</div>
165+
))}
166+
</div>
167+
) : null}
147168
{hasStack ? (
148169
<div
149170
ref={noticesRef}

0 commit comments

Comments
 (0)