Skip to content

Make getCurrentActivityForCell not depend on current position - #3627

Merged
Andrew Casey (amcasey) merged 16 commits into
mainfrom
amcasey/CurrentActivity
Aug 25, 2026
Merged

Make getCurrentActivityForCell not depend on current position#3627
Andrew Casey (amcasey) merged 16 commits into
mainfrom
amcasey/CurrentActivity

Conversation

@amcasey

@amcasey Andrew Casey (amcasey) commented Aug 21, 2026

Copy link
Copy Markdown
Member

It's fundamentally passing in a URI and cellID, so resolve those instead of trying to compare them to the active position.

Bonus: tidy up the hint tool so it uses a single state, rather than using two and trying to detect conflicts.

It's fundamentally passing in a URI and cellID, so resolve those instead of trying to compare them to the active position.
@amcasey

Copy link
Copy Markdown
Member Author

This is more for hygiene than to fix a bug, though it is a small behavioral change (if you manage to open another notebook without navigating to it, which is challenging).

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

Resolves notebook activities from the supplied URI and cell ID instead of stored progress position.

Changes:

  • Resolve the owning course and unit from the notebook URI.
  • Pass vscode.Uri directly from Copilot learning tools.

Reviewed changes

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

File Description
source/vscode/src/learning/service.ts Resolves cell activity locations from workbook URIs.
source/vscode/src/gh-copilot/learningTools.ts Passes the notebook URI object to the service.

💡 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/learning/service.ts

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread source/vscode/src/learning/service.ts Outdated
Comment thread source/vscode/src/gh-copilot/learningTools.ts
Comment thread source/vscode/src/gh-copilot/learningTools.ts Outdated
Comment thread source/vscode/src/learning/service.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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (3)

Previously missed (1) — in code that hasn't changed since the last review.

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

  • The method now returns a full LearningState, but its doc comment still says it builds a CurrentActivity. Update the contract description so callers are not misled.
  getLearningStateForCell(

source/vscode/src/gh-copilot/learningTools.ts:201

  • This branch is keyed to whether any notebook editor is active, not whether the target URI is a workbook. If the current course is notebook-based but no notebook editor is active, execution falls through to readUserCode() and returns the raw .ipynb JSON; conversely, an unrelated active notebook makes a Q# exercise return empty code. Detect the workbook from uri and use the editor only when it matches.
      const editor = vscode.window.activeNotebookEditor;
      if (editor) {
        let code = "";
        if (editor.notebook.uri.toString() === uri.toString()) {

source/vscode/src/gh-copilot/learningTools.ts:382

  • This still derives the unit counters from progress.currentPosition, which is the service's stored position. When the selected cell belongs to another unit—the mismatch this PR is intended to support—the returned position describes the selected unit while these counters describe the stored unit. Use state.position.location.unitId as the lookup key.
    const unitId = progress.currentPosition?.unitId;

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

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

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

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

source/vscode/src/gh-copilot/learningTools.ts:199

  • This now treats any active notebook as evidence that the current learning activity is notebook-based. If a learner is on a Q# course while an unrelated notebook is active, uri points to the Q# exercise but this branch returns an empty code value instead of calling readUserCode(). Gate the cell-based path on the active course kind (while still allowing the editor itself to be absent) so Q# activities continue to read their source file.
      const editor = vscode.window.activeNotebookEditor;
      if (editor) {

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

@HABER7789 Dhairya Patel (HABER7789) 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.

I have tested in the dev host. The state now correctly follows the visible notebook tab across units. No issues found.

Comment thread source/vscode/src/gh-copilot/learningTools.ts Outdated
@amcasey
Andrew Casey (amcasey) added this pull request to the merge queue Aug 25, 2026
Merged via the queue into main with commit 7534d3a Aug 25, 2026
14 checks passed
@amcasey
Andrew Casey (amcasey) deleted the amcasey/CurrentActivity branch August 25, 2026 02:06
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.

4 participants