Fix Learning notebook autosave - #3683
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
saveCourseWorkbook can report success even when the notebook remains dirty after saving, which can lead to stale-tab closure still prompting to save (or risking loss of edits).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves the VS Code Learning experience for *.workbook.ipynb notebooks by ensuring learner workbooks are auto-saved when Jupyter updates notebook metadata and by attempting to save workbooks before closing stale learning tabs, reducing unwanted “unsaved changes” prompts.
Changes:
- Added
LearningService.isCourseWorkbookandLearningService.saveCourseWorkbook(with per-notebook save queueing) to centralize workbook detection and serialized auto-save. - Updated learning notebook sync + notebook change handling to call
saveCourseWorkbookafter sync and on metadata/execution changes. - Updated stale-tab closing to save workbooks first and skip closing ones that could not be saved; adjusted notebook opening flow to explicitly show the notebook after the Jupyter API opens it.
File summaries
| File | Description |
|---|---|
| source/vscode/src/learning/service.ts | Adds workbook detection and queued saving; ensures stale learning tabs are saved (and skips closing when save fails). |
| source/vscode/src/learning/notebookSync.ts | Saves a course workbook after syncing when restoring sessions and uses service.isCourseWorkbook for context. |
| source/vscode/src/learning/index.ts | Auto-saves workbooks on notebook metadata changes (and execution changes) via saveCourseWorkbook. |
| source/vscode/src/learning/commands.ts | After opening via Jupyter’s API, explicitly shows the notebook document to ensure it is visible/active. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
Metadata-only changes can still occur after synchronization without triggering a save.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Balanced
Learning notebooks are now saved after metadata changes and before moving to another unit, preventing unwanted save prompts and preserving learner edits.