diff --git a/client/src/pages/Home.tsx b/client/src/pages/Home.tsx index 48b9bb3..22cc6c6 100644 --- a/client/src/pages/Home.tsx +++ b/client/src/pages/Home.tsx @@ -1052,7 +1052,11 @@ export default function HomePage() { const currentQuery = useQuery({ queryKey: ['home', tab, debouncedSearch, filtersStr, sortStr, offset], queryFn: () => fetchHomeTasks(tab, debouncedSearch, filters, sort, offset), - staleTime: isOnline ? 0 : 30000, + // Recent tab should always be fresh: a viewed task must appear immediately + // when the user returns to Home. Other tabs keep the previous offline-friendly + // behavior. + staleTime: tab === 'recent' ? 0 : (isOnline ? 0 : 30000), + refetchOnWindowFocus: tab === 'recent', }); useEffect(() => { diff --git a/client/src/pages/TaskDetail.tsx b/client/src/pages/TaskDetail.tsx index 275e635..28b0d2b 100644 --- a/client/src/pages/TaskDetail.tsx +++ b/client/src/pages/TaskDetail.tsx @@ -3108,7 +3108,9 @@ const TaskDetail = () => { apiRequest('POST', `/api/tasks/${taskIdNumber}/view`) .then(() => { if (!cancelled) { - queryClient.invalidateQueries({ queryKey: ['home'] }); + // Refetch Home queries in the background, including inactive ones, + // so the Recent tab is already fresh when the user comes back. + queryClient.refetchQueries({ queryKey: ['home'], type: 'all' }); } }) .catch((err) => {