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 threadErrorCode: string | null;
24 threadErrorBannerKey: string | null;
25 setThreadError: (threadId: ThreadId | null, error: string | null) => void;
26 setThreadErrorBannerDismissTick: Dispatch<SetStateAction<number>>;
27}) {
28 const {
29 providerStatus,
30 providerStatusBannerKey,
31 setDismissedProviderStatusBannerKey,
32 onOpenProviderSetup,
33 threadId,
34 threadError,
35 threadErrorClass,
36 threadErrorCode,
37 threadErrorBannerKey,
38 setThreadError,
39 setThreadErrorBannerDismissTick,
40 } = props;
41 return (
42 <div className="chat-banner-lane pointer-events-none absolute top-0 z-30 flex flex-col">
43 <ProviderStatusBanner
44 status={providerStatus}
45 onDismiss={() => setDismissedProviderStatusBannerKey(providerStatusBannerKey)}
46 onOpenProviderSetup={onOpenProviderSetup}
47 />
48 <ThreadErrorBanner
49 error={threadError}
50 errorClass={threadErrorClass}
51 errorCode={threadErrorCode}
52 onDismiss={() => {
53 setThreadError(threadId, null);
54 dismissThreadErrorBannerForSession(threadErrorBannerKey);
55 setThreadErrorBannerDismissTick((tick) => tick + 1);
56 }}
57 />
58 </div>
59 );
60}