From 0b9cb185faba35a005ab42a071c719e09b8442bc Mon Sep 17 00:00:00 2001 From: David <33458145+davidmcpowell@users.noreply.github.com> Date: Wed, 21 May 2025 09:47:33 +0100 Subject: [PATCH] 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 --- .../js/shared/context/local-compile-context.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/services/web/frontend/js/shared/context/local-compile-context.tsx b/services/web/frontend/js/shared/context/local-compile-context.tsx index e16fc53114..4ac3654a45 100644 --- a/services/web/frontend/js/shared/context/local-compile-context.tsx +++ b/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 @@ -125,6 +127,8 @@ export const LocalCompileProvider: FC = ({ const { openDocWithId, openDocs, currentDocument } = useEditorManagerContext() const { role } = useDetachContext() + const newEditor = useIsNewEditorEnabled() + const { _id: projectId, rootDocId, @@ -135,6 +139,8 @@ export const LocalCompileProvider: FC = ({ const { pdfPreviewOpen } = useLayoutContext() + const { openTab: openRailTab } = useRailContext() + const { features, alphaProgram, labsProgram } = useUserContext() const { fileTreeData } = useFileTreeData() @@ -742,8 +748,12 @@ export const LocalCompileProvider: FC = ({ const lastCompileOptions = useMemo(() => data?.options || {}, [data]) useEffect(() => { - const listener = (event: Event) => { - setShowLogs((event as CustomEvent).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 = ({ return () => { window.removeEventListener('editor:show-logs', listener) } - }, []) + }, [newEditor, openRailTab]) const value = useMemo( () => ({