فهرست منبع

Merge pull request #25740 from overleaf/dp-gutter-error-logs

Correctly open logs when using AI assist gutter button in new editor

GitOrigin-RevId: 2700832f9e18d10ca3e6ee52841d31613fee626c
David 1 سال پیش
والد
کامیت
0b9cb185fa
1فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 13 3
      services/web/frontend/js/shared/context/local-compile-context.tsx

+ 13 - 3
services/web/frontend/js/shared/context/local-compile-context.tsx

@@ -50,6 +50,8 @@ import { isSplitTestEnabled } from '@/utils/splitTestUtils'
 import { captureException } from '@/infrastructure/error-reporter'
 import OError from '@overleaf/o-error'
 import getMeta from '@/utils/meta'
+import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
+import { useRailContext } from '@/features/ide-redesign/contexts/rail-context'
 
 type PdfFile = Record<string, any>
 
@@ -125,6 +127,8 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
   const { openDocWithId, openDocs, currentDocument } = useEditorManagerContext()
   const { role } = useDetachContext()
 
+  const newEditor = useIsNewEditorEnabled()
+
   const {
     _id: projectId,
     rootDocId,
@@ -135,6 +139,8 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
 
   const { pdfPreviewOpen } = useLayoutContext()
 
+  const { openTab: openRailTab } = useRailContext()
+
   const { features, alphaProgram, labsProgram } = useUserContext()
 
   const { fileTreeData } = useFileTreeData()
@@ -742,8 +748,12 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
   const lastCompileOptions = useMemo(() => data?.options || {}, [data])
 
   useEffect(() => {
-    const listener = (event: Event) => {
-      setShowLogs((event as CustomEvent<boolean>).detail as boolean)
+    const listener = () => {
+      if (newEditor) {
+        openRailTab('errors')
+      } else {
+        setShowLogs(true)
+      }
     }
 
     window.addEventListener('editor:show-logs', listener)
@@ -751,7 +761,7 @@ export const LocalCompileProvider: FC<React.PropsWithChildren> = ({
     return () => {
       window.removeEventListener('editor:show-logs', listener)
     }
-  }, [])
+  }, [newEditor, openRailTab])
 
   const value = useMemo(
     () => ({