Skip to content

Conversation

@Artmann
Copy link
Contributor

@Artmann Artmann commented Dec 23, 2025

Example:

metadata:
  createdAt: 2025-09-05T08:01:27.190Z/Users/artmann/Downloads/Simple Query.ipynb
  modifiedAt: '2025-12-23T12:01:47.688Z'
project:
  ...
version: 1.0.0
execution:
  finishedAt: '2025-12-23T11:08:13.183Z'
  startedAt: '2025-12-23T11:08:12.998Z'
  summary:
    blocksExecuted: 4
    blocksFailed: 0
    blocksSucceeded: 4
    totalDurationMs: 185
environment:
  hash: sha256:70835bcbe95326b97ebc22984cc966567cdcd5bad62ca45d90e8e549cd976cbe
  packages:
    alembic: 1.17.1
    altair: 5.5.0
    annotated-types: 0.7.0
    anyio: 4.11.0
    appnope: 0.1.4
    argon2-cffi: 25.1.0
    argon2-cffi-bindings: 25.1.0
    arro3-core: 0.6.5
    arrow: 1.4.0
    asn1crypto: 1.5.1
    asttokens: 3.0.0
    asynch: 0.3.1
    attrs: 25.4.0
    bcrypt: 5.0.0
    beautifulsoup4: 4.14.2
    black: 25.11.0
    bleach: 6.3.0
    blinker: 1.9.0
    boto3: 1.40.71
    botocore: 1.40.71
    cachetools: 6.2.1
    certifi: 2025.11.12
    cffi: 1.17.1
    charset-normalizer: 3.4.4
    ciso8601: 2.3.3
    click: 8.3.0
    clickhouse-driver: 0.2.10
    clickhouse-sqlalchemy: 0.3.2
    comm: 0.2.3
    contourpy: 1.3.3
    cryptography: 44.0.3
    cycler: 0.12.1
    datafusion: 49.0.0
    db-dtypes: 1.3.1
    debugpy: 1.8.17
    decorator: 5.2.1
    deepnote-python-lsp-server: 1.13.1rc2
    deepnote-sqlalchemy-redshift: 0.8.17
    deepnote-toolkit: 1.1.0
    deepnote_vegafusion: 2.0.8
    defusedxml: 0.7.1
    dill: 0.4.0
    dnspython: 2.8.0
    docstring-to-markdown: '0.17'
    docutils: 0.22.4
    duckdb: 1.4.1
    executing: 2.2.1
    fastjsonschema: 2.21.2
    filelock: 3.20.0
    fonttools: 4.61.0
    fqdn: 1.5.1
    fsspec: 2025.10.0
    gitdb: 4.0.12
    gitpython: 3.1.45
    google-api-core: 2.28.1
    google-auth: 2.43.0
    google-cloud-bigquery: 3.38.0
    google-cloud-bigquery-storage: 2.34.0
    google-cloud-core: 2.5.0
    google-cloud-spanner: 3.59.0
    google-crc32c: 1.7.1
    google-resumable-media: 2.7.2
    googleapis-common-protos: 1.72.0
    greenlet: 3.2.4
    grpc-google-iam-v1: 0.14.3
    grpc-interceptor: 0.15.4
    grpcio: 1.76.0
    grpcio-status: 1.71.2
    h11: 0.16.0
    idna: '3.11'
    importlib_metadata: 8.7.0
    ipykernel: 7.1.0
    ipython: 9.7.0
    ipython_pygments_lexers: 1.1.1
    isoduration: 20.11.0
    itsdangerous: 2.2.0
    jedi: 0.19.2
    jinja2: 3.1.6
    jmespath: 1.0.1
    jsonpointer: 3.0.0
    jsonschema: 4.25.1
    jsonschema-specifications: 2025.9.1
    jupyter-events: 0.12.0
    jupyter-resource-usage: 1.2.0
    jupyter_client: 8.6.3
    jupyter_core: 5.9.1
    jupyter_server: 2.17.0
    jupyter_server_terminals: 0.5.3
    jupyterlab_pygments: 0.3.0
    kiwisolver: 1.4.9
    lark: 1.3.1
    leb128: 1.0.8
    loro: 1.10.3
    lz4: 4.4.5
    mako: 1.3.10
    marimo: 0.18.4
    markdown: '3.10'
    markupsafe: 3.0.3
    matplotlib: 3.10.7
    matplotlib-inline: 0.2.1
    mistune: 3.1.4
    msgspec: 0.20.0
    mypy_extensions: 1.1.0
    narwhals: 2.11.0
    nbclient: 0.10.2
    nbconvert: 7.16.6
    nbformat: 5.10.4
    nest-asyncio: 1.6.0
    numpy: 2.3.4
    packaging: '25.0'
    pandas: 2.2.3
    pandocfilters: 1.5.1
    paramiko: 3.5.1
    parso: 0.8.5
    pathspec: 0.12.1
    pexpect: 4.9.0
    pg8000: 1.31.5
    pillow: 12.0.0
    platformdirs: 4.5.0
    pluggy: 1.6.0
    prometheus_client: 0.23.1
    prompt_toolkit: 3.0.52
    proto-plus: 1.26.1
    protobuf: 5.29.5
    psutil: 7.1.3
    psycopg2-binary: 2.9.11
    ptyprocess: 0.7.0
    pure_eval: 0.2.3
    pyarrow: 21.0.0
    pyasn1: 0.6.1
    pyasn1_modules: 0.4.2
    pyathena: 3.9.0
    pycparser: '2.23'
    pydantic: 2.12.4
    pydantic_core: 2.41.5
    pydeck: 0.9.1
    pygments: 2.19.2
    pyjwt: 2.10.1
    pymdown-extensions: 10.19.1
    pymongo: 4.15.4
    pymssql: 2.3.9
    pymysql: 1.1.2
    pynacl: 1.6.0
    pyopenssl: 25.1.0
    pyparsing: 3.2.5
    python-dateutil: 2.9.0.post0
    python-json-logger: 4.0.0
    python-lsp-jsonrpc: 1.1.2
    pytokens: 0.3.0
    pytz: '2025.2'
    pyyaml: 6.0.3
    pyzmq: 27.1.0
    referencing: 0.37.0
    requests: 2.32.5
    rfc3339-validator: 0.1.4
    rfc3986-validator: 0.1.1
    rfc3987-syntax: 1.1.0
    rpds-py: 0.28.0
    rsa: 4.9.1
    s3transfer: 0.14.0
    scramp: 1.4.6
    send2trash: 1.8.3
    six: 1.17.0
    smmap: 5.0.2
    sniffio: 1.3.1
    snowflake-connector-python: 3.18.0
    snowflake-sqlalchemy: 1.7.7
    sortedcontainers: 2.4.0
    soupsieve: '2.8'
    sqlalchemy: 2.0.44
    sqlalchemy-bigquery: 1.16.0
    sqlalchemy-spanner: 1.17.1
    sqlalchemy_dremio: 3.0.4
    sqlparse: 0.5.3
    sshtunnel: 0.4.0
    stack-data: 0.6.3
    starlette: 0.50.0
    streamlit: 1.51.0
    tenacity: 9.1.2
    terminado: 0.18.1
    tinycss2: 1.4.0
    toml: 0.10.2
    tomlkit: 0.13.3
    tornado: 6.5.2
    traitlets: 5.14.3
    trino: 0.330.0
    typing-inspection: 0.4.2
    typing_extensions: 4.15.0
    tzdata: '2025.2'
    tzlocal: 5.3.1
    ujson: 5.11.0
    uri-template: 1.3.0
    urllib3: 2.5.0
    uvicorn: 0.40.0
    vl-convert-python: 1.7.0
    wcwidth: 0.2.14
    webcolors: 25.10.0
    webencodings: 0.5.1
    websocket-client: 1.9.0
    websockets: 15.0.1
    wrapt: 2.0.1
    zipp: 3.23.0
    zstd: 1.5.7.2
  platform: darwin-arm64
  python:
    environment: venv
    version: 3.13.9

Summary by CodeRabbit

Release Notes

  • New Features

    • Added environment snapshot capture before cell execution, recording Python version, installed packages, and environment type for better reproducibility and debugging.
    • Enhanced cell metadata tracking, now recording execution timestamps (start/end) and content hash for each cell.
    • Improved notebook serialization to preserve environment and execution metadata within saved files.
  • Tests

    • Added comprehensive unit tests for environment and metadata capture functionality.
  • Chores

    • Updated dependency: @deepnote/blocks to v1.4.0.
    • Enhanced spell-check dictionary.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

📝 Walkthrough

Walkthrough

This PR introduces snapshot metadata capture for Deepnote notebook execution. New modules handle environment detection (Python version, packages, platform), timing, and content hashing. The snapshot service integrates into the kernel execution pipeline to record cell state changes and environment details before execution begins. Serialization logic is updated to persist these metadata fields. Service registration wires the new components through dependency injection. Type definitions are extended to carry execution metadata through the Deepnote block hierarchy.

Sequence Diagram(s)

sequenceDiagram
    participant CellExecutionQueue
    participant SnapshotMetadataService
    participant EnvironmentCapture
    participant Kernel as Kernel<br/>(execute cells)
    participant DeepnoteSerializer
    participant Storage

    CellExecutionQueue->>SnapshotMetadataService: captureEnvironmentBeforeExecution(notebookUri)
    activate SnapshotMetadataService
    SnapshotMetadataService->>EnvironmentCapture: captureEnvironment(notebookUri)
    activate EnvironmentCapture
    EnvironmentCapture-->>SnapshotMetadataService: Environment {hash, packages, platform, python}
    deactivate EnvironmentCapture
    SnapshotMetadataService-->>CellExecutionQueue: environment captured & cached
    deactivate SnapshotMetadataService
    
    rect rgb(200, 220, 240)
    Note over CellExecutionQueue,Kernel: Cell Execution Loop
    loop per queued cell
        CellExecutionQueue->>SnapshotMetadataService: recordCellExecutionStart(cellId, startTime)
        CellExecutionQueue->>Kernel: execute cell
        Kernel->>Kernel: cell runs
        CellExecutionQueue->>SnapshotMetadataService: recordCellExecutionEnd(cellId, endTime, success)
        CellExecutionQueue->>SnapshotMetadataService: updateContentHash(cellId, hash)
    end
    end
    
    CellExecutionQueue->>DeepnoteSerializer: serialize notebook
    activate DeepnoteSerializer
    DeepnoteSerializer->>SnapshotMetadataService: getBlockExecutionMetadata(cellId)
    SnapshotMetadataService-->>DeepnoteSerializer: {contentHash, executionStartedAt, executionFinishedAt}
    DeepnoteSerializer->>SnapshotMetadataService: getEnvironmentMetadata()
    SnapshotMetadataService-->>DeepnoteSerializer: Environment details
    DeepnoteSerializer->>Storage: write notebook with metadata
    deactivate DeepnoteSerializer
Loading

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding environment information tracking during block execution, which aligns with the PR's core objective.

📜 Recent review details

Configuration used: Organization 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 3ea2c60 and 405ba1f.

📒 Files selected for processing (1)
  • src/notebooks/deepnote/snapshotMetadataService.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

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

**/*.{ts,tsx}: Use l10n.t() for all user-facing strings in TypeScript files
Use typed error classes from src/platform/errors/ instead of generic errors
Use ILogger service 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 CancellationToken

Order method, fields and properties first by accessibility (public/private/protected) and then by alphabetical order

Files:

  • src/notebooks/deepnote/snapshotMetadataService.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 run npm run format-fix before committing changes to ensure proper code formatting
FIX all TypeScript compilation errors before moving forward with development
Use npm run format-fix to auto-fix TypeScript formatting issues before committing
Use npm run lint to check for linter issues in TypeScript files and attempt to fix before committing

Files:

  • src/notebooks/deepnote/snapshotMetadataService.ts
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

src/**/*.{ts,tsx}: Don't add the Microsoft copyright header to new files
Use Uri.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., use import { 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/snapshotMetadataService.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/snapshotMetadataService.ts
🧬 Code graph analysis (1)
src/notebooks/deepnote/snapshotMetadataService.ts (2)
src/notebooks/deepnote/environmentCapture.node.ts (3)
  • injectable (58-248)
  • IEnvironmentCapture (47-47)
  • IEnvironmentCapture (49-54)
src/notebooks/deepnote/deepnoteSerializer.ts (1)
  • injectable (51-381)
⏰ 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

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

@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0%. Comparing base (71abe5f) to head (405ba1f).

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #254   +/-   ##
===========================
===========================
🚀 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: 15

📜 Review details

Configuration used: Organization 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 71abe5f and 02816e1.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (21)
  • build/esbuild/build.ts
  • package.json
  • src/kernels/execution/cellExecutionQueue.ts
  • src/kernels/kernelExecution.ts
  • src/kernels/kernelProvider.node.ts
  • src/notebooks/deepnote/deepnoteActivationService.ts
  • src/notebooks/deepnote/deepnoteDataConverter.ts
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/pipFileParser.ts
  • src/notebooks/deepnote/pipFileParser.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/notebooks/serviceRegistry.node.ts
  • src/platform/deepnote/deepnoteTypes.ts
  • src/platform/deepnote/pocket.ts
  • src/platform/interpreter/helpers.ts
  • src/platform/notebooks/cellExecutionStateService.ts
  • src/platform/notebooks/deepnote/types.ts
  • tsconfig.base.json
🧰 Additional context used
📓 Path-based instructions (18)
**/*.{ts,tsx}

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

**/*.{ts,tsx}: Use l10n.t() for all user-facing strings in TypeScript files
Use typed error classes from src/platform/errors/ instead of generic errors
Use ILogger service 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 CancellationToken

Order method, fields and properties first by accessibility (public/private/protected) and then by alphabetical order

Files:

  • build/esbuild/build.ts
  • src/notebooks/deepnote/pipFileParser.unit.test.ts
  • src/notebooks/deepnote/deepnoteDataConverter.ts
  • src/platform/notebooks/deepnote/types.ts
  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/kernels/kernelExecution.ts
  • src/kernels/execution/cellExecutionQueue.ts
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/notebooks/deepnote/deepnoteActivationService.ts
  • src/notebooks/deepnote/pipFileParser.ts
  • src/platform/deepnote/deepnoteTypes.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/platform/deepnote/pocket.ts
  • src/platform/notebooks/cellExecutionStateService.ts
  • src/kernels/kernelProvider.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
  • src/platform/interpreter/helpers.ts
  • src/notebooks/serviceRegistry.node.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 run npm run format-fix before committing changes to ensure proper code formatting
FIX all TypeScript compilation errors before moving forward with development
Use npm run format-fix to auto-fix TypeScript formatting issues before committing
Use npm run lint to check for linter issues in TypeScript files and attempt to fix before committing

Files:

  • build/esbuild/build.ts
  • src/notebooks/deepnote/pipFileParser.unit.test.ts
  • src/notebooks/deepnote/deepnoteDataConverter.ts
  • src/platform/notebooks/deepnote/types.ts
  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/kernels/kernelExecution.ts
  • src/kernels/execution/cellExecutionQueue.ts
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/notebooks/deepnote/deepnoteActivationService.ts
  • src/notebooks/deepnote/pipFileParser.ts
  • src/platform/deepnote/deepnoteTypes.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/platform/deepnote/pocket.ts
  • src/platform/notebooks/cellExecutionStateService.ts
  • src/kernels/kernelProvider.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
  • src/platform/interpreter/helpers.ts
  • src/notebooks/serviceRegistry.node.ts
**/*.unit.test.ts

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

Create unit tests in *.unit.test.ts files

**/*.unit.test.ts: Unit tests use Mocha/Chai framework with .unit.test.ts extension
Test files should be placed alongside the source files they test
Use assert.deepStrictEqual() for object comparisons instead of checking individual properties

Files:

  • src/notebooks/deepnote/pipFileParser.unit.test.ts
  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
**/*.test.ts

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

Create integration tests in *.test.ts files (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 undefined then property to avoid hanging tests
Use npm run test:unittests for TypeScript unit tests before committing changes

Files:

  • src/notebooks/deepnote/pipFileParser.unit.test.ts
  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

src/**/*.{ts,tsx}: Don't add the Microsoft copyright header to new files
Use Uri.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., use import { 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/pipFileParser.unit.test.ts
  • src/notebooks/deepnote/deepnoteDataConverter.ts
  • src/platform/notebooks/deepnote/types.ts
  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/kernels/kernelExecution.ts
  • src/kernels/execution/cellExecutionQueue.ts
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/notebooks/deepnote/deepnoteActivationService.ts
  • src/notebooks/deepnote/pipFileParser.ts
  • src/platform/deepnote/deepnoteTypes.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/platform/deepnote/pocket.ts
  • src/platform/notebooks/cellExecutionStateService.ts
  • src/kernels/kernelProvider.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
  • src/platform/interpreter/helpers.ts
  • src/notebooks/serviceRegistry.node.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/pipFileParser.unit.test.ts
  • src/notebooks/deepnote/deepnoteDataConverter.ts
  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/notebooks/deepnote/deepnoteActivationService.ts
  • src/notebooks/deepnote/pipFileParser.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
src/platform/**/*.ts

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

src/platform/**/*.ts: Use Inversify-based dependency injection with IServiceManager and IServiceContainer for managing service relationships and dependencies
Define service interfaces using Symbol-based exports (e.g., export const IFileSystem = Symbol('IFileSystem')) paired with corresponding TypeScript interfaces
Register types using the pattern serviceManager.addSingleton<IService>(IService, ServiceImplementation) in registerTypes functions
Use @Injectable() and @Inject() decorators from Inversify for class dependency injection configuration
Implement unified interfaces for cross-platform services (IFileSystem, IPlatformService, etc.) with graceful degradation for web environment limitations
Use structured logging with context via logger.info, logger.error, etc. rather than console.log
Provide platform capability checks and feature detection before using advanced platform-specific features
Register separate service implementations for desktop and web environments, allowing the DI container to resolve the correct platform implementation

Files:

  • src/platform/notebooks/deepnote/types.ts
  • src/platform/deepnote/deepnoteTypes.ts
  • src/platform/deepnote/pocket.ts
  • src/platform/notebooks/cellExecutionStateService.ts
  • src/platform/interpreter/helpers.ts
src/kernels/**/*.ts

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

src/kernels/**/*.ts: Respect CancellationToken in all async operations across kernel execution, session communication, and finder operations
Implement proper error handling in files using custom error types from errors/ directory (KernelDeadError, KernelConnectionTimeoutError, KernelInterruptTimeoutError, JupyterInvalidKernelError, KernelDependencyError)

Files:

  • src/kernels/kernelExecution.ts
  • src/kernels/execution/cellExecutionQueue.ts
  • src/kernels/kernelProvider.node.ts
src/kernels/{kernel.ts,kernelProvider.*.ts,execution/*.ts}

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

Use event-driven updates via EventEmitter for kernel state changes and lifecycle events (willRestart, willInterrupt, onDidChangeKernels, etc.)

Files:

  • src/kernels/execution/cellExecutionQueue.ts
  • src/kernels/kernelProvider.node.ts
src/kernels/{kernelProvider.*.ts,execution/*.ts}

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

Use weak references or proper cleanup patterns to avoid memory leaks with notebook references in kernel tracking and lifecycle management

Files:

  • src/kernels/execution/cellExecutionQueue.ts
  • src/kernels/kernelProvider.node.ts
src/kernels/execution/*.ts

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

Coordinate notebook-level execution through NotebookKernelExecution which manages CellExecutionQueue for sequential cell execution and uses CellExecutionMessageHandler to process kernel messages

Files:

  • src/kernels/execution/cellExecutionQueue.ts
src/kernels/{kernel.ts,kernelFinder.ts,execution/*.ts,**/launcher*.ts}

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

Add telemetry tracking for all kernel operations (discovery, startup, execution, errors) to enable usage analytics

Files:

  • src/kernels/execution/cellExecutionQueue.ts
**/*.node.ts

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

Platform Implementation - Desktop: Use .node.ts files for full file system access and Python environments

Files:

  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/kernels/kernelProvider.node.ts
  • src/notebooks/serviceRegistry.node.ts
src/kernels/{kernelProvider.node.ts,kernelProvider.web.ts}

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

Implement platform-specific variants for KernelProvider and session communication: kernelProvider.node.ts for Node.js environment with raw kernel support and ZeroMQ, kernelProvider.web.ts for web environment with remote kernels only

Files:

  • src/kernels/kernelProvider.node.ts
src/kernels/{serviceRegistry.*.ts,kernelProvider.*.ts,common/base*.ts}

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

Use dependency injection for all kernel system components to ensure testability and loose coupling between modules

Files:

  • src/kernels/kernelProvider.node.ts
src/kernels/{serviceRegistry.*.ts,kernelProvider.*.ts}

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

Implement lazy loading for finder activation, session creation, and Python extension feature integration to optimize performance

Files:

  • src/kernels/kernelProvider.node.ts
src/kernels/{kernelFinder.ts,kernelProvider.*.ts,**/session*.ts}

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

Implement caching strategies for kernel specs, connection metadata, and session reuse to reduce file system scanning and avoid unnecessary kernel restarts

Files:

  • src/kernels/kernelProvider.node.ts
src/kernels/{kernel.ts,kernelProvider.*.ts}

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

Use monitoring components (KernelCrashMonitor, KernelAutoReConnectMonitor, KernelAutoRestartMonitor) to detect kernel failures and implement transparent recovery mechanisms

Files:

  • src/kernels/kernelProvider.node.ts
🧬 Code graph analysis (14)
src/notebooks/deepnote/pipFileParser.unit.test.ts (2)
src/notebooks/deepnote/environmentCapture.node.ts (2)
  • parsePipFreezeFile (46-46)
  • parsePipFreezeFile (46-46)
src/notebooks/deepnote/pipFileParser.ts (1)
  • parsePipFreezeFile (11-44)
src/platform/notebooks/deepnote/types.ts (1)
src/notebooks/deepnote/snapshotMetadataService.ts (1)
  • ISnapshotMetadataService (78-78)
src/kernels/kernelExecution.ts (1)
src/platform/notebooks/deepnote/types.ts (2)
  • ISnapshotMetadataService (125-125)
  • ISnapshotMetadataService (126-138)
src/kernels/execution/cellExecutionQueue.ts (1)
src/platform/common/types.ts (1)
  • Resource (19-19)
src/notebooks/deepnote/deepnoteSerializer.ts (5)
src/notebooks/types.ts (2)
  • IDeepnoteNotebookManager (38-38)
  • IDeepnoteNotebookManager (39-59)
src/notebooks/deepnote/snapshotMetadataService.ts (2)
  • ISnapshotMetadataService (78-78)
  • ISnapshotMetadataServiceFull (80-112)
src/platform/notebooks/deepnote/types.ts (2)
  • ISnapshotMetadataService (125-125)
  • ISnapshotMetadataService (126-138)
src/platform/deepnote/deepnoteTypes.ts (1)
  • DeepnoteBlock (12-21)
src/notebooks/deepnote/environmentCapture.node.ts (1)
  • computeHash (114-130)
src/notebooks/deepnote/deepnoteActivationService.ts (2)
src/notebooks/deepnote/snapshotMetadataService.ts (2)
  • ISnapshotMetadataService (78-78)
  • ISnapshotMetadataServiceFull (80-112)
src/platform/notebooks/deepnote/types.ts (2)
  • ISnapshotMetadataService (125-125)
  • ISnapshotMetadataService (126-138)
src/notebooks/deepnote/pipFileParser.ts (1)
src/notebooks/deepnote/environmentCapture.node.ts (2)
  • parsePipFreezeFile (46-46)
  • parsePipFreezeFile (46-46)
src/platform/deepnote/deepnoteTypes.ts (1)
src/notebooks/deepnote/deepnoteSerializer.ts (2)
  • DeepnoteBlock (12-12)
  • DeepnoteFile (12-12)
src/notebooks/deepnote/environmentCapture.node.ts (2)
src/kernels/deepnote/environments/deepnoteEnvironment.ts (1)
  • DeepnoteEnvironment (9-60)
src/notebooks/deepnote/pipFileParser.ts (1)
  • parsePipFreezeFile (11-44)
src/notebooks/deepnote/snapshotMetadataService.unit.test.ts (1)
src/notebooks/deepnote/environmentCapture.node.ts (2)
  • IEnvironmentCapture (48-48)
  • IEnvironmentCapture (50-55)
src/platform/notebooks/cellExecutionStateService.ts (4)
src/kernels/execution/cellExecutionCreator.ts (3)
  • cell (38-40)
  • executionOrder (44-46)
  • executionOrder (47-52)
src/platform/logging/index.ts (1)
  • logger (35-48)
src/kernels/execution/cellExecution.ts (1)
  • executionOrder (93-95)
src/platform/common/utils/lifecycle.ts (1)
  • trackDisposable (26-29)
src/kernels/kernelProvider.node.ts (3)
src/kernels/raw/types.ts (2)
  • IRawNotebookSupportedService (59-59)
  • IRawNotebookSupportedService (60-62)
src/platform/notebooks/deepnote/types.ts (2)
  • ISnapshotMetadataService (125-125)
  • ISnapshotMetadataService (126-138)
src/kernels/kernelExecution.ts (1)
  • NotebookKernelExecution (53-388)
src/notebooks/deepnote/snapshotMetadataService.ts (3)
src/notebooks/deepnote/deepnoteSerializer.ts (1)
  • injectable (51-381)
src/notebooks/deepnote/environmentCapture.node.ts (3)
  • injectable (59-244)
  • IEnvironmentCapture (48-48)
  • IEnvironmentCapture (50-55)
src/platform/logging/index.ts (1)
  • logger (35-48)
src/notebooks/serviceRegistry.node.ts (2)
src/notebooks/deepnote/environmentCapture.node.ts (2)
  • IEnvironmentCapture (48-48)
  • IEnvironmentCapture (50-55)
src/platform/notebooks/deepnote/types.ts (2)
  • ISnapshotMetadataService (125-125)
  • ISnapshotMetadataService (126-138)
🪛 GitHub Check: Lint & Format
src/notebooks/deepnote/environmentCapture.unit.test.ts

[warning] 3-3:
'Uri' is defined but never used. Allowed unused vars must match /_\w*/u


[warning] 2-2:
'sinon' is defined but never used. Allowed unused vars must match /_\w*/u

⏰ 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 (27)
src/platform/interpreter/helpers.ts (1)

136-148: Formatting improvement approved.

The added blank lines at lines 140 and 146 improve readability by separating guard clauses from subsequent logic, with no impact to correctness. The function logic remains unchanged and sound.

src/platform/notebooks/cellExecutionStateService.ts (1)

6-6: Logging approach follows guidelines.

Correctly uses ILogger service and adds useful observability without behavior changes.

Also applies to: 52-58, 61-61, 66-66, 74-74

build/esbuild/build.ts (1)

62-67: LGTM! Node.js built-ins correctly externalized.

The additions align with environment capture functionality that requires process spawning and utility functions.

src/notebooks/deepnote/pipFileParser.ts (1)

11-44: LGTM! Pip freeze parser handles common formats correctly.

The function properly handles standard (==), file URL (@), and editable (-e) formats, plus normalizes package names to lowercase.

src/platform/deepnote/deepnoteTypes.ts (1)

1-37: LGTM! Type extensions are backward compatible.

The optional fields (contentHash, executionStartedAt, executionFinishedAt) preserve compatibility with existing code while enabling snapshot metadata tracking.

src/notebooks/deepnote/deepnoteDataConverter.ts (1)

94-106: LGTM! Conditional metadata inclusion is correct.

The spread syntax properly includes snapshot fields only when defined, maintaining backward compatibility.

src/platform/notebooks/deepnote/types.ts (1)

121-138: LGTM! Interface is well-defined.

The blocking nature of captureEnvironmentBeforeExecution is properly documented, which is important for callers to understand the async behavior.

package.json (1)

2503-2503: No public breaking changes documentation available for @deepnote/blocks 1.4.0.

@deepnote/blocks is a private Deepnote package with no public npm release notes. The version bump from 1.3.5 to 1.4.0 was merged in commit 02816e1 with message "feat: Track the environment information when executing blocks", suggesting a feature addition. Verify API compatibility through internal Deepnote documentation or manual testing if @deepnote/blocks internals were used directly.

src/notebooks/deepnote/pipFileParser.unit.test.ts (1)

1-159: LGTM!

Comprehensive test coverage for parsePipFreezeFile. Correctly uses assert.deepStrictEqual() for object comparisons per guidelines.

src/kernels/kernelProvider.node.ts (2)

55-57: LGTM!

Optional DI wiring is correct. Service gracefully degrades when unavailable.


115-118: LGTM!

Snapshot service correctly propagated to NotebookKernelExecution.

src/notebooks/serviceRegistry.node.ts (1)

245-248: LGTM!

Correct singleton registration pattern. Binding to IExtensionSyncActivationService ensures lifecycle integration.

src/notebooks/deepnote/snapshotMetadataService.unit.test.ts (1)

1-285: LGTM!

Thorough coverage of state management methods. Correctly isolates per-notebook state and handles edge cases.

src/notebooks/deepnote/deepnoteSerializer.ts (2)

55-58: LGTM!

Optional injection pattern correctly applied.


239-241: Index alignment is guaranteed by design.

convertCellsToBlocks() uses a simple map() operation without filtering or reordering, so blocks[i] always corresponds to data.cells[i].

src/kernels/execution/cellExecutionQueue.ts (1)

53-56: LGTM!

Optional parameters cleanly extend the constructor without breaking existing callers.

src/notebooks/deepnote/deepnoteActivationService.ts (2)

43-43: LGTM!

Serializer correctly receives the snapshot service.


32-33: No changes needed. The pattern of injecting by base interface symbol (ISnapshotMetadataService) while typing as the full interface (ISnapshotMetadataServiceFull) is correct—ISnapshotMetadataServiceFull extends the base interface, so the type hierarchy is valid. This is standard DI practice: inject by contract, type-hint actual implementation.

Likely an incorrect or invalid review comment.

src/kernels/kernelExecution.ts (2)

69-70: LGTM!

Clean optional parameter addition.


362-369: LGTM!

Snapshot service correctly wired through to CellExecutionQueue.

src/platform/deepnote/pocket.ts (3)

10-18: LGTM!

Array alphabetically sorted. New fields properly included.


22-33: LGTM!

Good JSDoc comments for new optional fields.


95-110: LGTM!

Consistent pattern with existing executionCount handling.

src/notebooks/deepnote/snapshotMetadataService.ts (4)

24-33: contentHash is required but initialized empty elsewhere.

At line 297, contentHash: '' is used. If it's optional, make it so. If required, ensure it's always set.


131-150: LGTM!

Clean activation pattern with proper disposal registration.


380-398: LGTM!

State initialization is correct with proper defaults.


400-426: LGTM!

Good use of VSCode's timing when available, sensible fallback.

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: 2

📜 Review details

Configuration used: Organization 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 02816e1 and 0b5c428.

📒 Files selected for processing (7)
  • cspell.json
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/platform/notebooks/cellExecutionStateService.ts
🧰 Additional context used
📓 Path-based instructions (8)
**/*.unit.test.ts

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

Create unit tests in *.unit.test.ts files

**/*.unit.test.ts: Unit tests use Mocha/Chai framework with .unit.test.ts extension
Test files should be placed alongside the source files they test
Use assert.deepStrictEqual() for object comparisons instead of checking individual properties

Files:

  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
**/*.test.ts

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

Create integration tests in *.test.ts files (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 undefined then property to avoid hanging tests
Use npm run test:unittests for TypeScript unit tests before committing changes

Files:

  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
**/*.{ts,tsx}

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

**/*.{ts,tsx}: Use l10n.t() for all user-facing strings in TypeScript files
Use typed error classes from src/platform/errors/ instead of generic errors
Use ILogger service 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 CancellationToken

Order method, fields and properties first by accessibility (public/private/protected) and then by alphabetical order

Files:

  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/platform/notebooks/cellExecutionStateService.ts
  • src/notebooks/deepnote/snapshotMetadataService.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 run npm run format-fix before committing changes to ensure proper code formatting
FIX all TypeScript compilation errors before moving forward with development
Use npm run format-fix to auto-fix TypeScript formatting issues before committing
Use npm run lint to check for linter issues in TypeScript files and attempt to fix before committing

Files:

  • src/notebooks/deepnote/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/platform/notebooks/cellExecutionStateService.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

src/**/*.{ts,tsx}: Don't add the Microsoft copyright header to new files
Use Uri.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., use import { 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/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/platform/notebooks/cellExecutionStateService.ts
  • src/notebooks/deepnote/snapshotMetadataService.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/environmentCapture.unit.test.ts
  • src/notebooks/deepnote/snapshotMetadataService.unit.test.ts
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/deepnoteSerializer.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
**/*.node.ts

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

Platform Implementation - Desktop: Use .node.ts files for full file system access and Python environments

Files:

  • src/notebooks/deepnote/environmentCapture.node.ts
src/platform/**/*.ts

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

src/platform/**/*.ts: Use Inversify-based dependency injection with IServiceManager and IServiceContainer for managing service relationships and dependencies
Define service interfaces using Symbol-based exports (e.g., export const IFileSystem = Symbol('IFileSystem')) paired with corresponding TypeScript interfaces
Register types using the pattern serviceManager.addSingleton<IService>(IService, ServiceImplementation) in registerTypes functions
Use @Injectable() and @Inject() decorators from Inversify for class dependency injection configuration
Implement unified interfaces for cross-platform services (IFileSystem, IPlatformService, etc.) with graceful degradation for web environment limitations
Use structured logging with context via logger.info, logger.error, etc. rather than console.log
Provide platform capability checks and feature detection before using advanced platform-specific features
Register separate service implementations for desktop and web environments, allowing the DI container to resolve the correct platform implementation

Files:

  • src/platform/notebooks/cellExecutionStateService.ts
🧬 Code graph analysis (5)
src/notebooks/deepnote/snapshotMetadataService.unit.test.ts (1)
src/notebooks/deepnote/environmentCapture.node.ts (2)
  • IEnvironmentCapture (47-47)
  • IEnvironmentCapture (49-54)
src/notebooks/deepnote/environmentCapture.node.ts (2)
src/kernels/deepnote/environments/deepnoteEnvironment.ts (1)
  • DeepnoteEnvironment (9-60)
src/notebooks/deepnote/pipFileParser.ts (1)
  • parsePipFreezeFile (11-44)
src/notebooks/deepnote/deepnoteSerializer.ts (3)
src/notebooks/types.ts (2)
  • IDeepnoteNotebookManager (38-38)
  • IDeepnoteNotebookManager (39-59)
src/notebooks/deepnote/snapshotMetadataService.ts (2)
  • ISnapshotMetadataService (77-77)
  • ISnapshotMetadataServiceFull (79-111)
src/platform/deepnote/deepnoteTypes.ts (1)
  • DeepnoteBlock (12-21)
src/platform/notebooks/cellExecutionStateService.ts (4)
src/kernels/execution/cellExecutionCreator.ts (3)
  • cell (38-40)
  • executionOrder (44-46)
  • executionOrder (47-52)
src/platform/logging/index.ts (1)
  • logger (35-48)
src/kernels/execution/cellExecution.ts (1)
  • executionOrder (93-95)
src/platform/common/utils/lifecycle.ts (1)
  • trackDisposable (26-29)
src/notebooks/deepnote/snapshotMetadataService.ts (1)
src/notebooks/deepnote/environmentCapture.node.ts (2)
  • IEnvironmentCapture (47-47)
  • IEnvironmentCapture (49-54)
⏰ 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 (14)
src/notebooks/deepnote/environmentCapture.unit.test.ts (1)

1-132: Well-structured unit tests for parsePipFreeze.

Good coverage of edge cases: editable installs, local packages, CRLF, complex versions.

cspell.json (1)

29-71: Dictionary additions are appropriate.

Terms align with environment capture functionality.

src/platform/notebooks/cellExecutionStateService.ts (1)

41-45: Prior feedback addressed.

STATE_NAMES moved to module-level. Logging now uses debug level.

Also applies to: 57-79

src/notebooks/deepnote/snapshotMetadataService.unit.test.ts (1)

1-278: Solid test coverage for metadata service.

Covers execution lifecycle, multi-notebook isolation, state clearing. Environment capture properly mocked.

src/notebooks/deepnote/deepnoteSerializer.ts (3)

55-58: Constructor extension looks correct.

Optional injection with @optional() handles missing snapshotService gracefully.


197-207: Serialization flow properly integrates snapshot metadata.

Metadata added before cloning blocks, environment/execution added before YAML dump.


239-266: No issue here. convertCellsToBlocks uses .map() which preserves a strict 1:1 correspondence between input cells and output blocks at matching indices—no filtering or reordering occurs.

Likely an incorrect or invalid review comment.

src/notebooks/deepnote/environmentCapture.node.ts (3)

23-42: withTimeout utility is well-implemented.

Proper cleanup of timeout handle in finally block.


76-78: Windows pip path handling implemented.

Addresses prior feedback about cross-platform support.


215-241: Package listing with timeout is robust.

Returns empty object on failure, logs appropriately.

src/notebooks/deepnote/snapshotMetadataService.ts (4)

199-209: Timeout handling fixed correctly.

Prior critical issue about throw in setTimeout resolved with Promise.race.


292-306: recordCellExecutionStart correctly initializes cell metadata.

Clears executionFinishedAt on re-execution.


400-426: handleCellExecutionStateChange handles timing correctly.

Uses VSCode's timing when available, defaults to Date.now(). Success defaults to true when undefined.


120-127: Constructor is clean.

Prior feedback about unused interpreterService addressed.

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

📜 Review details

Configuration used: Organization 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 0b5c428 and 3ea2c60.

📒 Files selected for processing (3)
  • cspell.json
  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.node.ts

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

Platform Implementation - Desktop: Use .node.ts files for full file system access and Python environments

Files:

  • src/notebooks/deepnote/environmentCapture.node.ts
**/*.{ts,tsx}

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

**/*.{ts,tsx}: Use l10n.t() for all user-facing strings in TypeScript files
Use typed error classes from src/platform/errors/ instead of generic errors
Use ILogger service 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 CancellationToken

Order method, fields and properties first by accessibility (public/private/protected) and then by alphabetical order

Files:

  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.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 run npm run format-fix before committing changes to ensure proper code formatting
FIX all TypeScript compilation errors before moving forward with development
Use npm run format-fix to auto-fix TypeScript formatting issues before committing
Use npm run lint to check for linter issues in TypeScript files and attempt to fix before committing

Files:

  • src/notebooks/deepnote/environmentCapture.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

src/**/*.{ts,tsx}: Don't add the Microsoft copyright header to new files
Use Uri.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., use import { 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/environmentCapture.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.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/environmentCapture.node.ts
  • src/notebooks/deepnote/snapshotMetadataService.ts
🧬 Code graph analysis (1)
src/notebooks/deepnote/environmentCapture.node.ts (2)
src/kernels/deepnote/environments/deepnoteEnvironment.ts (1)
  • DeepnoteEnvironment (9-60)
src/notebooks/deepnote/pipFileParser.ts (1)
  • parsePipFreezeFile (11-44)
🔇 Additional comments (2)
cspell.json (1)

26-81: LGTM!

Package names align with environment capture scope. Alphabetical order maintained.

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

1-247: LGTM! Past review issues have been addressed.

All previously flagged issues have been resolved:

  • Platform-aware pip path handling for Windows/Unix (lines 76-78)
  • Proper return type with undefined handling (lines 90-94, 140-154)
  • Timeout wrapper with cleanup (lines 38-40)
  • Correct variable logging (line 229)
  • Explicit return statements (line 183)

The environment capture implementation is solid with good error handling and cross-platform support.

@Artmann Artmann marked this pull request as ready for review December 23, 2025 13:16
@Artmann Artmann requested a review from a team as a code owner December 23, 2025 13:16
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 23, 2025
@dinohamzic
Copy link
Contributor

@Artmann is there an issue for this PR? Is this in relation to deepnote/deepnote#187?

Copy link
Contributor

@dinohamzic dinohamzic left a comment

Choose a reason for hiding this comment

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

Mainly nits and questions, will test soon. 👀

Comment on lines +23 to +42
async function withTimeout<T>(promise: Promise<T>, timeoutMs: number, fallback: T, operationName: string): Promise<T> {
let timeoutId: NodeJS.Timeout | undefined;

const timeoutPromise = new Promise<T>((resolve) => {
timeoutId = setTimeout(() => {
logger.warn(`[EnvironmentCapture] ${operationName} timed out after ${timeoutMs}ms`);
resolve(fallback);
}, timeoutMs);
});

try {
const result = await Promise.race([promise, timeoutPromise]);

return result;
} finally {
if (timeoutId) {
clearTimeout(timeoutId);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: might be worth extracting to a shared helper? Have you also checked in the codebase if raceTimeout is doing something similar?

export const onDidChangeNotebookCellExecutionState = eventEmitter.event;

export function changeCellState(cell: NotebookCell, state: NotebookCellExecutionState, executionOrder?: number) {
const cellId = cell.metadata?.id as string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the cast here necessary? 👀

return;
}
// Wait for VS Code to update the cell execution state before firing the event.
logger.debug(`[CellExecState] Waiting for VS Code to update cell before firing Idle event`);
Copy link
Contributor

Choose a reason for hiding this comment

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

micro nit: should we be editor agnostic? that is, avoiding using the "VS Code" name in favor of a more generic "Editor"?

Comment on lines +12 to +21
export interface DeepnoteBlock extends BaseDeepnoteBlock {
/** SHA-256 hash of block content (prefixed with "sha256:") */
contentHash?: string;

/** ISO 8601 timestamp when block execution started */
executionStartedAt?: string;

/** ISO 8601 timestamp when block execution finished */
executionFinishedAt?: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a question: what's the reason for not having these optional fields directly in DeepnoteBlock?

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.

3 participants