|
@@ -39,20 +39,17 @@ import { useFeatureFlag } from '@/shared/context/split-test-context'
|
|
|
import { useEditorManagerContext } from '@/features/ide-react/context/editor-manager-context'
|
|
import { useEditorManagerContext } from '@/features/ide-react/context/editor-manager-context'
|
|
|
import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context'
|
|
import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context'
|
|
|
import { getJSON } from '@/infrastructure/fetch-json'
|
|
import { getJSON } from '@/infrastructure/fetch-json'
|
|
|
-import { CompileResponseData, PDFFile } from '../../../../types/compile'
|
|
|
|
|
|
|
+import { CompileResponseData } from '../../../../types/compile'
|
|
|
import {
|
|
import {
|
|
|
PdfScrollPosition,
|
|
PdfScrollPosition,
|
|
|
usePdfScrollPosition,
|
|
usePdfScrollPosition,
|
|
|
} from '@/shared/hooks/use-pdf-scroll-position'
|
|
} from '@/shared/hooks/use-pdf-scroll-position'
|
|
|
import {
|
|
import {
|
|
|
- ClsiCachePromptSegmentation,
|
|
|
|
|
- ClsiCachePromptVariant,
|
|
|
|
|
DeliveryLatencies,
|
|
DeliveryLatencies,
|
|
|
HighlightData,
|
|
HighlightData,
|
|
|
LogEntry,
|
|
LogEntry,
|
|
|
PdfFileDataList,
|
|
PdfFileDataList,
|
|
|
} from '@/features/pdf-preview/util/types'
|
|
} from '@/features/pdf-preview/util/types'
|
|
|
-import { getSplitTestVariant, isSplitTestEnabled } from '@/utils/splitTestUtils'
|
|
|
|
|
import { captureException } from '@/infrastructure/error-reporter'
|
|
import { captureException } from '@/infrastructure/error-reporter'
|
|
|
import OError from '@overleaf/o-error'
|
|
import OError from '@overleaf/o-error'
|
|
|
import getMeta from '@/utils/meta'
|
|
import getMeta from '@/utils/meta'
|
|
@@ -101,11 +98,6 @@ export type CompileContext = {
|
|
|
setStopOnValidationError: (value: boolean) => void
|
|
setStopOnValidationError: (value: boolean) => void
|
|
|
showCompileTimeWarning: boolean
|
|
showCompileTimeWarning: boolean
|
|
|
showLogs: boolean
|
|
showLogs: boolean
|
|
|
- clsiCachePromptVariant: ClsiCachePromptVariant
|
|
|
|
|
- clsiCachePromptSegmentation: ClsiCachePromptSegmentation
|
|
|
|
|
- setClsiCachePromptSegmentation: Dispatch<
|
|
|
|
|
- SetStateAction<ClsiCachePromptSegmentation>
|
|
|
|
|
- >
|
|
|
|
|
stopOnFirstError: boolean
|
|
stopOnFirstError: boolean
|
|
|
stopOnValidationError: boolean
|
|
stopOnValidationError: boolean
|
|
|
stoppedOnFirstError: boolean
|
|
stoppedOnFirstError: boolean
|
|
@@ -206,9 +198,7 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
|
|
|
const [compiledOnce, setCompiledOnce] = useState(false)
|
|
const [compiledOnce, setCompiledOnce] = useState(false)
|
|
|
// fetch initial compile response from cache
|
|
// fetch initial compile response from cache
|
|
|
const [initialCompileFromCache, setInitialCompileFromCache] = useState(
|
|
const [initialCompileFromCache, setInitialCompileFromCache] = useState(
|
|
|
- getMeta('ol-projectOwnerHasPremiumOnPageLoad') &&
|
|
|
|
|
- (isSplitTestEnabled('populate-clsi-cache') ||
|
|
|
|
|
- isSplitTestEnabled('populate-clsi-cache-for-prompt')) &&
|
|
|
|
|
|
|
+ getMeta('ol-canUseClsiCache') &&
|
|
|
// Avoid fetching the initial compile from cache in PDF detach tab
|
|
// Avoid fetching the initial compile from cache in PDF detach tab
|
|
|
role !== 'detached'
|
|
role !== 'detached'
|
|
|
)
|
|
)
|
|
@@ -217,7 +207,6 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
|
|
|
useState(false)
|
|
useState(false)
|
|
|
// Raw data from clsi-cache, will need post-processing and check settings
|
|
// Raw data from clsi-cache, will need post-processing and check settings
|
|
|
const [dataFromCache, setDataFromCache] = useState<CompileResponseData>()
|
|
const [dataFromCache, setDataFromCache] = useState<CompileResponseData>()
|
|
|
- const [compileFromCacheStartedAt, setCompileFromCacheStartedAt] = useState(0)
|
|
|
|
|
|
|
|
|
|
// whether the cache is being cleared
|
|
// whether the cache is being cleared
|
|
|
const [clearingCache, setClearingCache] = useState(false)
|
|
const [clearingCache, setClearingCache] = useState(false)
|
|
@@ -225,18 +214,6 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
|
|
|
// whether the logs should be visible
|
|
// whether the logs should be visible
|
|
|
const [showLogs, setShowLogs] = useState(false)
|
|
const [showLogs, setShowLogs] = useState(false)
|
|
|
|
|
|
|
|
- // flags for clsi-cache prompt
|
|
|
|
|
- const [clsiCachePromptVariant, setClsiCachePromptVariant] =
|
|
|
|
|
- useState<ClsiCachePromptVariant>('default')
|
|
|
|
|
- const [clsiCachePromptSegmentation, setClsiCachePromptSegmentation] =
|
|
|
|
|
- useState<ClsiCachePromptSegmentation>({
|
|
|
|
|
- default: null,
|
|
|
|
|
- compile: null,
|
|
|
|
|
- preview: null,
|
|
|
|
|
- 'preview-error': null,
|
|
|
|
|
- synctex: null,
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
// whether the compile dropdown arrow should be animated
|
|
// whether the compile dropdown arrow should be animated
|
|
|
const [animateCompileDropdownArrow, setAnimateCompileDropdownArrow] =
|
|
const [animateCompileDropdownArrow, setAnimateCompileDropdownArrow] =
|
|
|
useState(false)
|
|
useState(false)
|
|
@@ -377,7 +354,6 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (initialCompileFromCache && !pendingInitialCompileFromCache) {
|
|
if (initialCompileFromCache && !pendingInitialCompileFromCache) {
|
|
|
setPendingInitialCompileFromCache(true)
|
|
setPendingInitialCompileFromCache(true)
|
|
|
- setCompileFromCacheStartedAt(performance.now())
|
|
|
|
|
getJSON(`/project/${projectId}/output/cached/output.overleaf.json`, {
|
|
getJSON(`/project/${projectId}/output/cached/output.overleaf.json`, {
|
|
|
signal: AbortSignal.timeout(5_000),
|
|
signal: AbortSignal.timeout(5_000),
|
|
|
})
|
|
})
|
|
@@ -425,14 +401,6 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
|
|
|
|
|
|
|
|
if (settingsUpToDate) {
|
|
if (settingsUpToDate) {
|
|
|
sendMB('compile-from-cache', { projectId })
|
|
sendMB('compile-from-cache', { projectId })
|
|
|
- dataFromCache.clsiCachePromptVariant = getSplitTestVariant(
|
|
|
|
|
- 'clsi-cache-prompt',
|
|
|
|
|
- 'default'
|
|
|
|
|
- ) as ClsiCachePromptVariant
|
|
|
|
|
- if (!dataFromCache.timings) dataFromCache.timings = {}
|
|
|
|
|
- dataFromCache.timings.compileTimeClientE2E = Math.ceil(
|
|
|
|
|
- performance.now() - compileFromCacheStartedAt
|
|
|
|
|
- )
|
|
|
|
|
setData(dataFromCache)
|
|
setData(dataFromCache)
|
|
|
setCompiledOnce(true)
|
|
setCompiledOnce(true)
|
|
|
}
|
|
}
|
|
@@ -441,7 +409,6 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
|
|
|
setPendingInitialCompileFromCache(false)
|
|
setPendingInitialCompileFromCache(false)
|
|
|
}, [
|
|
}, [
|
|
|
projectId,
|
|
projectId,
|
|
|
- compileFromCacheStartedAt,
|
|
|
|
|
dataFromCache,
|
|
dataFromCache,
|
|
|
joinedOnce,
|
|
joinedOnce,
|
|
|
currentDocument,
|
|
currentDocument,
|
|
@@ -519,32 +486,6 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
|
|
|
if (data.clsiServerId) {
|
|
if (data.clsiServerId) {
|
|
|
setClsiServerId(data.clsiServerId) // set in scope, for PdfSynctexController
|
|
setClsiServerId(data.clsiServerId) // set in scope, for PdfSynctexController
|
|
|
}
|
|
}
|
|
|
- setClsiCachePromptVariant(data.clsiCachePromptVariant ?? 'default')
|
|
|
|
|
- setClsiCachePromptSegmentation(prev => {
|
|
|
|
|
- if (
|
|
|
|
|
- !(
|
|
|
|
|
- data.status === 'success' &&
|
|
|
|
|
- (data.fromCache || data.stats?.isInitialCompile === 1)
|
|
|
|
|
- )
|
|
|
|
|
- ) {
|
|
|
|
|
- return { ...prev, compile: null }
|
|
|
|
|
- }
|
|
|
|
|
- const pdfSize = (
|
|
|
|
|
- data.outputFiles.find(f => f.path === 'output.pdf') as PDFFile
|
|
|
|
|
- )?.size
|
|
|
|
|
- return {
|
|
|
|
|
- ...prev,
|
|
|
|
|
- compile: {
|
|
|
|
|
- pdfSize,
|
|
|
|
|
- isCompileFromCache: Boolean(data.fromCache),
|
|
|
|
|
- isInitialCompile: data.stats?.isInitialCompile === 1,
|
|
|
|
|
- restoredClsiCache: data.stats?.restoredClsiCache === 1,
|
|
|
|
|
- compileTimeServerE2E: data.timings?.compileE2E,
|
|
|
|
|
- compileTimeClientE2E: data.timings?.compileTimeClientE2E,
|
|
|
|
|
- clsiCacheEnabled: Boolean(data.clsiCacheShard),
|
|
|
|
|
- },
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
|
|
|
if (data.outputFiles) {
|
|
if (data.outputFiles) {
|
|
|
const outputFiles = new Map()
|
|
const outputFiles = new Map()
|
|
@@ -840,9 +781,6 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
|
|
|
setStopOnFirstError,
|
|
setStopOnFirstError,
|
|
|
setStopOnValidationError,
|
|
setStopOnValidationError,
|
|
|
showLogs,
|
|
showLogs,
|
|
|
- clsiCachePromptVariant,
|
|
|
|
|
- clsiCachePromptSegmentation,
|
|
|
|
|
- setClsiCachePromptSegmentation,
|
|
|
|
|
startCompile,
|
|
startCompile,
|
|
|
stopCompile,
|
|
stopCompile,
|
|
|
stopOnFirstError,
|
|
stopOnFirstError,
|
|
@@ -893,9 +831,6 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
|
|
|
setStopOnValidationError,
|
|
setStopOnValidationError,
|
|
|
showCompileTimeWarning,
|
|
showCompileTimeWarning,
|
|
|
showLogs,
|
|
showLogs,
|
|
|
- clsiCachePromptVariant,
|
|
|
|
|
- clsiCachePromptSegmentation,
|
|
|
|
|
- setClsiCachePromptSegmentation,
|
|
|
|
|
startCompile,
|
|
startCompile,
|
|
|
stopCompile,
|
|
stopCompile,
|
|
|
stopOnFirstError,
|
|
stopOnFirstError,
|