Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Update monaco-editor to 0.52.0 #9431

Merged
merged 12 commits into from
Oct 11, 2024

Conversation

pzdr7
Copy link
Contributor

@pzdr7 pzdr7 commented Oct 6, 2024

Checklist

General

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the client coding and design guidelines.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).

Motivation and Context

After upgrading to 0.52.0, the Monaco editor would sometimes encounter errors related to its web worker, which would cause it to lose its language features.

Potentially related to microsoft/monaco-editor#4694, although it's not 100% clear if this is the same error

Description

Steps for Testing

  • 1 Instructor
  • 1 Course with:
    • 1 Programming exercise. The solution build must be finished and there must be at least one test case.
    • Communication enabled
  1. Navigate to Course management > Your course > Exercises > Your programming exercise and click the name of the programming exercise.
  2. Scroll down, click "Review changes" and verify that this does not load endlessly
  3. Close the modal, scroll up, and click on "Edit"
  4. Verify that you still get completions when typing in the problem statement editor.
  5. Go to the communication view of your course and open a channel.
  6. Verify that when you click on @, #, and "Exercise" in the Markdown editor action bar, the suggestion widget opens.

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Unchanged

Screenshots

No UI changes

Summary by CodeRabbit

  • New Features

    • Introduced a new completion feature in the Monaco editor, enhancing user experience by suggesting completions based on context.
  • Bug Fixes

    • Updated asset paths for the Monaco editor to improve resource loading during the build process.
  • Documentation

    • Revised method documentation for clarity regarding text insertion and completion triggering.
  • Chores

    • Updated the monaco-editor dependency to the latest version for improved performance and features.

@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Oct 6, 2024
@pzdr7 pzdr7 marked this pull request as ready for review October 7, 2024 17:39
@pzdr7 pzdr7 requested a review from a team as a code owner October 7, 2024 17:39
Copy link

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes in this pull request involve updates to the configuration and functionality of the Monaco Editor within an Angular project. Key modifications include changing asset paths in angular.json, updating the Monaco Editor dependency version in package.json, and enhancing the prebuild.mjs script to bundle worker scripts using esbuild. Additionally, several methods in the Monaco editor adapter classes have been modified or replaced to improve text insertion and completion features. Overall, these changes reflect a structured approach to optimizing the integration and performance of the Monaco Editor.

Changes

File Change Summary
angular.json Updated asset paths for Monaco Editor and detailed build configurations, including production and development settings.
package.json Updated monaco-editor dependency version from 0.51.0 to 0.52.0.
prebuild.mjs Integrated esbuild for bundling Monaco editor worker scripts; added new worker entry points and build logic.
src/main/webapp/app/core/config/monaco.config.ts Modified getWorkerUrl method to return dynamic worker URLs based on language identifiers; removed old comments.
src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts Removed typeText method; added triggerCompletion method to invoke editor suggestions.
src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts Removed typeText method; added triggerCompletion method.
src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts Updated run method to use replaceTextAtCurrentSelection and trigger completion after inserting text; revised documentation.
src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts Updated run method to use replaceTextAtCurrentSelection and trigger completion; revised documentation.
src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts Updated run method to use replaceTextAtCurrentSelection and trigger completion; revised documentation.
src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts Removed typeText method, altering the functionality of the class.

Possibly related PRs

Suggested labels

tests, enhancement

Suggested reviewers

  • egekurt123
  • JohannesStoehr
  • florian-glombik
  • b-fein
  • Jan-Thurner
  • sarpsahinalp

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 2e5ebe5 and 2078228.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • angular.json (1 hunks)
  • package.json (1 hunks)
  • prebuild.mjs (2 hunks)
  • src/main/webapp/app/core/config/monaco.config.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts
🧰 Additional context used
📓 Path-based instructions (6)
src/main/webapp/app/core/config/monaco.config.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

📓 Learnings (1)
src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts (1)
Learnt from: pzdr7
PR: ls1intum/Artemis#9124
File: src/main/webapp/app/shared/monaco-editor/model/actions/communication/monaco-user-mention.action.ts:63-65
Timestamp: 2024-07-28T20:43:40.544Z
Learning: In the `MonacoUserMentionAction` class, the context ensures that the course ID is always available, making the use of non-null assertion acceptable in this specific scenario.
🪛 Biome
prebuild.mjs

[error] 8-8: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)


[error] 9-9: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)


[error] 11-11: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)

🔇 Additional comments (7)
src/main/webapp/app/shared/monaco-editor/model/actions/communication/user-mention.action.ts (1)

48-49: LGTM: Improved method documentation

The updated documentation for the run method provides a more accurate description of the action performed. It now correctly states that the method "inserts" the text rather than "types" it, which aligns better with the actual implementation. This change improves clarity and maintains consistency between the documentation and the code.

src/main/webapp/app/shared/monaco-editor/model/actions/communication/exercise-reference.action.ts (1)

55-56: LGTM: Documentation update is clear and accurate.

The change in wording from "Types" to "Inserts" more accurately reflects the action being performed by the run method. The documentation is concise and follows the project's coding guidelines.

src/main/webapp/app/shared/monaco-editor/model/actions/communication/channel-reference.action.ts (2)

47-49: LGTM: Documentation update is accurate and clear.

The updated comment accurately reflects the new behavior of the run method. This change improves the clarity of the code and aligns with best practices for maintaining up-to-date documentation.


50-52: LGTM: Improved editor interaction and user experience.

The changes in the run method enhance the functionality:

  1. Using replaceTextAtCurrentSelection instead of typeText likely provides better control over text insertion.
  2. Adding editor.triggerCompletion() ensures immediate triggering of the completion provider, improving the user experience.

These modifications align with the coding guidelines and improve the overall functionality of the action.

src/main/webapp/app/shared/monaco-editor/model/actions/adapter/text-editor.interface.ts (1)

45-47: 🧹 Nitpick (assertive)

LGTM! Consider adding a comment for clarity.

The addition of triggerCompletion() method aligns with the PR objectives of addressing issues with code completions. This change improves the interface by providing a dedicated method for triggering completions.

Consider adding a brief comment to explain the purpose and expected behavior of this method. For example:

/**
 * Triggers the completion in the editor, e.g. by showing a widget.
 * This method is used to programmatically invoke the editor's completion functionality.
 */
triggerCompletion(): void;

The removal of the typeText method might impact other parts of the application. Let's verify its usage:

✅ Verification successful

Verified: No remaining usages of the typeText method found.

The removal of typeText does not impact any parts of the application. The addition of triggerCompletion() aligns with the intended improvements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of the removed typeText method

# Test: Search for typeText method calls
echo "Searching for typeText method calls:"
rg --type typescript 'typeText\(' src/main/webapp

Length of output: 169


Script:

#!/bin/bash
# Description: Check for any remaining usage of the removed typeText method

# Test: Search for typeText method calls in .ts and .tsx files
echo "Searching for typeText method calls:"
rg 'typeText\(' --glob '*.ts' --glob '*.tsx' src/main/webapp

Length of output: 145

package.json (1)

61-61: LGTM: Monaco Editor updated to version 0.52.0

The update of monaco-editor from version 0.51.0 to 0.52.0 aligns with the PR objectives. This change should address the mentioned web worker errors and the minor bug with code completions.

To ensure a smooth transition, please verify:

  1. Compatibility with other dependencies.
  2. Any necessary configuration updates in other files.

You can use the following script to check for other files that might need updates due to this change:

✅ Verification successful

Verified: Monaco Editor successfully updated to version 0.52.0

The monaco-editor dependency was updated, and no files contain version-specific references to the previous version. The update aligns with the PR objectives and should resolve the reported issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for files that might need updates due to Monaco Editor version change

# Test: Search for files referencing Monaco Editor
echo "Files potentially affected by Monaco Editor update:"
rg --type-not json "monaco-editor" -l

# Test: Check for version-specific imports or configurations
echo "\nFiles with version-specific Monaco Editor references:"
rg --type-not json "monaco-editor.*0\.51\.0" -l

Length of output: 12685

src/main/webapp/app/shared/monaco-editor/model/actions/adapter/monaco-text-editor.adapter.ts (1)

155-156: The triggerCompletion method correctly triggers the suggestion widget

The implementation appropriately invokes the suggestion widget using editor.trigger, which addresses the issue where typing no longer suffices to trigger completions.

angular.json Show resolved Hide resolved
src/main/webapp/app/core/config/monaco.config.ts Outdated Show resolved Hide resolved
prebuild.mjs Show resolved Hide resolved
prebuild.mjs Show resolved Hide resolved
prebuild.mjs Show resolved Hide resolved
prebuild.mjs Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 7, 2024
Copy link
Contributor

@JohannesWt JohannesWt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code

Copy link
Contributor

@magaupp magaupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS4.
"Review changes" diff view loads properly. Test cases are completed in the problem statement editor. Clicking the @, #, and "Exercise" buttons opens the completion popup.

Unrelated to this PR:
I noticed that the @ name completion does not show the correct names in a PostgreSQL deployment.
Also, clicking on "Disable split view" in the "Review Changes" modal does not work at the first try.

Copy link
Contributor

@az108 az108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS4 on a programming exercise, review changes was possible and problem statement editor was working as expected and markdown editor in communications section is also working 👍

@pzdr7 pzdr7 added this to the 7.6.0 milestone Oct 11, 2024
@krusche krusche merged commit 6e5e558 into develop Oct 11, 2024
42 of 46 checks passed
@krusche krusche deleted the chore/development/fix-monaco-52 branch October 11, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) ready to merge
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants