Skip to content

Fix Learning notebook autosave - #3683

Open
Dhairya Patel (HABER7789) wants to merge 1 commit into
mainfrom
HABER7789/notebook-autosave
Open

Fix Learning notebook autosave#3683
Dhairya Patel (HABER7789) wants to merge 1 commit into
mainfrom
HABER7789/notebook-autosave

Conversation

@HABER7789

Copy link
Copy Markdown
Contributor

Learning notebooks are now saved after metadata changes and before moving to another unit, preventing unwanted save prompts and preserving learner edits.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.isCourseWorkbook and LearningService.saveCourseWorkbook (with per-notebook save queueing) to centralize workbook detection and serialized auto-save.
  • Updated learning notebook sync + notebook change handling to call saveCourseWorkbook after 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}.`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants