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