Skip to content

Conversation

@Artmann
Copy link
Member

@Artmann Artmann commented Oct 17, 2025

Fixes #

Summary by CodeRabbit

  • Bug Fixes

    • Improved error reporting for server startup and toolkit installation by capturing recent stdout/stderr and surfacing typed, actionable errors instead of silent failures.
    • Ensures captured output is retained only as needed and cleaned up when processes stop.
  • New Features

    • Option to view and copy rich, formatted error reports via the output channel/clipboard when kernel initialization fails.
    • More reliable capture of process output for diagnostics during setup and startup.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 17, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds a structured Deepnote kernel error hierarchy and uses those error types across installer and server code. Toolkit installer methods now throw typed errors (DeepnoteVenvCreationError, DeepnoteToolkitInstallError) instead of returning undefined. Server starter tracks per-file stdout/stderr (keeps last 5000 chars), includes captured output in DeepnoteServerTimeoutError and DeepnoteServerStartupError, and cleans up per-file tracking on stop/dispose. DeepnoteKernelAutoSelector now depends on an output channel and handles kernel-selection failures by logging and offering “Show Output” / “Copy Error Details” flows.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Installer as ToolkitInstaller
    participant Errors as DeepnoteErrors

    Caller->>Installer: ensureInstalled(baseInterpreter, fileUri)
    Installer->>Installer: create venv
    alt venv creation fails
        Installer->>Errors: throw DeepnoteVenvCreationError(pythonPath, venvPath, stderr, cause)
        Errors-->>Caller: DeepnoteVenvCreationError
    else install toolkit
        Installer->>Installer: run pip install
        alt install fails
            Installer->>Errors: throw DeepnoteToolkitInstallError(pythonPath, venvPath, packageUrl, stdout, stderr, cause)
            Errors-->>Caller: DeepnoteToolkitInstallError
        else success
            Installer-->>Caller: PythonEnvironment
        end
    end
Loading
sequenceDiagram
    participant Caller
    participant ServerStarter
    participant Process as ServerProcess

    Caller->>ServerStarter: startServer(file)
    ServerStarter->>ServerStarter: init serverOutputByFile[file]={stdout:'',stderr:''}
    ServerStarter->>Process: spawn server
    Process-->>ServerStarter: stdout/stderr
    ServerStarter->>ServerStarter: append & trim outputs (last 5000 chars)
    alt health check succeeds
        ServerStarter-->>Caller: server ready
    else timeout/startup error
        ServerStarter->>ServerStarter: build error with captured output
        ServerStarter-->>Caller: throw DeepnoteServerTimeoutError / DeepnoteServerStartupError
    end
    Caller->>ServerStarter: stopServer(file)
    ServerStarter->>ServerStarter: remove serverOutputByFile[file]
Loading
sequenceDiagram
    participant User
    participant AutoSelector
    participant Output as OutputChannel
    participant Clipboard
    participant UI as VSCode UI

    User->>AutoSelector: trigger kernel selection
    AutoSelector->>AutoSelector: attempt load
    alt success
        AutoSelector-->>User: kernel ready
    else failure
        AutoSelector->>AutoSelector: handleKernelSelectionError(err)
        alt err is DeepnoteKernelError
            AutoSelector->>Output: append(err.getErrorReport())
            AutoSelector->>UI: show options [Show Output, Copy Error Details]
            alt Show Output
                AutoSelector->>Output: reveal()
            else Copy Error Details
                AutoSelector->>Clipboard: writeText(err.getErrorReport())
            end
        else generic error
            AutoSelector->>Output: append(err.toString())
            AutoSelector->>UI: show message [Show Output]
            alt Show Output
                AutoSelector->>Output: reveal()
            end
        end
    end
Loading

Possibly related PRs

Suggested reviewers

  • andyjakubowski
  • jamesbhobbs
  • jankuca

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Better error messages when installing the Deepnote kernel" directly aligns with the PR's core purpose: introducing a comprehensive error hierarchy (DeepnoteKernelError and subclasses) with user-friendly messages, technical details, and troubleshooting steps. The changes across deepnoteToolkitInstaller, deepnoteServerStarter, and deepnoteKernelAutoSelector all converge on enhancing error visibility and user guidance. While the PR also includes architectural shifts (exception-based error handling vs. undefined returns), these serve the primary objective of better error reporting. The title is sufficiently specific for teammates to understand the focus.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2677f00 and e52d03e.

📒 Files selected for processing (1)
  • src/kernels/deepnote/deepnoteServerStarter.node.ts (7 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71%. Comparing base (fbf4d88) to head (e52d03e).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@          Coverage Diff          @@
##            main     #77   +/-   ##
=====================================
  Coverage     71%     71%           
=====================================
  Files        527     527           
  Lines      39474   39474           
  Branches    4933    4933           
=====================================
  Hits       28277   28277           
  Misses      9563    9563           
  Partials    1634    1634           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 146cda4 and 9b00473.

📒 Files selected for processing (4)
  • src/kernels/deepnote/deepnoteServerStarter.node.ts (6 hunks)
  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (3 hunks)
  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts (6 hunks)
  • src/platform/errors/deepnoteKernelErrors.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.node.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use *.node.ts for Desktop-specific implementations that require full file system access and Python environments

Files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
  • src/kernels/deepnote/deepnoteServerStarter.node.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Inject interfaces, not concrete classes
Avoid circular dependencies
Use l10n.t() for user-facing strings
Use typed error classes from src/platform/errors/ when throwing or handling errors
Use the ILogger service instead of console.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 with CancellationToken

**/*.{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/deepnoteKernelAutoSelector.node.ts
  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
  • src/platform/errors/deepnoteKernelErrors.ts
  • src/kernels/deepnote/deepnoteServerStarter.node.ts
src/notebooks/deepnote/**

📄 CodeRabbit inference engine (CLAUDE.md)

Deepnote integration code resides under src/notebooks/deepnote/

Files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
src/kernels/**/*.ts

📄 CodeRabbit inference engine (.github/instructions/kernel.instructions.md)

src/kernels/**/*.ts: Use event-driven updates (EventEmitter) for state changes
Monitor and dispose pending promises to prevent leaks during teardown
Use WeakRef/weak references for notebook/object backreferences to avoid memory leaks
Respect CancellationToken in all async operations

Files:

  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
  • src/kernels/deepnote/deepnoteServerStarter.node.ts
**/!(*.node|*.web).ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Place shared cross-platform logic in common .ts files (not suffixed with .node or .web)

Files:

  • src/platform/errors/deepnoteKernelErrors.ts
src/platform/**/*.ts

📄 CodeRabbit inference engine (.github/instructions/platform.instructions.md)

src/platform/**/*.ts: Use Inversify decorators for DI: annotate classes with @Injectable() and inject dependencies with @Inject(Token)
Use the centralized logger (import { logger } from '../platform/logging') instead of console.log for application logging

Files:

  • src/platform/errors/deepnoteKernelErrors.ts
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/interactiveWindow.instructions.md:0-0
Timestamp: 2025-09-03T12:54:35.368Z
Learning: Applies to src/interactive-window/{interactiveWindow.ts,interactiveWindowController.ts} : Implement robust kernel error handling: automatic restart, clear error display in system info cells, graceful degradation when kernels are unavailable, and user notifications for critical failures
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/kernel.instructions.md:0-0
Timestamp: 2025-09-03T12:58:18.091Z
Learning: Applies to src/kernels/errors/**/*.ts : Use specific error types (e.g., KernelDeadError, KernelConnectionTimeoutError, KernelInterruptTimeoutError, JupyterInvalidKernelError, KernelDependencyError) for failure cases
Learnt from: dinohamzic
PR: deepnote/deepnote#18378
File: apps/webapp/server/api/landing.ts:130-136
Timestamp: 2025-09-10T08:51:54.455Z
Learning: In the Deepnote codebase, prefer explicit error messages over using raw error messages (like err.message) when handling errors that are exposed to customers, for security and user experience reasons.
📚 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/controllers/kernelSource/**/*.ts : For new kernel sources, implement ILocalNotebookKernelSourceSelector (or similar)

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.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/deepnoteActivationService.ts : deepnoteActivationService.ts manages VS Code activation for Deepnote

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
📚 Learning: 2025-09-03T12:58:18.091Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/kernel.instructions.md:0-0
Timestamp: 2025-09-03T12:58:18.091Z
Learning: Applies to src/kernels/kernelProvider.base.ts : KernelProviderBase must create/manage IKernel instances, track by NotebookDocument, manage lifecycle (start/restart/dispose), and expose INotebookKernelExecution

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.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/controllers/kernelSource/**/*.ts : Create a UI provider for kernel selection for the new kernel source

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.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/controllers/**/*KernelConnector*.ts : KernelConnector must present user-friendly error messages for connection failures

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
📚 Learning: 2025-09-03T12:54:35.368Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/interactiveWindow.instructions.md:0-0
Timestamp: 2025-09-03T12:54:35.368Z
Learning: Applies to src/interactive-window/{interactiveWindow.ts,interactiveWindowController.ts} : Implement robust kernel error handling: automatic restart, clear error display in system info cells, graceful degradation when kernels are unavailable, and user notifications for critical failures

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
📚 Learning: 2025-09-03T12:58:18.091Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/kernel.instructions.md:0-0
Timestamp: 2025-09-03T12:58:18.091Z
Learning: Applies to src/kernels/errors/**/*.ts : Use specific error types (e.g., KernelDeadError, KernelConnectionTimeoutError, KernelInterruptTimeoutError, JupyterInvalidKernelError, KernelDependencyError) for failure cases

Applied to files:

  • src/platform/errors/deepnoteKernelErrors.ts
🧬 Code graph analysis (3)
src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts (2)
src/platform/common/types.ts (2)
  • IOutputChannel (10-10)
  • IOutputChannel (11-11)
src/platform/common/constants.ts (1)
  • STANDARD_OUTPUT_CHANNEL (32-32)
src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (2)
src/platform/errors/deepnoteKernelErrors.ts (2)
  • DeepnoteVenvCreationError (50-89)
  • DeepnoteToolkitInstallError (94-169)
src/kernels/deepnote/types.ts (1)
  • DEEPNOTE_TOOLKIT_WHEEL_URL (158-158)
src/kernels/deepnote/deepnoteServerStarter.node.ts (1)
src/platform/errors/deepnoteKernelErrors.ts (2)
  • DeepnoteServerTimeoutError (252-287)
  • DeepnoteServerStartupError (174-247)
⏰ 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). (2)
  • GitHub Check: Lint & Format
  • GitHub Check: Build & Test
🔇 Additional comments (8)
src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (2)

163-167: Good: move to typed venv creation error.

Clearer upstream handling and better diagnostics.


260-266: Good: install failure is now a typed error.

Enables standardized reporting and UX.

src/kernels/deepnote/deepnoteServerStarter.node.ts (3)

45-46: Nice: per-file stdout/stderr ring buffer for diagnostics.

This will materially improve error context.


181-183: Good: initialize and trim output buffers.

Bounded to last 5k chars; low risk of memory growth.

Also applies to: 187-206


223-228: Timeout path correctly captures output before teardown.

The timeout error includes stderr; good UX.

src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts (2)

137-138: Good: route selection failures through a single handler.

Centralized UX keeps errors consistent.


85-87: DI binding for STANDARD_OUTPUT_CHANNEL is properly configured; no changes needed.

The container binding exists in src/extension.common.ts:125 as serviceManager.addSingletonInstance<OutputChannel>(IOutputChannel, standardOutputChannel, STANDARD_OUTPUT_CHANNEL). This identical injection pattern is already used successfully in multiple classes throughout the codebase (productInstaller.node.ts, deepnoteServerStarter.node.ts, deepnoteToolkitInstaller.node.ts, and others). The code is correct.

Likely an incorrect or invalid review comment.

src/platform/errors/deepnoteKernelErrors.ts (1)

1-2: Confirm header policy for new files.

This is a new file with a Microsoft header. Our guidelines elsewhere say not to add the header to new files. Confirm repo policy and adjust if needed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (8)
src/kernels/deepnote/deepnoteServerStarter.node.ts (3)

137-146: Incorrect venv PATH/VIRTUAL_ENV derivation (breaks on python3, Windows).

Regex trimming ‘/python’ or ‘\python.exe’ misses common paths (e.g., bin/python3), yielding bad PATH/VIRTUAL_ENV. Derive via path utilities.

Apply:

-        const venvBinDir = interpreter.uri.fsPath.replace(/\/python$/, '').replace(/\\python\.exe$/, '');
-        const env = { ...process.env };
-
-        // Prepend venv bin directory to PATH so shell commands use venv's Python
-        env.PATH = `${venvBinDir}${process.platform === 'win32' ? ';' : ':'}${env.PATH || ''}`;
-
-        // Also set VIRTUAL_ENV to indicate we're in a venv
-        const venvPath = venvBinDir.replace(/\/bin$/, '').replace(/\\Scripts$/, '');
-        env.VIRTUAL_ENV = venvPath;
+        const env = { ...process.env };
+        const pythonPath = interpreter.uri.fsPath;
+        const binDir = path.dirname(pythonPath);
+        const leaf = path.basename(binDir).toLowerCase();
+        const venvRoot =
+            leaf === 'scripts' || leaf === 'bin' ? path.dirname(binDir) : binDir;
+        const delim = process.platform === 'win32' ? ';' : ':';
+        // Ensure shell commands use the venv's Python
+        env.PATH = `${binDir}${delim}${env.PATH || ''}`;
+        // Advertise virtualenv root (used by many tools)
+        env.VIRTUAL_ENV = venvRoot;

Also applies to: 140-146


129-170: Localize OutputChannel strings.

User-facing text should use l10n.t(). Convert appendLine messages (start/stop status, warnings) to localized strings.

Example pattern:

- this.outputChannel.appendLine(`Starting Deepnote server on port ${port} for ${deepnoteFileUri.fsPath}...`);
+ this.outputChannel.appendLine(l10n.t('Starting Deepnote server on port {0} for {1}...', port, deepnoteFileUri.fsPath));

Add l10n import.


161-162: Compute working directory robustly.

Using Uri.joinPath(fileUri, '..') is brittle. Prefer dirname of the file path.

Apply:

-        const notebookDir = Uri.joinPath(deepnoteFileUri, '..').fsPath;
+        const notebookDir = path.dirname(deepnoteFileUri.fsPath);
src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (3)

128-129: Localize OutputChannel messages.

Wrap user-facing strings with l10n.t() throughout installer output for consistency with guidelines.

Example edits:

- this.outputChannel.appendLine(`Setting up Deepnote toolkit environment for ${deepnoteFileUri.fsPath}...`);
+ this.outputChannel.appendLine(l10n.t('Setting up Deepnote toolkit environment for {0}...', deepnoteFileUri.fsPath));
- this.outputChannel.appendLine('Upgrading pip...');
+ this.outputChannel.appendLine(l10n.t('Upgrading pip...'));
- this.outputChannel.appendLine('Installing deepnote-toolkit and ipykernel...');
+ this.outputChannel.appendLine(l10n.t('Installing deepnote-toolkit and ipykernel...'));
- this.outputChannel.appendLine('✓ Deepnote toolkit ready');
+ this.outputChannel.appendLine(l10n.t('✓ Deepnote toolkit ready'));
- this.outputChannel.appendLine('✗ deepnote-toolkit installation failed');
+ this.outputChannel.appendLine(l10n.t('✗ deepnote-toolkit installation failed'));
- this.outputChannel.appendLine('Failed to set up deepnote-toolkit; see logs for details');
+ this.outputChannel.appendLine(l10n.t('Failed to set up deepnote-toolkit; see logs for details'));

Add l10n to the vscode import list.

Also applies to: 175-176, 193-215, 254-259, 276-277


322-326: Windows path bug in display name.

Splitting by '/' fails on Windows. Use path.basename.

Apply:

-        const parts = deepnoteFileUri.fsPath.split('/');
-        return parts[parts.length - 1] || 'notebook';
+        return path.basename(deepnoteFileUri.fsPath) || 'notebook';

Import the existing path helper as in server starter.


176-206: Pass CancellationToken to exec calls and handle process termination on cancellation.

The concern is valid. The token parameter is accepted (line 122) but never passed to any exec() call (lines 176, 195, 226). When a user cancels during a pip operation, the Cancellation.throwIfCanceled(token) checks at lines 189 and 217 only fire after the operation completes—if cancellation happens during execution, the pip/venv process continues uninterrupted, leaving orphans.

Use execObservable() to access the child process and kill it on cancellation:

const upgrade = venvProcessService.execObservable(
  venvInterpreter.uri.fsPath,
  ['-m', 'pip', 'install', '--upgrade', 'pip'],
  { throwOnStdErr: false }
);
const sub = token?.onCancellationRequested(() => upgrade.proc?.kill());
// Await result; check API for exact property (.result, .completed, or wrap exit event)
sub?.dispose();

Apply the same pattern to lines 195 and 226.

src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts (2)

367-373: Avoid fsPath in provider handle; use a safe hash.

Handles with raw paths can include separators and be long. Use the existing venv hash.

Apply:

-                    const serverProviderHandle: JupyterServerProviderHandle = {
+                    const hash = this.toolkitInstaller.getVenvHash(baseFileUri);
+                    const serverProviderHandle: JupyterServerProviderHandle = {
                         extensionId: JVSC_EXTENSION_ID,
                         id: 'deepnote-server',
-                        handle: `deepnote-toolkit-server-${baseFileUri.fsPath}`
+                        handle: `deepnote-toolkit-server-${hash}`
                     };

535-538: Sanitize controller IDs; avoid embedding full paths.

Use a short hash to form the temporary controller ID.

Apply:

-        const loadingController = notebooks.createNotebookController(
-            `deepnote-loading-${notebookKey}`,
+        const safeId = this.toolkitInstaller.getVenvHash(notebook.uri.with({ query: '', fragment: '' }));
+        const loadingController = notebooks.createNotebookController(
+            `deepnote-loading-${safeId}`,
             DEEPNOTE_NOTEBOOK_TYPE,
             l10n.t('Loading Deepnote Kernel...')
         );

Also applies to: 549-555

♻️ Duplicate comments (3)
src/kernels/deepnote/deepnoteServerStarter.node.ts (1)

218-250: Bugfix verified: capture output before cleanup.

You now capture stdout/stderr before stop; timeout and unknown-failure paths preserve diagnostics. Good.

src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (1)

269-286: Output sanitization fix acknowledged.

You no longer echo raw exceptions to the Output channel; good alignment with learnings.

src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts (1)

557-612: UI strings localized and clipboard hardened.

Prior feedback addressed: l10n for messages/actions and clipboard write wrapped in try/catch.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b00473 and 2677f00.

📒 Files selected for processing (4)
  • src/kernels/deepnote/deepnoteServerStarter.node.ts (7 hunks)
  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (6 hunks)
  • src/kernels/deepnote/types.ts (1 hunks)
  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts (7 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.node.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use *.node.ts for Desktop-specific implementations that require full file system access and Python environments

Files:

  • src/kernels/deepnote/deepnoteServerStarter.node.ts
  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Inject interfaces, not concrete classes
Avoid circular dependencies
Use l10n.t() for user-facing strings
Use typed error classes from src/platform/errors/ when throwing or handling errors
Use the ILogger service instead of console.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 with CancellationToken

**/*.{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/kernels/deepnote/deepnoteServerStarter.node.ts
  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
  • src/kernels/deepnote/types.ts
  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
src/kernels/**/*.ts

📄 CodeRabbit inference engine (.github/instructions/kernel.instructions.md)

src/kernels/**/*.ts: Use event-driven updates (EventEmitter) for state changes
Monitor and dispose pending promises to prevent leaks during teardown
Use WeakRef/weak references for notebook/object backreferences to avoid memory leaks
Respect CancellationToken in all async operations

Files:

  • src/kernels/deepnote/deepnoteServerStarter.node.ts
  • src/kernels/deepnote/types.ts
  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
src/notebooks/deepnote/**

📄 CodeRabbit inference engine (CLAUDE.md)

Deepnote integration code resides under src/notebooks/deepnote/

Files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
**/!(*.node|*.web).ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Place shared cross-platform logic in common .ts files (not suffixed with .node or .web)

Files:

  • src/kernels/deepnote/types.ts
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/kernel.instructions.md:0-0
Timestamp: 2025-09-03T12:58:18.091Z
Learning: Applies to src/kernels/errors/**/*.ts : Use specific error types (e.g., KernelDeadError, KernelConnectionTimeoutError, KernelInterruptTimeoutError, JupyterInvalidKernelError, KernelDependencyError) for failure cases
📚 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/controllers/kernelSource/**/*.ts : For new kernel sources, implement ILocalNotebookKernelSourceSelector (or similar)

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.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/deepnoteActivationService.ts : deepnoteActivationService.ts manages VS Code activation for Deepnote

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
📚 Learning: 2025-09-03T12:58:18.091Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/kernel.instructions.md:0-0
Timestamp: 2025-09-03T12:58:18.091Z
Learning: Applies to src/kernels/kernelProvider.base.ts : KernelProviderBase must create/manage IKernel instances, track by NotebookDocument, manage lifecycle (start/restart/dispose), and expose INotebookKernelExecution

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.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/controllers/kernelSource/**/*.ts : Create a UI provider for kernel selection for the new kernel source

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.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/controllers/**/*KernelConnector*.ts : KernelConnector must present user-friendly error messages for connection failures

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
📚 Learning: 2025-09-03T12:54:35.368Z
Learnt from: CR
PR: deepnote/vscode-extension#0
File: .github/instructions/interactiveWindow.instructions.md:0-0
Timestamp: 2025-09-03T12:54:35.368Z
Learning: Applies to src/interactive-window/{interactiveWindow.ts,interactiveWindowController.ts} : Implement robust kernel error handling: automatic restart, clear error display in system info cells, graceful degradation when kernels are unavailable, and user notifications for critical failures

Applied to files:

  • src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts
📚 Learning: 2025-09-10T08:51:54.455Z
Learnt from: dinohamzic
PR: deepnote/deepnote#18378
File: apps/webapp/server/api/landing.ts:130-136
Timestamp: 2025-09-10T08:51:54.455Z
Learning: In the Deepnote codebase, prefer explicit error messages over using raw error messages (like err.message) when handling errors that are exposed to customers, for security and user experience reasons.

Applied to files:

  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
🧬 Code graph analysis (3)
src/kernels/deepnote/deepnoteServerStarter.node.ts (1)
src/platform/errors/deepnoteKernelErrors.ts (2)
  • DeepnoteServerTimeoutError (252-287)
  • DeepnoteServerStartupError (174-247)
src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts (2)
src/platform/common/types.ts (2)
  • IOutputChannel (10-10)
  • IOutputChannel (11-11)
src/platform/common/constants.ts (1)
  • STANDARD_OUTPUT_CHANNEL (32-32)
src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (2)
src/platform/errors/deepnoteKernelErrors.ts (2)
  • DeepnoteVenvCreationError (50-89)
  • DeepnoteToolkitInstallError (94-169)
src/kernels/deepnote/types.ts (1)
  • DEEPNOTE_TOOLKIT_WHEEL_URL (160-160)
⏰ 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 (3)
src/kernels/deepnote/types.ts (2)

159-161: Staging wheel URL hardcoded. Make configurable or gated.

The wheel points to a staging S3 bucket. Consider a config flag or environment-based selection to avoid shipping staging endpoints by mistake.

Would you like a quick patch to switch via package.json setting or environment variable?


75-84: Contract verified: ensureInstalled callers properly handle the tightened contract.

Both call sites avoid undefined checks:

  • deepnoteKernelAutoSelector.node.ts:350–356 directly accesses venvInterpreter.uri without null-checking
  • deepnoteServerStarter.node.ts:122 relies on exception propagation

No stale guards exist. Code is compliant.

src/notebooks/deepnote/deepnoteKernelAutoSelector.node.ts (1)

347-355: Change is correct—single call site properly passes venv interpreter.

Scan confirms only one deepnote getOrStartServer call site (line 360 in deepnoteKernelAutoSelector.node.ts) and it passes venvInterpreter. No alternative call sites pass a base interpreter, so the removal of installer logic from serverStarter is safe.

@Artmann Artmann marked this pull request as ready for review October 17, 2025 12:24
@Artmann Artmann enabled auto-merge (squash) October 17, 2025 12:55
Copy link
Member

@tkislan tkislan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, works nice

@Artmann Artmann merged commit a626bb3 into main Oct 22, 2025
12 of 13 checks passed
@Artmann Artmann deleted the chris/kernel-error-messages branch October 22, 2025 08:25
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.

5 participants