Skip to content

Autocomplete Hinter should support different p5.js versions #4104

Closed

Description

@ksen0

Increasing Access

The autocomplete hinter is am important tool to help newcomers navigate the codebase. However, it is not enabled by default, partly because it does not fully support multiple p5.js versions.

Feature enhancement details

Currently, the autocomplete hinter is does not completely support multiple different version of p5.js. You can switch to p5.js 2.0+ version with the hinter on and observe:

Although the link is to the correct website (beta.p5js.org), the dropdown is missing functions that exist on v2 (such as buildMaterialShader) and should be shown.

The differences between the APIs can be extracted from https://beta.p5js.org/reference/data.json (v2) and https://p5js.org/reference/data.json (v1).

Activity

  1. added
    EnhancementImprovement to an existing feature
    Needs DiscussionRequires further conversation or consensus
    p5v2 switch: requiredThis must be complete before p5v2 can be made default
    p5v2 switch: recommendedThis would be very valuable to complete before p5v2 becomes default, but is not a strict requirement
    and removed
    p5v2 switch: requiredThis must be complete before p5v2 can be made default
    on Apr 30, 2026
  2. VikasKSingh05 commented on May 8, 2026

    @VikasKSingh05

    Hello @ksen0 . I looked into this issue and would like to work on improving the autocomplete hinter’s support for multiple p5.js versions, particularly syncing suggestions with the selected v1/v2 API dataset.

    Please assign this issue to me if available.

  3. ksen0 commented on May 8, 2026

    @ksen0
    MemberAuthor

    Thanks for the interest @VikasKSingh05 ! This one's a bit tricky, the implementation is not obvious / there are different possible solutions. Could you explain how you would tackle this, where you'd start in the codebase and what approach you'd take, before we consider assignment? Thanks!

  4. VikasKSingh05 commented on May 9, 2026

    @VikasKSingh05

    Sure @ksen0 . I investigated the autocomplete generation pipeline locally and found that the issue comes from the generated hinter datasets being based on the v1 reference data.

    The update-p5-hinter.js script currently fetches from: https://p5js.org/reference/data.json

    After switching it to the v2 beta reference JSON and regenerating the hinter files via npm run update-p5-hinter, the missing v2 APIs (such as buildMaterialShader) started appearing correctly in the editor autocomplete suggestions.

    So the autocomplete itself already supports these APIs, its just that the generated datasets are outdated and still built against the v1 reference source.

    Before proceeding further, should the intended fix here be:

    1. updating the generation scripts/generated datasets to use the v2 reference data, or
    2. implementing proper multi-version-aware hinter generation/support?
    Image
  5. skyyash commented on Jun 2, 2026

    @skyyash
    Contributor

    hi @ksen0!
    interested in taking this on.

    my proposed approach:

    tldr:

    1. update update-p5-hinter.js to generate both p5-hinter-v1.js and p5-hinter-v2.js.
    2. pass version information to p5Javascript.js through stateUtils.js (either similarly to referenceBaseUrl, or infer it from referenceBaseUrl if that ends up being the better source of truth).
    3. select and pass the appropriate hints dataset (p5-hinter-v1 or p5-hinter-v2) to contextAwareHinter based on the active version.

    regardless of the implementation details, generating separate hinter files for both versions seems necessary since the APIs differ:

    both files would be generated from update-p5-hinter.js. we could also structure the script around an array of reference API URLs, making it easier to support additional p5.js versions in the future.

    for version propagation, i'd start by tracing the existing version-switching flow. we can pass versionInfo from client/modules/IDE/components/Editor/index.jsx to createNewFileState in client/modules/IDE/components/Editor/stateUtils.js through settings (similar to referenceBaseUrl). from there, it can be passed into p5Javascript via fileLanguage(versionInfo).

    then in p5Javascript.js, we can select the appropriate hinter dataset and pass it to contextAwareHinter.

    i also considered an alternative approach of merging all hints into a single dataset and filtering suggestions based on the active version. i ended up ruling that out because it would require propagating version information deeper into the completion pipeline, adding version metadata to hints, and performing filtering during completion generation. keeping separate generated datasets and selecting the correct one upfront seems simpler and easier to maintain.

  6. ksen0 commented on Jun 2, 2026

    @ksen0
    MemberAuthor

    Thanks for the quite complete/thorough proposal @skyash-dev , I'll assign! I'm keeping this as "Discussion" though in case there are roadblocks or other implementation challenges to be considered during review. Thanks!

  7. assigned and unassigned on Jun 2, 2026
  8. ksen0 commented on Jun 16, 2026

    @ksen0
    MemberAuthor

    Related PR has been merged, closing but please reopen as needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

EnhancementImprovement to an existing featureNeeds DiscussionRequires further conversation or consensusp5v2 switch: recommendedThis would be very valuable to complete before p5v2 becomes default, but is not a strict requirement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions