Skip to content

Split Learning reset into exercise and unit - #3635

Draft
Dhairya Patel (HABER7789) wants to merge 3 commits into
mainfrom
HABER7789/reset-unit-copilot-tool
Draft

Split Learning reset into exercise and unit#3635
Dhairya Patel (HABER7789) wants to merge 3 commits into
mainfrom
HABER7789/reset-unit-copilot-tool

Conversation

@HABER7789

@HABER7789 Dhairya Patel (HABER7789) commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

resetExercise reset one .qs file for Q# courses but wiped the entire notebook for notebook courses, while telling Copilot it "only resets an exercise." It now restores just the current activity one file, or one cell.

Adds resetUnit and a qdk-learning-reset-unit tool so chat can reset a whole unit, including by name.

Reset was picking the wrong notebook cell, because the stored position only moves when you run a cell, not when you click one. Now that #3627 has merged, reset resolves the selected cell by location the same way the hint and solution tools do. I also hardened the reset paths so a cancelled notebook close, rejected edit, or failed save aborts and keeps the user's progress instead of reporting success.

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.

Pull request overview

Splits QDK Learning resets into activity-level and unit-level operations.

Changes:

  • Restores individual notebook cells without affecting other work.
  • Adds whole-unit reset support for Q# and notebook courses.
  • Exposes the new tool through Copilot, commands, telemetry, and agent guidance.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
source/vscode/src/telemetry.ts Adds unit-reset telemetry.
source/vscode/src/learning/service.ts Implements activity and unit reset behavior.
source/vscode/src/learning/python/materialization.ts Restores individual notebook cells.
source/vscode/src/learning/notebookExercises.ts Adds cell source lookup and replacement.
source/vscode/src/learning/commands.ts Updates reset commands and notebook reopening.
source/vscode/src/gh-copilot/tools.ts Registers the unit-reset tool.
source/vscode/src/gh-copilot/learningTools.ts Adds tool orchestration and selected-cell synchronization.
source/vscode/package.json Contributes the command and tool metadata.
source/vscode/ai/qdk-learning.agent.md Documents activity versus unit resets.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread source/vscode/src/gh-copilot/learningTools.ts Outdated

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

Notebook close, edit, save, and rematerialization failures can currently be reported as successful resets.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

source/vscode/src/learning/python/materialization.ts:136

  • NotebookDocument.save() returns false when the document was not saved, but that result is ignored and the reset is reported as successful. In that case progress is cleared even though the restored cell was never persisted. Treat a false save result as a restoration failure rather than returning true.
  await notebook.save();
  return true;

source/vscode/src/learning/service.ts:1032

  • rematerializeUnitWorkbook delegates to materializeNotebook, which catches every filesystem/parsing failure and returns void (materialization.ts:147-170). Consequently this call always proceeds to finishUnitReset, clearing completion and telling the command/tool that the unit was reset even when the workbook was unchanged. Propagate a failure result here and only clear progress after the workbook was successfully restored.
      await rematerializeUnitWorkbook(unit);
  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread source/vscode/src/learning/service.ts Outdated
Comment thread source/vscode/src/learning/python/materialization.ts Outdated
- resetExercise now restores only current activity
- copilot can now reset a whole unit and can target a unit by name
- resetting something with no code, like a markdowncell, will now report instead of silently resetting another cell

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

Failed save paths can still discard learner work or incorrectly report a successful reset.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Balanced

// Save any unsaved edits first so the editor is clean, then overwrite
// the file on disk. The editor will pick up the change automatically
// because it's no longer dirty.
await this.saveOpenDocument(uri);
Comment on lines +134 to +137
if (!(await vscode.workspace.applyEdit(edit))) {
return false;
}
return notebook.save();
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