Skip to content

Sessions Overhaul #3140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2afd465
Feature: Add temporary session ID indicator in primary popup and plac…
salmonkarp Feb 5, 2025
60a4ae8
Merge remote-tracking branch 'origin/master' into sessions-overhaul
salmonkarp Feb 5, 2025
4324746
Add AceMultiSelectionManager"
TheMythologist Feb 14, 2025
c57c738
Revert first commit
TheMythologist Feb 20, 2025
2548634
Add AceRadarView
TheMythologist Feb 20, 2025
862c17a
Add basic information to Session Management Tab
salmonkarp Feb 21, 2025
727284f
Clean up `useShareAce` implementation
TheMythologist Feb 21, 2025
5ffaa89
Merge branch 'sessions-overhaul' of https://github.com/source-academy…
TheMythologist Feb 21, 2025
0862623
Use proper role enum
TheMythologist Feb 21, 2025
fbf3de7
Basid user display with updated binding
salmonkarp Mar 13, 2025
bec06c5
Cleanup and fix missing ace-build require
TheMythologist Mar 13, 2025
846571e
Implement changing of language
TheMythologist Mar 13, 2025
696b7cc
More cleanup and fix invalid source chapter strings
TheMythologist Mar 14, 2025
0bc2bf1
Cleanup WIP
TheMythologist Mar 14, 2025
d2c5ebb
Cleanup Part 2
TheMythologist Mar 14, 2025
1cea88e
Implement changing of roles
TheMythologist Mar 15, 2025
fc9fa73
Combine viewing and editing sessionIds into 1
TheMythologist Mar 15, 2025
bfab102
Refactor to functional component to prepare for local storage
TheMythologist Mar 16, 2025
6c8dd11
Update moduleResolution to bundler
TheMythologist Mar 16, 2025
cfbd599
Add description and styles of management tab
salmonkarp Mar 20, 2025
7b42fa3
Simplify session creation/joining/leaving into one popover
salmonkarp Mar 20, 2025
a0efc24
Cleanup and add toggle of default role upon join
salmonkarp Mar 27, 2025
fb535d1
Add prototype link sharing
salmonkarp Mar 27, 2025
1fcbd8e
Add bad navigation bar fix
salmonkarp Apr 3, 2025
e07521b
Add consistent URL behaviour on session creation and exit
salmonkarp Apr 4, 2025
e4f0119
ui: hide toggle for admins
TheMythologist Apr 4, 2025
1aeb5b1
ui: Reflect ownership in button modal
TheMythologist Apr 4, 2025
9867f68
cleanup
TheMythologist Apr 4, 2025
679bfdd
UI cleanup
TheMythologist Apr 4, 2025
200d5e9
hotfix
TheMythologist Apr 16, 2025
e784dac
ui: non-admins can see role too
TheMythologist Apr 16, 2025
7ab7006
Blinking fix
salmonkarp May 14, 2025
33141e0
Formatting
TheMythologist Jun 23, 2025
3cd5e4b
Merge branch 'master' into sessions-overhaul
TheMythologist Jun 23, 2025
76eb241
Remove unnecessary comments
TheMythologist Jun 23, 2025
a37ef17
Fix lint errors
TheMythologist Jun 23, 2025
bf86dda
Formatting
TheMythologist Jun 24, 2025
5d29267
Fix import error
RichDom2185 Jun 25, 2025
8958b5f
Merge branch 'master' into sessions-overhaul
RichDom2185 Jun 25, 2025
d2af4fe
Reduce unnecessary changes
TheMythologist Jun 26, 2025
ed93f38
Fix `WritableDraft` errors
TheMythologist Jun 26, 2025
025c90d
Fix constant refreshing on direct playground code access
TheMythologist Jun 26, 2025
cdfa2aa
Removed some unncessary code
salmonkarp Jun 26, 2025
8080016
Merge branches 'sessions-overhaul' and 'master' of https://github.com…
RichDom2185 Jun 27, 2025
0919f11
Deduplicate dependencies
RichDom2185 Jun 27, 2025
2f9502f
Fix breaking changes post-merge
RichDom2185 Jun 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@blueprintjs/datetime2": "^2.3.3",
"@blueprintjs/icons": "^5.9.0",
"@blueprintjs/select": "^5.1.3",
"@convergencelabs/ace-collab-ext": "^0.6.0",
"@mantine/hooks": "^7.11.2",
"@octokit/rest": "^20.0.0",
"@reduxjs/toolkit": "^1.9.7",
Expand All @@ -43,7 +44,7 @@
"@szhsin/react-menu": "^4.0.0",
"@tanstack/react-table": "^8.9.3",
"@tremor/react": "^1.8.2",
"ace-builds": "^1.36.3",
"ace-builds": "^1.42.1",
"acorn": "^8.9.0",
"ag-grid-community": "^32.3.1",
"ag-grid-react": "^32.3.1",
Expand All @@ -58,6 +59,7 @@
"hastscript": "^9.0.0",
"i18next": "^25.0.0",
"i18next-browser-languagedetector": "^8.0.0",
"immer": "^10.1.1",
"java-slang": "^1.0.13",
"js-cookie": "^3.0.5",
"js-slang": "^1.0.84",
Expand Down Expand Up @@ -126,7 +128,7 @@
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.4.3",
"@testing-library/user-event": "^14.6.0",
"@types/estree": "^1.0.5",
"@types/gapi": "^0.0.47",
"@types/gapi.auth2": "^0.0.61",
Expand Down
3 changes: 2 additions & 1 deletion src/commons/application/ApplicationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ export const createDefaultWorkspace = (workspaceLocation: WorkspaceLocation): Wo
enableDebugging: true,
debuggerContext: {} as DebuggerContext,
lastDebuggerResult: undefined,
files: {}
files: {},
updateUserRoleCallback: () => {}
});

const defaultFileName = 'program.js';
Expand Down
18 changes: 16 additions & 2 deletions src/commons/collabEditing/CollabEditingActions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { CollabEditingAccess } from '@sourceacademy/sharedb-ace/types';

Check failure on line 1 in src/commons/collabEditing/CollabEditingActions.ts

View workflow job for this annotation

GitHub Actions / lint (tsc)

Cannot find module '@sourceacademy/sharedb-ace/types' or its corresponding type declarations.

Check failure on line 1 in src/commons/collabEditing/CollabEditingActions.ts

View workflow job for this annotation

GitHub Actions / lint (build)

Cannot find module '@sourceacademy/sharedb-ace/types' or its corresponding type declarations.

import { createActions } from '../redux/utils';
import { WorkspaceLocation } from '../workspace/WorkspaceTypes';

Expand All @@ -8,7 +10,7 @@
}),
setSessionDetails: (
workspaceLocation: WorkspaceLocation,
sessionDetails: { docId: string; readOnly: boolean } | null
sessionDetails: { docId?: string; readOnly?: boolean; owner?: boolean } | null
) => ({ workspaceLocation, sessionDetails }),
/**
* Sets ShareDB connection status.
Expand All @@ -19,11 +21,23 @@
setSharedbConnected: (workspaceLocation: WorkspaceLocation, connected: boolean) => ({
workspaceLocation,
connected
}),
setUpdateUserRoleCallback: (
workspaceLocation: WorkspaceLocation,
updateUserRoleCallback: (id: string, newRole: CollabEditingAccess) => void
) => ({
workspaceLocation,
updateUserRoleCallback
})
});

// For compatibility with existing code (reducer)
export const { setEditorSessionId, setSessionDetails, setSharedbConnected } = CollabEditingActions;
export const {
setEditorSessionId,
setSessionDetails,
setSharedbConnected,
setUpdateUserRoleCallback
} = CollabEditingActions;

// For compatibility with existing code (actions helper)
export default CollabEditingActions;
28 changes: 26 additions & 2 deletions src/commons/collabEditing/CollabEditingHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ export function getSessionUrl(sessionId: string, ws?: boolean): string {
return url.toString();
}

export function getPlaygroundSessionUrl(sessionId: string): string {
let url = window.location.href;
if (window.location.href.endsWith('/playground')) {
url += `/${sessionId}`;
}
return url;
}

export async function getDocInfoFromSessionId(
sessionId: string
): Promise<{ docId: string; readOnly: boolean } | null> {
): Promise<{ docId: string; defaultReadOnly: boolean } | null> {
const resp = await fetch(getSessionUrl(sessionId));

if (resp && resp.ok) {
Expand All @@ -27,7 +35,7 @@ export async function getDocInfoFromSessionId(

export async function createNewSession(
contents: string
): Promise<{ docId: string; sessionEditingId: string; sessionViewingId: string }> {
): Promise<{ docId: string; sessionId: string }> {
const resp = await fetch(Constants.sharedbBackendUrl, {
method: 'POST',
body: JSON.stringify({ contents }),
Expand All @@ -42,3 +50,19 @@ export async function createNewSession(

return resp.json();
}

export async function changeDefaultEditable(sessionId: string, defaultReadOnly: boolean) {
const resp = await fetch(getSessionUrl(sessionId), {
method: 'PATCH',
body: JSON.stringify({ defaultReadOnly }),
headers: { 'Content-Type': 'application/json' }
});

if (!resp || !resp.ok) {
throw new Error(
resp ? `Could not update session: ${await resp.text()}` : 'Unknown error updating session'
);
}

return resp.json();
}
Loading
Loading