From 865d9407da53f00c56d4de64f9b6d45e1be10725 Mon Sep 17 00:00:00 2001 From: Harry Nguyen Date: Thu, 2 Apr 2026 02:31:02 +0000 Subject: [PATCH 1/2] fix: preserve %run and %fs magic commands in notebook cells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/extension.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index e7f1bc1..01f29d0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -534,10 +534,17 @@ async function handleMagicInPythonCell( magic: string, languageId: string ): Promise { - // %pip cells should stay as Python cells (like Jupyter) - don't convert or remove - if (magic === '%pip') { + // %pip, %run, and %fs cells should stay as Python cells - don't convert or remove the magic command. + // These are special Databricks commands that must remain visible in the cell content. + const magicTypeMap: Record = { + '%pip': 'pip', + '%run': 'run', + '%fs': 'fs', + }; + const preservedType = magicTypeMap[magic]; + if (preservedType) { // Only update metadata if not already set to avoid repeated cell replacements - if (cell.metadata?.databricksType !== 'pip') { + if (cell.metadata?.databricksType !== preservedType) { const cellKey = cell.document.uri.toString(); // Skip if already processed if (autoDetectedCells.has(cellKey)) { @@ -549,7 +556,7 @@ async function handleMagicInPythonCell( languageId: 'python', metadata: { ...c.metadata, - databricksType: 'pip', + databricksType: preservedType, }, }), { enterEditMode: true, From 69c1fbba96702fb8ec7571593c15f595fcc43fde Mon Sep 17 00:00:00 2001 From: Harry Nguyen Date: Thu, 2 Apr 2026 02:32:31 +0000 Subject: [PATCH 2/2] chore: bump version to 0.4.5 and update changelog https://claude.ai/code/session_01HgXdZmSTBP8XnqTpYQHEQB --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e6065b..64e706d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to the Databricks Notebook Studio extension will be document The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.4.5] - 2026-04-02 + +### Fixed +- **%run and %fs magic commands no longer stripped from notebook cells**: The notebook rendering was incorrectly removing `%run` and `%fs` prefixes from cell content when the notebook change handler fired, treating them as removable magic commands instead of preserving them like `%pip` + ## [0.4.4] - 2026-03-03 ### Fixed diff --git a/package.json b/package.json index 39fd322..0ef36aa 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "databricks-notebook-studio", "displayName": "Databricks Notebook Studio", "description": "Visualize Databricks .py notebooks with rich DataFrame display, interactive tables, column sorting/resizing, and multi-profile authentication", - "version": "0.4.4", + "version": "0.4.5", "license": "MIT", "type": "commonjs", "publisher": "databricks-notebook-studio",