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: Hide suggestions during response generation #9919

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kaancayli
Copy link
Contributor

@kaancayli kaancayli commented Nov 30, 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 principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.

Motivation and Context

This PR addresses an inconsistency in the Iris chat interface where suggestions remain visible and clickable while responses are being generated, despite the text input field being disabled during this time. The change implements validation checks to hide suggestions during response generation, ensuring consistent behavior across the interface.

Description

Added validation logic to control suggestion visibility based on the chat's response generation state. This ensures suggestions are automatically disabled when a response is being generated.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Students
  • 1 Programming Exercise with Iris enabled
  1. Log in to Artemis
  2. Navigate to an Exercise with Iris enabled
  3. Send a message to Iris
  4. Make sure you received a response from the Iris, and suggestions are displayed
  5. Select a suggestion or send a custom message to Iris to advance the conversation
  6. Make sure the suggestions are disabled while a response is being generated.

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

TBD - Coverage script gives an empty result.

Screenshots

ezgif com-video-to-gif-converter

Summary by CodeRabbit

  • New Features

    • Enhanced conditional rendering logic for displaying suggestions in the chatbot interface, ensuring suggestions are shown only under specific criteria.
  • Tests

    • Introduced new test cases to validate the rendering of suggestions based on various conditions, improving test coverage of the chatbot component.

@kaancayli kaancayli requested a review from a team as a code owner November 30, 2024 23:51
@kaancayli kaancayli self-assigned this Nov 30, 2024
@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Nov 30, 2024
Copy link

coderabbitai bot commented Nov 30, 2024

Walkthrough

The changes in this pull request involve modifications to the conditional rendering logic in the iris-base-chatbot.component.html file, enhancing the criteria under which suggestions are displayed in the chatbot interface. The updated conditions require several checks, including the state of suggestions, userAccepted, isLoading, active, rateLimitInfo, and hasActiveStage. Additionally, new test cases have been added to the iris-base-chatbot.component.spec.ts file to validate the rendering behavior of suggestions under these updated conditions.

Changes

File Change Summary
src/main/webapp/app/iris/base-chatbot/iris-base-chatbot.component.html Modified conditional rendering logic for suggestions based on multiple criteria.
src/test/javascript/spec/component/iris/ui/iris-base-chatbot.component.spec.ts Added new test cases to validate rendering of suggestions based on updated conditions.

Possibly related PRs

  • Iris: Add conversation suggestions #8714: This PR adds conversation suggestions to the Iris chatbot, which is directly related to the changes in the main PR that modify the conditional rendering logic for displaying suggestions in the chat interface.
  • Iris: Enable text copy-paste from Iris exercise chatbot window #9761: This PR addresses usability issues in the Iris exercise chatbot window, specifically allowing text copying while maintaining the ability to drag the chatbot. This is relevant as it enhances user interaction with the chatbot, which is a focus of the main PR's changes to suggestion display logic.
  • Development: Fix exercise deletion with existing Iris sessions #9567: Although primarily focused on fixing exercise deletion, it includes integration tests that may indirectly relate to the overall functionality of the Iris chatbot, which is affected by how suggestions are managed and displayed in the main PR.

Suggested labels

client, bugfix, tests, ready for review

Suggested reviewers

  • Hialus
  • krusche
  • sebastianloose
  • alexjoham

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

🧹 Outside diff range and nitpick comments (1)
src/test/javascript/spec/component/iris/ui/iris-base-chatbot.component.spec.ts (1)

483-571: Consider extracting common test setup.

While the current implementation is clear, consider extracting the repeated setup code into a shared helper function to reduce duplication:

function setupSuggestionsTest(component: IrisBaseChatbotComponent, chatService: IrisChatService) {
  const expectedSuggestions = ['suggestion1', 'suggestion2'];
  const mockMessages = [mockClientMessage, mockServerMessage];

  jest.spyOn(chatService, 'currentSuggestions').mockReturnValue(of(expectedSuggestions));
  jest.spyOn(chatService, 'currentMessages').mockReturnValue(of(mockMessages));

  component.ngOnInit();
  return expectedSuggestions;
}

This would simplify each test case while maintaining clarity:

it('should not render suggestions if isLoading is true', () => {
  // Arrange
  setupSuggestionsTest(component, chatService);
  
  // Act
  component.isLoading = true;
  fixture.detectChanges();

  // Assert
  const suggestionButtons = fixture.nativeElement.querySelectorAll('.suggestion-button');
  expect(suggestionButtons).toHaveLength(0);
});
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dece904 and 06f09d1.

📒 Files selected for processing (2)
  • src/main/webapp/app/iris/base-chatbot/iris-base-chatbot.component.html (1 hunks)
  • src/test/javascript/spec/component/iris/ui/iris-base-chatbot.component.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/main/webapp/app/iris/base-chatbot/iris-base-chatbot.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/test/javascript/spec/component/iris/ui/iris-base-chatbot.component.spec.ts (1)

Pattern src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

🔇 Additional comments (2)
src/main/webapp/app/iris/base-chatbot/iris-base-chatbot.component.html (1)

63-70: LGTM! Well-structured conditional logic.

The conditions for displaying suggestions are comprehensive and efficiently ordered, with simple checks preceding complex ones. This implementation successfully prevents suggestions from appearing during response generation.

src/test/javascript/spec/component/iris/ui/iris-base-chatbot.component.spec.ts (1)

483-571: LGTM! Excellent test coverage.

The test suite comprehensively covers all conditions for hiding suggestions with well-structured, focused test cases. Each test follows the AAA pattern and uses appropriate mocking strategies.

Copy link

@Malekos74 Malekos74 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 Server: 03

Works as expected. I like this change!

Copy link
Contributor

@yassinsws yassinsws 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

@alekspetrov9e alekspetrov9e 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 TS3. Works as described. Nice feature!

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
Status: Work In Progress
Development

Successfully merging this pull request may close these issues.

4 participants