Skip to content

Conversation

@lastmjs
Copy link
Member

@lastmjs lastmjs commented Oct 6, 2025

Contributor

  • Related issues have been linked and all tasks have been completed or made into separate issues
  • All features are described below in the "Features" section
  • All breaking changes
    • Described below in the "Breaking Changes" section
    • Migration path described
  • PR title:
    • feat: prefix used if functionality should be included in the Features section of the release notes
    • Indicates breaking changes with suffix "(breaking changes)"
    • Described well for release notes
    • Not sentence cased
  • Code quality
    • Declarative
    • Appropriate JSDocs, Rustdocs, or comments
    • Beautiful error handling (no unwraps, expects, etc)
    • Thoroughly tested
  • New documentation enumerated in the release issue
  • AI review requested and addressed

Reviewer

  • Related issues have been linked and all tasks have been completed or made into separate issues
  • All features are described below in the "Features" section
  • All breaking changes
    • Described below in the "Breaking Changes" section
    • Migration path described
  • PR title:
    • feat: prefix used if functionality should be included in the Features section of the release notes
    • Indicates breaking changes with suffix "(breaking changes)"
    • Described well for release notes
    • Not sentence cased
  • Code quality
    • Declarative
    • Appropriate JSDocs, Rustdocs, or comments
    • Beautiful error handling (no unwraps, expects, etc)
    • Thoroughly tested
  • New documentation enumerated in the release issue

Features

  • None

Breaking Changes

  • None

@lastmjs lastmjs requested a review from Copilot October 6, 2025 17:36
Copy link

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 simplifies the candid and method meta pointer retrieval by introducing a structured approach to return both a pointer and its length, replacing the previous null-terminated string approach.

  • Introduces a PointerAndLength struct to bundle pointer and length data
  • Updates the retrieval logic to use length-based string reading instead of null-termination
  • Adds error handling for missing canister names in build commands

Reviewed Changes

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

File Description
src/stable/build/commands/build/wasm_binary/rust/stable_canister_template/src/candid_and_method_meta.rs Adds PointerAndLength struct and updates functions to return pointer with length
src/stable/build/commands/build/candid_and_method_meta/execute.ts Updates string retrieval to use length-based reading with new readPointerAndLength function
src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/candid.rs Mirrors the stable template changes with PointerAndLength struct
src/build.ts Adds validation to ensure canister name is provided for certain commands

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

Comment on lines 134 to 138
function readPointerAndLength(
memoryBuffer: ArrayBuffer,
baseAddress: number
): { pointer: number; length: number } {
const view = new DataView(memoryBuffer, baseAddress, 8);
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The magic number 8 should be replaced with a named constant or calculated from the struct size. This represents the size of the PointerAndLength struct (4 bytes for pointer + 4 bytes for length on 32-bit systems).

Suggested change
function readPointerAndLength(
memoryBuffer: ArrayBuffer,
baseAddress: number
): { pointer: number; length: number } {
const view = new DataView(memoryBuffer, baseAddress, 8);
const POINTER_AND_LENGTH_SIZE = 8;
function readPointerAndLength(
memoryBuffer: ArrayBuffer,
baseAddress: number
): { pointer: number; length: number } {
const view = new DataView(memoryBuffer, baseAddress, POINTER_AND_LENGTH_SIZE);

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

Choose a reason for hiding this comment

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

Did I do a good job resolving this?

Copy link
Member Author

Choose a reason for hiding this comment

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

@copilot What do you think of my changes?

Comment on lines 141 to 142
pointer: view.getUint32(0, true),
length: view.getUint32(4, true)
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The offset value 4 should be a named constant representing the pointer field size. Consider defining constants for field offsets to improve maintainability.

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

Choose a reason for hiding this comment

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

Did I do a good job resolving this?

Copy link
Member Author

Choose a reason for hiding this comment

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

@copilot What do you think of my changes?

@lastmjs
Copy link
Member Author

lastmjs commented Oct 6, 2025

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

1 similar comment
@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

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.

2 participants