Implement interactive code blocks with hover variable inspection using reactivity library #357
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.
This PR implements #107 (Interactive CodeBlock - Show inspect information when variable got hovered) using the reactivity library for high-performance variable tracking, which also addresses #303 (Inspect runtime value inside code blocks).
Problem
Previously, users had no way to inspect Python variables in code blocks by hovering over them. The original issues proposed two approaches:
globals()after every execution (memory leak concerns)Solution
This implementation leverages the newly available reactivity library to provide efficient, real-time variable inspection:
Key Components Added
1. Enhanced Syntax Highlighting (
highlight.ts)data-variableanddata-inspectableattributes to inspectable identifiers2. Interactive Code Block Component (
InteractiveCodeBlock.svelte)pyNotebook.inspect()andpyNotebook.watch()methodscreate_effectfor efficient variable watching with automatic cleanup3. Smart Component Selection (
notebook/Code.svelte)InteractiveCodeBlockfor Python code whenpyNotebookis availableCodeBlockfor non-Python code or when notebook API is unavailable4. Tooltip Integration (
Tooltip.svelte)Technical Benefits
Usage
After running Python code in a notebook:
This provides the foundation for advanced code inspection features while maintaining excellent performance through the reactivity library.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.