Skip to content

Conversation

@Senan04
Copy link
Contributor

@Senan04 Senan04 commented Jan 24, 2026

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 guidelines.
  • I strictly followed the AET UI-UX 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 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

Opening a new chat on an exercise or lecture page initializes the conversation with the corresponding exercise/lecture as the chat context. Previously, opening a new chat on the dashboard initialized it with the entire course as context, without the option to select a specific exercise or lecture.

This pull request introduces a new context selection feature. When a user starts a new chat from the course dashboard, they now have the flexibility to choose a specific context through a new context selection interface.

Closes IRIS-94

Description

Key Features:

  • Context Selection UI: A new component ContextSelectionComponent is displayed for new chat sessions, allowing users to select one of the following contexts:
    • The entire course
    • A specific lecture
    • A specific exercise (Programming and Text exercises are supported)
  • Focused Conversations: Selecting a context (course or a specific lecture/ exercise) starts a new chat session that is scoped to that content, enabling more accurate and relevant responses from Iris.
  • Search and Filter: For courses with many lectures or exercises, a search bar is provided to quickly find the desired item.

Implementation Details:

  • The ContextSelectionComponent is shown within the IrisBaseChatbotComponent when there are no messages in the current session and the feature is enabled.
  • The CourseChatbotComponent now activates this feature by default.
  • The IrisChatService.switchTo & IrisChatService.start methods were updated with the option to force the creation of a new session.
  • New translations have been added for the UI elements.
  • Tests for the new ContextSelectionComponent have been added.

Steps for Testing

Prerequisites:

  • 1 Course with different exercises (programming/text/quiz...)
  • 1 Student
  • Iris must be enabled
  1. Log in to Artemis
  2. Navigate to the dashboard
  3. Try the context selection that is shown when a new chat is enabled and verify that:
    • The course is highlighted as the context by default
    • When selecting an exercise or lecture, the user gets visual feedback
    • The exercise list only shows programming/text exercises, as modeling or quiz exercises are not supported by iris
    • After selecting an exercise or lecture as the context, Iris' responses are clearly related to that exercise or lecture

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

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 even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2

Test Coverage

Last updated: 2026-01-27 09:23:31 UTC

Screenshots

context_selection

Summary by CodeRabbit

  • New Features

    • Context selection UI in the Iris chatbot empty state to choose course, lecture, or exercise (searchable lists, icons, loading/empty states).
    • Chatbot now surfaces context selection when viewing a course.
    • Option to start a fresh chat session when switching contexts.
  • Tests

    • Comprehensive unit tests covering context flows, filtering, navigation, and chat-mode transitions.
  • Documentation

    • Added English and German translations for context selection text.

✏️ Tip: You can customize this high-level summary in your review settings.

…ise or a Lecture. Adjust CourseChatbotComponent & IrisBaseChatbotComponent to use the new UI
…nitial context selection from CourseChatbotComponent to ContextSelectionComponent
…of navigating to an existing one if there is one with the same context
…w programming and text exercises, Improve UI (uniform box sizes, show when no due date)
@github-project-automation github-project-automation bot moved this to Work In Progress in Artemis Development Jan 24, 2026
@github-actions github-actions bot added client Pull requests that update TypeScript code. (Added Automatically!) iris Pull requests that affect the corresponding module labels Jan 24, 2026
@github-actions
Copy link

@Senan04 Test coverage has been automatically updated in the PR description.

@Senan04 Senan04 marked this pull request as ready for review January 26, 2026 17:51
@Senan04 Senan04 requested review from a team and krusche as code owners January 26, 2026 17:51
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Walkthrough

Adds a ContextSelection UI component (course/lecture/exercise), integrates it into the Iris base chatbot via new inputs, updates IrisChatService to optionally force new sessions on context switches, and adds translations plus unit tests.

Changes

Cohort / File(s) Summary
Context Selection Component
src/main/webapp/app/iris/overview/context-selection/context-selection.component.ts, .../context-selection.component.html, .../context-selection.component.scss, .../context-selection.component.spec.ts
New component providing a three-view context selector (main, lecture-selection, exercise-selection). Loads lectures/exercises from cache or server, supports search/filtering, selection actions that call IrisChatService, includes styling and extensive unit tests.
Base Chatbot Integration
src/main/webapp/app/iris/overview/base-chatbot/iris-base-chatbot.component.ts, .../iris-base-chatbot.component.html
Added public inputs courseId and showContextSelection; conditionally renders jhi-context-selection within the empty-chat message when showContextSelection() is true.
Course Chatbot Template
src/main/webapp/app/iris/overview/course-chatbot/course-chatbot.component.html
Passes [showContextSelection]="true" and [courseId]="courseId()" into the base chatbot template when a course exists.
Chat Service Enhancement
src/main/webapp/app/iris/overview/services/iris-chat.service.ts
Extended start(forceNew = false) and switchTo(mode, id?, forceNew = false) signatures; added createNewSession() and changed switch flow to call close() then start(forceNew) to support forced session recreation.
Internationalization
src/main/webapp/i18n/en/iris.json, src/main/webapp/i18n/de/iris.json
Added contextSelection translation keys (labels, descriptions, selected states, empty/loading messages) for English and German.

Sequence Diagram

sequenceDiagram
    participant User
    participant ContextSelection as Context Selection
    participant CourseStorage as Course Storage
    participant CourseManagement as Course Management
    participant ChatService as Iris Chat Service

    User->>ContextSelection: open / choose context
    ContextSelection->>CourseStorage: request lectures/exercises for courseId
    alt Cache hit
        CourseStorage-->>ContextSelection: return cached data
    else Cache miss
        ContextSelection->>CourseManagement: fetch course data
        CourseManagement-->>ContextSelection: return lectures/exercises
    end
    ContextSelection->>ContextSelection: filter/search & present list
    User->>ContextSelection: select course/lecture/exercise
    ContextSelection->>ChatService: switchTo(mode, id?, forceNew=true)
    ChatService->>ChatService: close()
    ChatService->>ChatService: start(forceNew=true)
    ChatService-->>ContextSelection: session ready
    ContextSelection-->>User: chat mode switched
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: introducing context selection functionality for Iris dashboard chats, which is the primary feature added across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/iris/initial-context-selection-dashboard-chat

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@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: 2

🤖 Fix all issues with AI agents
In
`@src/main/webapp/app/iris/overview/base-chatbot/iris-base-chatbot.component.html`:
- Line 2: Remove the invalid <script> tag from the Angular template (the line
loading "../../shared/context-selection/context-selection.component.ts") because
Angular templates must not include script imports; instead rely on the existing
ContextSelectionComponent import in the component TypeScript and its inclusion
in the component's imports array. Locate iris-base-chatbot.component.html and
delete that <script> line; verify that ContextSelectionComponent is still
referenced only via the component class import and the imports array in the
corresponding TypeScript file (where ContextSelectionComponent is imported and
registered).

In `@src/main/webapp/app/iris/overview/services/iris-chat.service.ts`:
- Around line 533-542: Update the JSDoc for the switchTo method to clarify
forceNew behavior: explain that forceNew only applies when the context actually
changes (isDifferent=true) and therefore will create a new session when
switching to a different context; note that when selecting the same context (no
change to sessionCreationIdentifier) forceNew has no effect because start() is
not invoked. Reference the switchTo method and the
sessionCreationIdentifier/start/close calls so reviewers can locate where the
behavior is enforced.
🧹 Nitpick comments (3)
src/main/webapp/app/iris/overview/context-selection/context-selection.component.scss (1)

12-85: Add focus-visible styling for keyboard navigation.

Hover/active states are defined, but explicit focus-visible styling improves keyboard accessibility while keeping the theme consistent.

♿ Suggested focus-visible styles
 .context-selection-box {
     display: flex;
@@
     &:hover:not(:disabled) {
         background-color: var(--iris-tool-background);
         border-color: var(--primary);
     }
 
+    &:focus-visible {
+        outline: 2px solid var(--primary);
+        outline-offset: 2px;
+    }
+
     &:active:not(:disabled) {
         transform: scale(0.98);
     }
@@
 .back-button {
     display: flex;
@@
     &:hover {
         background-color: var(--iris-suggestion-background);
         border-color: var(--primary);
     }
+
+    &:focus-visible {
+        outline: 2px solid var(--primary);
+        outline-offset: 2px;
+    }
 }

Also applies to: 115-136

src/main/webapp/app/iris/overview/context-selection/context-selection.component.ts (2)

114-140: Consider fetching when cache is partially hydrated.

If the cached course can contain only lectures or only exercises, the current length check can skip the server call and leave the missing list empty. Guarding on undefined lists avoids that edge case.

♻️ Suggested tweak to cache guard
-                    const cachedCourse = this.courseStorageService.getCourse(courseId);
-                    if (cachedCourse?.lectures?.length || cachedCourse?.exercises?.length) {
-                        return of({ lectures: cachedCourse.lectures ?? [], exercises: cachedCourse.exercises ?? [] });
-                    }
+                    const cachedCourse = this.courseStorageService.getCourse(courseId);
+                    const hasCachedLectures = cachedCourse?.lectures !== undefined;
+                    const hasCachedExercises = cachedCourse?.exercises !== undefined;
+                    if (hasCachedLectures && hasCachedExercises) {
+                        return of({ lectures: cachedCourse.lectures ?? [], exercises: cachedCourse.exercises ?? [] });
+                    }

167-174: Guard against missing/unsupported exercise types.

Exercise.type is optional; defaulting to programming when it’s absent can open the wrong scope. A small guard keeps the selection state consistent.

🛡️ Defensive guard
     selectExercise(exercise: Exercise): void {
+        if (!exercise.type || !SUPPORTED_EXERCISE_TYPES.includes(exercise.type)) {
+            return;
+        }
         this.selection.set({ type: 'exercise', exercise });
         this.currentView.set('main');
         if (exercise.id !== undefined) {
             const mode = exercise.type === ExerciseType.TEXT ? ChatServiceMode.TEXT_EXERCISE : ChatServiceMode.PROGRAMMING_EXERCISE;
             this.chatService.switchTo(mode, exercise.id, true);
         }
     }
Based on learnings, defensive guards help avoid inconsistent states without user-facing noise.

@github-actions
Copy link

@Senan04 Test coverage has been automatically updated in the PR description.

@github-project-automation github-project-automation bot moved this from Work In Progress to Ready For Review in Artemis Development Jan 26, 2026
@github-actions
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ✅Skipped ⚠️FailedTime ⏱
End-to-End (E2E) Test Report223 ran222 passed1 skipped0 failed1h 26m 58s 191ms
TestResultTime ⏱
No test annotations available

Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In `@src/main/webapp/app/iris/overview/services/iris-chat.service.ts`:
- Around line 538-541: The code calls this.start(forceNew) unconditionally when
isDifferent is true, but must guard against missing sessionCreationIdentifier
(or newIdentifier) as closeAndStart() did; update the block around isDifferent
to check that this.sessionCreationIdentifier (or the computed newIdentifier) is
defined before invoking this.start(forceNew), and bail out (or return) if it's
undefined to avoid the "Session creation identifier not set" error; reference
the existing methods closeAndStart(), close(), start(),
sessionCreationIdentifier and variable newIdentifier when making the change.

@github-actions
Copy link

@Senan04 Test coverage has been automatically updated in the PR description.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 26, 2026
@github-actions
Copy link

@Senan04 Test coverage has been automatically updated in the PR description.

@github-actions
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report223 ran220 passed1 skipped2 failed1h 36m 28s 352ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/exam/ExamTestRun.spec.ts
ts.Exam test run › Delete a test run › Deletes a test run❌ failure2m 59s 900ms
e2e/exam/ExamAssessment.spec.ts
ts.Exam assessment › Quiz exercise assessment › Assesses quiz automatically❌ failure24s 970ms

…ection-dashboard-chat' into feature/iris/initial-context-selection-dashboard-chat
@github-actions
Copy link

@Senan04 Test coverage has been automatically updated in the PR description.

@github-actions
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report223 ran219 passed1 skipped3 failed1h 45m 22s 371ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/atlas/LearningPathManagement.spec.ts
ts.Learning Path Management › Create simple learning path❌ failure23s 146ms
e2e/exam/test-exam/TestExamParticipation.spec.ts
ts.Test exam participation › Early Hand-in › Using exercise sidebar to navigate within exam❌ failure4m 42s 513ms
ts.Test exam participation › Early Hand-in › Using exercise overview to navigate within exam❌ failure4m 54s 647ms

@helios-aet helios-aet bot temporarily deployed to artemis-test3.artemis.cit.tum.de January 27, 2026 15:26 Inactive
@helios-aet helios-aet bot temporarily deployed to artemis-test1.artemis.cit.tum.de January 27, 2026 20:54 Inactive
Copy link

@maxgutke maxgutke left a comment

Choose a reason for hiding this comment

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

I tested this PR on TS1. I followed the instructions and everything worked as expected

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!) iris Pull requests that affect the corresponding module ready for review

Projects

Status: Ready For Review

Development

Successfully merging this pull request may close these issues.

3 participants