fix: show token alert popover during agent responses and agent failure cases (#3536)
This commit is contained in:
@@ -382,7 +382,7 @@ export default function ChatInput({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
clearAlerts();
|
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 (isTokenLimitLoaded && tokenLimit && numTokens && numTokens > 0) {
|
||||||
if (numTokens >= tokenLimit) {
|
if (numTokens >= tokenLimit) {
|
||||||
// Only show error alert when limit reached
|
// 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
|
// Add tool count alert if we have the data
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ interface AlertPopoverProps {
|
|||||||
|
|
||||||
export default function BottomMenuAlertPopover({ alerts }: AlertPopoverProps) {
|
export default function BottomMenuAlertPopover({ alerts }: AlertPopoverProps) {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [hasShownInitial, setHasShownInitial] = useState(false);
|
|
||||||
const [isHovered, setIsHovered] = useState(false);
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const [wasAutoShown, setWasAutoShown] = useState(false);
|
const [wasAutoShown, setWasAutoShown] = useState(false);
|
||||||
const [popoverPosition, setPopoverPosition] = useState({ top: 0, left: 0 });
|
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
|
// Only auto-show if any of the new/changed alerts have autoShow: true
|
||||||
const hasNewAutoShowAlert = changedAlerts.some((alert) => alert.autoShow === true);
|
const hasNewAutoShowAlert = changedAlerts.some((alert) => alert.autoShow === true);
|
||||||
|
|
||||||
// Auto show the popover only if:
|
// Auto show the popover for new auto-show alerts
|
||||||
// 1. There are new alerts that should auto-show AND
|
if (hasNewAutoShowAlert) {
|
||||||
// 2. We haven't shown this specific alert before (tracked by hasShownInitial)
|
|
||||||
if (hasNewAutoShowAlert && !hasShownInitial) {
|
|
||||||
setIsOpen(true);
|
setIsOpen(true);
|
||||||
setHasShownInitial(true);
|
|
||||||
setWasAutoShown(true);
|
setWasAutoShown(true);
|
||||||
// Start 3 second timer for auto-show
|
// Start 3 second timer for auto-show
|
||||||
startHideTimer(3000);
|
startHideTimer(3000);
|
||||||
}
|
}
|
||||||
}, [alerts, hasShownInitial, startHideTimer]);
|
}, [alerts, startHideTimer]);
|
||||||
|
|
||||||
// Handle auto-hide based on hover state changes
|
// Handle auto-hide based on hover state changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export const DirSwitcher: React.FC<DirSwitcherProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent className="max-w-96 overflow-auto scrollbar-thin" side="top">
|
<TooltipContent side="top">
|
||||||
{window.appConfig.get('GOOSE_WORKING_DIR') as string}
|
{window.appConfig.get('GOOSE_WORKING_DIR') as string}
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
Reference in New Issue
Block a user