Skip to content

Commit d7a7d34

Browse files
authored
feat: sync with CRDT (Loro)
The app now works with its own backend for syncronization (see https://github.com/swouf/collaborative-board-backend) BREAKING-CHANGE: The state is now managed with a Loro document and does not rely on AppData anymore. fix(deps): update react monorepo to v19 (major) fix(deps): update @tanstack/react-query feat: sync with custom backend using loro fix: disable https in production (protected by LB) feat: ai feedback feat: threads style: clean code test: fix cypress setup ci: disable automatic run of cypress workflow
1 parent 8ea6ae4 commit d7a7d34

File tree

123 files changed

+3149
-2465
lines changed

Some content is hidden

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

123 files changed

+3149
-2465
lines changed

.github/workflows/cypress.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Cypress UI tests
22

33
on:
4-
push:
4+
# push:
55

66
jobs:
77
cypress-run:

.github/workflows/deploy-dev.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
VITE_VERSION: ${{ github.sha }}
3333
VITE_WS_HOST: ${{ vars.WS_HOST }}
3434
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
35+
VITE_BACKEND_HOST: ${{ vars.BACKEND_HOST }}
36+
VITE_BACKEND_WS_ROUTE: ${{ vars.BACKEND_WS_ROUTE }}
3537
# add any env variable needed by your app here
3638
run: yarn build
3739
shell: bash

.github/workflows/deploy-prod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
VITE_VERSION: ${{ steps.set-version.outputs.VERSION }}
4848
VITE_WS_HOST: ${{ vars.WS_HOST }}
4949
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
50+
VITE_BACKEND_HOST: ${{ vars.BACKEND_HOST }}
51+
VITE_BACKEND_WS_ROUTE: ${{ vars.BACKEND_WS_ROUTE }}
5052
# add any env variable needed by your app here
5153
run: yarn build
5254
shell: bash

.github/workflows/deploy-stage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
VITE_VERSION: ${{ steps.set-version.outputs.VERSION }}
4848
VITE_WS_HOST: ${{ vars.WS_HOST }}
4949
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
50+
VITE_BACKEND_HOST: ${{ vars.BACKEND_HOST }}
51+
VITE_BACKEND_WS_ROUTE: ${{ vars.BACKEND_WS_ROUTE }}
5052
# add any env variable needed by your app here
5153
run: yarn build
5254
shell: bash

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ cypress/downloads/
4848
*.pem
4949
*.crt
5050
*.key
51+
52+
# TS
53+
*.tsbuildinfo

cypress.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export default defineConfig({
1010
VITE_API_HOST: process.env.VITE_API_HOST,
1111
VITE_ENABLE_MOCK_API: process.env.VITE_ENABLE_MOCK_API,
1212
VITE_GRAASP_APP_KEY: process.env.VITE_GRAASP_APP_KEY,
13+
VITE_BACKEND_HOST: process.env.VITE_BACKEND_HOST,
14+
VITE_BACKEND_ROUTE: process.env.VITE_BACKEND_ROUTE,
1315
},
1416
retries: { runMode: 1, openMode: 0 },
1517
setupNodeEvents(on, config) {

cypress/fixtures/appData.ts

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

33
import { AppDataTypes } from '@/config/appDataTypes';
4-
import { ActivityStatus, ActivityType } from '@/interfaces/interactionProcess';
4+
import { ActivityStatus, ActivityType } from '@/interfaces/activity_state';
55
import { ResponseData } from '@/interfaces/response';
66

77
import { MEMBERS } from './members';
@@ -32,7 +32,7 @@ const appDataFactory = (
3232
};
3333

3434
const responseFactory = (
35-
responseData: ResponseData,
35+
responseData: Partial<ResponseData>,
3636
account: Member,
3737
): AppData =>
3838
appDataFactory(

cypress/fixtures/appSettings.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,37 @@ import { AppSetting } from '@graasp/sdk';
33
import cloneDeep from 'lodash.clonedeep';
44

55
import { AllSettingsType } from '@/config/appSettingsType';
6-
import { AssistantType } from '@/interfaces/assistant';
7-
import { EvaluationType } from '@/interfaces/evaluation';
86
import {
97
ActivityType,
108
ResponseVisibilityMode,
11-
} from '@/interfaces/interactionProcess';
9+
} from '@/interfaces/activity_state';
10+
import { AssistantType } from '@/interfaces/assistant';
11+
import { EvaluationType } from '@/interfaces/evaluation';
1212

1313
import { MEMBERS } from './members';
1414
import { MOCK_SERVER_DISCRIMINATED_ITEM } from './mockItem';
1515

1616
let settingCounter = 0;
1717

18+
// /**
19+
// * Reads the content of a text file relative to the project root.
20+
// * @param relativePath Path to the file, relative to the project root.
21+
// * @returns The content of the file as a string.
22+
// */
23+
// function readTextFile(relativePath: string): string {
24+
// // Resolve absolute path relative to project root (process.cwd())
25+
// const absolutePath = path.resolve(process.cwd(), relativePath);
26+
27+
// try {
28+
// const content = cy.fixture(absolutePath, 'utf-8');
29+
// return content;
30+
// } catch (err) {
31+
// throw new Error(
32+
// `Failed to read file at ${absolutePath}: ${(err as Error).message}`,
33+
// );
34+
// }
35+
// }
36+
1837
const newSettingFactory = (
1938
settingName: string,
2039
data: AppSetting['data'],
@@ -61,7 +80,7 @@ export const ALL_SETTINGS_OBJECT: AllSettingsType = {
6180
id: MEMBERS.ANNA.id,
6281
},
6382
activity: {
64-
mode: ResponseVisibilityMode.Open,
83+
mode: ResponseVisibilityMode.Sync,
6584
numberOfResponsesPerSet: 3,
6685
numberOfBotResponsesPerSet: 1,
6786
exclusiveResponseDistribution: true,
@@ -93,6 +112,11 @@ export const ALL_SETTINGS_OBJECT: AllSettingsType = {
93112
selectedSet: 'test',
94113
maxNumberOfQueries: 5,
95114
},
115+
feedback: {
116+
enabled: false,
117+
systemPrompt: 'Whatever',
118+
userPrompt: 'Whatever',
119+
},
96120
};
97121

98122
export const ALL_SETTINGS = Object.entries(ALL_SETTINGS_OBJECT).map(

cypress/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"extends": "../tsconfig.eslint.json",
33
"compilerOptions": {
4-
"target": "es5",
5-
"lib": ["es5", "dom"],
4+
"target": "es6",
5+
"lib": ["es6", "dom"],
66
"types": ["cypress", "node"],
77
"esModuleInterop": true
88
},

package.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,32 @@
4141
"@nivo/boxplot": "^0.88.0",
4242
"@sentry/react": "^9.0.0",
4343
"@sentry/vite-plugin": "^3.0.0",
44-
"@tanstack/react-query": "^4.36.1",
45-
"@tanstack/react-query-devtools": "^4.36.1",
44+
"@tanstack/react-query": "4.36.1",
45+
"@tanstack/react-query-devtools": "4.36.1",
4646
"@uiw/react-codemirror": "^4.21.22",
4747
"date-fns": "^4.0.0",
4848
"dompurify": "^3.2.6",
4949
"file-saver": "^2.0.5",
5050
"highlight.js": "^11.11.1",
5151
"i18next": "24.2.2",
52-
"liquidjs": "^10.10.1",
52+
"liquidjs": "^10.21.1",
5353
"lodash.clone": "^4.5.0",
5454
"lodash.isequal": "^4.5.0",
5555
"lodash.shuffle": "^4.2.0",
56+
"loro-crdt": "^1.3.5",
5657
"lucide-react": "^0.474.0",
5758
"marked": "^15.0.12",
5859
"marked-highlight": "^2.2.1",
5960
"papaparse": "^5.4.1",
61+
"peerjs": "^1.5.4",
6062
"plotly.js": "^2.29.1",
6163
"qs": "6.14.0",
62-
"react": "18.3.1",
63-
"react-dom": "18.3.1",
64+
"react": "^19.0.0",
65+
"react-dom": "^19.0.0",
6466
"react-i18next": "15.4.0",
6567
"react-plotly.js": "^2.6.0",
6668
"react-router-dom": "^7.0.0",
67-
"typescript": "5.7.3"
69+
"typescript": "5.8.3"
6870
},
6971
"scripts": {
7072
"dev": "yarn vite",
@@ -82,7 +84,7 @@
8284
"check": "concurrently --kill-others-on-fail -s all -n \"type-check,linter,prettier\" \"yarn type-check\" \"yarn lint\" \"yarn prettier:check\"",
8385
"pre-commit": "concurrently --kill-others-on-fail -s all -n \"checks,tests\" \"yarn check\" \"yarn test\"",
8486
"cypress:open": "env-cmd -f ./.env.test cypress open",
85-
"test": "concurrently -k -s first -n \"test-server,cypress\" \"yarn start:test\" \"yarn test:ci\"",
87+
"test": "wait-on http://localhost:3433/health && concurrently -k -s first -n \"test-server,cypress\" \"yarn start:test\" \"yarn test:ci\"",
8688
"test:ci": "env-cmd -f ./.env.test cypress run --browser chrome --headless && nyc report --reporter=text --reporter=text-summary",
8789
"unit-tests": "vitest run",
8890
"cov:report": "open ./coverage/lcov-report/index.html"
@@ -106,8 +108,8 @@
106108
"@types/lodash.shuffle": "^4.2.9",
107109
"@types/node": "22.16.0",
108110
"@types/papaparse": "^5",
109-
"@types/react": "18.3.23",
110-
"@types/react-dom": "18.3.7",
111+
"@types/react": "^19.0.0",
112+
"@types/react-dom": "^19.0.0",
111113
"@types/react-plotly.js": "^2.6.3",
112114
"@typescript-eslint/eslint-plugin": "8.35.1",
113115
"@typescript-eslint/parser": "8.35.1",
@@ -138,7 +140,10 @@
138140
"vite": "^6.0.0",
139141
"vite-plugin-checker": "^0.9.0",
140142
"vite-plugin-istanbul": "^6.0.0",
141-
"vitest": "^3.0.0"
143+
"vite-plugin-top-level-await": "^1.4.4",
144+
"vite-plugin-wasm": "^3.4.1",
145+
"vitest": "^3.0.0",
146+
"wait-on": "^9.0.1"
142147
},
143148
"browserslist": {
144149
"production": [

0 commit comments

Comments
 (0)