File size: 11,139 Bytes
6f25064
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# Migration Guide: Streamlit to React/Next.js Frontend

**Version**: 1.0.0
**Last Updated**: October 2025

This guide helps existing Open Notebook users migrate from the legacy Streamlit frontend to the new React/Next.js frontend.

---

## ⚠️ Breaking Changes in v1.0

Open Notebook v1.0 introduces breaking changes that require manual migration. Please read this section carefully before upgrading.

### Docker Tag Changes

**The "latest" tag is now frozen** at the last Streamlit version. Starting with v1.0, we use versioned tags to prevent unexpected breaking changes:

- **`latest`** and **`latest-single`** β†’ FROZEN at Streamlit version (will not update)
- **`v1-latest`** and **`v1-latest-single`** β†’ NEW tags for v1.x releases (recommended)
- **`X.Y.Z`** and **`X.Y.Z-single`** β†’ Specific version tags (unchanged)

**Why this change?**
The v1.0 release brings significant architectural changes (Streamlit β†’ React/Next.js frontend). Freezing the "latest" tag prevents existing deployments from breaking unexpectedly, while the new "v1-latest" tag allows users to explicitly opt into the v1 architecture.

### Quick Migration for Docker Users

If you're currently using `latest` or `latest-single`, you need to:

1. **Update your docker-compose.yml or docker run command**:
   ```yaml
   # Before:
   image: lfnovo/open_notebook:latest-single

   # After (recommended):
   image: lfnovo/open_notebook:v1-latest-single
   ```

2. **Expose port 5055** for the API (required in v1):
   ```yaml
   ports:
     - "8502:8502"  # Frontend
     - "5055:5055"  # API (NEW - required)
   ```

3. **Verify API connectivity** after upgrade:
   ```bash
   curl http://localhost:5055/api/config
   ```

### API Connectivity (Port 5055)

**Important:** v1.0 requires port 5055 to be exposed to your host machine so the frontend can communicate with the API.

**Auto-Detection:** The Next.js frontend automatically detects the API URL:
- If you access the frontend at `http://localhost:8502`, it uses `http://localhost:5055`
- If you access the frontend at `http://192.168.1.100:8502`, it uses `http://192.168.1.100:5055`
- If you access the frontend at `http://my-server:8502`, it uses `http://my-server:5055`

**Manual Override:** If auto-detection doesn't work (e.g., reverse proxy, complex networking), set the `API_URL` environment variable:

```bash
# Docker run example
docker run -d \
  --name open-notebook \
  -p 8502:8502 -p 5055:5055 \
  -e API_URL=http://my-custom-api:5055 \
  -v ./notebook_data:/app/data \
  -v ./surreal_data:/mydata \
  lfnovo/open_notebook:v1-latest-single
```

```yaml
# docker-compose.yml example
services:
  open_notebook:
    image: lfnovo/open_notebook:v1-latest-single
    ports:
      - "8502:8502"
      - "5055:5055"
    environment:
      - API_URL=http://my-custom-api:5055
    volumes:
      - ./notebook_data:/app/data
      - ./surreal_data:/mydata
```

### Health Check

Verify your API is accessible with:

```bash
# Local deployment
curl http://localhost:5055/api/config

# Remote deployment
curl http://your-server-ip:5055/api/config
```

Expected response:
```json
{
  "version": "1.0.0",
  "latestVersion": "1.0.0",
  "hasUpdate": false,
  "dbStatus": "online"
}
```

Note: The API URL is now auto-detected by the frontend from the hostname you're accessing, so `/api/config` no longer returns `apiUrl`.

### Troubleshooting

**Problem:** Frontend shows "Cannot connect to API" error
- **Check:** Is port 5055 exposed? Run `docker ps` and verify port mapping
- **Check:** Can you reach the API? Run `curl http://localhost:5055/api/config`
- **Solution:** If using custom networking, set `API_URL` environment variable

**Problem:** Auto-detection uses wrong hostname
- **Example:** Frontend at `http://internal-hostname:8502` but API should use `http://public-hostname:5055`
- **Solution:** Set `API_URL=http://public-hostname:5055` environment variable

**Problem:** Still running the old Streamlit version after `docker pull`
- **Check:** Are you using the "latest" tag? It's frozen at Streamlit version
- **Solution:** Update to `v1-latest` or `v1-latest-single` tag

---

## What Changed

Open Notebook has migrated from a Streamlit-based frontend to a modern React/Next.js application. This brings significant improvements in performance, user experience, and maintainability.

### Key Changes

| Aspect | Before (Streamlit) | After (React/Next.js) |
|--------|-------------------|----------------------|
| **Frontend Framework** | Streamlit | Next.js 15 + React 18 |
| **UI Components** | Streamlit widgets | shadcn/ui + Radix UI |
| **Frontend Port** | 8502 | 8502 (unchanged) |
| **API Port** | 5055 | 5055 (unchanged) |
| **Navigation** | Sidebar with emoji icons | Clean sidebar navigation |
| **Performance** | Server-side rendering | Client-side React with API calls |
| **Customization** | Limited | Highly customizable |

### What Stayed the Same

- **Core functionality**: All features remain available
- **API backend**: FastAPI backend unchanged
- **Database**: SurrealDB unchanged
- **Data format**: No data migration needed
- **Configuration**: Same environment variables
- **Docker deployment**: Same ports and setup

## Migration Paths

### Path 1: Docker Users (Recommended)

If you're running Open Notebook via Docker, migration is automatic:

1. **Stop the current version**:
   ```bash
   docker-compose down
   ```

2. **Update to the latest image**:
   ```bash
   # Update docker-compose.yml to use v1-latest
   # Change from:
   image: lfnovo/open_notebook:latest-single
   # To:
   image: lfnovo/open_notebook:v1-latest-single
   ```

3. **Start the new version**:
   ```bash
   docker-compose pull
   docker-compose up -d
   ```

4. **Access the new frontend**:
   - Frontend: http://localhost:8502 (new React UI)
   - API Docs: http://localhost:5055/docs

**Your data is automatically preserved!** All notebooks, sources, and notes carry over seamlessly.

### Path 2: Source Code Users

If you're running from source code:

1. **Pull the latest code**:
   ```bash
   git pull origin main
   ```

2. **Install frontend dependencies**:
   ```bash
   cd frontend
   npm install
   cd ..
   ```

3. **Update Python dependencies**:
   ```bash
   uv sync
   ```

4. **Start services** (3 terminals):
   ```bash
   # Terminal 1: Database
   make database

   # Terminal 2: API
   uv run python api/main.py

   # Terminal 3: Frontend (NEW)
   cd frontend && npm run dev
   ```

5. **Access the application**:
   - Frontend: http://localhost:8502
   - API: http://localhost:5055

## Breaking Changes

### Removed Features

The following Streamlit-specific features are no longer available:

- **Streamlit cache**: Replaced with React Query caching
- **Streamlit session state**: Replaced with React state management
- **Direct file access via Streamlit**: Use API endpoints instead

### Changed Navigation

Navigation paths have been simplified:

| Old Path | New Path |
|----------|----------|
| Settings β†’ Models | Models |
| Settings β†’ Advanced | Advanced |
| Other paths | (Same but cleaner navigation) |

### API Changes

**No breaking API changes!** The REST API remains fully backward compatible.

## New Features in React Version

The React frontend brings several improvements:

### Performance
- **Faster page loads**: Client-side rendering with React
- **Better caching**: React Query for intelligent data caching
- **Optimized builds**: Next.js automatic code splitting

### User Experience
- **Modern UI**: Clean, professional interface with shadcn/ui
- **Responsive design**: Better mobile and tablet support
- **Keyboard shortcuts**: Improved keyboard navigation
- **Real-time updates**: Better WebSocket support

### Developer Experience
- **TypeScript**: Full type safety
- **Component library**: Reusable UI components
- **Hot reload**: Instant updates during development
- **Testing**: Better test infrastructure

## Troubleshooting

### Issue: Can't access the frontend

**Solution**:
```bash
# Check if services are running
docker-compose ps

# Check logs
docker-compose logs open_notebook

# Restart services
docker-compose restart
```

### Issue: API errors in new frontend

**Solution**:
The new frontend requires the API to be running. Ensure:
```bash
# API should be accessible at
curl http://localhost:5055/health

# If not, check API logs
docker-compose logs open_notebook | grep api
```

### Issue: Missing data after migration

**Solution**:
Data is preserved automatically. If you don't see your data:

1. Check database volume is mounted correctly:
   ```bash
   docker-compose down
   # Verify volumes in docker-compose.yml:
   # - ./surreal_data:/mydata  (for multi-container)
   # - ./surreal_single_data:/mydata (for single-container)
   docker-compose up -d
   ```

2. Check SurrealDB is running:
   ```bash
   docker-compose logs surrealdb
   ```

### Issue: Port conflicts

**Solution**:
If ports 8502 or 5055 are already in use:

```bash
# Find what's using the port
lsof -i :8502
lsof -i :5055

# Stop conflicting service or change Open Notebook ports
# Edit docker-compose.yml:
ports:
  - "8503:8502"  # Change external port
  - "5056:5055"  # Change external port
```

## Rollback Instructions

If you need to roll back to the Streamlit version:

### Docker Users

```bash
# Stop current version
docker-compose down

# Edit docker-compose.yml to use old image
# Change to: lfnovo/open_notebook:streamlit-latest

# Start old version
docker-compose up -d
```

### Source Code Users

```bash
# Checkout the last Streamlit version tag
git checkout tags/streamlit-final

# Install dependencies
uv sync

# Start Streamlit
uv run streamlit run app_home.py
```

## Getting Help

If you encounter issues during migration:

- **Discord**: Join our [Discord community](https://discord.gg/37XJPXfz2w) for real-time help
- **GitHub Issues**: Report bugs at [github.com/lfnovo/open-notebook/issues](https://github.com/lfnovo/open-notebook/issues)
- **Documentation**: Check [full documentation](https://github.com/lfnovo/open-notebook/tree/main/docs)

## FAQs

### Will my notebooks and data be lost?
No! All data is preserved. The database and API backend are unchanged.

### Do I need to update my API integrations?
No! The REST API remains fully backward compatible.

### Can I use both frontends simultaneously?
Technically yes, but not recommended. Choose one for consistency.

### What about my custom Streamlit pages?
Custom Streamlit pages won't work with the React frontend. Consider:
- Using the REST API to build custom integrations
- Contributing React components to the project
- Requesting features in GitHub issues

### Is the Streamlit version still supported?
The Streamlit version is no longer actively developed. We recommend migrating to the React version for the best experience and latest features.

## Timeline

- **Legacy (Pre-v1.0)**: Streamlit frontend
- **Current (v1.0+)**: React/Next.js frontend
- **Future**: Continued React development with new features

---

**Ready to migrate?** Follow the migration path for your deployment method above. The process is straightforward and your data is safe!