Skip to content

Commit 11f0b71

Browse files
committed
Ensure collaboration is working as expected
1 parent dde14ec commit 11f0b71

File tree

8 files changed

+118
-12
lines changed

8 files changed

+118
-12
lines changed

CLAUDE.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ npm run type-check # TypeScript checking
2525
npm run check # Run all checks (format, lint, type)
2626
npm run check:fix # Auto-fix and check all
2727
npm test # Run tests
28+
29+
# Development Examples (packages/react)
30+
cd packages/react
31+
npm run start # Start with remote server config
32+
npm run start-local # Start with local server (both webpack + jupyter)
33+
npm run start-local:webpack # Start only webpack with local config
2834
```
2935

3036
## Requirements
@@ -39,9 +45,12 @@ npm test # Run tests
3945
- `.prettierrc.json` - Formatter config
4046
- `.prettierignore` - Excludes MDX files
4147
- `patches/` - Third-party fixes (auto-applied)
42-
- `packages/react/webpack.config.js` - Build config
48+
- `packages/react/webpack.config.js` - Build config (change ENTRY to switch examples)
49+
- `packages/react/public/index.html` - Remote server config
50+
- `packages/react/public/index-local.html` - Local server config
51+
- `dev/config/jupyter_server_config.py` - Jupyter server settings
4352

44-
## Recent Fixes (2024)
53+
## Recent Fixes (2024-2025)
4554

4655
- MDX comments: `{/_``{/** **/}` in 13 files
4756
- Node requirement: 18 → 20+
@@ -51,16 +60,58 @@ npm test # Run tests
5160
- React 18 deprecations fixed
5261
- Storybook CI: Added wait-on and --url for test reliability
5362
- Terminal component: Fixed BoxPanel initialization issue
63+
- **Collaboration fix**: Updated WebSocket room path from `api/collaboration/document` to `api/collaboration/room` for jupyter-collaboration v4.x compatibility
5464

5565
## Common Issues
5666

5767
1. **Storybook errors**: Check MDX syntax, run `npx patch-package`
5868
2. **Node version**: Use Node 20+ (`nvm use`)
5969
3. **Lint errors**: Run `npm run lint:fix`
6070
4. **Build fails**: Run `npm run type-check`
71+
5. **Collaboration not working**:
72+
- Ensure `jupyter-collaboration` is installed (`pip install jupyter-collaboration`)
73+
- Enable in config: `c.LabApp.collaborative = True` in `dev/config/jupyter_server_config.py`
74+
- Restart Jupyter server after config changes
75+
- Check WebSocket connections are not blocked
76+
77+
## Testing Collaboration
78+
79+
1. **Install dependencies**:
80+
81+
```bash
82+
pip install jupyter-collaboration jupyterlab
83+
```
84+
85+
2. **Enable collaboration** in `dev/config/jupyter_server_config.py`:
86+
87+
```python
88+
c.LabApp.collaborative = True
89+
```
90+
91+
3. **Start servers**:
92+
93+
```bash
94+
npm run jupyter:server # Terminal 1
95+
cd packages/react && npm run start-local:webpack # Terminal 2
96+
```
97+
98+
4. **Test**: Open http://localhost:3208/ in two browser windows
99+
100+
## Example Selection
101+
102+
To change the example being served, edit `packages/react/webpack.config.js`:
103+
104+
```javascript
105+
const ENTRY = './src/examples/NotebookCollaborative'; // Change this line
106+
```
107+
108+
Then restart webpack.
61109

62110
## AI Assistant Notes
63111

64112
- Always use npm, not yarn
65113
- Prefer editing over creating files
66114
- Run lint/type checks before committing
115+
- Comment out old code instead of deleting when making changes
116+
117+
- Use the playwright MCP server when you need to actually see how the frendered pages look

dev/config/jupyter_server_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@
106106
# JupyterLab
107107
#################
108108

109-
c.LabApp.collaborative = False
109+
c.LabApp.collaborative = True

dev/notebooks/collaboration.ipynb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Collaboration Example\n",
8+
"This notebook is for testing real-time collaboration."
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"metadata": {},
15+
"outputs": [],
16+
"source": [
17+
"print('Hello from collaboration notebook!')"
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": null,
23+
"metadata": {},
24+
"outputs": [],
25+
"source": [
26+
"# Test collaboration by editing this cell\n",
27+
"x = 10a\n",
28+
"y = 20asd\n",
29+
"print(f'x + y = {x + y}') asass"
30+
]
31+
}
32+
],
33+
"metadata": {
34+
"kernelspec": {
35+
"display_name": "Python 3 (ipykernel)",
36+
"language": "python",
37+
"name": "python3"
38+
},
39+
"language_info": {
40+
"codemirror_mode": {
41+
"name": "ipython",
42+
"version": 3
43+
},
44+
"file_extension": ".py",
45+
"mimetype": "text/x-python",
46+
"name": "python",
47+
"nbconvert_exporter": "python",
48+
"pygments_lexer": "ipython3",
49+
"version": "3.13.5"
50+
}
51+
},
52+
"nbformat": 4,
53+
"nbformat_minor": 4
54+
}

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"start-noconfig": "cross-env NO_CONFIG=true webpack serve",
5555
"start-local": "run-p -c 'start-local:*'",
5656
"start-local:webpack": "cross-env LOCAL_JUPYTER_SERVER=true webpack serve",
57-
"start-local:jupyter-server": "cd ./../.. && make start-jupyter-server",
57+
"start-local:jupyter-server": "cd ./../.. && npm run jupyter:server",
5858
"stylelint": "npm stylelint:check --fix",
5959
"stylelint:check": "stylelint --cache \"style/**/*.css\"",
6060
"test": "jest --coverage",

packages/react/public/index-local.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"appUrl": "/lab",
2929
"themesUrl": "/lab/api/themes",
3030
"disableRTC": false,
31-
"terminalsAvailable": "false",
31+
"terminalsAvailable": "true",
3232
"mathjaxUrl": "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js",
3333
"mathjaxConfig": "TeX-AMS_CHTML-full,Safe"
3434
}

packages/react/src/components/notebook/Notebook.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ export const Notebook = (props: INotebookProps) => {
301301
if (collaborative == 'jupyter') {
302302
const token =
303303
jupyterReactStore.getState().jupyterConfig?.jupyterServerToken;
304+
304305
const session = await requestJupyterCollaborationSession(
305306
'json',
306307
'notebook',

packages/react/src/jupyter/collaboration/JupyterCollaboration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { URLExt } from '@jupyterlab/coreutils';
88
import { Contents, ServerConnection } from '@jupyterlab/services';
99

10-
export const COLLABORATION_ROOM_URL_PATH = 'api/collaboration/document';
10+
export const COLLABORATION_ROOM_URL_PATH = 'api/collaboration/room';
1111

1212
export const COLLABORATION_SESSION_URL_PATH = 'api/collaboration/session';
1313

packages/react/webpack.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ const ENTRY =
4949
// './src/examples/NotebookCellSidebar';
5050
// './src/examples/NotebookCellToolbar';
5151
// './src/examples/NotebookColormode';
52-
// './src/examples/NotebookCollaborative';
53-
// './src/examples/NotebookExtension';
54-
// './src/examples/NotebookKernel';
55-
// './src/examples/NotebookKernelChange';
56-
// './src/examples/NotebookLess';
57-
'./src/examples/NotebookLite';
52+
'./src/examples/NotebookCollaborative';
53+
// './src/examples/NotebookExtension';
54+
// './src/examples/NotebookKernel';
55+
// './src/examples/NotebookKernelChange';
56+
// './src/examples/NotebookLess';
57+
// './src/examples/NotebookLite';
5858
// './src/examples/NotebookLiteContext';
5959
// './src/examples/NotebookLocalServer';
6060
// './src/examples/NotebookMutationsKernel';

0 commit comments

Comments
 (0)