@@ -6,6 +6,7 @@ import type { DebugInfo } from '../shared/types'
66import type { DevIndicatorServerState } from '../../server/dev/dev-indicator-server-state'
77import { parseStack } from '../../server/lib/parse-stack'
88import { isConsoleError } from '../shared/console-error'
9+ import type { CacheIndicatorState } from './cache-indicator'
910
1011export type DevToolsConfig = {
1112 theme ?: 'light' | 'dark' | 'system'
@@ -49,6 +50,7 @@ export interface OverlayState {
4950 readonly notFound : boolean
5051 readonly buildingIndicator : boolean
5152 readonly renderingIndicator : boolean
53+ readonly cacheIndicator : CacheIndicatorState
5254 readonly staticIndicator : 'pending' | 'static' | 'dynamic' | 'disabled'
5355 readonly showIndicator : boolean
5456 readonly disableDevIndicator : boolean
@@ -72,6 +74,7 @@ export interface OverlayState {
7274type DevtoolsPanelName = string
7375export type OverlayDispatch = React . Dispatch < DispatcherEvent >
7476
77+ export const ACTION_CACHE_INDICATOR = 'cache-indicator'
7578export const ACTION_STATIC_INDICATOR = 'static-indicator'
7679export const ACTION_BUILD_OK = 'build-ok'
7780export const ACTION_BUILD_ERROR = 'build-error'
@@ -110,6 +113,11 @@ export const STORE_KEY_SHARED_PANEL_LOCATION =
110113export const ACTION_DEVTOOL_UPDATE_ROUTE_STATE =
111114 'segment-explorer-update-route-state'
112115
116+ interface CacheIndicatorAction {
117+ type : typeof ACTION_CACHE_INDICATOR
118+ cacheIndicator : CacheIndicatorState
119+ }
120+
113121interface StaticIndicatorAction {
114122 type : typeof ACTION_STATIC_INDICATOR
115123 staticIndicator : 'pending' | 'static' | 'dynamic' | 'disabled'
@@ -216,6 +224,7 @@ export type DispatcherEvent =
216224 | UnhandledErrorAction
217225 | UnhandledRejectionAction
218226 | VersionInfoAction
227+ | CacheIndicatorAction
219228 | StaticIndicatorAction
220229 | DebugInfoAction
221230 | DevIndicatorAction
@@ -263,6 +272,7 @@ export const INITIAL_OVERLAY_STATE: Omit<
263272 errors : [ ] ,
264273 notFound : false ,
265274 renderingIndicator : false ,
275+ cacheIndicator : 'disabled' ,
266276 staticIndicator : 'disabled' ,
267277 /*
268278 This is set to `true` when we can reliably know
@@ -287,7 +297,8 @@ export const INITIAL_OVERLAY_STATE: Omit<
287297}
288298
289299function getInitialState (
290- routerType : 'pages' | 'app'
300+ routerType : 'pages' | 'app' ,
301+ enableCacheIndicator : boolean
291302) : OverlayState & { routerType : 'pages' | 'app' } {
292303 return {
293304 ...INITIAL_OVERLAY_STATE ,
@@ -296,13 +307,15 @@ function getInitialState(
296307 // TODO: Should be the same default as App Router once we surface console.error in Pages Router.
297308 isErrorOverlayOpen : routerType === 'pages' ,
298309 routerType,
310+ cacheIndicator : enableCacheIndicator ? 'ready' : 'disabled' ,
299311 }
300312}
301313
302314export function useErrorOverlayReducer (
303315 routerType : 'pages' | 'app' ,
304316 getOwnerStack : ( error : Error ) => string | null | undefined ,
305- isRecoverableError : ( error : Error ) => boolean
317+ isRecoverableError : ( error : Error ) => boolean ,
318+ enableCacheIndicator : boolean
306319) {
307320 function pushErrorFilterDuplicates (
308321 events : readonly SupportedErrorEvent [ ] ,
@@ -349,6 +362,9 @@ export function useErrorOverlayReducer(
349362 case ACTION_DEBUG_INFO : {
350363 return { ...state , debugInfo : action . debugInfo }
351364 }
365+ case ACTION_CACHE_INDICATOR : {
366+ return { ...state , cacheIndicator : action . cacheIndicator }
367+ }
352368 case ACTION_STATIC_INDICATOR : {
353369 return { ...state , staticIndicator : action . staticIndicator }
354370 }
@@ -496,6 +512,6 @@ export function useErrorOverlayReducer(
496512 }
497513 }
498514 } ,
499- getInitialState ( routerType )
515+ getInitialState ( routerType , enableCacheIndicator )
500516 )
501517}
0 commit comments