Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions frontend/src/components/UnifiedChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ export function UnifiedChat() {
const assistantStreamingRef = useRef(false);

const abortControllerRef = useRef<AbortController | null>(null);
const billingRefreshTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
const documentInputRef = useRef<HTMLInputElement>(null);

Expand Down Expand Up @@ -992,6 +993,15 @@ export function UnifiedChat() {
}
}, [input]);

// Cleanup billing refresh timeout on unmount
useEffect(() => {
return () => {
if (billingRefreshTimeoutRef.current) {
clearTimeout(billingRefreshTimeoutRef.current);
}
};
}, []);

// Auto-focus textbox on desktop (not mobile to avoid keyboard popup interrupting reading)
// Focus when: app launches, new chat, conversation loads, or assistant finishes streaming
useEffect(() => {
Expand Down Expand Up @@ -2365,6 +2375,12 @@ export function UnifiedChat() {
// Re-enable polling after streaming completes
assistantStreamingRef.current = false;
setCurrentResponseId(undefined);

// Invalidate billing status after a delay to allow backend processing
billingRefreshTimeoutRef.current = setTimeout(() => {
queryClient.invalidateQueries({ queryKey: ["billingStatus"] });
billingRefreshTimeoutRef.current = null;
}, 3000);
Comment thread
AnthonyRonning marked this conversation as resolved.
}
} catch (error) {
console.error("Failed to send message:", error);
Expand Down
Loading