Skip to content

Commit 7e1a243

Browse files
tsammeowRichDom2185martin-henz
authored
integrate conductor into frontend (#3084)
* integrate conductor into frontend publicFlags.ts contains a list of "public" flags to be displayed in some sort of UI later set flag `conductor.enable` to true to use conductor execution * upgrade yarn(4.6.0) this enables use of prepack hooks to automatically build raw deps on install * fix lint issues * fix gl resolution problem * change github actions to use --immutable instead of --frozen-lockfile as argument to yarn install * add sa-conductor to list of ignored module paths in jest config * readd gl@^8.0.2 resolution to package.json * format with prettier * update caniuse-lite * update sa-conductor(0.0.13) this should fix webpack complaining about the dynamic import * add ui to edit feature flags also make feature flags a full class, and add evaluator url flag * support repl, and use stop button to kill runner instead of timeout * extract actual feature selector to separate function and rename selectFeature -> selectFeatureSaga this makes it clear that selectFeature is intended to be called from redux-saga * stop replReducer setting isRunning to true when using conductor, as it should be a no-op also change featureSelector to take a flag instead of just its name * revert replReducer change as it causes an error when using the repl introduce missing conductor feature flag check in eval button logic * hide eval button if not running when using conductor * update lockfile after package.json change * upgrade sa-conductor(0.1.3) to use new file communication protocol * upgrade sa-conductor(0.1.4) --------- Co-authored-by: Richard Dominick <34370238+RichDom2185@users.noreply.github.com> Co-authored-by: Martin Henz <henz@comp.nus.edu.sg>
1 parent 98d6052 commit 7e1a243

28 files changed

+20444
-14510
lines changed

.github/workflows/build-development.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: echo "time=$(date -Iseconds)" >> $GITHUB_OUTPUT
2828
- name: yarn install and build
2929
run: |
30-
yarn install --frozen-lockfile
30+
yarn install --immutable
3131
yarn run build
3232
env:
3333
REACT_APP_URL_SHORTENER_SIGNATURE: ${{ secrets.REACT_APP_URL_SHORTENER_SIGNATURE }}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
node-version: 20
3737
cache: yarn
3838
- name: Install dependencies
39-
run: yarn install --frozen-lockfile
39+
run: yarn install --immutable
4040
- name: Run command
4141
run: yarn run ${{ matrix.commands }}
4242
- name: Coveralls - Upload test coverage report

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,19 @@ yarn-error.log
3434
# emacs backup files
3535

3636
*~
37+
38+
# yarn files
39+
40+
.yarn/*
41+
!.yarn/patches
42+
!.yarn/plugins
43+
!.yarn/releases
44+
!.yarn/sdks
45+
!.yarn/versions
46+
47+
# Swap the comments on the following lines if you wish to use zero-installs
48+
# In that case, don't forget to run `yarn config set enableGlobalCache false`!
49+
# Documentation here: https://yarnpkg.com/features/caching#zero-installs
50+
51+
#!.yarn/cache
52+
.pnp.*

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

craco.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ const cracoConfig = {
139139
'split-on-first',
140140
'filter-obj',
141141
'@sourceacademy/c-slang',
142-
'java-parser'
142+
'java-parser',
143+
'sa-conductor'
143144
),
144145
'^.+\\.module\\.(css|sass|scss)$'
145146
];

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"private": true,
33
"name": "frontend",
4+
"packageManager": "yarn@4.6.0",
45
"version": "1.4.3",
56
"scripts-info": {
67
"analyze": "Analyze bundle size breakdown",
@@ -91,6 +92,8 @@
9192
"redux-mock-store": "^1.5.4",
9293
"redux-saga": "^1.2.3",
9394
"rehype-react": "^8.0.0",
95+
"sa-conductor": "https://github.com/tsammeow/sa-conductor.git#0.1.4",
96+
"sa-languages": "https://github.com/source-academy/sa-languages.git",
9497
"showdown": "^2.1.0",
9598
"sourceror": "^0.8.5",
9699
"unified": "^11.0.0",
@@ -138,7 +141,6 @@
138141
"cross-env": "^7.0.3",
139142
"eslint": "^9.9.0",
140143
"eslint-plugin-react": "^7.35.0",
141-
"//": "See: https://github.com/facebook/react/issues/28313#issuecomment-2076798972, https://github.com/t3-oss/create-t3-turbo/issues/984#issuecomment-2076413457",
142144
"eslint-plugin-react-hooks": "5.1.0-canary-cb151849e1-20240424",
143145
"eslint-plugin-react-refresh": "^0.4.9",
144146
"eslint-plugin-simple-import-sort": "^12.1.1",
@@ -164,7 +166,7 @@
164166
"webpack-bundle-analyzer": "^4.9.0"
165167
},
166168
"resolutions": {
167-
"**/gl": "^8.0.2"
169+
"gl": "^8.0.2"
168170
},
169171
"browserslist": {
170172
"production": [

src/commons/application/ApplicationTypes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PlaybackStatus, RecordingStatus } from '../../features/sourceRecorder/S
77
import { StoriesEnvState, StoriesState } from '../../features/stories/StoriesTypes';
88
import { freshSortState } from '../../pages/academy/grading/subcomponents/GradingSubmissionsTable';
99
import { WORKSPACE_BASE_PATHS } from '../../pages/fileSystem/createInBrowserFileSystem';
10+
import { defaultFeatureFlags, FeatureFlagsState } from '../featureFlags';
1011
import { FileSystemState } from '../fileSystem/FileSystemTypes';
1112
import { SideContentManagerState, SideContentState } from '../sideContent/SideContentTypes';
1213
import Constants from '../utils/Constants';
@@ -29,6 +30,7 @@ export type OverallState = {
2930
readonly stories: StoriesState;
3031
readonly workspaces: WorkspaceManagerState;
3132
readonly dashboard: DashboardState;
33+
readonly featureFlags: FeatureFlagsState;
3234
readonly fileSystem: FileSystemState;
3335
readonly sideContent: SideContentManagerState;
3436
};
@@ -612,6 +614,7 @@ export const defaultState: OverallState = {
612614
session: defaultSession,
613615
stories: defaultStories,
614616
workspaces: defaultWorkspaceManager,
617+
featureFlags: defaultFeatureFlags,
615618
fileSystem: defaultFileSystem,
616619
sideContent: defaultSideContentManager
617620
};

src/commons/application/reducers/RootReducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { combineReducers, Reducer } from '@reduxjs/toolkit';
2+
import { FeatureFlagsReducer as featureFlags } from 'src/commons/featureFlags';
23
import { SourceActionType } from 'src/commons/utils/ActionsHelper';
34

45
import { AchievementReducer as achievement } from '../../../features/achievement/AchievementReducer';
@@ -20,6 +21,7 @@ const rootReducer: Reducer<OverallState, SourceActionType> = combineReducers({
2021
session,
2122
stories,
2223
workspaces,
24+
featureFlags,
2325
fileSystem,
2426
sideContent
2527
});

src/commons/controlBar/ControlBarAutorunButtons.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { Switch } from '@blueprintjs/core';
22
import { IconNames } from '@blueprintjs/icons';
33
import React from 'react';
4+
import { flagConductorEnable } from 'src/features/conductor/flagConductorEnable';
45

56
import ControlButton from '../ControlButton';
7+
import { useFeature } from '../featureFlags/useFeature';
68
import { useResponsive } from '../utils/Hooks';
79
import { ControlBarRunButton } from './ControlBarRunButton';
810

@@ -46,7 +48,8 @@ export const ControlBarAutorunButtons: React.FC<ControlBarAutorunButtonProps> =
4648

4749
// stop button does not do anything due to the blocking nature of eval methods (e.g. runInContext)
4850
// to prevent "flickering", we will just disable Stop Button for now
49-
const showStopButton = false && (
51+
const conductorEnabled = useFeature(flagConductorEnable);
52+
const showStopButton = conductorEnabled && props.isRunning && (
5053
<ControlButton label="Stop" icon={IconNames.STOP} onClick={props.handleInterruptEval} />
5154
);
5255

@@ -87,7 +90,14 @@ export const ControlBarAutorunButtons: React.FC<ControlBarAutorunButtonProps> =
8790
/>
8891
</div>
8992
)}
90-
{showAutoRunIndicator || showStopButton || showRunButton}
93+
{conductorEnabled ? (
94+
<>
95+
{showAutoRunIndicator || showRunButton}
96+
{showStopButton}
97+
</>
98+
) : (
99+
showAutoRunIndicator || showStopButton || showRunButton
100+
)}
91101
{showDebuggerPause}
92102
{showDebuggerResume}
93103
{showDebuggerReset('Stop Debugger')}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { Tooltip } from '@blueprintjs/core';
22
import { IconNames } from '@blueprintjs/icons';
33
import React from 'react';
4+
import { flagConductorEnable } from 'src/features/conductor/flagConductorEnable';
45

56
import ControlButton from '../ControlButton';
7+
import { useFeature } from '../featureFlags/useFeature';
68

79
type Props = {
810
handleReplEval: () => void;
911
isRunning: boolean;
1012
};
1113

1214
export const ControlBarEvalButton: React.FC<Props> = ({ handleReplEval, isRunning }) => {
13-
return isRunning ? null : (
15+
const conductorEnabled = useFeature(flagConductorEnable);
16+
const showEvalButton = conductorEnabled ? isRunning : !isRunning;
17+
return showEvalButton ? (
1418
<Tooltip content="...or press shift-enter in the REPL">
1519
<ControlButton label="Eval" icon={IconNames.CODE} onClick={handleReplEval} />
1620
</Tooltip>
17-
);
21+
) : null;
1822
};

0 commit comments

Comments
 (0)