Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions frontend/app/auth/callback/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ function AuthCallbackContent() {
}
sessionStorage.setItem(callbackKey, "true");

let redirectTimeoutId: NodeJS.Timeout;

const handleCallback = async () => {
try {
// Get parameters from URL
Expand Down Expand Up @@ -158,7 +160,7 @@ function AuthCallbackContent() {
localStorage.removeItem("auth_redirect_to");

// Redirect to the original page or home
setTimeout(() => {
redirectTimeoutId = setTimeout(() => {
router.push(redirectTo);
}, 2000);
} else {
Expand All @@ -170,7 +172,7 @@ function AuthCallbackContent() {
localStorage.removeItem("auth_purpose");

// Redirect to settings page with success indicator
setTimeout(() => {
redirectTimeoutId = setTimeout(() => {
router.push("/settings?oauth_success=true");
}, 2000);
}
Expand All @@ -191,6 +193,7 @@ function AuthCallbackContent() {
};

handleCallback();
return () => clearTimeout(redirectTimeoutId);
}, [searchParams, router, refreshAuth]);

// Dynamic UI content based on purpose
Expand Down
9 changes: 7 additions & 2 deletions frontend/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ function ChatPage() {

// Load conversation data from context
useEffect(() => {
let focusTimeoutId: NodeJS.Timeout;
// Only load conversation data when:
// 1. conversationData exists AND
// 2. (It's a different conversation OR we're not streaming and data has changed) AND
Expand Down Expand Up @@ -486,13 +487,15 @@ function ChatPage() {
}));

// Focus input when loading a conversation
setTimeout(() => {
focusTimeoutId = setTimeout(() => {
chatInputRef.current?.focusInput();
}, 100);
} else if (!conversationData) {
// No conversation selected (new conversation)
lastLoadedConversationRef.current = null;
}

return () => clearTimeout(focusTimeoutId);
}, [
conversationData,
isUserInteracting,
Expand All @@ -504,16 +507,18 @@ function ChatPage() {

// Handle new conversation creation - only reset messages when placeholderConversation is set
useEffect(() => {
let focusTimeoutId: NodeJS.Timeout;
if (placeholderConversation && currentConversationId === null) {
console.log("Starting new conversation");
setMessages([INITIAL_ASSISTANT_MESSAGE]);
lastLoadedConversationRef.current = null;

// Focus input when starting a new conversation
setTimeout(() => {
focusTimeoutId = setTimeout(() => {
chatInputRef.current?.focusInput();
}, 100);
}
return () => clearTimeout(focusTimeoutId);
}, [placeholderConversation, currentConversationId]);

const { isOnboardingComplete } = useOnboardingState();
Expand Down
5 changes: 4 additions & 1 deletion frontend/app/onboarding/_components/onboarding-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ const OnboardingCard = ({

// Monitor tasks and call onComplete when all tasks are done
useEffect(() => {
let completeTimeoutId: NodeJS.Timeout;
if (currentStep === null || !tasks || !isEmbedding) {
return;
}
Expand Down Expand Up @@ -404,10 +405,12 @@ const OnboardingCard = ({
// Set to final step to show "Done"
setCurrentStep(totalSteps);
// Wait a bit before completing
setTimeout(() => {
completeTimeoutId = setTimeout(() => {
onComplete();
}, 1000);
}

return () => clearTimeout(completeTimeoutId);
}, [
tasks,
currentStep,
Expand Down
7 changes: 5 additions & 2 deletions frontend/app/onboarding/_components/onboarding-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => {

// Monitor tasks and call onComplete when file processing is done
useEffect(() => {
let completeTimeoutId: NodeJS.Timeout;
if (currentStep === null || !tasks || !uploadedTaskId) {
return;
}
Expand Down Expand Up @@ -161,7 +162,7 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => {
refetchNudges();

// Wait a bit before completing (after filter is created)
setTimeout(() => {
completeTimeoutId = setTimeout(() => {
onComplete();
}, 1000);
});
Expand All @@ -171,11 +172,13 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => {
refetchNudges();

// Wait a bit before completing
setTimeout(() => {
completeTimeoutId = setTimeout(() => {
onComplete();
}, 1000);
}
}

return () => clearTimeout(completeTimeoutId);
}, [
tasks,
currentStep,
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/settings/_components/agent-settings-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export function AgentSettingsSection() {
const newParams = new URLSearchParams(searchParams.toString());
newParams.delete("focusLlmModel");
router.replace(`${pathname}?${newParams.toString()}`, { scroll: false });
setTimeout(() => setOpenLlmSelector(false), 100);
const timeoutId = setTimeout(() => setOpenLlmSelector(false), 100);
return () => clearTimeout(timeoutId);
}
}, [focusLlmModel, searchParams, router, pathname]);

Expand Down
Loading