Skip to content

fix: preserve %run and %fs magic commands in notebook cells#30

Merged
Hazzng merged 2 commits into
mainfrom
claude/fix-notebook-run-command-8rdja
Apr 2, 2026
Merged

fix: preserve %run and %fs magic commands in notebook cells#30
Hazzng merged 2 commits into
mainfrom
claude/fix-notebook-run-command-8rdja

Conversation

@Hazzng

@Hazzng Hazzng commented Apr 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Bug fix: %run and %fs magic commands were being stripped from cell content when the notebook rendered. The handleMagicInPythonCell function only preserved %pip as a special case, but %run and %fs are also Python-language cells that need their magic command prefix kept intact.
  • Version bump: 0.4.4 → 0.4.5 with changelog entry

Root Cause

In extension.ts, handleMagicInPythonCell had a special case for %pip to keep it visible in the cell, but %run and %fs fell through to the removeMagicCommand path — which stripped the prefix thinking the user had changed the cell language back to Python.

Fix

Extended the preservation logic to cover %run and %fs alongside %pip, using a shared magicTypeMap lookup instead of a single %pip check.

Test plan

  • Verified parser correctly preserves %run in cell content
  • Verified round-trip serialization (unchanged cells produce identical output)
  • Verified re-serialization of modified %run cells includes # MAGIC %run prefix
  • Verified compiled webpack bundle contains the fix
  • Webpack compiles successfully

https://claude.ai/code/session_01HgXdZmSTBP8XnqTpYQHEQB

Hazzng added 2 commits April 2, 2026 03:22
The handleMagicInPythonCell function was stripping %run (and %fs) from
cell content because only %pip was exempted from the removeMagicCommand
path. Since %run and %fs cells are Python-language cells that need their
magic command prefix preserved (just like %pip), they must be handled
the same way — keeping the content intact and only updating metadata.

https://claude.ai/code/session_01HgXdZmSTBP8XnqTpYQHEQB
@Hazzng Hazzng force-pushed the claude/fix-notebook-run-command-8rdja branch from 00976c7 to 69c1fbb Compare April 2, 2026 03:22
@Hazzng Hazzng merged commit fe431f5 into main Apr 2, 2026
6 checks passed
@Hazzng Hazzng deleted the claude/fix-notebook-run-command-8rdja branch April 14, 2026 14:41
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.

1 participant