Explorar el Código

Display previous fix from AI error assistant (#19278)

GitOrigin-RevId: 12468956281d11f9ebdc50a2e30e5f8213f68308
Alf Eaton hace 2 años
padre
commit
cfb1a5b82f

+ 1 - 0
services/web/config/settings.defaults.js

@@ -876,6 +876,7 @@ module.exports = {
     sourceEditorExtensions: [],
     sourceEditorComponents: [],
     pdfLogEntryComponents: [],
+    pdfLogEntriesComponents: [],
     diagnosticActions: [],
     sourceEditorCompletionSources: [],
     sourceEditorSymbolPalette: [],

+ 3 - 0
services/web/frontend/extracted-translations.json

@@ -687,6 +687,7 @@
   "last_modified": "",
   "last_name": "",
   "last_resort_trouble_shooting_guide": "",
+  "last_suggested_fix": "",
   "last_updated_date_by_x": "",
   "last_used": "",
   "latam_discount_modal_info": "",
@@ -715,6 +716,7 @@
   "limited_offer": "",
   "limited_to_n_editors_per_project": "",
   "limited_to_n_editors_per_project_plural": "",
+  "line": "",
   "line_height": "",
   "line_width_is_the_width_of_the_line_in_the_current_environment": "",
   "link": "",
@@ -1333,6 +1335,7 @@
   "suggest_fix": "",
   "suggested": "",
   "suggested_fix_for_error_in_path": "",
+  "suggestion_applied": "",
   "sure_you_want_to_cancel_plan_change": "",
   "sure_you_want_to_change_plan": "",
   "sure_you_want_to_delete": "",

+ 9 - 0
services/web/frontend/js/features/pdf-preview/components/pdf-logs-entries.jsx

@@ -4,9 +4,12 @@ import { useTranslation } from 'react-i18next'
 import PreviewLogsPaneMaxEntries from '../../preview/components/preview-logs-pane-max-entries'
 import PdfLogEntry from './pdf-log-entry'
 import { useDetachCompileContext } from '../../../shared/context/detach-compile-context'
+import importOverleafModules from '../../../../macros/import-overleaf-module.macro'
 
 const LOG_PREVIEW_LIMIT = 100
 
+const pdfLogEntriesComponents = importOverleafModules('pdfLogEntriesComponents')
+
 function PdfLogsEntries({ entries, hasErrors }) {
   const { t } = useTranslation()
   const { syncToEntry } = useDetachCompileContext()
@@ -22,6 +25,12 @@ function PdfLogsEntries({ entries, hasErrors }) {
         />
       )}
 
+      {pdfLogEntriesComponents.map(
+        ({ import: { default: Component }, path }) => (
+          <Component key={path} />
+        )
+      )}
+
       {logEntries.map((logEntry, index) => (
         <PdfLogEntry
           key={logEntry.key}

+ 2 - 0
services/web/locales/en.json

@@ -1003,6 +1003,7 @@
   "last_modified": "Last Modified",
   "last_name": "Last Name",
   "last_resort_trouble_shooting_guide": "If that doesn’t help, follow our <0>troubleshooting guide</0>.",
+  "last_suggested_fix": "Last suggested fix",
   "last_updated": "Last Updated",
   "last_updated_date_by_x": "__lastUpdatedDate__ by __person__",
   "last_used": "last used",
@@ -1902,6 +1903,7 @@
   "suggested": "Suggested",
   "suggested_fix_for_error_in_path": "Suggested fix for error in __path__",
   "suggestion": "Suggestion",
+  "suggestion_applied": "Suggestion applied",
   "support": "Support",
   "sure_you_want_to_cancel_plan_change": "Are you sure you want to revert your scheduled plan change? You will remain subscribed to the <0>__planName__</0> plan.",
   "sure_you_want_to_change_plan": "Are you sure you want to change plan to <0>__planName__</0>?",

+ 9 - 1
services/web/test/frontend/components/pdf-preview/pdf-logs-entries.spec.tsx

@@ -8,6 +8,7 @@ import {
   EditorManager,
   EditorManagerContext,
 } from '@/features/ide-react/context/editor-manager-context'
+import { EditorView } from '@codemirror/view'
 
 describe('<PdfLogsEntries/>', function () {
   const fakeFindEntityResult: FindResult = {
@@ -57,6 +58,10 @@ describe('<PdfLogsEntries/>', function () {
     },
   ]
 
+  const scope = {
+    'editor.view': new EditorView({ doc: '\\documentclass{article}' }),
+  }
+
   beforeEach(function () {
     cy.interceptCompile()
     cy.interceptEvents()
@@ -64,7 +69,7 @@ describe('<PdfLogsEntries/>', function () {
 
   it('displays human readable hint', function () {
     cy.mount(
-      <EditorProviders>
+      <EditorProviders scope={scope}>
         <PdfLogsEntries entries={logEntries} />
       </EditorProviders>
     )
@@ -75,6 +80,7 @@ describe('<PdfLogsEntries/>', function () {
   it('opens doc on click', function () {
     cy.mount(
       <EditorProviders
+        scope={scope}
         providers={{ EditorManagerProvider, FileTreePathProvider }}
       >
         <PdfLogsEntries entries={logEntries} />
@@ -104,6 +110,7 @@ describe('<PdfLogsEntries/>', function () {
 
     cy.mount(
       <EditorProviders
+        scope={scope}
         providers={{ EditorManagerProvider, FileTreePathProvider }}
       >
         <PdfLogsEntries entries={logEntries} />
@@ -143,6 +150,7 @@ describe('<PdfLogsEntries/>', function () {
 
     cy.mount(
       <EditorProviders
+        scope={scope}
         providers={{ EditorManagerProvider, FileTreePathProvider }}
       >
         <PdfLogsEntries entries={logEntries} />

+ 5 - 0
services/web/test/frontend/components/pdf-preview/scope.tsx

@@ -1,3 +1,5 @@
+import { EditorView } from '@codemirror/view'
+
 export const mockScope = () => ({
   settings: {
     syntaxValidation: false,
@@ -8,6 +10,9 @@ export const mockScope = () => ({
       doc_id: 'test-doc',
       getSnapshot: () => 'some doc content',
     },
+    view: new EditorView({
+      doc: '\\documentclass{article}',
+    }),
   },
   hasLintingError: false,
   ui: {