[web] Tear down client-side-references feature flag (#29088)

GitOrigin-RevId: 635d6054ed1ed131bbc456bab203408fd4293e6d
This commit is contained in:
Mathias Jakobsen
2025-10-24 08:05:34 +00:00
committed by Copybot
parent 7f4d947b56
commit d0d360c1bd
3 changed files with 9 additions and 49 deletions
@@ -21,7 +21,6 @@ import { useEditorManagerContext } from './editor-manager-context'
import { signalWithTimeout } from '@/utils/abort-signal'
import { postJSON } from '@/infrastructure/fetch-json'
import { debugConsole } from '@/utils/debugging'
import { useFeatureFlag } from '@/shared/context/split-test-context'
import type { ReferenceIndexer } from '../references/reference-indexer'
import { AdvancedReferenceSearchResult } from '@/features/ide-react/references/types'
import clientId from '@/utils/client-id'
@@ -50,38 +49,19 @@ export const ReferencesProvider: FC<React.PropsWithChildren> = ({
const abortControllerRef = useRef<AbortController | null>(null)
const [referenceKeys, setReferenceKeys] = useState(new Set<string>())
const clientSideReferences = useFeatureFlag('client-side-references')
const [existingIndexHash, setExistingIndexHash] = useState<
Record<string, { hash: string; timestamp: number }>
>({})
const indexAllReferencesServerside = useCallback(
async (shouldBroadcast: boolean) => {
return postJSON(`/project/${projectId}/references/indexAll`, {
body: {
shouldBroadcast,
},
})
.then((response: { keys: string[] }) => {
setReferenceKeys(new Set(response.keys))
})
.catch(error => {
// allow the request to fail
debugConsole.error(error)
})
},
[projectId]
)
const indexerRef = useRef<Promise<ReferenceIndexer> | null>(null)
if (clientSideReferences && indexerRef.current === null) {
if (indexerRef.current === null) {
indexerRef.current = import('../references/reference-indexer').then(
m => new m.ReferenceIndexer()
)
}
const indexAllReferencesLocally = useCallback(
const indexAllReferences = useCallback(
async (shouldBroadcast: boolean) => {
if (permissionsLevel === 'readOnly') {
// Not going to search the references, so let's not index them.
@@ -123,10 +103,6 @@ export const ReferencesProvider: FC<React.PropsWithChildren> = ({
[projectSnapshot, openDocs, projectId, permissionsLevel]
)
const indexAllReferences = clientSideReferences
? indexAllReferencesLocally
: indexAllReferencesServerside
const indexReferencesIfDocModified = useCallback(
(doc: ShareJsDoc, shouldBroadcast: boolean) => {
// avoid reindexing references if the bib file has not changed since the
@@ -195,17 +171,11 @@ export const ReferencesProvider: FC<React.PropsWithChildren> = ({
allDocs: boolean,
refresherId: string
) => {
if (clientSideReferences) {
if (refresherId === clientId.get()) {
// We asked for this broadcast, so we must have already done the indexing
return
}
indexAllReferences(false)
} else {
setReferenceKeys(oldDocs =>
allDocs ? new Set(keys) : new Set([...oldDocs, ...keys])
)
if (refresherId === clientId.get()) {
// We asked for this broadcast, so we must have already done the indexing
return
}
indexAllReferences(false)
}
socket.on('references:keys:updated', processUpdatedReferenceKeys)
@@ -216,7 +186,7 @@ export const ReferencesProvider: FC<React.PropsWithChildren> = ({
)
}
}
}, [projectJoined, indexAllReferences, socket, clientSideReferences])
}, [projectJoined, indexAllReferences, socket])
const searchLocalReferences = useCallback(
async (query: string): Promise<AdvancedReferenceSearchResult> => {