-
Notifications
You must be signed in to change notification settings - Fork 346
Programming exercises
: Configure file limits for Monaco Diff Editor
#11475
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
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughAdds Monaco DiffEditor initialization options in two places, setting maxFileSize to 20 and maxComputationTime to 3000. Changes are limited to diff editor creation/configuration and do not modify exports or standalone editor behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/webapp/app/shared/monaco-editor/service/monaco-editor.service.ts (1)
82-83
: Extract duplicated limits into shared constants and document their behavior.
- Move
20
(MB) and3000
(ms) from
src/.../service/monaco-editor.service.ts
(lines 82–83) and
src/.../diff.utils.ts
(lines 147–148) into a shared constants file.- In that file, clarify units and behavior on exceedance (timeout cancels diff; oversized files skip full diff).
- Import and use those constants in both places.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/webapp/app/programming/shared/utils/diff.utils.ts
(1 hunks)src/main/webapp/app/shared/monaco-editor/service/monaco-editor.service.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/**/*.ts
⚙️ CodeRabbit configuration file
Files:
src/main/webapp/app/shared/monaco-editor/service/monaco-editor.service.ts
src/main/webapp/app/programming/shared/utils/diff.utils.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: ekayandan
PR: ls1intum/Artemis#10885
File: src/main/webapp/app/programming/shared/utils/diff.utils.ts:143-143
Timestamp: 2025-05-25T13:26:42.641Z
Learning: In Monaco Editor diff computation, creating a diff editor with a detached DOM element (not appended to document.body) is an intentional performance optimization to prevent rendering while still allowing diff calculation functionality to work properly.
📚 Learning: 2024-10-08T15:35:52.595Z
Learnt from: pzdr7
PR: ls1intum/Artemis#9407
File: src/main/webapp/app/shared/monaco-editor/monaco-editor.service.ts:66-66
Timestamp: 2024-10-08T15:35:52.595Z
Learning: In the `MonacoDiffEditorComponent` (`src/main/webapp/app/shared/monaco-editor/monaco-diff-editor.component.ts`), the diff editor is always set to read-only (`readOnly: true`), and there are currently no use cases that require editing in the diff view.
Applied to files:
src/main/webapp/app/shared/monaco-editor/service/monaco-editor.service.ts
src/main/webapp/app/programming/shared/utils/diff.utils.ts
📚 Learning: 2025-05-25T13:26:42.641Z
Learnt from: ekayandan
PR: ls1intum/Artemis#10885
File: src/main/webapp/app/programming/shared/utils/diff.utils.ts:143-143
Timestamp: 2025-05-25T13:26:42.641Z
Learning: In Monaco Editor diff computation, creating a diff editor with a detached DOM element (not appended to document.body) is an intentional performance optimization to prevent rendering while still allowing diff calculation functionality to work properly.
Applied to files:
src/main/webapp/app/programming/shared/utils/diff.utils.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Build and Push Docker Image / Build linux/arm64 Docker Image for ls1intum/artemis
- GitHub Check: Build and Push Docker Image / Build linux/amd64 Docker Image for ls1intum/artemis
- GitHub Check: Build .war artifact
- GitHub Check: client-style
- GitHub Check: client-tests-selected
- GitHub Check: client-tests
- GitHub Check: server-style
- GitHub Check: server-tests
- GitHub Check: Analyse
const diffEditor = monaco.editor.createDiffEditor(document.createElement('div'), { | ||
readOnly: true, | ||
automaticLayout: false, | ||
maxFileSize: 20, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What unit is this size? Lines? kiB? Some comment would be helpful.
I guess the computation time below are milliseconds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add onto this: the input.constants.ts
file provides a lot of constants, like e.g. MAX_FILE_SIZE
, which you can use instead of a hardcoded value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End-to-End (E2E) Test Results Summary
|
Checklist
General
Motivation and Context
When diffs are too big between files (eg. csv files), Monaco Editor crashes browsers due to out-of-memory, as described in #11469. Limiting diff computation time and maximum file size should solve this issue.
Description
Added necessary configurations to limit computation time and file size.
Steps for Testing
Testserver States
You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.
Review Progress
Code Review
Manual Tests
Summary by CodeRabbit