From 3d5f395ce6f839f92f350efbc540f1031141ee23 Mon Sep 17 00:00:00 2001 From: Zane <75694352+zanesq@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:33:11 -0700 Subject: [PATCH] fix: show token alert popover during agent responses and agent failure cases (#3536) --- ui/desktop/src/components/ChatInput.tsx | 12 +++++++++++- .../bottom_menu/BottomMenuAlertPopover.tsx | 10 +++------- .../src/components/bottom_menu/DirSwitcher.tsx | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ui/desktop/src/components/ChatInput.tsx b/ui/desktop/src/components/ChatInput.tsx index 597201b5..da3da8da 100644 --- a/ui/desktop/src/components/ChatInput.tsx +++ b/ui/desktop/src/components/ChatInput.tsx @@ -382,7 +382,7 @@ export default function ChatInput({ useEffect(() => { clearAlerts(); - // Only show token alerts if we have loaded the real token limit + // Always show token alerts if we have loaded the real token limit and have tokens if (isTokenLimitLoaded && tokenLimit && numTokens && numTokens > 0) { if (numTokens >= tokenLimit) { // Only show error alert when limit reached @@ -409,6 +409,16 @@ export default function ChatInput({ }, }); } + } else if (isTokenLimitLoaded && tokenLimit) { + // Always show context window info even when no tokens are present (start of conversation) + addAlert({ + type: AlertType.Info, + message: 'Context window', + progress: { + current: 0, + total: tokenLimit, + }, + }); } // Add tool count alert if we have the data diff --git a/ui/desktop/src/components/bottom_menu/BottomMenuAlertPopover.tsx b/ui/desktop/src/components/bottom_menu/BottomMenuAlertPopover.tsx index 3cf85f7b..bd34285f 100644 --- a/ui/desktop/src/components/bottom_menu/BottomMenuAlertPopover.tsx +++ b/ui/desktop/src/components/bottom_menu/BottomMenuAlertPopover.tsx @@ -12,7 +12,6 @@ interface AlertPopoverProps { export default function BottomMenuAlertPopover({ alerts }: AlertPopoverProps) { const [isOpen, setIsOpen] = useState(false); - const [hasShownInitial, setHasShownInitial] = useState(false); const [isHovered, setIsHovered] = useState(false); const [wasAutoShown, setWasAutoShown] = useState(false); const [popoverPosition, setPopoverPosition] = useState({ top: 0, left: 0 }); @@ -116,17 +115,14 @@ export default function BottomMenuAlertPopover({ alerts }: AlertPopoverProps) { // Only auto-show if any of the new/changed alerts have autoShow: true const hasNewAutoShowAlert = changedAlerts.some((alert) => alert.autoShow === true); - // Auto show the popover only if: - // 1. There are new alerts that should auto-show AND - // 2. We haven't shown this specific alert before (tracked by hasShownInitial) - if (hasNewAutoShowAlert && !hasShownInitial) { + // Auto show the popover for new auto-show alerts + if (hasNewAutoShowAlert) { setIsOpen(true); - setHasShownInitial(true); setWasAutoShown(true); // Start 3 second timer for auto-show startHideTimer(3000); } - }, [alerts, hasShownInitial, startHideTimer]); + }, [alerts, startHideTimer]); // Handle auto-hide based on hover state changes useEffect(() => { diff --git a/ui/desktop/src/components/bottom_menu/DirSwitcher.tsx b/ui/desktop/src/components/bottom_menu/DirSwitcher.tsx index 5dd5483e..c51bea91 100644 --- a/ui/desktop/src/components/bottom_menu/DirSwitcher.tsx +++ b/ui/desktop/src/components/bottom_menu/DirSwitcher.tsx @@ -35,7 +35,7 @@ export const DirSwitcher: React.FC = ({ - + {window.appConfig.get('GOOSE_WORKING_DIR') as string}