Merge branch 'main' into bugfix/383-dark-mode-dialog-opacity

This commit is contained in:
Surajdusane 2025-05-19 12:17:50 +05:30 committed by GitHub
commit a52b7823d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 23 deletions

View File

@ -1013,38 +1013,32 @@ export default function ThreadPage({
}
}, [project?.account_id, billingStatusQuery]);
// Check billing when agent status changes
useEffect(() => {
const previousStatus = previousAgentStatus.current;
let timeoutId: NodeJS.Timeout;
const shouldCheckBilling =
project?.account_id &&
(initialLoadCompleted.current ||
(messagesLoadedRef.current && !isLoading) ||
(previousAgentStatus.current === 'running' && agentStatus === 'idle'));
// Check if agent just completed (status changed from running to idle)
if (previousStatus === 'running' && agentStatus === 'idle') {
checkBillingLimits();
if (shouldCheckBilling) {
timeoutId = setTimeout(() => {
checkBillingLimits();
}, 500);
}
// Store current status for next comparison
previousAgentStatus.current = agentStatus;
}, [agentStatus, checkBillingLimits]);
// Check billing on initial load
useEffect(() => {
if (project?.account_id && initialLoadCompleted.current) {
console.log('Checking billing status on page load');
checkBillingLimits();
}
}, [project?.account_id, checkBillingLimits, initialLoadCompleted]);
// Check billing after messages loaded
useEffect(() => {
if (messagesLoadedRef.current && project?.account_id && !isLoading) {
console.log('Checking billing status after messages loaded');
checkBillingLimits();
}
return () => {
if (timeoutId) {
clearTimeout(timeoutId);
}
};
}, [
messagesLoadedRef.current,
checkBillingLimits,
project?.account_id,
isLoading,
agentStatus,
checkBillingLimits
]);
// Check for debug mode in URL on initial load and when URL changes