Skip to content

Commit 94adc97

Browse files
authored
feat: orchestration bar and activity plan (#104)
app can be used autonomously feat(orchestration): next step button feat(orchestration): steps buttons and round feat: timer fix: remove stepper in response collection add cancel button for input phase test: add correct selectors refactor: pausable use activity context feat: change response handling response visibilitiy is set to item fix: refetch data before creating sets feat: next step color change when time is out feat: reformulate responses with bot fix(assistants): reformulation prompt fix: useAssistants prompt refactor: move steps logic into new hook feat(actions): record action for next step feat(actions): post action when moving back to previous step fix: start first step when playing activity for the first time feat: record actions on play/pause close #54 fix(deps): upgrade @graasp sdk & apps-query-client test: fix test for new release of sdk & apps-query-client refactor: factor out default lang feat: add dialog to prevent undesired switch to next step chore: clean code
1 parent 395c9e6 commit 94adc97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2166
-1729
lines changed

cypress.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ export default defineConfig({
1111
VITE_GRAASP_APP_KEY: process.env.VITE_GRAASP_APP_KEY,
1212
},
1313
retries: { runMode: 1, openMode: 0 },
14-
// We've imported your old cypress plugins here.
15-
// You may want to clean this up later by importing these.
1614
setupNodeEvents(on, config) {
1715
registerCodeCoverage(on, config);
1816
return config;

cypress/fixtures/appSettings.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { AppSetting } from '@graasp/sdk';
33
import { AllSettingsType } from '@/config/appSettingsType';
44
import { DEFAULT_SYSTEM_PROMPT } from '@/config/prompts';
55
import { EvaluationType } from '@/interfaces/evaluationType';
6-
import { ResponseVisibilityMode } from '@/interfaces/interactionProcess';
6+
import {
7+
ActivityType,
8+
ResponseVisibilityMode,
9+
} from '@/interfaces/interactionProcess';
710

811
import { MEMBERS } from './members';
912
import { MOCK_SERVER_DISCRIMINATED_ITEM } from './mockItem';
@@ -47,6 +50,24 @@ export const ALL_SETTINGS_OBJECT: AllSettingsType = {
4750
numberOfBotResponsesPerSet: 1,
4851
exclusiveResponseDistribution: true,
4952
evaluationType: EvaluationType.UsefulnessNoveltyRating,
53+
steps: [
54+
{
55+
type: ActivityType.Collection,
56+
round: 0,
57+
time: 60,
58+
},
59+
{
60+
type: ActivityType.Collection,
61+
round: 1,
62+
time: 60,
63+
},
64+
{
65+
type: ActivityType.Evaluation,
66+
round: 2,
67+
time: 120,
68+
},
69+
],
70+
reformulateResponses: false,
5071
},
5172
notParticipating: { ids: [] },
5273
chatbot: {

cypress/fixtures/mockItem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const MOCK_SERVER_DISCRIMINATED_ITEM: DiscriminatedItem = {
2121
url: '',
2222
},
2323
},
24+
lang: 'en',
2425
createdAt: MOCK_SERVER_ITEM.createdAt.toISOString(),
2526
updatedAt: MOCK_SERVER_ITEM.updatedAt.toISOString(),
2627
};

index.html

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/light_bulb.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<meta name="Graasp App Collaborative Ideation" content="A Graasp App for generating ideas together." />
7+
<meta
8+
name="Graasp App Collaborative Ideation"
9+
content="A Graasp App for generating ideas together."
10+
/>
811
<meta name="version-info" content="%VITE_VERSION%" />
9-
<!--
10-
manifest.json provides metadata used when your web app is installed on a
11-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
12-
-->
13-
<link rel="manifest" href="/manifest.json" />
14-
<!-- Load Roboto font from Google fonts -->
1512
<link
1613
rel="stylesheet"
1714
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@
2626
"@codemirror/lang-javascript": "^6.2.1",
2727
"@emotion/react": "11.11.4",
2828
"@emotion/styled": "11.11.0",
29-
"@graasp/apps-query-client": "^3.4.4",
30-
"@graasp/sdk": "3.6.0",
31-
"@mui/icons-material": "5.15.12",
32-
"@mui/lab": "5.0.0-alpha.167",
33-
"@mui/material": "5.15.12",
29+
"@graasp/apps-query-client": "^3.4.8",
30+
"@graasp/sdk": "4.1.0",
31+
"@mui/icons-material": "5.15.11",
32+
"@mui/lab": "5.0.0-alpha.166",
33+
"@mui/material": "5.15.11",
3434
"@mui/x-data-grid": "^6.19.4",
3535
"@sentry/react": "7.104.0",
3636
"@tanstack/react-query": "^4.36.1",
3737
"@tanstack/react-query-devtools": "^4.36.1",
3838
"@uiw/react-codemirror": "^4.21.22",
3939
"date-fns": "^3.3.1",
4040
"i18next": "23.10.0",
41+
"liquidjs": "^10.10.1",
4142
"lodash.isequal": "^4.5.0",
4243
"lodash.shuffle": "^4.2.0",
4344
"plotly.js": "^2.29.1",

src/config/appActionsTypes.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Data, LocalContext } from '@graasp/apps-query-client';
22
import { AppAction, AppData } from '@graasp/sdk';
33

4+
import { ActivityStep } from '@/interfaces/interactionProcess';
45
import {
5-
AnonymousResponseData,
66
CurrentStateData,
77
RatingsData,
8+
ResponseAppData,
89
ResponseData,
910
} from './appDataTypes';
1011

@@ -16,6 +17,10 @@ export enum AppActionTypes {
1617
EvaluateResponse = 'evaluate-response',
1718
ChangeActivityState = 'change-activity-state',
1819
PromptAssistant = 'prompt-assistant',
20+
NextStep = 'next-step',
21+
PreviousStep = 'previous-step',
22+
PlayActivity = 'play-activity',
23+
PauseActivity = 'pause-activity',
1924
}
2025

2126
type AppDataRef<T extends Data> = Pick<AppData<T>, 'id' | 'type' | 'data'> &
@@ -33,7 +38,7 @@ export type DeleteResponseAction = Pick<AppAction, 'type' | 'data'> & {
3338

3439
export type ChooseResponseAction = Pick<AppAction, 'type' | 'data'> & {
3540
type: AppActionTypes.ChooseResponse;
36-
data: AnonymousResponseData;
41+
data: ResponseAppData;
3742
};
3843

3944
export type OpenAppAction = Pick<AppAction, 'type' | 'data'> & {
@@ -48,3 +53,23 @@ export type EvaluateResponseAction<T> = Pick<AppAction, 'type' | 'data'> & {
4853
type: AppActionTypes.EvaluateResponse;
4954
data: AppDataRef<RatingsData<T>>;
5055
};
56+
57+
type StepAction = Pick<AppAction, 'type' | 'data'> & {
58+
data: ActivityStep & { stepIndex: number };
59+
};
60+
61+
export type NextStepAction = StepAction & {
62+
type: AppActionTypes.NextStep;
63+
};
64+
65+
export type PreviousStepAction = StepAction & {
66+
type: AppActionTypes.PreviousStep;
67+
};
68+
69+
export type PlayActivityAction = Pick<AppAction, 'type' | 'data'> & {
70+
type: AppActionTypes.PlayActivity;
71+
};
72+
73+
export type PauseActivityAction = Pick<AppAction, 'type' | 'data'> & {
74+
type: AppActionTypes.PauseActivity;
75+
};

src/config/appDataTypes.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,24 @@ export type ResponseData<T = UsefulnessNoveltyRatings> = {
1818
response: string;
1919
round?: number;
2020
bot?: boolean;
21+
assistantId?: AssistantId;
2122
parentId?: string;
22-
encoding?: 'text' | 'markdown';
23+
encoding?: 'raw' | 'markdown';
24+
originalResponse?: string;
2325
ratings?: T;
2426
};
2527

26-
export type AnonymousResponseData<RatingsT = UsefulnessNoveltyRatings> =
27-
ResponseData<RatingsT> & { id: string };
28-
29-
export type ResponsesData<RatingsT = UsefulnessNoveltyRatings> =
30-
AnonymousResponseData<RatingsT>[];
31-
3228
export type ResponseAppData = AppData & {
3329
type: AppDataTypes.Response;
3430
data: ResponseData;
31+
visibility: AppDataVisibility.Item;
3532
};
3633

3734
export type ResponsesSetAppData = AppData & {
3835
type: AppDataTypes.ResponsesSet;
3936
data: {
4037
round: number;
41-
responses: ResponsesData;
38+
responses: Array<ResponseAppData['id']>;
4239
assistant?: AssistantId;
4340
};
4441
};
@@ -47,6 +44,8 @@ export type CurrentStateData = {
4744
round?: number;
4845
status: ActivityStatus;
4946
activity: ActivityType;
47+
startTime: Date;
48+
stepIndex?: number;
5049
};
5150

5251
export type CurrentStateAppData = AppData & {

src/config/appSettingsType.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { Member } from '@graasp/sdk';
22

33
import { AssistantPersona } from '@/interfaces/assistant';
44
import { EvaluationType } from '@/interfaces/evaluationType';
5-
import { ResponseVisibilityMode } from '@/interfaces/interactionProcess';
5+
import {
6+
ActivityStep,
7+
ActivityType,
8+
ResponseVisibilityMode,
9+
} from '@/interfaces/interactionProcess';
610

711
import { DEFAULT_SYSTEM_PROMPT } from './prompts';
812

@@ -29,6 +33,8 @@ export type ActivitySetting = {
2933
numberOfBotResponsesPerSet: number;
3034
exclusiveResponseDistribution: boolean;
3135
evaluationType: EvaluationType;
36+
steps: ActivityStep[];
37+
reformulateResponses: boolean;
3238
};
3339

3440
export type AssistantsSetting = {
@@ -63,8 +69,35 @@ export const defaultSettingsValues: AllSettingsType = {
6369
mode: ResponseVisibilityMode.Open,
6470
numberOfResponsesPerSet: 3,
6571
numberOfBotResponsesPerSet: 1,
66-
exclusiveResponseDistribution: true,
72+
exclusiveResponseDistribution: false,
6773
evaluationType: EvaluationType.UsefulnessNoveltyRating,
74+
reformulateResponses: false,
75+
steps: [
76+
{
77+
type: ActivityType.Collection,
78+
round: 0,
79+
time: 120,
80+
},
81+
{
82+
type: ActivityType.Collection,
83+
round: 1,
84+
time: 120,
85+
},
86+
{
87+
type: ActivityType.Collection,
88+
round: 2,
89+
time: 120,
90+
},
91+
{
92+
type: ActivityType.Collection,
93+
round: 3,
94+
time: 120,
95+
},
96+
{
97+
type: ActivityType.Evaluation,
98+
time: 180,
99+
},
100+
],
68101
},
69102
notParticipating: { ids: [] },
70103
chatbot: {

src/config/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const INITIAL_STATE: {
2020
status: ActivityStatus.WaitingForStart,
2121
activity: ActivityType.Collection,
2222
round: 0,
23+
startTime: new Date(),
2324
},
2425
visibility: AppDataVisibility.Item,
2526
};
@@ -42,3 +43,5 @@ export const DEFAULT_CHATBOT_RESPONSE_APP_DATA: Pick<
4243
};
4344

4445
export const DEFAULT_BOT_USERNAME = 'GraaspBot';
46+
export const SHORT_TIME_LIMIT = 10; // seconds
47+
export const DEFAULT_LANG = 'en';

src/config/i18n.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import i18n from 'i18next';
44

55
import en from '../langs/en.json';
66
import fr from '../langs/fr.json';
7+
import { DEFAULT_LANG } from './constants';
78

89
export const defaultNS = 'translations';
910
export const resources = {
@@ -20,7 +21,7 @@ declare module 'react-i18next' {
2021

2122
i18n.use(initReactI18next).init({
2223
resources,
23-
lng: 'en',
24+
lng: DEFAULT_LANG,
2425
// debug only when not in production
2526
debug: import.meta.env.DEV,
2627
ns: [defaultNS],

0 commit comments

Comments
 (0)