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: Redesign and refactor Iris UI #8579

Merged
merged 28 commits into from
May 29, 2024
Merged

Conversation

bassner
Copy link
Member

@bassner bassner commented May 12, 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.

Motivation and Context

Pyris V2 now submits status updates that we want to display in the UI.
It did also not look really pretty.
Additionally, the previous implementation was overengineered.

Description

  • Updated the UI to look cleaner, have animations, and display the process status
  • Modified the communication of server and client regarding IRIS to be simpler and more organized
  • Resending messages is currently not working, but is not high priority and will be fixed in a follow-up

Steps for Testing

Prerequisites:

  • 1 Programming Exercise with IRIS enabled
  1. Log in to Artemis
  2. Navigate to the exercise page as a student
  3. Chat with IRIS about the exercise.
  4. Verify that the pipeline status is displayed correctly and that the messages are coming in correctly

Testserver States

Note

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


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

CleanShot.2024-05-12.at.16.52.23.mp4

@bassner bassner self-assigned this May 12, 2024
@bassner bassner requested a review from a team as a code owner May 12, 2024 15:17
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) labels May 12, 2024
@bassner bassner marked this pull request as draft May 12, 2024 15:18
Copy link

coderabbitai bot commented May 12, 2024

Walkthrough

The recent updates primarily focus on renaming and refactoring classes related to the Iris chat sessions, transitioning from IrisChatSession to IrisTutorChatSession. This change extends across Java backend and TypeScript frontend, impacting repositories, services, and models. Additionally, new functionalities and methods are introduced in user and session management, enhancing the system's capability to handle specific tutor chat sessions and user data more effectively.

Changes

File Path Change Summary
.../domain/iris/session/*.java Renamed IrisChatSession to IrisTutorChatSession. Updated references and method signatures to accommodate new session type.
.../repository/*.java Updated repositories to align with new session types and added methods for detailed user fetch.
.../service/connectors/pyris/*.java Renamed session references and added logging and error handling in pipeline services.
.../service/iris/*.java Updated service layers, replacing IrisChatSessionService with IrisTutorChatSessionService and adjusting related functionalities.
.../web/rest/iris/*.java Introduced new REST endpoints for managing tutor chat sessions and updated existing ones to support new session type.
.../web/rest/open/PublicAccountResource.java Modified method to include irisAccepted timestamp in user fetch.
.../app/core/user/*.ts Updated user model and service in TypeScript, adding irisAccepted property and removing old methods.
.../app/entities/iris/*.ts Introduced and updated TypeScript models to reflect backend changes and new data structures for chat sessions and messages.
.../app/iris/base-chatbot/*.ts, *.html, *.scss Developed new components for the Iris chatbot interface, handling user interactions, message display, and chat functionalities.
.../app/iris/exercise-chatbot/*.ts, *.scss Adjustments in chatbot button components, including style and interaction enhancements.

This table provides a concise overview of the changes across the system, highlighting the shift towards a more specialized tutor chat session management and enhanced user data handling.


Tip

Early Access Features
  • gpt-4o model for chat

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

Out of diff range and nitpick comments (4)
src/main/webapp/app/iris/iris-chat-base.service.ts (3)

31-31: Document the constructor parameters to enhance code readability and maintainability.


198-208: The getCurrentSessionOrCreate method throws a generic error. Use a more descriptive error message or handle specific cases differently.


214-224: Similar to getCurrentSessionOrCreate, the createNewSession method should provide more detailed error messages for better debugging and user feedback.

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

188-209: The resendMessage method should provide feedback to the user when a message cannot be resent due to missing ID or content.

overflow: hidden;
transition: all 0.2s;

max-height: 0;
Copy link

Choose a reason for hiding this comment

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

Remove the unexpected empty line before the declaration to maintain consistency and adhere to CSS best practices.

-        

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.

Suggested change
max-height: 0;
max-height: 0;

min-height: 0;
padding: 0 5px;

display: flex;
Copy link

Choose a reason for hiding this comment

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

Remove the unexpected empty line before the declaration to maintain consistency and adhere to CSS best practices.

-        

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.

Suggested change
display: flex;
display: flex;

justify-content: center;
width: 100%;

.part {
Copy link

Choose a reason for hiding this comment

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

Reorder CSS selectors to maintain specificity and prevent potential styling conflicts.

-        .part {
+        .chat-status-bar .progress-bar .part {

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.

Suggested change
.part {
.chat-status-bar .progress-bar .part {

background-color: var(--success);
transform: scaleX(1);
}
&.in_progress {
Copy link

Choose a reason for hiding this comment

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

Add an empty line before the rule for better readability and to adhere to CSS best practices.

+        
        &.done {

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.

Suggested change
&.in_progress {
&.in_progress {
&.done {

background-color: var(--warning);
transition: transform 10s linear;
}
&.skipped {
Copy link

Choose a reason for hiding this comment

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

Add an empty line before the rule for better readability and to adhere to CSS best practices.

+        
        &.skipped {

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.

Suggested change
&.skipped {
&.skipped {

@@ -129,8 +129,8 @@ public void checkRateLimit(IrisSession session, User user) {
*/
@SuppressWarnings("unchecked")
private <S extends IrisSession> IrisSubFeatureWrapper<S> getIrisSessionSubService(S session) {
if (session instanceof IrisChatSession chatSession) {
return (IrisSubFeatureWrapper<S>) new IrisSubFeatureWrapper<>(irisChatSessionService, chatSession);
if (session instanceof IrisTutorChatSession chatSession) {
Copy link

Choose a reason for hiding this comment

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

Improve the exception message for clarity when an unknown Iris session type is encountered.

- throw new BadRequestException("Unknown Iris session type " + session.getClass().getSimpleName());
+ throw new BadRequestException("The provided Iris session type '" + session.getClass().getSimpleName() + "' is not supported.");

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.

Suggested change
if (session instanceof IrisTutorChatSession chatSession) {
if (session instanceof IrisTutorChatSession chatSession) {

if (chatSession.getExercise().isExamExercise()) {
throw new ConflictException("Iris is not supported for exam exercises", "Iris", "irisExamExercise");
}
// TODO support more exercise types
Copy link

Choose a reason for hiding this comment

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

Consider opening a GitHub issue to track the TODO for supporting more exercise types in requestAndHandleResponse.

Would you like me to open a GitHub issue for this task?

private route: ActivatedRoute,
) {}

ngOnInit() {
Copy link

Choose a reason for hiding this comment

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

Ensure proper error handling for parseInt in case of invalid exerciseId values.

-            const exerciseId = parseInt(params['exerciseId'], 10);
+            const exerciseId = parseInt(params['exerciseId'], 10);
+            if (isNaN(exerciseId)) {
+                throw new Error('Invalid exercise ID');
+            }

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.

Suggested change
ngOnInit() {
ngOnInit() {
const exerciseId = parseInt(params['exerciseId'], 10);
if (isNaN(exerciseId)) {
throw new Error('Invalid exercise ID');
}

WHERE s.exercise.id = :exerciseId
AND s.user.id = :userId
ORDER BY s.creationDate DESC
LIMIT 1
Copy link

Choose a reason for hiding this comment

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

The LIMIT clause is not supported in JPQL; consider revising the query to fetch only the latest record correctly.

-                LIMIT 1
+                // JPQL does not support LIMIT. Consider using a different approach to fetch only the latest record.

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.

Suggested change
LIMIT 1
// JPQL does not support LIMIT. Consider using a different approach to fetch only the latest record.

* Checks the availability of Iris by sending a heartbeat request.
*/
private checkHeartbeat(): void {
if (this.disconnected) return;
Copy link

Choose a reason for hiding this comment

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

Add error handling for the getIrisStatus HTTP request to manage potential failures gracefully.

+            .catch((error) => {
+                console.error('Failed to fetch Iris status:', error);
+                this.active = false;
+                this.activeSubject.next(this.active);
+            });

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.

Suggested change
if (this.disconnected) return;
if (this.disconnected) return;
.catch((error) => {
console.error('Failed to fetch Iris status:', error);
this.active = false;
this.activeSubject.next(this.active);
});

@github-actions github-actions bot added the database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. label May 27, 2024
@bassner bassner changed the base branch from develop to hd3-develop May 29, 2024 07:14
@bassner bassner merged commit fe4794f into hd3-develop May 29, 2024
13 of 21 checks passed
@bassner bassner deleted the feature/iris/client-refactor branch May 29, 2024 19:18
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!) database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

None yet

3 participants