Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 8, 2025

This PR implements comprehensive Jupyter notebook support for SageMath, addressing the user request for SageMath code highlighting and execution capabilities in VS Code notebooks.

Key Features Added

Notebook Kernel Support

  • SageMath Notebook Controller: A dedicated kernel that enables executing SageMath code directly in Jupyter notebook cells
  • Cell Execution: Seamless execution of SageMath code with proper output handling and error reporting
  • Execution Order: Supports proper cell execution ordering and lifecycle management

Enhanced Language Support

  • Syntax Highlighting: SageMath syntax highlighting automatically works in notebook cells
  • IntelliSense: Existing language features extend to notebook contexts
  • Multi-language Support: Supports both 'sage' and 'python' language modes in notebooks

Configuration & Integration

  • Unified Settings: Reuses existing extension configuration (interpreter path, WSL support)
  • Toggle Control: New sagemathEnhanced.notebookKernelEnabled setting to enable/disable notebook functionality
  • Cross-platform: Full support for Windows (with WSL), macOS, and Linux

Technical Implementation

The implementation adds a SageMathNotebookController class that:

  • Registers as a VS Code notebook controller for Jupyter notebooks
  • Creates temporary .sage files for each cell execution
  • Uses the existing SageMath interpreter infrastructure
  • Handles proper cleanup of temporary files
  • Provides robust error handling with informative messages

Usage

  1. Open any .ipynb file in VS Code
  2. Select "SageMath" from the kernel picker
  3. Write SageMath code in cells with full syntax highlighting
  4. Execute cells to run SageMath code and see results

Example

# Symbolic mathematics in notebook cells x = var('x') f = x^3 - 2*x^2 + x - 1 print(f"Function: {f}") print(f"Derivative: {diff(f, x)}") factor(f)

The implementation maintains full backward compatibility with existing .sage file functionality while adding the requested notebook capabilities.

Fixes #1.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mirrors.huaweicloud.com
    • Triggering command: npm install (dns block)
    • Triggering command: npm ci (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI assigned Copilot and n-WN Aug 8, 2025
Copy link
Contributor Author

Copilot AI commented Aug 8, 2025

@n-WN 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 3 commits August 8, 2025 19:59
Co-authored-by: n-WN <30841158+n-WN@users.noreply.github.com>
Co-authored-by: n-WN <30841158+n-WN@users.noreply.github.com>
Co-authored-by: n-WN <30841158+n-WN@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Notebook support Add Jupyter Notebook Support for SageMath Aug 8, 2025
@Copilot Copilot AI requested a review from n-WN August 8, 2025 20:08
Copilot finished work on behalf of n-WN August 8, 2025 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants