-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Support Deepnote input blocks #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…tomaskislan/grn-4762-support-big-number-blocks
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
GRN-4776 Support input blocks
We'll transform them into code blocks that set the variable with the defined value. |
📝 WalkthroughWalkthroughAdds a Deepnote input conversion framework and nine concrete converters in src/notebooks/deepnote/converters/inputConverters.ts (BaseInputBlockConverter plus converters for text, textarea, select, slider, checkbox, date, date-range, file, and button). Adds corresponding zod schemas in deepnoteSchemas, registers converters in DeepnoteDataConverter, introduces a NotebookCellStatusBarItemProvider for Deepnote input blocks and registers it in service registries, and adds unit tests for converters and the status-bar provider. Converters validate/serialize metadata, preserve raw content on parse failures, and round-trip cell ↔ DeepnoteBlock metadata. Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant VSCode as "VS Code Notebook"
participant DataConv as "DeepnoteDataConverter"
participant Registry as "Converters Registry"
participant Conv as "Input*BlockConverter"
participant Schema as "Zod Schema"
note over DataConv,Registry: register 9 input converters on init
DataConv->>Registry: register(InputText,...,Button)
User->>VSCode: open Deepnote notebook
VSCode->>DataConv: request convert blocks -> cells
DataConv->>Registry: get converters for each block
loop per block
DataConv->>Conv: canConvert(block.type)?
alt supported
DataConv->>Conv: convertToCell(block)
Conv->>Schema: validate/parse metadata
alt raw content present
Conv->>VSCode: NotebookCellData(value=raw JSON)
else validation OK
Conv->>VSCode: NotebookCellData(value=stringified metadata or defaults)
else validation failed
Conv->>VSCode: NotebookCellData(value=stringified defaults)
end
else not supported
DataConv-->>DataConv: continue
end
end
sequenceDiagram
autonumber
actor User
participant VSCode as "VS Code Notebook"
participant Conv as "Input*BlockConverter"
participant Schema as "Zod Schema"
participant Block as "DeepnoteBlock"
User->>VSCode: edit JSON cell value
VSCode->>Conv: applyChangesToBlock(block, cell)
Conv->>Schema: parseJsonWithFallback(cell.value)
alt parse & schema OK
Conv->>Block: remove DEEPNOTE_VSCODE_RAW_CONTENT_KEY if present
Conv->>Block: merge parsed config into block.metadata
Conv-->>VSCode: updated block metadata
else parse/validation fails
Conv->>Block: set metadata[DEEPNOTE_VSCODE_RAW_CONTENT_KEY] = cell.value
Conv-->>VSCode: raw content stored on block
end
Possibly related PRs
Suggested reviewers
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (5)**/!(*.node|*.web).ts📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
src/notebooks/deepnote/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/notebooks/deepnote/deepnoteDataConverter.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.node.ts📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧠 Learnings (5)📓 Common learnings📚 Learning: 2025-10-09T11:21:57.494ZApplied to files:
📚 Learning: 2025-09-03T12:59:14.489ZApplied to files:
📚 Learning: 2025-10-16T13:09:32.543ZApplied to files:
📚 Learning: 2025-10-09T11:21:57.494ZApplied to files:
🧬 Code graph analysis (1)src/notebooks/deepnote/deepnoteDataConverter.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (4)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
src/notebooks/deepnote/converters/inputConverters.ts(1 hunks)src/notebooks/deepnote/converters/inputConverters.unit.test.ts(1 hunks)src/notebooks/deepnote/deepnoteDataConverter.ts(3 hunks)src/notebooks/deepnote/deepnoteSchemas.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/!(*.node|*.web).ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Place shared cross-platform logic in common
.tsfiles (not suffixed with.nodeor.web)
Files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/converters/inputConverters.tssrc/notebooks/deepnote/converters/inputConverters.unit.test.tssrc/notebooks/deepnote/deepnoteSchemas.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Inject interfaces, not concrete classes
Avoid circular dependencies
Usel10n.t()for user-facing strings
Use typed error classes fromsrc/platform/errors/when throwing or handling errors
Use theILoggerservice instead ofconsole.log
Preserve error details while scrubbing PII in messages and telemetry
Include the Microsoft copyright header in source files
Prefer async/await and handle cancellation withCancellationToken
**/*.{ts,tsx}: Order class members (methods, fields, properties) first by accessibility (public/protected/private) and then alphabetically
Do not add the Microsoft copyright header to new files
Use Uri.joinPath() to construct file paths instead of manual string concatenation
Add a blank line after groups of const declarations and before return statements for readability
Separate third-party imports from local file imports
Files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/converters/inputConverters.tssrc/notebooks/deepnote/converters/inputConverters.unit.test.tssrc/notebooks/deepnote/deepnoteSchemas.ts
src/notebooks/deepnote/**
📄 CodeRabbit inference engine (CLAUDE.md)
Deepnote integration code resides under src/notebooks/deepnote/
Files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/converters/inputConverters.tssrc/notebooks/deepnote/converters/inputConverters.unit.test.tssrc/notebooks/deepnote/deepnoteSchemas.ts
src/notebooks/deepnote/deepnoteDataConverter.ts
📄 CodeRabbit inference engine (CLAUDE.md)
deepnoteDataConverter.ts performs Deepnote data transformations
Files:
src/notebooks/deepnote/deepnoteDataConverter.ts
**/*.unit.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Place unit tests in files matching
*.unit.test.ts
**/*.unit.test.ts: Unit tests must use Mocha/Chai and have the .unit.test.ts extension
Place unit test files alongside the source files they test
Use assert.deepStrictEqual() for object comparisons in tests instead of checking individual properties
Files:
src/notebooks/deepnote/converters/inputConverters.unit.test.ts
**/*.{test,spec}.ts
📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
In unit tests, when a mock is returned from a promise, ensure the mocked instance has an undefined
thenproperty to avoid hanging tests
Files:
src/notebooks/deepnote/converters/inputConverters.unit.test.ts
🧠 Learnings (3)
📚 Learning: 2025-10-09T11:21:57.494Z
Learnt from: CR
PR: deepnote/vscode-deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T11:21:57.494Z
Learning: Applies to src/notebooks/deepnote/deepnoteDataConverter.ts : deepnoteDataConverter.ts performs Deepnote data transformations
Applied to files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/converters/inputConverters.tssrc/notebooks/deepnote/converters/inputConverters.unit.test.ts
📚 Learning: 2025-09-03T12:59:14.489Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/notebooks.instructions.md:0-0
Timestamp: 2025-09-03T12:59:14.489Z
Learning: Applies to src/notebooks/export/**/*.ts : Update FileConverter to handle the new export format
Applied to files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/converters/inputConverters.ts
📚 Learning: 2025-10-09T11:21:57.494Z
Learnt from: CR
PR: deepnote/vscode-deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T11:21:57.494Z
Learning: Applies to src/notebooks/deepnote/deepnoteTypes.ts : deepnoteTypes.ts contains Deepnote-related type definitions
Applied to files:
src/notebooks/deepnote/deepnoteSchemas.ts
🧬 Code graph analysis (3)
src/notebooks/deepnote/deepnoteDataConverter.ts (1)
src/notebooks/deepnote/converters/inputConverters.ts (9)
InputTextBlockConverter(77-89)InputTextareaBlockConverter(91-103)InputSelectBlockConverter(105-117)InputSliderBlockConverter(119-131)InputCheckboxBlockConverter(133-145)InputDateBlockConverter(147-159)InputDateRangeBlockConverter(161-173)InputFileBlockConverter(175-187)ButtonBlockConverter(189-201)
src/notebooks/deepnote/converters/inputConverters.ts (5)
src/notebooks/deepnote/converters/blockConverter.ts (1)
BlockConverter(5-10)src/test/mocks/vsc/extHostedTypes.ts (1)
NotebookCellData(2523-2549)src/notebooks/deepnote/dataConversionUtils.ts (1)
parseJsonWithFallback(5-11)src/notebooks/deepnote/converters/constants.ts (1)
DEEPNOTE_VSCODE_RAW_CONTENT_KEY(1-1)src/notebooks/deepnote/deepnoteSchemas.ts (9)
DeepnoteTextInputMetadataSchema(48-65)DeepnoteTextareaInputMetadataSchema(67-80)DeepnoteSelectInputMetadataSchema(82-123)DeepnoteSliderInputMetadataSchema(125-154)DeepnoteCheckboxInputMetadataSchema(156-173)DeepnoteDateInputMetadataSchema(175-196)DeepnoteDateRangeInputMetadataSchema(198-215)DeepnoteFileInputMetadataSchema(217-234)DeepnoteButtonMetadataSchema(236-253)
src/notebooks/deepnote/converters/inputConverters.unit.test.ts (3)
src/notebooks/deepnote/converters/inputConverters.ts (9)
InputTextBlockConverter(77-89)InputTextareaBlockConverter(91-103)InputSelectBlockConverter(105-117)InputSliderBlockConverter(119-131)InputCheckboxBlockConverter(133-145)InputDateBlockConverter(147-159)InputDateRangeBlockConverter(161-173)InputFileBlockConverter(175-187)ButtonBlockConverter(189-201)src/notebooks/deepnote/converters/constants.ts (1)
DEEPNOTE_VSCODE_RAW_CONTENT_KEY(1-1)src/test/mocks/vsc/extHostedTypes.ts (1)
NotebookCellData(2523-2549)
🔇 Additional comments (3)
src/notebooks/deepnote/deepnoteDataConverter.ts (2)
12-22: LGTM: input converters importImports look correct and scoped to deepnote converters.
36-44: LGTM: register input convertersRegistration order and coverage look good.
src/notebooks/deepnote/converters/inputConverters.unit.test.ts (1)
1-1151: Solid coverage overallTests cover convertToCell/applyChangesToBlock, defaults, arrays, booleans, and raw content fallback for invalid JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
src/notebooks/deepnote/converters/inputConverters.ts (1)
52-69: Remove console.*, rename vars; keep pretty-printDrop console.error/debug/log and avoid logging metadata. Rename to generic vars for clarity. Behavior unchanged.
As per coding guidelines.
- convertToCell(block: DeepnoteBlock): NotebookCellData { - const deepnoteJupyterRawContentResult = z.string().safeParse(block.metadata?.[DEEPNOTE_VSCODE_RAW_CONTENT_KEY]); - const deepnoteMetadataResult = this.schema().safeParse(block.metadata); - - if (deepnoteMetadataResult.error != null) { - console.error('Error parsing deepnote input metadata:', deepnoteMetadataResult.error); - console.debug('Metadata:', JSON.stringify(block.metadata)); - } - - const configStr = deepnoteJupyterRawContentResult.success - ? deepnoteJupyterRawContentResult.data - : deepnoteMetadataResult.success - ? JSON.stringify(deepnoteMetadataResult.data, null, 2) - : JSON.stringify(this.defaultConfig(), null, 2); - - const cell = new NotebookCellData(NotebookCellKind.Code, configStr, 'json'); - console.log(cell); - return cell; - } + convertToCell(block: DeepnoteBlock): NotebookCellData { + const rawContentResult = z.string().safeParse(block.metadata?.[DEEPNOTE_VSCODE_RAW_CONTENT_KEY]); + const metadataResult = this.schema().safeParse(block.metadata); + + const configStr = rawContentResult.success + ? rawContentResult.data + : metadataResult.success + ? JSON.stringify(metadataResult.data, null, 2) + : JSON.stringify(this.defaultConfig(), null, 2); + + const cell = new NotebookCellData(NotebookCellKind.Code, configStr, 'json'); + return cell; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
src/notebooks/deepnote/converters/inputConverters.ts(1 hunks)src/notebooks/deepnote/deepnoteDataConverter.ts(2 hunks)src/notebooks/deepnote/deepnoteSchemas.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/!(*.node|*.web).ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Place shared cross-platform logic in common
.tsfiles (not suffixed with.nodeor.web)
Files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/deepnoteSchemas.tssrc/notebooks/deepnote/converters/inputConverters.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Inject interfaces, not concrete classes
Avoid circular dependencies
Usel10n.t()for user-facing strings
Use typed error classes fromsrc/platform/errors/when throwing or handling errors
Use theILoggerservice instead ofconsole.log
Preserve error details while scrubbing PII in messages and telemetry
Include the Microsoft copyright header in source files
Prefer async/await and handle cancellation withCancellationToken
**/*.{ts,tsx}: Order class members (methods, fields, properties) first by accessibility (public/protected/private) and then alphabetically
Do not add the Microsoft copyright header to new files
Use Uri.joinPath() to construct file paths instead of manual string concatenation
Add a blank line after groups of const declarations and before return statements for readability
Separate third-party imports from local file imports
Files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/deepnoteSchemas.tssrc/notebooks/deepnote/converters/inputConverters.ts
src/notebooks/deepnote/**
📄 CodeRabbit inference engine (CLAUDE.md)
Deepnote integration code resides under src/notebooks/deepnote/
Files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/deepnoteSchemas.tssrc/notebooks/deepnote/converters/inputConverters.ts
src/notebooks/deepnote/deepnoteDataConverter.ts
📄 CodeRabbit inference engine (CLAUDE.md)
deepnoteDataConverter.ts performs Deepnote data transformations
Files:
src/notebooks/deepnote/deepnoteDataConverter.ts
🧠 Learnings (2)
📚 Learning: 2025-10-09T11:21:57.494Z
Learnt from: CR
PR: deepnote/vscode-deepnote#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T11:21:57.494Z
Learning: Applies to src/notebooks/deepnote/deepnoteDataConverter.ts : deepnoteDataConverter.ts performs Deepnote data transformations
Applied to files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/converters/inputConverters.ts
📚 Learning: 2025-09-03T12:59:14.489Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/notebooks.instructions.md:0-0
Timestamp: 2025-09-03T12:59:14.489Z
Learning: Applies to src/notebooks/export/**/*.ts : Update FileConverter to handle the new export format
Applied to files:
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/converters/inputConverters.ts
🧬 Code graph analysis (2)
src/notebooks/deepnote/deepnoteDataConverter.ts (1)
src/notebooks/deepnote/converters/inputConverters.ts (9)
InputTextBlockConverter(77-89)InputTextareaBlockConverter(91-103)InputSelectBlockConverter(105-117)InputSliderBlockConverter(119-131)InputCheckboxBlockConverter(133-145)InputDateBlockConverter(147-159)InputDateRangeBlockConverter(161-173)InputFileBlockConverter(175-187)ButtonBlockConverter(189-201)
src/notebooks/deepnote/converters/inputConverters.ts (4)
src/notebooks/deepnote/converters/blockConverter.ts (1)
BlockConverter(5-10)src/notebooks/deepnote/dataConversionUtils.ts (1)
parseJsonWithFallback(5-11)src/notebooks/deepnote/converters/constants.ts (1)
DEEPNOTE_VSCODE_RAW_CONTENT_KEY(1-1)src/notebooks/deepnote/deepnoteSchemas.ts (9)
DeepnoteTextInputMetadataSchema(48-65)DeepnoteTextareaInputMetadataSchema(67-80)DeepnoteSelectInputMetadataSchema(82-123)DeepnoteSliderInputMetadataSchema(125-154)DeepnoteCheckboxInputMetadataSchema(156-173)DeepnoteDateInputMetadataSchema(175-196)DeepnoteDateRangeInputMetadataSchema(198-215)DeepnoteFileInputMetadataSchema(217-234)DeepnoteButtonMetadataSchema(236-253)
🔇 Additional comments (1)
src/notebooks/deepnote/deepnoteDataConverter.ts (1)
12-22: Wiring of input converters looks goodImports and registrations are correct and ordered consistently with existing converters.
Also applies to: 36-45
…maskislan/grn-4776-support-input-blocks
…-number-blocks' into tomaskislan/grn-4776-support-input-blocks Signed-off-by: Tomas Kislan <tomas@kislan.sk>
…m:deepnote/vscode-deepnote into tomaskislan/grn-4776-support-input-blocks
The base branch was changed.
…support-input-blocks Signed-off-by: Tomas Kislan <tomas@kislan.sk>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #42 +/- ##
======================================
Coverage 71% 72%
======================================
Files 532 536 +4
Lines 40018 40681 +663
Branches 4973 4982 +9
======================================
+ Hits 28788 29442 +654
- Misses 9569 9578 +9
Partials 1661 1661
🚀 New features to boost your workflow:
|
|
Is the plan to then convert these JSON editors into actual input elements like a text box, select box, etc? |
Notebook cells are rendered within the VSCode codebase .. I couldn't find a way how to change this into something else |
|
You might be right. I researched this briefly and it indeed seems to be limited to these editors. The status bar solution sounds good but we can iterate on that. |
|
We need a codeowner approval (cc @saltenasl) for merging this. |
saltenasl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@saltenasl did not look into that yet .. and we also have a separate task for code completion related to init notebooks as well |

Summary by CodeRabbit
New Features
Tests