Fix Learning notebook autosave - #3683
Open
Dhairya Patel (HABER7789) wants to merge 1 commit into
Open
Conversation
Dhairya Patel (HABER7789)
requested review from
Andrew Casey (amcasey),
Bill Ticehurst (billti) and
Ian Davis (idavis)
as code owners
September 3, 2026 01:26
Dhairya Patel (HABER7789)
requested
a lite review from Copilot
and removed request for
Andrew Casey (amcasey),
Bill Ticehurst (billti) and
Ian Davis (idavis)
September 3, 2026 01:28
Copilot started reviewing on behalf of
Dhairya Patel (HABER7789)
September 3, 2026 01:29
View session
Contributor
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.
Comment on lines
+530
to
+534
| const didSave = await notebook.save(); | ||
| saved = didSave || !notebook.isDirty; | ||
| if (!saved) { | ||
| log.warn(`Could not save learning workbook ${notebook.uri.fsPath}.`); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learning notebooks are now saved after metadata changes and before moving to another unit, preventing unwanted save prompts and preserving learner edits.