-
Notifications
You must be signed in to change notification settings - Fork 5
fix: Ensure that Code blocks are Code blocks #244
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
Adding code blocks is handled by the VS Code so we can't modify that behaviour, so instead we check that the block has the correct settings after it's created.
📝 WalkthroughWalkthroughNew Deepnote notebook service DeepnoteNewCellLanguageService was added and exported; it implements IExtensionSyncActivationService and registers on activation a workspace.onDidChangeNotebookDocument listener. The listener examines added cells in Deepnote notebooks, ignores non-code/markup or non-empty cells, preserves cells with __deepnotePocket metadata, and resets empty code cells that inherited a non‑Python language to Python via languages.setTextDocumentLanguage. The service is registered as a singleton activation service in both node and web service registries. Unit tests were added to validate activation, listener behavior, and language-change scenarios. A test mock enum member Markup = 1 was also introduced. Sequence DiagramsequenceDiagram
participant ExtensionHost as Extension Host
participant Service as DeepnoteNewCellLanguageService
participant Workspace as VS Code Workspace
participant NotebookDoc as Notebook Document
participant Languages as VS Code languages API
ExtensionHost->>Service: activate()
Service->>Workspace: workspace.onDidChangeNotebookDocument(listener)
Workspace-->>Service: listener registered
Note over NotebookDoc: User adds one or more cells
NotebookDoc->>Workspace: onDidChangeNotebookDocument(event)
Workspace->>Service: invoke listener(event)
Service->>Service: for each added cell: is Deepnote notebook?
alt not Deepnote
Service-->>Workspace: ignore
else Deepnote
Service->>Service: is cell Code and empty/whitespace-only?
alt not Code or non-empty
Service-->>Workspace: ignore
else candidate
Service->>Service: has __deepnotePocket metadata?
alt has pocket (intentional SQL/JSON/Input)
Service-->>Workspace: preserve language
else no pocket
Service->>Languages: setTextDocumentLanguage(cell.document, "python")
Languages-->>Service: success / noop / error
end
end
end
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #244 +/- ##
===========================
===========================
🚀 New features to boost your workflow:
|
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
src/notebooks/deepnote/deepnoteNewCellLanguageService.ts(1 hunks)src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts(1 hunks)src/notebooks/serviceRegistry.node.ts(2 hunks)src/notebooks/serviceRegistry.web.ts(2 hunks)src/test/mocks/vsc/extHostedTypes.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Usel10n.t()for all user-facing strings in TypeScript files
Use typed error classes fromsrc/platform/errors/instead of generic errors
UseILoggerservice instead of console.log for logging
Preserve error details in error messages while scrubbing personally identifiable information (PII)
Prefer async/await over promise chains
Handle cancellation with CancellationTokenOrder method, fields and properties first by accessibility (public/private/protected) and then by alphabetical order
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.tssrc/notebooks/serviceRegistry.web.tssrc/notebooks/serviceRegistry.node.tssrc/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.tssrc/test/mocks/vsc/extHostedTypes.ts
**/*.ts
📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
**/*.ts: ALWAYS check the 'Core - Build' task output for TypeScript compilation errors before running any script or declaring work complete
ALWAYS runnpm run format-fixbefore committing changes to ensure proper code formatting
FIX all TypeScript compilation errors before moving forward with development
Usenpm run format-fixto auto-fix TypeScript formatting issues before committing
Usenpm run lintto check for linter issues in TypeScript files and attempt to fix before committing
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.tssrc/notebooks/serviceRegistry.web.tssrc/notebooks/serviceRegistry.node.tssrc/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.tssrc/test/mocks/vsc/extHostedTypes.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
src/**/*.{ts,tsx}: Don't add the Microsoft copyright header to new files
UseUri.joinPath()for constructing file paths instead of string concatenation with/to ensure platform-correct path separators
Follow established patterns when importing new packages, using helper imports rather than direct imports (e.g., useimport { generateUuid } from '../platform/common/uuid'instead of importing uuid directly)
Add blank lines after const groups and before return statements for readability
Separate third-party and local file imports
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.tssrc/notebooks/serviceRegistry.web.tssrc/notebooks/serviceRegistry.node.tssrc/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.tssrc/test/mocks/vsc/extHostedTypes.ts
src/notebooks/deepnote/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Deepnote integration located in
src/notebooks/deepnote/with refactored architecture:deepnoteTypes.ts(type definitions),deepnoteNotebookManager.ts(state management),deepnoteNotebookSelector.ts(UI selection logic),deepnoteDataConverter.ts(data transformations),deepnoteSerializer.ts(main serializer/orchestration),deepnoteActivationService.ts(VSCode activation)
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.tssrc/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
**/*.web.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Platform Implementation - Web: Use
.web.tsfiles for browser-compatible APIs
Files:
src/notebooks/serviceRegistry.web.ts
**/*.node.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Platform Implementation - Desktop: Use
.node.tsfiles for full file system access and Python environments
Files:
src/notebooks/serviceRegistry.node.ts
**/*.unit.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Create unit tests in
*.unit.test.tsfiles
**/*.unit.test.ts: Unit tests use Mocha/Chai framework with.unit.test.tsextension
Test files should be placed alongside the source files they test
Useassert.deepStrictEqual()for object comparisons instead of checking individual properties
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Create integration tests in
*.test.tsfiles (not*.unit.test.ts)
**/*.test.ts: ALWAYS check the 'Unittest - Build' task output for TypeScript compilation errors before running any script or declaring work complete
When a mock is returned from a promise in unit tests, ensure the mocked instance has an undefinedthenproperty to avoid hanging tests
Usenpm run test:unittestsfor TypeScript unit tests before committing changes
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
🧬 Code graph analysis (2)
src/notebooks/deepnote/deepnoteNewCellLanguageService.ts (2)
src/kernels/deepnote/types.ts (1)
DEEPNOTE_NOTEBOOK_TYPE(352-352)src/platform/common/constants.ts (1)
PYTHON_LANGUAGE(4-4)
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts (2)
src/test/mocks/vsc/extHostedTypes.ts (1)
Disposable(146-174)src/test/vscode-mock.ts (2)
resetVSCodeMocks(57-305)mockedVSCodeNamespaces(15-15)
🔇 Additional comments (5)
src/test/mocks/vsc/extHostedTypes.ts (1)
104-108: Enum alias forNotebookCellKind.Markuplooks safeHaving both
MarkdownandMarkupshare the same numeric value keeps older tests working while allowing newer code to useMarkup, with no behavioral change for enum comparisons.src/notebooks/serviceRegistry.web.ts (1)
54-55: Web DI wiring forDeepnoteNewCellLanguageServiceis consistentThe new import and
addSingleton<IExtensionSyncActivationService>(..., DeepnoteNewCellLanguageService)follow the existing activation-service pattern and mirror the node registration; nothing else needed here.Also applies to: 127-130
src/notebooks/deepnote/deepnoteNewCellLanguageService.ts (1)
16-22: Activation and disposable management are correctInjecting
IDisposableRegistryand pushing theworkspace.onDidChangeNotebookDocumentsubscription into it ensures the handler is cleaned up with the rest of the extension disposables.src/notebooks/serviceRegistry.node.ts (1)
85-86: Node DI registration forDeepnoteNewCellLanguageServiceis correctly placedImporting the service and registering it as an
IExtensionSyncActivationServicealongside other Deepnote kernel services keeps the activation lifecycle consistent across node and web.Also applies to: 217-220
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts (1)
100-305: Test coverage for new-cell language behavior is thoroughThe suite exercises all key branches: notebook type filtering, cell kind/content checks,
__deepnotePocketmetadata, multiple added cells and content changes, and the “no added cells” path, giving high confidence in the service logic.
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
Outdated
Show resolved
Hide resolved
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.unit.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Create unit tests in
*.unit.test.tsfiles
**/*.unit.test.ts: Unit tests use Mocha/Chai framework with.unit.test.tsextension
Test files should be placed alongside the source files they test
Useassert.deepStrictEqual()for object comparisons instead of checking individual properties
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Create integration tests in
*.test.tsfiles (not*.unit.test.ts)
**/*.test.ts: ALWAYS check the 'Unittest - Build' task output for TypeScript compilation errors before running any script or declaring work complete
When a mock is returned from a promise in unit tests, ensure the mocked instance has an undefinedthenproperty to avoid hanging tests
Usenpm run test:unittestsfor TypeScript unit tests before committing changes
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Usel10n.t()for all user-facing strings in TypeScript files
Use typed error classes fromsrc/platform/errors/instead of generic errors
UseILoggerservice instead of console.log for logging
Preserve error details in error messages while scrubbing personally identifiable information (PII)
Prefer async/await over promise chains
Handle cancellation with CancellationTokenOrder method, fields and properties first by accessibility (public/private/protected) and then by alphabetical order
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
**/*.ts
📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
**/*.ts: ALWAYS check the 'Core - Build' task output for TypeScript compilation errors before running any script or declaring work complete
ALWAYS runnpm run format-fixbefore committing changes to ensure proper code formatting
FIX all TypeScript compilation errors before moving forward with development
Usenpm run format-fixto auto-fix TypeScript formatting issues before committing
Usenpm run lintto check for linter issues in TypeScript files and attempt to fix before committing
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
src/**/*.{ts,tsx}: Don't add the Microsoft copyright header to new files
UseUri.joinPath()for constructing file paths instead of string concatenation with/to ensure platform-correct path separators
Follow established patterns when importing new packages, using helper imports rather than direct imports (e.g., useimport { generateUuid } from '../platform/common/uuid'instead of importing uuid directly)
Add blank lines after const groups and before return statements for readability
Separate third-party and local file imports
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
src/notebooks/deepnote/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Deepnote integration located in
src/notebooks/deepnote/with refactored architecture:deepnoteTypes.ts(type definitions),deepnoteNotebookManager.ts(state management),deepnoteNotebookSelector.ts(UI selection logic),deepnoteDataConverter.ts(data transformations),deepnoteSerializer.ts(main serializer/orchestration),deepnoteActivationService.ts(VSCode activation)
Files:
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts
🧬 Code graph analysis (1)
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts (2)
src/test/mocks/vsc/extHostedTypes.ts (1)
Disposable(146-174)src/test/vscode-mock.ts (2)
resetVSCodeMocks(57-305)mockedVSCodeNamespaces(15-15)
⏰ 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). (1)
- GitHub Check: Build & Test
🔇 Additional comments (1)
src/notebooks/deepnote/deepnoteNewCellLanguageService.unit.test.ts (1)
1-78: Well-structured test setup and helpers.Mock wiring correctly captures the change handler, and activation tests verify listener registration and disposable tracking.
Adding code blocks is handled by VS Code, so we can't modify that behaviour, so instead we check that the block has the correct settings after it's created.
Fixes #227
Summary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.