From bee698c01d179cc40abd1207865ffb4ec8e2bfc4 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Mon, 24 Jun 2024 12:25:58 +0100 Subject: [PATCH] Updates to the AI error assistant (#19065) * Only show the AI error assistant to users with write permission on the project * Fix line number in searchDocLines * Abort the request after 60 seconds * Move comment * Jump to file + line when suggestion line number is clicked * Set tool_choice: 'required' * Fix handling of suggestLineChange * Tidy up getDocLines * Avoid showing Suggest Fix button in gutter marker for typesetting warnings * Log request errors * Fix prefixed function name * Update tool description * Tweak the prompt in an attempt to improve the line number * Reject if the total message content is too large * Change the structure of the suggested change * Reduce line highlight * Fix change highlighting on deletion GitOrigin-RevId: afde096e547050b8518195ef51b68983bc3b0be3 --- .../app/src/Features/Project/ProjectController.js | 4 +++- .../js/features/pdf-preview/util/output-files.js | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 7e98e1803f..57b093964c 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -544,7 +544,9 @@ const _ProjectController = { const showAiErrorAssistant = userId && Features.hasFeature('saas') && - (user.features?.aiErrorAssistant || user.alphaProgram) + (user.features?.aiErrorAssistant || user.alphaProgram) && + (privilegeLevel === PrivilegeLevels.READ_AND_WRITE || + privilegeLevel === PrivilegeLevels.OWNER) const template = detachRole === 'detached' diff --git a/services/web/frontend/js/features/pdf-preview/util/output-files.js b/services/web/frontend/js/features/pdf-preview/util/output-files.js index 17885f635f..0eca1e6aa0 100644 --- a/services/web/frontend/js/features/pdf-preview/util/output-files.js +++ b/services/web/frontend/js/features/pdf-preview/util/output-files.js @@ -153,7 +153,7 @@ export function buildLogEntryAnnotations(entries, fileTreeData, rootDocId) { logEntryAnnotations[entity._id] = [] } - logEntryAnnotations[entity._id].push({ + const annotation = { id: entry.key, entryIndex: logEntryAnnotations[entity._id].length, // used for maintaining the order of items on the same line row: entry.line - 1, @@ -161,10 +161,17 @@ export function buildLogEntryAnnotations(entries, fileTreeData, rootDocId) { text: entry.message, source: 'compile', // NOTE: this is used in Ace for filtering the annotations ruleId: entry.ruleId, - firstOnLine: !seenLine[entry.line], - }) + } - seenLine[entry.line] = true + // set firstOnLine for the first non-typesetting annotation on a line + if (entry.level !== 'typesetting') { + if (!seenLine[entry.line]) { + annotation.firstOnLine = true + seenLine[entry.line] = true + } + } + + logEntryAnnotations[entity._id].push(annotation) } } }