From 01c50ab971be69d6d8eb9daa99c93e5e8d53a1b7 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Mon, 23 Mar 2026 14:43:41 +0100 Subject: [PATCH] fix(pagespeed): make frequency interactive and show next check time - Replace dead frequency badge with inline dropdown selector - Add "Next in Xh" indicator from next_check_at - Demote "Disable" button to subtle text link (was competing with Run Check) - Add cursor-pointer to prev/next history arrows - Narrow filmstrip fade to avoid covering content --- app/sites/[id]/pagespeed/page.tsx | 71 +++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/app/sites/[id]/pagespeed/page.tsx b/app/sites/[id]/pagespeed/page.tsx index 6ff082c..8ef7e7d 100644 --- a/app/sites/[id]/pagespeed/page.tsx +++ b/app/sites/[id]/pagespeed/page.tsx @@ -49,6 +49,18 @@ function formatTimeAgo(dateString: string | null): string { return `${Math.floor(diffSec / 86400)}d ago` } +function formatTimeUntil(dateString: string | null): string | null { + if (!dateString) return null + const date = new Date(dateString) + const now = new Date() + const diffMs = date.getTime() - now.getTime() + if (diffMs <= 0) return 'soon' + const diffSec = Math.floor(diffMs / 1000) + if (diffSec < 3600) return `in ${Math.floor(diffSec / 60)}m` + if (diffSec < 86400) return `in ${Math.floor(diffSec / 3600)}h` + return `in ${Math.floor(diffSec / 86400)}d` +} + // * Get dot color for audit items based on score function getAuditDotColor(score: number | null): string { if (score === null) return 'bg-neutral-400' @@ -175,6 +187,18 @@ export default function PageSpeedPage() { } } + // * Change frequency inline (without disabling/re-enabling) + const handleFrequencyChange = async (newFrequency: string) => { + setFrequency(newFrequency) + try { + await updatePageSpeedConfig(siteId, { enabled: true, frequency: newFrequency }) + mutateConfig() + } catch { + toast.error('Failed to update check frequency') + if (config?.frequency) setFrequency(config.frequency) + } + } + // * Trigger a manual PageSpeed check const pollRef = useRef | null>(null) const stopPolling = useCallback(() => { @@ -400,14 +424,13 @@ export default function PageSpeedPage() { > {running ? 'Running...' : 'Run Check'} - + )} @@ -443,7 +466,7 @@ export default function PageSpeedPage() {