use courseware_url from language_options, filter them by is_enrollable#3276
Conversation
…ns course runs by is_enrollable Co-authored-by: Copilot <copilot@github.com>
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
There was a problem hiding this comment.
Pull request overview
Updates the dashboard/program language selection logic to only consider enrollable course runs and removes the previously supported “synthetic” (language option without a concrete V2 run) resolution path, alongside bumping the MITxOnline API client dependency source.
Changes:
- Filter
language_optionsdown to those backed bycourserunswithis_enrollable=true, and adjust selection heuristics accordingly. - Remove synthetic run creation in
getResolvedRunForSelectedLanguage(now returnsnullwhen no concrete run/enrollment exists). - Update/extend unit tests and switch
@mitodl/mitxonline-api-axiosdependency to a GitHub-hosted tarball URL.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/languageOptions.ts |
Filters language options to enrollable runs; removes synthetic run resolution path. |
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/languageOptions.test.ts |
Updates fixtures and adds coverage for unenrollable options being ignored. |
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.test.tsx |
Updates test data to include language_options/courseware_url and ensure runs are enrollable where needed. |
frontends/main/package.json |
Points @mitodl/mitxonline-api-axios to a GitHub tarball URL. |
frontends/api/package.json |
Points @mitodl/mitxonline-api-axios to a GitHub tarball URL. |
yarn.lock |
Updates resolution/checksum for the GitHub tarball dependency. |
| "@floating-ui/react": "^0.27.16", | ||
| "@mitodl/course-search-utils": "^3.5.2", | ||
| "@mitodl/mitxonline-api-axios": "2026.4.29", | ||
| "@mitodl/mitxonline-api-axios": "https://github.com/mitodl/mitxonline-api-clients/raw/dfa6c8772184ca05c36fda8b745c5e4663310ece/src/typescript/mitxonline-api-axios/package.tgz", |
There was a problem hiding this comment.
Copilot doesn't understand that this is temporary
| }, | ||
| "dependencies": { | ||
| "@mitodl/mitxonline-api-axios": "2026.4.29", | ||
| "@mitodl/mitxonline-api-axios": "https://github.com/mitodl/mitxonline-api-clients/raw/dfa6c8772184ca05c36fda8b745c5e4663310ece/src/typescript/mitxonline-api-axios/package.tgz", |
There was a problem hiding this comment.
Copilot doesn't understand that this is temporary
| run_tag: selectedLanguageOption.run_tag, | ||
| __synthetic: true, | ||
| } satisfies SyntheticCourseRunV2 | ||
| return null |
| // Return a synthetic selected-language run id/title/courseware mapped onto a | ||
| // scoped template run so unenrolled language selection can still resolve. | ||
| return { | ||
| ...templateRun, | ||
| id: selectedLanguageOption.id, | ||
| title: selectedLanguageOption.title, | ||
| courseware_id: selectedLanguageOption.courseware_id, | ||
| run_tag: selectedLanguageOption.run_tag, | ||
| __synthetic: true, | ||
| } satisfies SyntheticCourseRunV2 |
There was a problem hiding this comment.
i think we still need this, just include courseware_url via selectedLanguageOption ?
…l because it's still necessary Co-authored-by: Copilot <copilot@github.com>
ChristopherChudzicki
left a comment
There was a problem hiding this comment.
👍 working now with getResolvedRunForSelectedLanguage synthetic branch restored.
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
| if (!selectedLanguageKey) { | ||
| const resolvedLanguageKey = | ||
| selectedLanguageKey || getDefaultLanguageOptionKey(course) || "" | ||
|
|
||
| if (!resolvedLanguageKey) { | ||
| return null | ||
| } | ||
| return ( | ||
| (course.language_options ?? []).find( | ||
| (option) => getLanguageOptionKey(option) === selectedLanguageKey, |
There was a problem hiding this comment.
Bug: getDefaultLanguageOptionKey can return null when the default run is unenrollable and its courseware_id differs from the enrollable alternative, causing incorrect language pre-selection.
Severity: MEDIUM
Suggested Fix
In getDefaultLanguageOptionKey, after attempting to find a match by courseware_id, add a fallback step. If no match is found, use the language code from the unenrollable defaultRun to find any enrollable option with the same language code in enrollableLanguageOptions. This ensures a valid key is returned.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/languageOptions.ts#L120-L145
Potential issue: The function `getDefaultLanguageOptionKey` can incorrectly return
`null` when a user's default course run (`next_run_id`) is unenrollable and the
corresponding enrollable run for the same language has a different `courseware_id`. The
logic fails to fall back to matching by language code. This `null` value causes
`getDistinctLanguageOptions` to miscalculate language frequencies, potentially sorting a
non-default language first. Consequently, UI components like `EnrollmentDisplay.tsx` and
`ContractContent.tsx` may pre-select the wrong language for the user, showing Spanish
instead of English, for example.
Also affects:
frontends/main/src/app-pages/DashboardPage/EnrollmentDisplay/EnrollmentDisplay.tsxfrontends/main/src/app-pages/DashboardPage/ContractContent/ContractContent.tsx
Did we get this right? 👍 / 👎 to inform future reviews.
What are the relevant tickets?
Description (What does it do?)
Screenshots (if appropriate):
How can this be tested?
Additional Context