Open History to see the last commit
1import type {
2 OrchestrationV2ProviderFailureClass,
3 ProviderInstanceId,
4 ServerProvider,
5 ThreadId,
6} from "@t3tools/contracts";
7import type { Dispatch, SetStateAction } from "react";
8import { ProviderStatusBanner } from "./ProviderStatusBanner";
9import { dismissThreadErrorBannerForSession, ThreadErrorBanner } from "./ThreadErrorBanner";
10
11/**
12 * The banners pinned above the timeline. The dismiss handlers are built here from plain
13 * values, so a ChatView render that changes neither banner leaves both cached.
14 */
15export function ChatBannerLane(props: {
16 providerStatus: ServerProvider | null;
17 providerStatusBannerKey: string | null;
18 setDismissedProviderStatusBannerKey: Dispatch<SetStateAction<string | null>>;
19 onOpenProviderSetup: (instanceId: ProviderInstanceId) => void;
20 threadId: ThreadId;
21 threadError: string | null;
22 threadErrorClass: OrchestrationV2ProviderFailureClass | null;
23 threadErrorBannerKey: string | null;
24 setThreadError: (threadId: ThreadId | null, error: string | null) => void;
25 setThreadErrorBannerDismissTick: Dispatch<SetStateAction<number>>;
26}) {
27 const {
28 providerStatus,
29 providerStatusBannerKey,
30 setDismissedProviderStatusBannerKey,
31 onOpenProviderSetup,
32 threadId,
33 threadError,
34 threadErrorClass,
35 threadErrorBannerKey,
36 setThreadError,
37 setThreadErrorBannerDismissTick,
38 } = props;
39 return (
40 <div className="chat-banner-lane pointer-events-none absolute top-0 z-30 flex flex-col">
41 <ProviderStatusBanner
42 status={providerStatus}
43 onDismiss={() => setDismissedProviderStatusBannerKey(providerStatusBannerKey)}
44 onOpenProviderSetup={onOpenProviderSetup}
45 />
46 <ThreadErrorBanner
47 error={threadError}
48 errorClass={threadErrorClass}
49 onDismiss={() => {
50 setThreadError(threadId, null);
51 dismissThreadErrorBannerForSession(threadErrorBannerKey);
52 setThreadErrorBannerDismissTick((tick) => tick + 1);
53 }}
54 />
55 </div>
56 );
57}