Skip to content

Conversation

loyaltypollution
Copy link

Simple proof-of-concept for adding additional languages via a language-directory.

  • Wrote as feature flag to avoid breaking changes.

To-Do?

  • Add UI support to allow users to view language directory URLs in frontend.

Questions:

  • Is SourceAcademy planning to make conductors a “first-class” concept?
    • removing the hardcoding of languages in drop down?
    • ensuring that all -slang variants support conductors?

Happy to collaborate with relevant people on making conductors first-class if that’s the direction we are taking 👍

@martin-henz
Copy link
Member

Yes, the Source Academy frontends should be configurable to provide a desired set of languages and their implementations. The purpose of the language directory is to provide a mapping from language names to the "official" x-slang implementations.

What remains to be worked out is to configure what languages should be provided by sourceacademy.org and sourceacademy.nus.edu.sg and other frontends.

Should that be done in a config file at build time, or should this also come from a github page?

Any proposals?

@s-kybound
Copy link
Member

Should that be done in a config file at build time, or should this also come from a github page?
Any proposals?

@martin-henz best to be done in a config file i think, less layers of indirection especially when setting up new frontends.

@coveralls
Copy link

coveralls commented Sep 1, 2025

Pull Request Test Coverage Report for Build 17429370465

Details

  • 303 of 2358 (12.85%) changed or added relevant lines in 18 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-1.4%) to 42.463%

Changes Missing Coverage Covered Lines Changed/Added Lines %
public/evaluators/pie-slang/pie.js 0 1 0.0%
src/commons/controlBar/LegacyControlBarChapterSelect.tsx 68 69 98.55%
src/commons/navigationBar/subcomponents/NavigationBarLangSelectButton.tsx 22 27 81.48%
src/commons/controlBar/ControlBarChapterSelect.tsx 43 49 87.76%
src/commons/featureFlags/publicFlags.ts 0 6 0.0%
public/evaluators/py-slang/standard.js 0 694 0.0%
public/evaluators/py-slang/pyscript.js 0 1342 0.0%
Files with Coverage Reduction New Missed Lines %
src/commons/navigationBar/subcomponents/NavigationBarLangSelectButton.tsx 4 81.82%
Totals Coverage Status
Change from base Build 17424153377: -1.4%
Covered Lines: 21065
Relevant Lines: 51961

💛 - Coveralls

Copy link
Member

@s-kybound s-kybound left a comment

Choose a reason for hiding this comment

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

minor nits, after resolution LGTM! please make sure the frontend has been tested first.

@@ -41,6 +41,7 @@
"@reduxjs/toolkit": "^1.9.7",
"@sentry/react": "^10.5.0",
"@sourceacademy/c-slang": "^1.0.21",
"@sourceacademy/language-directory": "https://github.com/loyaltypollution/language-directory.git#866cc934372a19e514af0025947ce7f1f5a6e1fc",
Copy link
Member

Choose a reason for hiding this comment

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

is it necessary for the language directory to point to your version?


import {
Copy link
Member

Choose a reason for hiding this comment

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

not a review comment - this is beautiful. thanks!

<ChapterSelectComponent
items={choices.filter(({ mainLanguage }) => mainLanguage === selectedLang)}
onItemSelect={handleChapterSelect}
itemRenderer={chapterRenderer(isFolderModeEnabled)}
Copy link
Member

Choose a reason for hiding this comment

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

is it right to say that folder mode will be disabled for the new evaluators for now? if so please doc it as a limitation

import WorkspaceActions from 'src/commons/workspace/WorkspaceActions';
import { playgroundConfigLanguage } from 'src/features/playground/PlaygroundActions';

// TODO: Hardcoded to use the first sublanguage for each language
Copy link
Member

Choose a reason for hiding this comment

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

again, beautiful

import LanguageDirectoryActions from 'src/features/languageDirectory/LanguageDirectoryActions';
import type { ILanguageDefinition } from 'src/features/languageDirectory/LanguageDirectoryTypes';

// Remove when conductors.languageDirectory is default behaviour
Copy link
Member

Choose a reason for hiding this comment

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

please mark this explicitly as a TODO, if possible with name and date as well

// TODO <name> <date>: Remove when conductors.languageDirectory is default behaviour

import LegacyNavigationBarLangSelectButton from './LegacyNavigationBarLangSelectButton';

function useDirectoryOptions() {
const langs = useTypedSelector(s => s.languageDirectory.languages) as ILanguageDefinition[];
Copy link
Member

Choose a reason for hiding this comment

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

correct me if i'm wrong, but i'm pretty sure you don't need this type assertation here

}, [languagesLoaded, dispatch]);

const directoryEnabled = useFeature(flagLanguageDirectoryEnable);
if (!directoryEnabled) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: this should be moved higher as a guard clause to cleanly separate logic. to my understanding the code above and below this correspond to the new Navigation bar lang select button, but this corresponds to the original button.

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.

5 participants