Skip to content

fix: improve runtime placeholder handling#4447

Merged
GordonSmith merged 1 commit intohpcc-systems:candidate-3.x.xfrom
GordonSmith:OHQ_UPDATE_FIX
Sep 5, 2025
Merged

fix: improve runtime placeholder handling#4447
GordonSmith merged 1 commit intohpcc-systems:candidate-3.x.xfrom
GordonSmith:OHQ_UPDATE_FIX

Conversation

@GordonSmith
Copy link
Copy Markdown
Member

@GordonSmith GordonSmith commented Sep 5, 2025

Fixes previous issues with update and remove

Checklist:

  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit message includes a "fixes" reference if appropriate.
    • The commit is signed.
  • The change has been fully tested:
    • I have viewed all related gallery items
    • I have viewed all related dermatology items
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised new issues to address them separately

Testing:

@GordonSmith GordonSmith requested a review from Copilot September 5, 2025 11:39

This comment was marked as outdated.

Fixes previous issues with update and remove

Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves runtime placeholder handling by refactoring the notebook compilation and runtime management system. The changes rename the main compilation function and enhance the NotebookRuntime class with better cell lifecycle management.

  • Renamed compileKit to compileNotebook and added compileCell for individual cell compilation
  • Enhanced NotebookRuntime with separate add, update, and clear methods for better cell management
  • Added proper error handling for non-existent cells and duplicate cell IDs

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/observablehq-compiler/tests/index-notebookkit.ts Updated imports and function calls to use renamed compilation functions
packages/observablehq-compiler/tests/index-notebookkit.js Updated imports and function calls to use renamed compilation functions
packages/observablehq-compiler/src/kit/runtime.ts Enhanced runtime with improved cell lifecycle management and error handling
packages/observablehq-compiler/src/kit/index.ts Reordered exports for better organization
packages/observablehq-compiler/src/kit/compiler.ts Refactored compilation to support individual cells and renamed main function
packages/observablehq-compiler/src/index.ts Updated exports to include all kit functionality
packages/observablehq-compiler/src/compiler.ts Updated function call to use renamed compilation function
packages/observablehq-compiler/index-kit.html Uncommented CSS styles for better presentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if (!state) {
throw new Error(`Cell with id ${cellId} does not exist`);
}
void this.clear(cellId);
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The void operator is being used to explicitly ignore the Promise returned by this.clear(cellId). However, this could lead to issues if the clear operation fails. Consider awaiting the operation or handling potential errors.

Suggested change
void this.clear(cellId);
await this.clear(cellId);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The void is documenting that await is not needed here.

...cell,
mode: "md",
value: `\
const sourceIDOffset = 1000000;
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The magic number 1000000 should be defined as a named constant to improve code readability and maintainability. Consider defining it as const SOURCE_ID_OFFSET = 1000000; at the top of the file.

Copilot uses AI. Check for mistakes.
@GordonSmith GordonSmith requested a review from jeclrsg September 5, 2025 13:58
Copy link
Copy Markdown
Contributor

@jeclrsg jeclrsg left a comment

Choose a reason for hiding this comment

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

@GordonSmith Would approve. Copilot had that code-style nitpick about the source id offset being a CONST up at the top of the file. I only mention it because you'd 👎 the other one about the void

@GordonSmith GordonSmith merged commit 605b250 into hpcc-systems:candidate-3.x.x Sep 5, 2025
1 check passed
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