Skip to content

Commit 07891e9

Browse files
authored
fix(web): bound disconnected send toasts (pingdotgg#9592)
Co-authored-by: maria-rcks <[email protected]>
1 parent b34ff8f commit 07891e9

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,8 @@ function chatActionErrorMessage(error: unknown): string {
13351335
return error instanceof Error ? error.message : "An error occurred.";
13361336
}
13371337

1338+
const ENVIRONMENT_UNAVAILABLE_SEND_TOAST_TRAIL_SIZE = 3;
1339+
13381340
/**
13391341
* Drops the send-time anchored end space. That space is what holds a sent
13401342
* message near the top while its turn streams, and it keeps LegendList's
@@ -1641,6 +1643,7 @@ function ChatViewContent(props: ChatViewProps) {
16411643
const attachmentPreviewHandoffByMessageIdRef = useRef<Record<string, string[]>>({});
16421644
const attachmentPreviewPromotionInFlightByMessageIdRef = useRef<Record<string, true>>({});
16431645
const sendInFlightRef = useRef(false);
1646+
const environmentUnavailableSendToastSlotRef = useRef(0);
16441647
const feedbackUploadsInFlightRef = useRef(new Set<string>());
16451648
const terminalUiOpenByThreadRef = useRef<Record<string, boolean>>({});
16461649

@@ -6073,13 +6076,17 @@ function ChatViewContent(props: ChatViewProps) {
60736076
return;
60746077
}
60756078
if (activeEnvironmentUnavailable) {
6076-
toastManager.add(
6077-
stackedThreadToast({
6079+
const toastSlot = environmentUnavailableSendToastSlotRef.current;
6080+
environmentUnavailableSendToastSlotRef.current =
6081+
(toastSlot + 1) % ENVIRONMENT_UNAVAILABLE_SEND_TOAST_TRAIL_SIZE;
6082+
toastManager.add({
6083+
...stackedThreadToast({
60786084
type: "warning",
60796085
title: "Not connected: message not sent",
60806086
description: "Reconnecting to the environment. Try again once it is connected.",
60816087
}),
6082-
);
6088+
id: `chat-send-environment-unavailable:${toastSlot}`,
6089+
});
60836090
return;
60846091
}
60856092
if (activePendingProgress) {

0 commit comments

Comments
 (0)