Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

Add warning for delayed ai response

Khuram Niazc737413c9c63
diff --git a/src/components/common/SlowResponseWarning.tsx b/src/components/common/SlowResponseWarning.tsx
new file mode 100644
index 0000000..c32e091
--- /dev/null
+++ b/src/components/common/SlowResponseWarning.tsx
@@ -0,0 +1,12 @@
+import { Clock } from "lucide-react";
+
+export const SlowResponseWarning = () => (
+ <div className="flex items-center gap-2 text-amber-600 dark:text-amber-400 text-sm mt-3 px-3 py-2 bg-amber-50 dark:bg-amber-950/30 rounded-md border border-amber-200 dark:border-amber-800 animate-in fade-in duration-500">
+ <Clock className="h-4 w-4 flex-shrink-0" />
+ <span>
+ The model is taking longer than usual. Either wait or try a different,
+ faster model in <span className="font-medium">Settings</span> for quicker
+ responses.
+ </span>
+ </div>
+);
diff --git a/src/components/profile/AiJobMatchSection.tsx b/src/components/profile/AiJobMatchSection.tsx
index a096b2b..3cf1a61 100644
--- a/src/components/profile/AiJobMatchSection.tsx
+++ b/src/components/profile/AiJobMatchSection.tsx
@@ -34,6 +34,8 @@ import { Info, CheckCircle, XCircle } from "lucide-react";
import { checkOllamaConnection } from "@/utils/ai.utils";
import { JobMatchSchema } from "@/models/ai.schemas";
import { getUserSettings } from "@/actions/userSettings.actions";
+import { useSlowResponseWarning } from "@/hooks/useSlowResponseWarning";
+import { SlowResponseWarning } from "../common/SlowResponseWarning";
interface AiSectionProps {
aISectionOpen: boolean;
@@ -198,6 +200,8 @@ export const AiJobMatchSection = ({
const hasContent =
object && (object.matchScore !== undefined || object.summary);
+ const showSlowWarning = useSlowResponseWarning(isLoading, !!hasContent);
+
return (
<Sheet open={aISectionOpen} onOpenChange={onOpenChange}>
<SheetPortal>
@@ -272,6 +276,7 @@ export const AiJobMatchSection = ({
<div className="flex items-center flex-col mt-4">
<Loading />
<div className="mt-2">Analyzing job match...</div>
+ {showSlowWarning && <SlowResponseWarning />}
</div>
) : (
<AiJobMatchResponseContent
diff --git a/src/components/profile/AiResumeReviewSection.tsx b/src/components/profile/AiResumeReviewSection.tsx
index 21444b8..71b63ad 100644
--- a/src/components/profile/AiResumeReviewSection.tsx
+++ b/src/components/profile/AiResumeReviewSection.tsx
@@ -26,6 +26,8 @@ import {
import { checkOllamaConnection } from "@/utils/ai.utils";
import { ResumeReviewSchema } from "@/models/ai.schemas";
import { getUserSettings } from "@/actions/userSettings.actions";
+import { useSlowResponseWarning } from "@/hooks/useSlowResponseWarning";
+import { SlowResponseWarning } from "../common/SlowResponseWarning";
interface AiSectionProps {
resume: Resume;
@@ -108,6 +110,8 @@ const AiResumeReviewSection = ({ resume }: AiSectionProps) => {
// Check if we have any content to show
const hasContent = object && (object.scores?.overall !== undefined || object.summary);
+ const showSlowWarning = useSlowResponseWarning(isLoading, !!hasContent);
+
return (
<Sheet open={aISectionOpen} onOpenChange={triggerSheetChange}>
<div className="ml-2">
@@ -184,6 +188,7 @@ const AiResumeReviewSection = ({ resume }: AiSectionProps) => {
<div className="flex items-center flex-col mt-4">
<Loading />
<div className="mt-2">Analyzing resume...</div>
+ {showSlowWarning && <SlowResponseWarning />}
</div>
) : (
<AiResumeReviewResponseContent
diff --git a/src/hooks/useSlowResponseWarning.ts b/src/hooks/useSlowResponseWarning.ts
new file mode 100644
index 0000000..2926801
--- /dev/null
+++ b/src/hooks/useSlowResponseWarning.ts
@@ -0,0 +1,30 @@
+import { useState, useEffect, useRef } from "react";
+import { APP_CONSTANTS } from "@/lib/constants";
+
+export function useSlowResponseWarning(isLoading: boolean, hasContent: boolean) {
+ const [showWarning, setShowWarning] = useState(false);
+ const timerRef = useRef<NodeJS.Timeout | null>(null);
+
+ useEffect(() => {
+ if (isLoading && !hasContent) {
+ timerRef.current = setTimeout(() => {
+ setShowWarning(true);
+ }, APP_CONSTANTS.AI_SLOW_RESPONSE_THRESHOLD_MS);
+ } else {
+ setShowWarning(false);
+ if (timerRef.current) {
+ clearTimeout(timerRef.current);
+ timerRef.current = null;
+ }
+ }
+
+ return () => {
+ if (timerRef.current) {
+ clearTimeout(timerRef.current);
+ timerRef.current = null;
+ }
+ };
+ }, [isLoading, hasContent]);
+
+ return showWarning;
+}
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index d5e392d..0305f7f 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -16,6 +16,7 @@ export const APP_CONSTANTS = {
ACTIVITY_MAX_DURATION_MINUTES: 8 * 60, // 8 Hours
ACTIVITY_MAX_DURATION_MS: 8 * 60 * 60 * 1000, // 8 hours in milliseconds
RECENT_NUM_JOBS_ACTIVITIES: 7,
+ AI_SLOW_RESPONSE_THRESHOLD_MS: 15_000, // 15 seconds
} as const;
export const SCHEDULER_CONSTANTS = {