Kaynağa Gözat

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

GitOrigin-RevId: 635d6054ed1ed131bbc456bab203408fd4293e6d
Mathias Jakobsen 9 ay önce
ebeveyn
işleme
d0d360c1bd

+ 0 - 1
services/web/app/src/Features/Project/ProjectController.mjs

@@ -401,7 +401,6 @@ const _ProjectController = {
       'overleaf-assist-bundle',
       'word-count-client',
       'editor-popup-ux-survey',
-      'client-side-references',
       'editor-redesign-new-users',
       'writefull-frontend-migration',
       'chat-edit-delete',

+ 2 - 11
services/web/frontend/js/features/file-view/components/file-view-refresh-button.tsx

@@ -16,7 +16,6 @@ import { sendMB } from '@/infrastructure/event-tracking'
 import useIsMounted from '@/shared/hooks/use-is-mounted'
 import clientId from '@/utils/client-id'
 import { useReferencesContext } from '@/features/ide-react/context/references-context'
-import { useFeatureFlag } from '@/shared/context/split-test-context'
 
 type FileViewRefreshButtonProps = {
   setRefreshError: Dispatch<SetStateAction<Nullable<string>>>
@@ -38,7 +37,6 @@ export default function FileViewRefreshButton({
   const [refreshing, setRefreshing] = useState(false)
   const isMountedRef = useIsMounted()
   const { indexAllReferences } = useReferencesContext()
-  const clientSideReferences = useFeatureFlag('client-side-references')
 
   const refreshFile = useCallback(
     (isTPR: Nullable<boolean>) => {
@@ -57,7 +55,7 @@ export default function FileViewRefreshButton({
           if (isMountedRef.current) {
             setRefreshing(false)
           }
-          if (clientSideReferences && shouldReindexReferences) {
+          if (shouldReindexReferences) {
             indexAllReferences(false)
           }
           sendMB('refresh-linked-file', {
@@ -71,14 +69,7 @@ export default function FileViewRefreshButton({
           }
         })
     },
-    [
-      file,
-      projectId,
-      setRefreshError,
-      isMountedRef,
-      indexAllReferences,
-      clientSideReferences,
-    ]
+    [file, projectId, setRefreshError, isMountedRef, indexAllReferences]
   )
 
   if (tprFileViewRefreshButton.length > 0) {

+ 7 - 37
services/web/frontend/js/features/ide-react/context/references-context.tsx

@@ -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> => {