@devries-cameron20 / t3code Mirror · read-only / commits / 141de5e9f4
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 18:30 UTC

fix(web): a dismissed provider banner stays dismissed when you switch threads (#25513)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Tomasz Tórz committed Nov 13, 2026 at 00:59 UTC 141de5e9f4c808d014aa96a60f5a1bb4c38d19a3
4 files changed +110 -42
apps/web/src/components/ChatView.tsx
+9 -11
@@ -309,8 +309,9 @@ import {
309 shouldShowEnvironmentIndicator,
310 } from "./BranchToolbar.logic";
311 import {
312 - getProviderStatusBannerKey,
312 + getProviderStatusDismissalKey,
313 shouldShowProviderStatusBanner,
314 + useProviderStatusBannerDismissed,
315 } from "./chat/ProviderStatusBanner";
316 import {
317 getThreadErrorBannerKey,
@@ -1707,16 +1708,14 @@ export default function ChatView(props: ChatViewProps) {
1708 null,
1709 DismissedFallbackWindowSchema,
1710 );
1710 - const providerStatusBannerKey = getProviderStatusBannerKey(activeProviderStatus);
1711 - const [dismissedProviderStatusBannerKey, setDismissedProviderStatusBannerKey] = useState<
1712 - string | null
1713 - >(null);
1714 - if (providerStatusBannerKey === null && dismissedProviderStatusBannerKey !== null) {
1715 - setDismissedProviderStatusBannerKey(null);
1716 - }
1711 + const providerStatusDismissalKey = getProviderStatusDismissalKey(
1712 + providerEnvironmentId,
1713 + activeProviderStatus,
1714 + );
1715 + const providerStatusDismissed = useProviderStatusBannerDismissed(providerStatusDismissalKey);
1716 const visibleProviderStatus = shouldShowProviderStatusBanner(
1717 activeProviderStatus,
1719 - dismissedProviderStatusBannerKey,
1718 + providerStatusDismissed,
1719 )
1720 ? activeProviderStatus
1721 : null;
@@ -3376,8 +3375,7 @@ export default function ChatView(props: ChatViewProps) {
3375 <ChatBannerLane
3376 environmentId={activeThread.environmentId}
3377 providerStatus={visibleProviderStatus}
3379 - providerStatusBannerKey={providerStatusBannerKey}
3380 - setDismissedProviderStatusBannerKey={setDismissedProviderStatusBannerKey}
3378 + providerStatusDismissalKey={providerStatusDismissalKey}
3379 onOpenProviderSetup={openProviderSetupStable}
3380 threadId={activeThread.id}
3381 threadError={timelineThreadError}
apps/web/src/components/chat/ChatBannerLane.tsx
+7 -6
@@ -6,7 +6,10 @@ import type {
6 ThreadId,
7 } from "@t3tools/contracts";
8 import type { Dispatch, SetStateAction } from "react";
9 -import { ProviderStatusBanner } from "./ProviderStatusBanner";
9 +import {
10 + dismissProviderStatusBannerForSession,
11 + ProviderStatusBanner,
12 +} from "./ProviderStatusBanner";
13 import { dismissThreadErrorBannerForSession, ThreadErrorBanner } from "./ThreadErrorBanner";
14
15 /**
@@ -16,8 +19,7 @@ import { dismissThreadErrorBannerForSession, ThreadErrorBanner } from "./ThreadE
19 export function ChatBannerLane(props: {
20 environmentId: EnvironmentId;
21 providerStatus: ServerProvider | null;
19 - providerStatusBannerKey: string | null;
20 - setDismissedProviderStatusBannerKey: Dispatch<SetStateAction<string | null>>;
22 + providerStatusDismissalKey: string | null;
23 onOpenProviderSetup: (instanceId: ProviderInstanceId) => void;
24 threadId: ThreadId;
25 threadError: string | null;
@@ -29,8 +31,7 @@ export function ChatBannerLane(props: {
31 }) {
32 const {
33 providerStatus,
32 - providerStatusBannerKey,
33 - setDismissedProviderStatusBannerKey,
34 + providerStatusDismissalKey,
35 onOpenProviderSetup,
36 threadId,
37 threadError,
@@ -45,7 +46,7 @@ export function ChatBannerLane(props: {
46 <ProviderStatusBanner
47 environmentId={props.environmentId}
48 status={providerStatus}
48 - onDismiss={() => setDismissedProviderStatusBannerKey(providerStatusBannerKey)}
49 + onDismiss={() => dismissProviderStatusBannerForSession(providerStatusDismissalKey)}
50 onOpenProviderSetup={onOpenProviderSetup}
51 />
52 <ThreadErrorBanner
apps/web/src/components/chat/ProviderStatusBanner.test.ts
+58 -22
@@ -1,8 +1,11 @@
1 import { describe, expect, it } from "vite-plus/test";
2 import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3tools/contracts";
3 import {
4 + dismissProviderStatusBannerForSession,
5 getProviderStatusBannerKey,
6 + getProviderStatusDismissalKey,
7 getProviderStatusMessage,
8 + isProviderStatusBannerDismissedForSession,
9 shouldShowProviderStatusBanner,
10 } from "./ProviderStatusBanner";
11
@@ -26,18 +29,18 @@ const provider: ServerProvider = {
29 },
30 };
31
32 +function shownAfterDismissing(dismissed: ServerProvider, shown: ServerProvider): boolean {
33 + return shouldShowProviderStatusBanner(
34 + shown,
35 + getProviderStatusBannerKey(shown) === getProviderStatusBannerKey(dismissed),
36 + );
37 +}
38 +
39 describe("compatibility banners", () => {
40 it("shows and dismisses a warning on a healthy provider, then clears it after policy relaxation", () => {
31 - expect(shouldShowProviderStatusBanner(provider, null)).toBe(true);
32 - expect(shouldShowProviderStatusBanner(provider, getProviderStatusBannerKey(provider))).toBe(
33 - false,
34 - );
35 - expect(
36 - shouldShowProviderStatusBanner(
37 - { ...provider, version: "1.0.1" },
38 - getProviderStatusBannerKey(provider),
39 - ),
40 - ).toBe(true);
41 + expect(shouldShowProviderStatusBanner(provider, false)).toBe(true);
42 + expect(shownAfterDismissing(provider, provider)).toBe(false);
43 + expect(shownAfterDismissing(provider, { ...provider, version: "1.0.1" })).toBe(true);
44 const relaxed: ServerProvider = {
45 ...provider,
46 compatibilityAdvisory: {
@@ -72,7 +75,7 @@ describe("compatibility banners", () => {
75 recommendedRange: ">=1.14.19 <2.0.0",
76 },
77 };
75 - expect(shouldShowProviderStatusBanner(broken, null)).toBe(true);
78 + expect(shouldShowProviderStatusBanner(broken, false)).toBe(true);
79 const timeoutOnly: ServerProvider = {
80 ...broken,
81 compatibilityAdvisory: {
@@ -81,18 +84,13 @@ describe("compatibility banners", () => {
84 message: null,
85 },
86 };
84 - expect(shouldShowProviderStatusBanner(broken, getProviderStatusBannerKey(timeoutOnly))).toBe(
85 - true,
86 - );
87 - expect(shouldShowProviderStatusBanner(broken, getProviderStatusBannerKey(broken))).toBe(false);
87 + expect(shownAfterDismissing(timeoutOnly, broken)).toBe(true);
88 + expect(shownAfterDismissing(broken, broken)).toBe(false);
89 expect(
89 - shouldShowProviderStatusBanner(
90 - {
91 - ...broken,
92 - compatibilityAdvisory: { ...broken.compatibilityAdvisory!, message: "Use 1.14.20." },
93 - },
94 - getProviderStatusBannerKey(broken),
95 - ),
90 + shownAfterDismissing(broken, {
91 + ...broken,
92 + compatibilityAdvisory: { ...broken.compatibilityAdvisory!, message: "Use 1.14.20." },
93 + }),
94 ).toBe(true);
95 expect(getProviderStatusMessage(broken)).toBe(message);
96 expect(
@@ -110,3 +108,41 @@ describe("compatibility banners", () => {
108 );
109 });
110 });
111 +
112 +describe("banner dismissal", () => {
113 + const { compatibilityAdvisory: _advisory, ...healthy } = provider;
114 + const failing: ServerProvider = {
115 + ...healthy,
116 + instanceId: ProviderInstanceId.make("codex-dismissal"),
117 + status: "error",
118 + message: "Could not start Codex CLI.",
119 + };
120 +
121 + it("keeps a dismissed status hidden in other views until the status changes", () => {
122 + const key = getProviderStatusDismissalKey("environment-a", failing);
123 + expect(isProviderStatusBannerDismissedForSession(key)).toBe(false);
124 +
125 + dismissProviderStatusBannerForSession(key);
126 +
127 + expect(
128 + isProviderStatusBannerDismissedForSession(
129 + getProviderStatusDismissalKey("environment-a", failing),
130 + ),
131 + ).toBe(true);
132 + expect(
133 + isProviderStatusBannerDismissedForSession(
134 + getProviderStatusDismissalKey("environment-a", { ...failing, message: "Codex exited." }),
135 + ),
136 + ).toBe(false);
137 + });
138 +
139 + it("keeps a dismissal to the environment it was taken in", () => {
140 + dismissProviderStatusBannerForSession(getProviderStatusDismissalKey("environment-c", failing));
141 +
142 + expect(
143 + isProviderStatusBannerDismissedForSession(
144 + getProviderStatusDismissalKey("environment-d", failing),
145 + ),
146 + ).toBe(false);
147 + });
148 +});
apps/web/src/components/chat/ProviderStatusBanner.tsx
+36 -3
@@ -4,7 +4,7 @@ import {
4 type ServerProvider,
5 } from "@t3tools/contracts";
6 import { useAtomValue } from "@effect/atom-react";
7 -import { memo, useRef, useState } from "react";
7 +import { memo, useRef, useState, useSyncExternalStore } from "react";
8 import { InfoIcon, XIcon } from "lucide-react";
9 import { Alert, AlertAction, AlertDescription, AlertTitle } from "../ui/alert";
10 import { Button, InlineButton } from "../ui/button";
@@ -51,10 +51,43 @@ export function getProviderStatusBannerKey(status: ServerProvider | null): strin
51
52 export function shouldShowProviderStatusBanner(
53 status: ServerProvider | null,
54 - dismissedBannerKey: string | null,
54 + isDismissed: boolean,
55 ): boolean {
56 + return getProviderStatusBannerKey(status) !== null && !isDismissed;
57 +}
58 +
59 +// Built-in instance ids such as `codex` repeat across environments.
60 +export function getProviderStatusDismissalKey(
61 + environmentId: string | undefined,
62 + status: ServerProvider | null,
63 +): string | null {
64 const bannerKey = getProviderStatusBannerKey(status);
57 - return bannerKey !== null && bannerKey !== dismissedBannerKey;
65 + return bannerKey === null ? null : `${environmentId ?? ""}\u0000${bannerKey}`;
66 +}
67 +
68 +// A dismissal lasts the session, not one view, so opening another thread cannot bring it back.
69 +const sessionDismissedProviderStatusBannerKeys = new Set<string>();
70 +const dismissalListeners = new Set<() => void>();
71 +
72 +export function dismissProviderStatusBannerForSession(bannerKey: string | null): void {
73 + if (bannerKey === null || sessionDismissedProviderStatusBannerKeys.has(bannerKey)) return;
74 + sessionDismissedProviderStatusBannerKeys.add(bannerKey);
75 + for (const listener of dismissalListeners) listener();
76 +}
77 +
78 +export function isProviderStatusBannerDismissedForSession(bannerKey: string | null): boolean {
79 + return bannerKey !== null && sessionDismissedProviderStatusBannerKeys.has(bannerKey);
80 +}
81 +
82 +function subscribeToDismissals(listener: () => void) {
83 + dismissalListeners.add(listener);
84 + return () => dismissalListeners.delete(listener);
85 +}
86 +
87 +export function useProviderStatusBannerDismissed(bannerKey: string | null): boolean {
88 + return useSyncExternalStore(subscribeToDismissals, () =>
89 + isProviderStatusBannerDismissedForSession(bannerKey),
90 + );
91 }
92
93 export function hasProviderSetup(status: ServerProvider): boolean {