Skip to content

Conversation

@mraman-2U
Copy link
Contributor

This pull request refactors the Chat component in the courseware to use a generic plugin slot system instead of a feature-specific implementation, simplifying the logic and making it more extensible for future tools. Additionally, it updates environment configuration files and modernizes the related test suite for the new architecture.

Major changes include:

Chat Component Refactor

  • Refactored Chat.jsx to remove all feature-specific logic (such as Xpert and enrollment mode checks) and instead render a generic PluginSlot with minimal context, allowing plugins to handle their own requirements. This makes the component more maintainable and extensible. [1] [2]
  • Updated prop types for Chat to remove unused props and reflect the simplified interface.

Test Suite Overhaul

  • Rewrote Chat.test.jsx to mock the new PluginSlot and test the new, simplified rendering logic, focusing on correct context propagation and conditional rendering based solely on the enabled prop. The tests no longer depend on Redux or feature-specific logic.

Environment Configuration Updates

  • Changed the development server port and base URL in .env.development from 2000 to 2010 to align with updated local development practices. [1] [2]
  • Added ENABLE_XPERT_AUDIT='true' to .env.development and removed the unused FEATURE_ENABLE_CHAT_V2_ENDPOINT flag from both .env and .env.development, cleaning up obsolete configuration. [1] [2]

These changes collectively make the chat integration more modular, easier to maintain, and ready for future plugin-based learner tools.

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.82%. Comparing base (f91af21) to head (fa32637).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1810      +/-   ##
==========================================
- Coverage   90.84%   90.82%   -0.03%     
==========================================
  Files         345      345              
  Lines        5800     5787      -13     
  Branches     1376     1324      -52     
==========================================
- Hits         5269     5256      -13     
  Misses        514      514              
  Partials       17       17              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mraman-2U mraman-2U changed the title feat: update chat component to use PluginSlot and simplify logic feat: update chat component to use PluginSlot Oct 21, 2025
Copy link
Contributor

@michaelroytman michaelroytman left a comment

Choose a reason for hiding this comment

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

I left some comments.

Something we should think about is the learning assistant Redux store, which is included in the learning MFE store definition. Can it be removed easily? It references the learning assistant, so it should be.

There are some references to it in the repository still.

PRIVACY_POLICY_URL='http://localhost:18000/privacy'
OPTIMIZELY_FULL_STACK_SDK_KEY=''
SHOW_UNGRADED_ASSIGNMENT_PROGRESS=''
ENABLE_XPERT_AUDIT='true'
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should add this here, because its use is being removed in this PR.

I think we should just provide instructions in the component README to add this environment variable to a developer's environment.

contentToolsEnabled={contentToolsEnabled}
unitId={unitId}
isUpgradeEligible={auditMode}
<PluginSlot
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like there's a conflict between the name of this component and its new purpose. Is this plugin slot meant to be used for an implementation of a chat bot? Or is it, as the ID suggests, a plugin slot for learner tools? I believe it should be the latter. Can we update the name of this component and references to "chat"?

ACCESS_TOKEN_COOKIE_NAME='edx-jwt-cookie-header-payload'
APP_ID='learning'
BASE_URL='http://localhost:2000'
BASE_URL='http://localhost:2010'
Copy link
Contributor

Choose a reason for hiding this comment

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

The change to use port 2010 was a 2U only change, so this should remain 2000, as this is what the community continues to use.

Comment on lines +15 to +18
// If chat is disabled, don't show anything
if (!enabled) {
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this condition. The plugin framework allows developers to programmatically insert plugins into the plugin slot. Either the plugin can not be inserted into the plugin slot, or the plugin can determine its own rendering logic.

Also, we should probably remove the reference to course.learningAssistantEnabled here, as it's Xpert specific.

return null;
}

// Provide minimal, generic context - no feature-specific flags
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

@mraman-2U
Copy link
Contributor Author

I left some comments.

Something we should think about is the learning assistant Redux store, which is included in the learning MFE store definition. Can it be removed easily? It references the learning assistant, so it should be.

There are some references to it in the repository still.

At present it is difficult to remove this learning assistant Redux store usage from MFE. Though it defeats the purpose of having the library independent of the MFE. This may be acceptable for cross component coordination and not related to MFE business logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants