From 3f37029dfd90665da08018ee4c36a00ebcff5206 Mon Sep 17 00:00:00 2001 From: DaKheera47 Date: Fri, 23 Jan 2026 12:08:17 +0000 Subject: [PATCH] address comments --- orchestrator/src/client/api/client.ts | 19 ++++++++++++++++--- .../src/client/components/OnboardingGate.tsx | 6 +++--- .../src/client/pages/SettingsPage.tsx | 10 +++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/orchestrator/src/client/api/client.ts b/orchestrator/src/client/api/client.ts index 182e772..46b8cbd 100644 --- a/orchestrator/src/client/api/client.ts +++ b/orchestrator/src/client/api/client.ts @@ -168,8 +168,20 @@ export async function importManualJob(input: { } // Settings & Profile API +let settingsPromise: Promise | null = null; + export async function getSettings(): Promise { - return fetchApi('/settings'); + if (settingsPromise) return settingsPromise; + + settingsPromise = fetchApi('/settings').finally(() => { + // Clear the promise after a short delay to allow subsequent fresh fetches + // but coalesce simultaneous requests. + setTimeout(() => { + settingsPromise = null; + }, 100); + }); + + return settingsPromise; } export async function getProfileProjects(): Promise { @@ -260,9 +272,10 @@ export async function getRxResumes(): Promise<{ id: string; name: string }[]> { return data.resumes; } -export async function getRxResumeProjects(resumeId: string): Promise { +export async function getRxResumeProjects(resumeId: string, signal?: AbortSignal): Promise { const data = await fetchApi<{ projects: ResumeProjectCatalogItem[] }>( - `/settings/rx-resumes/${encodeURIComponent(resumeId)}/projects` + `/settings/rx-resumes/${encodeURIComponent(resumeId)}/projects`, + { signal } ); return data.projects; } diff --git a/orchestrator/src/client/components/OnboardingGate.tsx b/orchestrator/src/client/components/OnboardingGate.tsx index 8d5e740..4e5b528 100644 --- a/orchestrator/src/client/components/OnboardingGate.tsx +++ b/orchestrator/src/client/components/OnboardingGate.tsx @@ -165,13 +165,13 @@ export const OnboardingGate: React.FC = () => { const message = reason instanceof Error ? reason.message : "Validation checks failed" toast.error(message) } - }, [settings, validateOpenrouter, validateRxresume]) + }, [settings, validateOpenrouter, validateRxresume, validateBaseResume]) useEffect(() => { if (!settings || settingsLoading) return - if (openrouterValidation.checked || rxresumeValidation.checked) return + if (openrouterValidation.checked || rxresumeValidation.checked || baseResumeValidation.checked) return void runAllValidations() - }, [settings, settingsLoading, openrouterValidation.checked, rxresumeValidation.checked, runAllValidations]) + }, [settings, settingsLoading, openrouterValidation.checked, rxresumeValidation.checked, baseResumeValidation.checked, runAllValidations]) const handleRefresh = async () => { const results = await Promise.allSettled([refreshSettings(), runAllValidations()]) diff --git a/orchestrator/src/client/pages/SettingsPage.tsx b/orchestrator/src/client/pages/SettingsPage.tsx index a286d4a..f697a04 100644 --- a/orchestrator/src/client/pages/SettingsPage.tsx +++ b/orchestrator/src/client/pages/SettingsPage.tsx @@ -156,7 +156,7 @@ const normalizeResumeProjectsForCatalog = ( const lockedProjectIds = base.lockedProjectIds.filter((id) => allowed.has(id)) const lockedSet = new Set(lockedProjectIds) - const aiSelectableProjectIds = (base.aiSelectableProjectIds.length + const aiSelectableProjectIds = (current ? base.aiSelectableProjectIds : catalog.map((project) => project.id) ) @@ -320,21 +320,24 @@ export const SettingsPage: React.FC = () => { useEffect(() => { let isMounted = true + const controller = new AbortController() if (!rxResumeBaseResumeIdDraft) { setRxResumeProjectsOverride(null) return () => { isMounted = false + controller.abort() } } if (!hasRxResumeAccess) return () => { isMounted = false + controller.abort() } setIsFetchingRxResumeProjects(true) api - .getRxResumeProjects(rxResumeBaseResumeIdDraft) + .getRxResumeProjects(rxResumeBaseResumeIdDraft, controller.signal) .then((projects) => { if (!isMounted) return setRxResumeProjectsOverride(projects) @@ -347,7 +350,7 @@ export const SettingsPage: React.FC = () => { } }) .catch((error) => { - if (!isMounted) return + if (!isMounted || error.name === 'AbortError') return const message = error instanceof Error ? error.message : "Failed to load RxResume projects" toast.error(message) setRxResumeProjectsOverride(null) @@ -359,6 +362,7 @@ export const SettingsPage: React.FC = () => { return () => { isMounted = false + controller.abort() } }, [rxResumeBaseResumeIdDraft, hasRxResumeAccess, getValues, setValue])