Skip to content

Commit 631a714

Browse files
committed
fix(web): /usage-limits shows above the Tasks row before tucking behind it
1 parent e340aae commit 631a714

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import { observeResize } from "~/lib/observeResize";
99

1010
// Match the duration-220 exit transition before removing a dismissed notice.
1111
const DISMISS_TRANSITION_MS = 220;
12+
// How long a revealed notice stays open before tucking behind the front banner.
13+
const REVEAL_MS = 5_000;
1214

1315
export interface ComposerBannerStackItem {
1416
readonly id: string;
1517
readonly variant: ComposerBannerVariant;
1618
readonly priority?: "urgent" | "activity" | "notice";
19+
/** The user asked for this notice, so it opens the stack when it lands behind another banner. */
20+
readonly reveal?: boolean;
1721
readonly icon: ReactNode;
1822
readonly title: ReactNode;
1923
readonly description?: ReactNode;
@@ -73,6 +77,27 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
7377
setStackExpanded(false);
7478
}
7579

80+
const orderedItems = items.toSorted((a, b) => bannerPriority(a) - bannerPriority(b));
81+
const stackedItems = orderedItems.slice(1);
82+
const revealItemId =
83+
stackedItems.find((item) => "reveal" in item && item.reveal === true)?.id ?? null;
84+
const [revealedItemId, setRevealedItemId] = useState<string | null>(null);
85+
if (revealItemId !== null && revealItemId !== revealedItemId) {
86+
setRevealedItemId(revealItemId);
87+
setStackExpanded(true);
88+
}
89+
90+
// Tuck the revealed notice away unless the user is reading it; leaving it collapses as usual.
91+
useEffect(() => {
92+
if (revealedItemId === null) return;
93+
const timeout = setTimeout(() => {
94+
const notices = noticesRef.current;
95+
if (notices?.matches(":hover") || notices?.contains(document.activeElement)) return;
96+
setStackExpanded(false);
97+
}, REVEAL_MS);
98+
return () => clearTimeout(timeout);
99+
}, [revealedItemId]);
100+
76101
useLayoutEffect(() => {
77102
if (stackExpanded && pendingFocusRef.current === "notice") {
78103
pendingFocusRef.current = null;
@@ -86,7 +111,6 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
86111
}
87112
}, [stackExpanded]);
88113

89-
const orderedItems = items.toSorted((a, b) => bannerPriority(a) - bannerPriority(b));
90114
const frontItem = orderedItems[0];
91115
if (!frontItem) {
92116
return (
@@ -97,7 +121,6 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
97121
</>
98122
);
99123
}
100-
const stackedItems = orderedItems.slice(1);
101124
const hasStack = stackedItems.length > 0;
102125
const showCollapsedStackCap = hasStack && exitingItemId !== frontItem.id;
103126
const firstStackedItem = stackedItems[0];

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export function usageLimitsBannerItem(
5959
id,
6060
variant: "info",
6161
priority: "notice",
62+
reveal: true,
6263
icon: <GaugeIcon />,
6364
title: "Usage limits",
6465
description: summary,

0 commit comments

Comments
 (0)