Skip to content

Commit 54349ea

Browse files
refactor(web): ChatView's timeline banners render in ChatBannerLane
ChatView rebuilt both banners' dismiss closures on every render, so the memoized banners re-rendered with it. The lane builds them from plain values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 300d3ce commit 54349ea

2 files changed

Lines changed: 74 additions & 23 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { feedbackBannerItem } from "./chat/ComposerFeedback";
4848
import { useUsageLimitsPanel } from "./chat/useUsageLimitsPanel";
4949
import { useWorktreeSetup } from "./chat/useWorktreeSetup";
5050
import { useChatShortcuts } from "./chat/useChatShortcuts";
51+
import { ChatBannerLane } from "./chat/ChatBannerLane";
5152
import * as Schema from "effect/Schema";
5253
import {
5354
AuthOrchestrationOperateScope,
@@ -282,15 +283,12 @@ import {
282283
} from "./BranchToolbar.logic";
283284
import {
284285
getProviderStatusBannerKey,
285-
ProviderStatusBanner,
286286
shouldShowProviderStatusBanner,
287287
} from "./chat/ProviderStatusBanner";
288288
import {
289-
dismissThreadErrorBannerForSession,
290289
getThreadErrorBannerKey,
291290
isThreadErrorBannerDismissedForSession,
292291
shouldShowThreadErrorBanner,
293-
ThreadErrorBanner,
294292
} from "./chat/ThreadErrorBanner";
295293
import { QueuedRunsControl, type QueuedRunsControlHandle } from "./chat/QueuedRunsControl";
296294
import { useThreadLinkedPullRequest } from "./pullRequest/useThreadLinkedPullRequest";
@@ -3229,26 +3227,22 @@ export default function ChatView(props: ChatViewProps) {
32293227
>
32303228
<ThreadFind onClose={focusComposerStable} />
32313229
{isWorkspaceFileDragActive ? <WorkspaceFileDropOverlay /> : null}
3232-
<div className="chat-banner-lane pointer-events-none absolute top-0 z-30 flex flex-col">
3233-
<ProviderStatusBanner
3234-
status={visibleProviderStatus}
3235-
onDismiss={() => setDismissedProviderStatusBannerKey(providerStatusBannerKey)}
3236-
onOpenProviderSetup={openProviderSetupStable}
3237-
/>
3238-
<ThreadErrorBanner
3239-
error={timelineThreadError}
3240-
errorClass={
3241-
localServerError === null && visibleThreadError === serverRuntime?.lastError
3242-
? (serverRuntime?.lastErrorClass ?? null)
3243-
: null
3244-
}
3245-
onDismiss={() => {
3246-
setThreadError(activeThread.id, null);
3247-
dismissThreadErrorBannerForSession(threadErrorBannerKey);
3248-
setThreadErrorBannerDismissTick((tick) => tick + 1);
3249-
}}
3250-
/>
3251-
</div>
3230+
<ChatBannerLane
3231+
providerStatus={visibleProviderStatus}
3232+
providerStatusBannerKey={providerStatusBannerKey}
3233+
setDismissedProviderStatusBannerKey={setDismissedProviderStatusBannerKey}
3234+
onOpenProviderSetup={openProviderSetupStable}
3235+
threadId={activeThread.id}
3236+
threadError={timelineThreadError}
3237+
threadErrorClass={
3238+
localServerError === null && visibleThreadError === serverRuntime?.lastError
3239+
? (serverRuntime?.lastErrorClass ?? null)
3240+
: null
3241+
}
3242+
threadErrorBannerKey={threadErrorBannerKey}
3243+
setThreadError={setThreadError}
3244+
setThreadErrorBannerDismissTick={setThreadErrorBannerDismissTick}
3245+
/>
32523246
<div className="relative flex min-h-0 flex-1 flex-col bg-background">
32533247
<MessagesTimeline
32543248
citationRequest={paintOnlyDisplayedTimeline ? null : citationRequest}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import type {
2+
OrchestrationV2ProviderFailureClass,
3+
ProviderInstanceId,
4+
ServerProvider,
5+
ThreadId,
6+
} from "@t3tools/contracts";
7+
import type { Dispatch, SetStateAction } from "react";
8+
import { ProviderStatusBanner } from "./ProviderStatusBanner";
9+
import { 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+
*/
15+
export 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+
}

0 commit comments

Comments
 (0)