Skip to content

Commit 9895fe1

Browse files
committed
fix(web): /usage-limits shows above the Tasks row before tucking behind it
1 parent 72dde22 commit 9895fe1

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
@@ -1,5 +1,5 @@
11
import { InfoIcon } from "lucide-react";
2-
import { useId, useLayoutEffect, useRef, useState, type ReactNode } from "react";
2+
import { useEffect, useId, useLayoutEffect, useRef, useState, type ReactNode } from "react";
33
import { flushSync } from "react-dom";
44

55
import { cn } from "~/lib/utils";
@@ -10,11 +10,15 @@ import { observeResize } from "~/lib/observeResize";
1010

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

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

7579
const orderedItems = items.toSorted((a, b) => bannerPriority(a) - bannerPriority(b));
80+
const stackedItems = orderedItems.slice(1);
81+
const revealItemId =
82+
stackedItems.find((item) => "reveal" in item && item.reveal === true)?.id ?? null;
83+
const [revealedItemId, setRevealedItemId] = useState<string | null>(null);
84+
if (revealItemId !== null && revealItemId !== revealedItemId) {
85+
setRevealedItemId(revealItemId);
86+
setStackExpanded(true);
87+
}
88+
89+
// Tuck the revealed notice away unless the user is reading it; leaving it collapses as usual.
90+
useEffect(() => {
91+
if (revealedItemId === null) return;
92+
const timeout = setTimeout(() => {
93+
const notices = noticesRef.current;
94+
if (notices?.matches(":hover") || notices?.contains(document.activeElement)) return;
95+
setStackExpanded(false);
96+
}, REVEAL_MS);
97+
return () => clearTimeout(timeout);
98+
}, [revealedItemId]);
99+
76100
const frontItem = orderedItems[0];
77101
if (!frontItem) {
78102
return (
@@ -83,7 +107,6 @@ export function ComposerBannerStack({ className, items, attachedAbove }: Compose
83107
</>
84108
);
85109
}
86-
const stackedItems = orderedItems.slice(1);
87110
const hasStack = stackedItems.length > 0;
88111
const showCollapsedStackCap = hasStack && exitingItemId !== frontItem.id;
89112
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)