Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): add stuck pausing and restoring escalations (#43368)

Danny White73692b0a4d23
diff --git a/apps/studio/components/interfaces/BranchManagement/BranchManagement.utils.ts b/apps/studio/components/interfaces/BranchManagement/BranchManagement.utils.ts
index 26e45c7fc5f..cc1ad9a8cb8 100644
--- a/apps/studio/components/interfaces/BranchManagement/BranchManagement.utils.ts
+++ b/apps/studio/components/interfaces/BranchManagement/BranchManagement.utils.ts
@@ -6,6 +6,7 @@ import {
} from '../DiskManagement/ui/DiskManagement.constants'
import { DiskAttributesData } from '@/data/config/disk-attributes-query'
import { DesiredInstanceSize, instanceSizeSpecs } from '@/data/projects/new-project.constants'
+import { estimateRestoreTimeFromSizeGb } from '@/lib/restore-estimate'
// Ref: https://supabase.com/docs/guides/platform/compute-and-disk
const maxDiskForCompute = new Map([
@@ -61,6 +62,5 @@ export const estimateDiskCost = (disk: DiskAttributesData['attributes']) => {
}
export const estimateRestoreTime = (disk: DiskAttributesData['attributes']) => {
- // This is interpolated from real restore time
- return (720 / 21000) * disk.size_gb + 3
+ return estimateRestoreTimeFromSizeGb(disk.size_gb)
}
diff --git a/apps/studio/components/layouts/ProjectLayout/PausingState.tsx b/apps/studio/components/layouts/ProjectLayout/PausingState.tsx
index 657392bf59e..1752ea40bfb 100644
--- a/apps/studio/components/layouts/ProjectLayout/PausingState.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/PausingState.tsx
@@ -1,12 +1,23 @@
-import { useParams } from 'common'
+import { SupportCategories } from '@supabase/shared-types/out/constants'
+import { LOCAL_STORAGE_KEYS, useParams } from 'common'
import { Circle, Loader } from 'lucide-react'
import { useEffect, useState } from 'react'
-import { Badge } from 'ui'
+import { Badge, Button } from 'ui'
+import { SupportLink } from '@/components/interfaces/Support/SupportLink'
import { useInvalidateProjectsInfiniteQuery } from '@/data/projects/org-projects-infinite-query'
import { Project, useInvalidateProjectDetailsQuery } from '@/data/projects/project-detail-query'
import { useProjectStatusQuery } from '@/data/projects/project-status-query'
+import { useLongRunningTransitionState } from '@/hooks/misc/useLongRunningTransitionState'
import { PROJECT_STATUS } from '@/lib/constants'
+import {
+ clearPersistedTransitionStartTime,
+ FALLBACK_LONG_RUNNING_STATE_THRESHOLD_MINUTES,
+ minutesToMilliseconds,
+} from '@/lib/project-transition-state'
+
+const LONG_RUNNING_STATE_THRESHOLD_MINUTES = FALLBACK_LONG_RUNNING_STATE_THRESHOLD_MINUTES
+const LONG_RUNNING_STATE_THRESHOLD_MS = minutesToMilliseconds(LONG_RUNNING_STATE_THRESHOLD_MINUTES)
export interface PausingStateProps {
project: Project
@@ -15,6 +26,11 @@ export interface PausingStateProps {
export const PausingState = ({ project }: PausingStateProps) => {
const { ref } = useParams()
const [startPolling, setStartPolling] = useState(false)
+ const pauseStateStartStorageKey = ref ? LOCAL_STORAGE_KEYS.PROJECT_PAUSING_STARTED_AT(ref) : null
+ const isTakingLongerThanExpected = useLongRunningTransitionState({
+ storageKey: pauseStateStartStorageKey,
+ thresholdMs: LONG_RUNNING_STATE_THRESHOLD_MS,
+ })
const { invalidateProjectsQuery } = useInvalidateProjectsInfiniteQuery()
const { invalidateProjectDetailsQuery } = useInvalidateProjectDetailsQuery()
@@ -25,27 +41,38 @@ export const PausingState = ({ project }: PausingStateProps) => {
enabled: startPolling,
refetchInterval: (query) => {
const data = query.state.data
- return data?.status === PROJECT_STATUS.INACTIVE ? false : 2000
+ return data?.status === PROJECT_STATUS.INACTIVE ||
+ data?.status === PROJECT_STATUS.PAUSE_FAILED
+ ? false
+ : 2000
},
}
)
useEffect(() => {
if (!isProjectStatusSuccess) return
- if (projectStatusData?.status === PROJECT_STATUS.INACTIVE) {
+ if (
+ projectStatusData?.status === PROJECT_STATUS.INACTIVE ||
+ projectStatusData?.status === PROJECT_STATUS.PAUSE_FAILED
+ ) {
+ if (pauseStateStartStorageKey) {
+ clearPersistedTransitionStartTime(pauseStateStartStorageKey)
+ }
if (ref) invalidateProjectDetailsQuery(ref)
invalidateProjectsQuery()
}
}, [
isProjectStatusSuccess,
projectStatusData,
+ pauseStateStartStorageKey,
ref,
invalidateProjectDetailsQuery,
invalidateProjectsQuery,
])
useEffect(() => {
- setTimeout(() => setStartPolling(true), 4000)
+ const timeoutId = setTimeout(() => setStartPolling(true), 4000)
+ return () => clearTimeout(timeoutId)
}, [])
return (
@@ -73,9 +100,26 @@ export const PausingState = ({ project }: PausingStateProps) => {
</div>
<p className="text-center">Pausing {project.name}</p>
<p className="text-center text-sm text-foreground-light">
- You may restore your project anytime thereafter, and your data will be restored to
- when it was initially paused.
+ {isTakingLongerThanExpected
+ ? `This is taking longer than usual. Contact support if your project is still pausing after ${LONG_RUNNING_STATE_THRESHOLD_MINUTES} minutes.`
+ : 'Your project is being paused now. This usually takes a few minutes. While paused, your data stays safe, and you can turn the project back on anytime.'}
</p>
+ {isTakingLongerThanExpected && (
+ <div className="flex justify-center">
+ <Button asChild type="default">
+ <SupportLink
+ queryParams={{
+ category: SupportCategories.DATABASE_UNRESPONSIVE,
+ projectRef: project.ref,
+ subject: 'Project stuck in pausing state',
+ message: `Project "${project.name}" has remained in a pausing state for over ${LONG_RUNNING_STATE_THRESHOLD_MINUTES} minutes.`,
+ }}
+ >
+ Contact support
+ </SupportLink>
+ </Button>
+ </div>
+ )}
</div>
</div>
</div>
diff --git a/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx b/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx
index 54a788982a0..a55cc3ab26c 100644
--- a/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/RestoringState.tsx
@@ -1,19 +1,9 @@
import { SupportCategories } from '@supabase/shared-types/out/constants'
-import { useParams } from 'common'
-import dayjs from 'dayjs'
+import { LOCAL_STORAGE_KEYS, useParams } from 'common'
import { CheckCircle, Download, Loader } from 'lucide-react'
import { useEffect, useState } from 'react'
-import {
- Button,
- Dialog,
- DialogContent,
- DialogFooter,
- DialogHeader,
- DialogSection,
- DialogSectionSeparator,
- DialogTitle,
- DialogTrigger,
-} from 'ui'
+import { Button } from 'ui'
+import { Admonition } from 'ui-patterns/admonition'
import { SupportLink } from '@/components/interfaces/Support/SupportLink'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
@@ -21,8 +11,14 @@ import { useBackupDownloadMutation } from '@/data/database/backup-download-mutat
import { useDownloadableBackupQuery } from '@/data/database/backup-query'
import { useInvalidateProjectDetailsQuery } from '@/data/projects/project-detail-query'
import { useProjectStatusQuery } from '@/data/projects/project-status-query'
+import { useLongRunningTransitionState } from '@/hooks/misc/useLongRunningTransitionState'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { PROJECT_STATUS } from '@/lib/constants'
+import {
+ clearPersistedTransitionStartTime,
+ minutesToMilliseconds,
+} from '@/lib/project-transition-state'
+import { getRestoreLongRunningThresholdMinutes } from '@/lib/restore-estimate'
export const RestoringState = () => {
const { ref } = useParams()
@@ -30,10 +26,19 @@ export const RestoringState = () => {
const [loading, setLoading] = useState(false)
const [isCompleted, setIsCompleted] = useState(false)
+ const restoreStateStartStorageKey = ref
+ ? LOCAL_STORAGE_KEYS.PROJECT_RESTORING_STARTED_AT(ref)
+ : null
const { data } = useDownloadableBackupQuery({ projectRef: ref })
const backups = data?.backups ?? []
const logicalBackups = backups.filter((b) => !b.isPhysicalBackup)
+ const longRunningThresholdMinutes = getRestoreLongRunningThresholdMinutes(project?.volumeSizeGb)
+ const longRunningThresholdMs = minutesToMilliseconds(longRunningThresholdMinutes)
+ const isTakingLongerThanExpected = useLongRunningTransitionState({
+ storageKey: restoreStateStartStorageKey,
+ thresholdMs: longRunningThresholdMs,
+ })
const { invalidateProjectDetailsQuery } = useInvalidateProjectDetailsQuery()
@@ -43,14 +48,14 @@ export const RestoringState = () => {
enabled: project?.status !== PROJECT_STATUS.ACTIVE_HEALTHY,
refetchInterval: (query) => {
const data = query.state.data
- return data?.status === PROJECT_STATUS.ACTIVE_HEALTHY ? false : 4000
+ return data?.status === PROJECT_STATUS.ACTIVE_HEALTHY ||
+ data?.status === PROJECT_STATUS.RESTORE_FAILED
+ ? false
+ : 4000
},
}
)
- const restoreInitiatedSinceMinutes = dayjs().diff(dayjs.utc(project?.updated_at), 'minute')
- const showSupportCta = restoreInitiatedSinceMinutes >= 30
-
const { mutate: downloadBackup, isPending: isDownloading } = useBackupDownloadMutation({
onSuccess: (res) => {
const { fileUrl } = res
@@ -78,10 +83,26 @@ export const RestoringState = () => {
}
useEffect(() => {
- if (isProjectStatusSuccess && projectStatusData.status === PROJECT_STATUS.ACTIVE_HEALTHY) {
+ if (!isProjectStatusSuccess) return
+
+ if (projectStatusData.status === PROJECT_STATUS.ACTIVE_HEALTHY) {
+ if (restoreStateStartStorageKey) {
+ clearPersistedTransitionStartTime(restoreStateStartStorageKey)
+ }
setIsCompleted(true)
+ } else if (projectStatusData.status === PROJECT_STATUS.RESTORE_FAILED) {
+ if (restoreStateStartStorageKey) {
+ clearPersistedTransitionStartTime(restoreStateStartStorageKey)
+ }
+ if (ref) void invalidateProjectDetailsQuery(ref)
}
- }, [isProjectStatusSuccess, projectStatusData])
+ }, [
+ isProjectStatusSuccess,
+ projectStatusData,
+ restoreStateStartStorageKey,
+ ref,
+ invalidateProjectDetailsQuery,
+ ])
return (
<div className="flex items-center justify-center h-full">
@@ -119,47 +140,33 @@ export const RestoringState = () => {
size of your database. Your project will be offline while the restoration is
running.
</p>
+ {isTakingLongerThanExpected && (
+ <Admonition
+ type="warning"
+ title="This is taking longer than usual"
+ layout="responsive"
+ description="Contact support if this project remains in a restoring state."
+ actions={
+ <Button asChild type="default">
+ <SupportLink
+ queryParams={{
+ category: SupportCategories.DATABASE_UNRESPONSIVE,
+ projectRef: project?.ref ?? ref,
+ subject: 'Project stuck in restoring state',
+ message: `Project "${project?.name ?? 'Unknown project'}" (ref: ${project?.ref ?? ref ?? 'unknown'}) has remained in a restoring state for over ${longRunningThresholdMinutes} minutes.`,
+ }}
+ >
+ Contact support
+ </SupportLink>
+ </Button>
+ }
+ className="!mt-5"
+ />
+ )}
</div>
</div>
</div>
<div className="border-t border-overlay flex items-center justify-end py-4 px-8 gap-x-2">
- {showSupportCta && (
- <Dialog>
- <DialogTrigger>
- <Button type="text" className="text-foreground-light">
- Taking longer than expected?
- </Button>
- </DialogTrigger>
- <DialogContent aria-describedby={undefined}>
- <DialogHeader>
- <DialogTitle>Restoration taking longer than expected?</DialogTitle>
- </DialogHeader>
- <DialogSectionSeparator />
- <DialogSection>
- <p className="text-sm">
- Restores may take from a minutes up to several hours depending on the size
- of your database. However, if the restoration process is taking far longer
- than expected for the size of your database, you may reach out to us via
- Support for help.
- </p>
- </DialogSection>
- <DialogFooter>
- <Button asChild type="default">
- <SupportLink
- queryParams={{
- category: SupportCategories.DATABASE_UNRESPONSIVE,
- projectRef: project?.ref,
- subject: 'Ongoing restoration for project',
- }}
- >
- Contact support
- </SupportLink>
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- )}
-
<ButtonTooltip
type="default"
icon={<Download />}
diff --git a/apps/studio/components/layouts/ProjectLayout/index.test.tsx b/apps/studio/components/layouts/ProjectLayout/index.test.tsx
index de834e83828..76125dc25a3 100644
--- a/apps/studio/components/layouts/ProjectLayout/index.test.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/index.test.tsx
@@ -124,15 +124,15 @@ vi.mock('./BuildingState', () => ({ default: () => null }))
vi.mock('./ConnectingState', () => ({ default: () => null }))
vi.mock('./LoadingState', () => ({ LoadingState: () => null }))
vi.mock('./PausedState/ProjectPausedState', () => ({ ProjectPausedState: () => null }))
-vi.mock('./PauseFailedState', () => ({ default: () => null }))
-vi.mock('./PausingState', () => ({ default: () => null }))
+vi.mock('./PauseFailedState', () => ({ PauseFailedState: () => null }))
+vi.mock('./PausingState', () => ({ PausingState: () => null }))
vi.mock('./ProductMenuBar', () => ({
default: ({ children }: { children: ReactNode }) => <>{children}</>,
}))
-vi.mock('./ResizingState', () => ({ default: () => null }))
+vi.mock('./ResizingState', () => ({ ResizingState: () => null }))
vi.mock('./RestartingState', () => ({ default: () => null }))
-vi.mock('./RestoreFailedState', () => ({ default: () => null }))
-vi.mock('./RestoringState', () => ({ default: () => null }))
+vi.mock('./RestoreFailedState', () => ({ RestoreFailedState: () => null }))
+vi.mock('./RestoringState', () => ({ RestoringState: () => null }))
vi.mock('./UpgradingState', () => ({ UpgradingState: () => null }))
vi.mock('@/components/interfaces/BranchManagement/CreateBranchModal', () => ({
diff --git a/apps/studio/hooks/misc/useLongRunningTransitionState.test.ts b/apps/studio/hooks/misc/useLongRunningTransitionState.test.ts
new file mode 100644
index 00000000000..e3a09d58266
--- /dev/null
+++ b/apps/studio/hooks/misc/useLongRunningTransitionState.test.ts
@@ -0,0 +1,53 @@
+import { act, renderHook } from '@testing-library/react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+
+import { useLongRunningTransitionState } from './useLongRunningTransitionState'
+
+describe('useLongRunningTransitionState', () => {
+ beforeEach(() => {
+ vi.useFakeTimers()
+ vi.setSystemTime(new Date('2026-01-01T00:00:00.000Z'))
+ window.localStorage.clear()
+ })
+
+ afterEach(() => {
+ vi.useRealTimers()
+ window.localStorage.clear()
+ })
+
+ it('immediately marks the transition as long-running when the persisted timer has already elapsed', () => {
+ const storageKey = 'project-transition-start'
+ window.localStorage.setItem(storageKey, String(Date.now() - 61_000))
+
+ const { result } = renderHook(() =>
+ useLongRunningTransitionState({ storageKey, thresholdMs: 60_000 })
+ )
+
+ expect(result.current).toBe(true)
+ })
+
+ it('keeps a stable in-memory timer when no storage key is available', () => {
+ const { result, rerender } = renderHook(
+ ({ thresholdMs }: { thresholdMs: number }) =>
+ useLongRunningTransitionState({ storageKey: null, thresholdMs }),
+ {
+ initialProps: { thresholdMs: 120_000 },
+ }
+ )
+
+ expect(result.current).toBe(false)
+
+ act(() => {
+ vi.advanceTimersByTime(30_000)
+ })
+
+ rerender({ thresholdMs: 60_000 })
+ expect(result.current).toBe(false)
+
+ act(() => {
+ vi.advanceTimersByTime(30_000)
+ })
+
+ expect(result.current).toBe(true)
+ })
+})
diff --git a/apps/studio/hooks/misc/useLongRunningTransitionState.ts b/apps/studio/hooks/misc/useLongRunningTransitionState.ts
new file mode 100644
index 00000000000..a68815b6c39
--- /dev/null
+++ b/apps/studio/hooks/misc/useLongRunningTransitionState.ts
@@ -0,0 +1,52 @@
+import { useEffect, useRef, useState } from 'react'
+
+import {
+ getPersistedTransitionStartTime,
+ getRemainingTransitionTimeMs,
+ hoursToMilliseconds,
+ MAX_PERSISTED_TRANSITION_AGE_HOURS,
+} from '@/lib/project-transition-state'
+
+interface UseLongRunningTransitionStateParams {
+ storageKey: string | null
+ thresholdMs: number
+}
+
+export const useLongRunningTransitionState = ({
+ storageKey,
+ thresholdMs,
+}: UseLongRunningTransitionStateParams) => {
+ const [isTakingLongerThanExpected, setIsTakingLongerThanExpected] = useState(false)
+ const fallbackStartTimeRef = useRef<number | null>(null)
+
+ useEffect(() => {
+ const now = Date.now()
+ const fallbackStartTime = fallbackStartTimeRef.current ?? now
+ fallbackStartTimeRef.current = fallbackStartTime
+
+ const startTime = storageKey
+ ? getPersistedTransitionStartTime(
+ storageKey,
+ now,
+ hoursToMilliseconds(MAX_PERSISTED_TRANSITION_AGE_HOURS)
+ )
+ : fallbackStartTime
+
+ const remainingThresholdMs = getRemainingTransitionTimeMs({
+ startTimeMs: startTime,
+ thresholdMs,
+ now,
+ })
+
+ if (remainingThresholdMs === 0) {
+ setIsTakingLongerThanExpected(true)
+ return
+ }
+
+ setIsTakingLongerThanExpected(false)
+ const timeoutId = setTimeout(() => setIsTakingLongerThanExpected(true), remainingThresholdMs)
+ return () => clearTimeout(timeoutId)
+ }, [storageKey, thresholdMs])
+
+ return isTakingLongerThanExpected
+}
diff --git a/apps/studio/lib/project-transition-state.test.ts b/apps/studio/lib/project-transition-state.test.ts
new file mode 100644
index 00000000000..9603bfc05c8
--- /dev/null
+++ b/apps/studio/lib/project-transition-state.test.ts
@@ -0,0 +1,81 @@
+import { beforeEach, describe, expect, it } from 'vitest'
+
+import {
+ clearPersistedTransitionStartTime,
+ getPersistedTransitionStartTime,
+ getRemainingTransitionTimeMs,
+ hoursToMilliseconds,
+ minutesToMilliseconds,
+} from './project-transition-state'
+
+describe('project-transition-state', () => {
+ beforeEach(() => {
+ window.localStorage.clear()
+ })
+
+ describe('getPersistedTransitionStartTime', () => {
+ it('stores the current time when no start time exists', () => {
+ const startTime = getPersistedTransitionStartTime('transition-key', 1_000)
+
+ expect(startTime).toBe(1_000)
+ expect(window.localStorage.getItem('transition-key')).toBe('1000')
+ })
+
+ it('reuses an existing stored start time', () => {
+ window.localStorage.setItem('transition-key', '2_000'.replace('_', ''))
+
+ const startTime = getPersistedTransitionStartTime('transition-key', 3_000)
+
+ expect(startTime).toBe(2_000)
+ expect(window.localStorage.getItem('transition-key')).toBe('2000')
+ })
+
+ it('replaces malformed stored values with the current time', () => {
+ window.localStorage.setItem('transition-key', 'not-a-number')
+
+ const startTime = getPersistedTransitionStartTime('transition-key', 3_000)
+
+ expect(startTime).toBe(3_000)
+ expect(window.localStorage.getItem('transition-key')).toBe('3000')
+ })
+
+ it('replaces stale stored values when they exceed the allowed max age', () => {
+ window.localStorage.setItem('transition-key', '1_000'.replace('_', ''))
+
+ const startTime = getPersistedTransitionStartTime(
+ 'transition-key',
+ hoursToMilliseconds(30),
+ hoursToMilliseconds(24)
+ )
+
+ expect(startTime).toBe(hoursToMilliseconds(30))
+ expect(window.localStorage.getItem('transition-key')).toBe(String(hoursToMilliseconds(30)))
+ })
+ })
+
+ it('removes a persisted transition start time', () => {
+ window.localStorage.setItem('transition-key', '1000')
+
+ clearPersistedTransitionStartTime('transition-key')
+
+ expect(window.localStorage.getItem('transition-key')).toBeNull()
+ })
+
+ it('returns the remaining threshold time and clamps at zero', () => {
+ expect(
+ getRemainingTransitionTimeMs({
+ startTimeMs: 1_000,
+ thresholdMs: minutesToMilliseconds(10),
+ now: 4_000,
+ })
+ ).toBe(minutesToMilliseconds(10) - 3_000)
+
+ expect(
+ getRemainingTransitionTimeMs({
+ startTimeMs: 1_000,
+ thresholdMs: minutesToMilliseconds(10),
+ now: minutesToMilliseconds(10) + 5_000,
+ })
+ ).toBe(0)
+ })
+})
diff --git a/apps/studio/lib/project-transition-state.ts b/apps/studio/lib/project-transition-state.ts
new file mode 100644
index 00000000000..dda2c627fc5
--- /dev/null
+++ b/apps/studio/lib/project-transition-state.ts
@@ -0,0 +1,55 @@
+export const FALLBACK_LONG_RUNNING_STATE_THRESHOLD_MINUTES = 10
+// Persist long enough for same-browser reloads, but not so long that a later transition reuses stale state.
+export const MAX_PERSISTED_TRANSITION_AGE_HOURS = 24
+
+const MS_PER_MINUTE = 60 * 1000
+const MS_PER_HOUR = 60 * MS_PER_MINUTE
+
+export const minutesToMilliseconds = (minutes: number) => minutes * MS_PER_MINUTE
+export const hoursToMilliseconds = (hours: number) => hours * MS_PER_HOUR
+
+export const getPersistedTransitionStartTime = (
+ storageKey: string,
+ now = Date.now(),
+ maxAgeMs = Number.POSITIVE_INFINITY
+) => {
+ if (typeof window === 'undefined') return now
+
+ const existingValue = window.localStorage.getItem(storageKey)
+
+ if (existingValue !== null) {
+ const parsedStartTime = Number(existingValue)
+ const elapsedMs = now - parsedStartTime
+
+ if (
+ Number.isFinite(parsedStartTime) &&
+ parsedStartTime > 0 &&
+ elapsedMs >= 0 &&
+ elapsedMs <= maxAgeMs
+ ) {
+ return parsedStartTime
+ }
+ }
+
+ window.localStorage.setItem(storageKey, String(now))
+ return now
+}
+
+export const clearPersistedTransitionStartTime = (storageKey: string) => {
+ if (typeof window === 'undefined') return
+
+ window.localStorage.removeItem(storageKey)
+}
+
+export const getRemainingTransitionTimeMs = ({
+ startTimeMs,
+ thresholdMs,
+ now = Date.now(),
+}: {
+ startTimeMs: number
+ thresholdMs: number
+ now?: number
+}) => {
+ const elapsedMs = now - startTimeMs
+ return Math.max(thresholdMs - elapsedMs, 0)
+}
diff --git a/apps/studio/lib/restore-estimate.test.ts b/apps/studio/lib/restore-estimate.test.ts
new file mode 100644
index 00000000000..3ad94014e70
--- /dev/null
+++ b/apps/studio/lib/restore-estimate.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, it } from 'vitest'
+
+import {
+ estimateRestoreTimeFromSizeGb,
+ getRestoreLongRunningThresholdMinutes,
+} from './restore-estimate'
+
+describe('restore-estimate', () => {
+ it('keeps the existing restore interpolation', () => {
+ expect(estimateRestoreTimeFromSizeGb(0)).toBe(3)
+ expect(estimateRestoreTimeFromSizeGb(21_000)).toBeCloseTo(723, 0)
+ })
+
+ it('uses a 10 minute floor when size is missing or small', () => {
+ expect(getRestoreLongRunningThresholdMinutes()).toBe(10)
+ expect(getRestoreLongRunningThresholdMinutes(null)).toBe(10)
+ expect(getRestoreLongRunningThresholdMinutes(100)).toBe(10)
+ })
+
+ it('scales the long-running threshold for larger restores', () => {
+ expect(getRestoreLongRunningThresholdMinutes(200)).toBe(15)
+ expect(getRestoreLongRunningThresholdMinutes(500)).toBe(31)
+ expect(getRestoreLongRunningThresholdMinutes(1_000)).toBe(56)
+ })
+})
diff --git a/apps/studio/lib/restore-estimate.ts b/apps/studio/lib/restore-estimate.ts
new file mode 100644
index 00000000000..0485572d69a
--- /dev/null
+++ b/apps/studio/lib/restore-estimate.ts
@@ -0,0 +1,22 @@
+import { FALLBACK_LONG_RUNNING_STATE_THRESHOLD_MINUTES } from './project-transition-state'
+
+const RESTORE_TIME_SLOPE = 720 / 21000
+const RESTORE_TIME_BASE_MINUTES = 3
+const LONG_RUNNING_RESTORE_THRESHOLD_MULTIPLIER = 1.5
+
+export const estimateRestoreTimeFromSizeGb = (sizeGb: number) => {
+ return RESTORE_TIME_SLOPE * sizeGb + RESTORE_TIME_BASE_MINUTES
+}
+
+export const getRestoreLongRunningThresholdMinutes = (volumeSizeGb?: number | null) => {
+ if (typeof volumeSizeGb !== 'number' || !Number.isFinite(volumeSizeGb)) {
+ return FALLBACK_LONG_RUNNING_STATE_THRESHOLD_MINUTES
+ }
+
+ return Math.max(
+ FALLBACK_LONG_RUNNING_STATE_THRESHOLD_MINUTES,
+ Math.ceil(
+ estimateRestoreTimeFromSizeGb(volumeSizeGb) * LONG_RUNNING_RESTORE_THRESHOLD_MULTIPLIER
+ )
+ )
+}
diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.ts
index 235cffb2443..a13f52b70c4 100644
--- a/packages/common/constants/local-storage.ts
+++ b/packages/common/constants/local-storage.ts
@@ -81,6 +81,8 @@ export const LOCAL_STORAGE_KEYS = {
API_KEYS_FEEDBACK_DISMISSED: (ref: string) => `supabase-api-keys-feedback-dismissed-${ref}`,
MAINTENANCE_WINDOW_BANNER: 'maintenance-window-banner-2026-01-16',
REPORT_DATERANGE: 'supabase-report-daterange',
+ PROJECT_PAUSING_STARTED_AT: (ref: string) => `supabase-project-pausing-started-at-${ref}`,
+ PROJECT_RESTORING_STARTED_AT: (ref: string) => `supabase-project-restoring-started-at-${ref}`,
// api keys view switcher for new and legacy api keys
API_KEYS_VIEW: (ref: string) => `supabase-api-keys-view-${ref}`,