feat: enhance billing dashboard with historical data & security hardening

- Fix usage tracking zero-value bug with self-healing logic
- Add month selector for historical usage views
- Implement start-of-month graceful initialization
- Merge PR #372: Harden user-scoped access in subscription routes
- Fix UI bugs in UsageDashboard component
This commit is contained in:
ajaysi
2026-03-05 10:21:56 +05:30
parent 261c224dca
commit 26131232c7
8 changed files with 234 additions and 161 deletions

View File

@@ -85,17 +85,37 @@ export const useAgentHuddleFeed = (options?: { detailTier?: 'summary' | 'detaile
useEffect(() => {
stopRef.current = false;
let pollingTimer: ReturnType<typeof setInterval> | null = null;
let backoffMs = BASE_BACKOFF_MS;
// If polling fails repeatedly, try to reconnect SSE
const handlePollingError = () => {
if (connectionMode === 'polling' && reconnectAttemptRef.current < 5) {
connect();
}
};
const startPolling = () => {
setConnectionMode('polling');
if (pollingTimer) clearInterval(pollingTimer);
pollingTimer = setInterval(async () => {
const poll = async () => {
if (document.hidden) return;
try {
await loadSnapshot(cursorRef.current);
} catch {
// no-op
backoffMs = BASE_BACKOFF_MS;
} catch (err: any) {
if (err?.response?.status === 429) {
// Exponential backoff for 429s
backoffMs = Math.min(backoffMs * 2, 60000);
clearInterval(pollingTimer!);
pollingTimer = setInterval(poll, backoffMs);
} else {
handlePollingError();
}
}
}, 7000);
};
pollingTimer = setInterval(poll, 10000);
};
const connect = async () => {