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

Iris: Render newlines properly and display warning if Iris is offline #8848

Merged
merged 4 commits into from
Jun 23, 2024

Conversation

bassner
Copy link
Member

@bassner bassner commented Jun 22, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

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.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

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).
  • I tested all changes and their related features with all corresponding user types on a test server configured with Gitlab and Jenkins.

Motivation and Context

Description

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Programming Exercise with Complaints enabled
  1. Log in to Artemis
  2. Navigate to Course Administration
  3. ...

Exam Mode Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Exam with a Programming Exercise
  1. Log in to Artemis
  2. Participate in the exam as a student
  3. Make sure that the UI of the programming exercise in the exam mode stays unchanged. You can use the exam mode documentation as reference.
  4. ...

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

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

Screenshots

Summary by CodeRabbit

  • Enhancements
    • Improved message handling in the chatbot by doubling line breaks for better readability.
    • Enhanced message processing by removing unnecessary spaces and newlines before sending messages.

@bassner bassner self-assigned this Jun 22, 2024
@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Jun 22, 2024
@bassner bassner added this to the 7.3.0 milestone Jun 23, 2024
@bassner bassner marked this pull request as ready for review June 23, 2024 15:02
@bassner bassner requested a review from a team as a code owner June 23, 2024 15:02
Copy link

coderabbitai bot commented Jun 23, 2024

Warning

Rate limit exceeded

@bassner has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 44 minutes and 47 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between aeccdf7 and b1e40de.

Walkthrough

The recent changes enhance message handling in an Angular application by integrating lodash's cloneDeep for manipulating text in IrisBaseChatbotComponent and trimming spaces and newlines in the IrisChatService before message processing. This update aims to improve text message manipulation and cleanliness.

Changes

File / Path Change Summary
src/main/webapp/app/iris/base-chatbot/iris-base-chatbot.component.ts Imported lodash, used cloneDeep to reverse and manipulate messages by doubling line breaks for text messages.
src/main/webapp/app/iris/iris-chat.service.ts Added message trimming functionality to remove spaces and newlines before creating a new message.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant IrisBaseChatbotComponent
    participant IrisChatService

    User->>IrisBaseChatbotComponent: Sends a message
    IrisBaseChatbotComponent->>IrisChatService: Send message content (using `cloneDeep`)
    IrisChatService->>IrisChatService: Trim spaces and newlines from message
    IrisChatService->>IrisBaseChatbotComponent: Send processed message
    IrisBaseChatbotComponent->>User: Display processed message
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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: 1

Outside diff range comments (6)
src/main/webapp/app/iris/iris-chat.service.ts (3)

Line range hint 87-87: Avoid using non-null assertions.

Using non-null assertions (!) bypasses TypeScript's type safety, potentially leading to runtime errors if the value is actually null or undefined. It's better to handle such cases explicitly.

- this.replaceOrAddMessage(m.body!);
+ if (m.body) {
+   this.replaceOrAddMessage(m.body);
+ } else {
+   // Handle undefined or null body appropriately
+ }
Tools
Biome

[error] 81-81: Reassigning a function parameter is confusing. (lint/style/noParameterAssign)

The parameter is declared here:

Use a local variable instead.


Line range hint 128-128: Specify a type instead of using any.

Using any type can lead to errors that TypeScript's static analysis would normally catch. It's a good practice to define a more specific type.

- const map = new Map<string, any>();
+ const map = new Map<string, unknown>(); // Use 'unknown' if the type really can't be predicted, otherwise specify a more precise type.
Tools
Biome

[error] 81-81: Reassigning a function parameter is confusing. (lint/style/noParameterAssign)

The parameter is declared here:

Use a local variable instead.


Line range hint 284-284: Prefer template literals over string concatenation.

Using template literals can make the code cleaner and easier to read, especially when building strings that include variables.

- const newIdentifier = mode && id ? mode + '/' + id : undefined;
+ const newIdentifier = mode && id ? `${mode}/${id}` : undefined;
Tools
Biome

[error] 81-81: Reassigning a function parameter is confusing. (lint/style/noParameterAssign)

The parameter is declared here:

Use a local variable instead.

src/main/webapp/app/iris/base-chatbot/iris-base-chatbot.component.ts (3)

Line range hint 194-194: Avoid using assignments in expressions.

Assignments within expressions can lead to code that is harder to read and understand. It's generally a good practice to perform assignments as standalone statements.

- this.userAccepted = !!this.accountService.userIdentity?.irisAccepted;
+ const isAccepted = !!this.accountService.userIdentity?.irisAccepted;
+ this.userAccepted = isAccepted;

Line range hint 373-373: Use strict equality checks.

Using != can lead to unexpected type coercion. Always use !== for comparison to avoid potential bugs related to type coercion.

- if (newRows != this.rows) {
+ if (newRows !== this.rows) {

Line range hint 358-358: Use Number.parseInt instead of the global parseInt.

For consistency and to avoid using globals, prefer Number.parseInt.

- const lineHeight = parseInt(getComputedStyle(textarea).lineHeight, 10) + bufferForSpaceBetweenLines;
- const lineHeight = parseInt(window.getComputedStyle(textarea).lineHeight);
+ const lineHeight = Number.parseInt(getComputedStyle(textarea).lineHeight, 10) + bufferForSpaceBetweenLines;
+ const lineHeight = Number.parseInt(window.getComputedStyle(textarea).lineHeight);

Also applies to: 389-389

Comment on lines +80 to +82
// Trim messages (Spaces, newlines)
message = message.trim();

Copy link

Choose a reason for hiding this comment

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

Avoid reassigning function parameters directly.

The reassignment of the function parameter message can lead to confusion and potential bugs in larger codebases. It's generally a best practice to work with a new local variable instead.

- message = message.trim();
+ const trimmedMessage = message.trim();
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Trim messages (Spaces, newlines)
message = message.trim();
// Trim messages (Spaces, newlines)
const trimmedMessage = message.trim();
Tools
Biome

[error] 81-81: Reassigning a function parameter is confusing. (lint/style/noParameterAssign)

The parameter is declared here:

Use a local variable instead.

@github-actions github-actions bot added the tests label Jun 23, 2024
@bassner bassner changed the title Iris: render newlines properly Iris: Render newlines properly and display warning if Iris is offline Jun 23, 2024
@bassner bassner merged commit 13b0d50 into develop Jun 23, 2024
19 of 26 checks passed
@bassner bassner deleted the feat/iris/newlines branch June 23, 2024 15:43
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 for review tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant