@@ -8,17 +8,19 @@ import { createRoot } from 'react-dom/client'
88import {
99 captureActivePage ,
1010 captureErrorMessage ,
11+ PAGE_CHANGED_MESSAGE ,
1112 PageCaptureError ,
1213 SiteAccessRequiredError ,
1314 UnreadableSelectionError ,
1415} from '@/capture'
1516import { CAPTURE_INTENT_KEY , CAPTURE_INTENT_TTL_MS , REFERENCE_PAGE_KEY , SIM_ORIGIN } from '@/config'
1617import { type CaptureIntent , captureIntentSchema } from '@/intent'
17- import { createReferenceCapture } from '@/reference'
18+ import { createReferenceCapture , PAGE_ATTACHMENT_PENDING_MESSAGE } from '@/reference'
1819import { SearchRecoveryDialog } from '@/search-recovery-dialog'
1920import { PageAccessButton , SiteAccessDialog } from '@/site-access'
2021import '@/shell.css'
2122
23+ const PAGE_ATTACHMENT_EXPIRED_MESSAGE = 'The page attachment expired. Attach it again.'
2224const BLOCKED_SELECTION =
2325 'Select readable text again, attach the page explicitly, or turn off Reference current page.'
2426const KEYBOARD_FOCUS_HINT = navigator . platform . startsWith ( 'Mac' )
@@ -49,9 +51,7 @@ function SidePanel({ origin }: SidePanelProps) {
4951 if ( ! ( status instanceof SiteAccessRequiredError ) ) return
5052 const navigated = ( tabId : number , change : chrome . tabs . OnUpdatedInfo ) => {
5153 if ( tabId === status . tabId && ( change . status === 'loading' || change . url !== undefined ) ) {
52- setStatus ( ( current ) =>
53- current === status ? 'The page changed. Attach it again.' : current
54- )
54+ setStatus ( ( current ) => ( current === status ? PAGE_CHANGED_MESSAGE : current ) )
5555 }
5656 }
5757 const activated = ( tab : chrome . tabs . OnActivatedInfo ) => {
@@ -74,7 +74,7 @@ function SidePanel({ origin }: SidePanelProps) {
7474 if ( Date . now ( ) - Date . parse ( snapshot . capturedAt ) > CAPTURE_INTENT_TTL_MS ) {
7575 pendingRef . current = null
7676 focusRequested . current = false
77- setStatus ( 'The page attachment expired. Attach it again.' )
77+ setStatus ( PAGE_ATTACHMENT_EXPIRED_MESSAGE )
7878 return
7979 }
8080 const message : ExtensionToAppMessage = {
@@ -130,12 +130,12 @@ function SidePanel({ origin }: SidePanelProps) {
130130 }
131131 ) {
132132 if ( referenceRef . current ?. busy ( ) ) {
133- setStatus ( 'Wait for the page attachment, then try again.' )
133+ setStatus ( PAGE_ATTACHMENT_PENDING_MESSAGE )
134134 return
135135 }
136136 if ( busyRef . current ) return
137137 if ( pendingRef . current ) {
138- setStatus ( 'Wait for the page attachment, then try again.' )
138+ setStatus ( PAGE_ATTACHMENT_PENDING_MESSAGE )
139139 return
140140 }
141141 busyRef . current = true
@@ -171,7 +171,7 @@ function SidePanel({ origin }: SidePanelProps) {
171171 manualCaptureError : ( ) => {
172172 if ( busyRef . current || pendingRef . current || processingManual || manualIntents . size )
173173 return {
174- message : 'Wait for the page attachment, then try again.' ,
174+ message : PAGE_ATTACHMENT_PENDING_MESSAGE ,
175175 }
176176 if ( unreadableSelection . current ) return { message : BLOCKED_SELECTION , reason : 'selection' }
177177 } ,
@@ -249,7 +249,7 @@ function SidePanel({ origin }: SidePanelProps) {
249249 }
250250 if ( disposed || ! intent ) return
251251 if ( ! currentIntent ( intent , window . id ) ) {
252- setStatus ( 'The page attachment expired. Attach it again.' )
252+ setStatus ( PAGE_ATTACHMENT_EXPIRED_MESSAGE )
253253 return
254254 }
255255 if ( intent . kind === 'focus' ) {
@@ -362,7 +362,7 @@ function SidePanel({ origin }: SidePanelProps) {
362362 ) {
363363 pendingRef . current = null
364364 focusRequested . current = false
365- setStatus ( 'The page attachment expired. Attach it again.' )
365+ setStatus ( PAGE_ATTACHMENT_EXPIRED_MESSAGE )
366366 }
367367 void consumeIntent ( )
368368 } , 5_000 )
0 commit comments