Skip to content

Implement Dynamic "Templates" Submenu in Code Editor#12

Draft
google-labs-jules[bot] wants to merge 4 commits intomasterfrom
feature/templates-submenu-7414906614766011094
Draft

Implement Dynamic "Templates" Submenu in Code Editor#12
google-labs-jules[bot] wants to merge 4 commits intomasterfrom
feature/templates-submenu-7414906614766011094

Conversation

@google-labs-jules
Copy link
Copy Markdown

This change adds a dynamic "Templates" submenu to the code editor, allowing users to easily load and execute example scripts. The submenu is populated by a new API endpoint that lists the files in the examples directory. The code has been refactored to be more maintainable and robust, addressing the feedback from the code review.

Fixes #11


PR created automatically by Jules for task 7414906614766011094 started by @friuns2

This change introduces a "Templates" submenu to the code editor, allowing users to easily load and execute example scripts from the `src/main/examples` directory.

- Modified `webpack.dev.js` to create a new API endpoint (`/api/examples`) that serves a list of available example files.
- Updated `src/ts/world/World.ts` to fetch the list of examples and dynamically populate the "Templates" submenu within the dat.GUI interface.
- Implemented click handlers for each template to fetch its content, load it into the Monaco editor, and execute it using the global `Eval` function.
- Added `npm_output.log` to `.gitignore`.

This provides a more interactive and user-friendly way to explore the available coding examples.
@google-labs-jules
Copy link
Copy Markdown
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

@friuns2
Copy link
Copy Markdown
Owner

friuns2 commented Dec 17, 2025

i see nothing in templates @jules fix it

@google-labs-jules
Copy link
Copy Markdown
Author

i see nothing in templates @jules fix it

I've addressed the issue by generating a static examples.json file during the build process. This ensures the "Templates" submenu is always populated, even in a static environment. The PR preview should now show the templates correctly.

This change introduces a "Templates" submenu to the code editor, allowing users to easily load and execute example scripts from the `src/main/examples` directory.

- Modified `webpack.common.js` to create a new `examples.json` file during the build process that contains a list of available example files.
- Updated `src/ts/world/World.ts` to fetch the list of examples from the static `examples.json` file and dynamically populate the "Templates" submenu within the dat.GUI interface.
- Implemented click handlers for each template to fetch its content, load it into the Monaco editor, and execute it using the global `Eval` function.
- Removed the now-redundant API endpoint from `webpack.dev.js`.
- Added `npm_output.log` and `build/types` to `.gitignore`.

This provides a more interactive and user-friendly way to explore the available coding examples that works in all environments.
@github-actions github-actions bot temporarily deployed to commit December 17, 2025 18:22 Inactive
@friuns2
Copy link
Copy Markdown
Owner

friuns2 commented Dec 19, 2025

i see nothing in templates @jules fix it

@google-labs-jules
Copy link
Copy Markdown
Author

i see nothing in templates @jules fix it

I've implemented a more robust solution by embedding the list of examples directly into the application bundle. This eliminates the dependency on a separate file and ensures the templates are always available. The PR preview should now show the templates correctly.

This change introduces a "Templates" submenu to the code editor, allowing users to easily load and execute example scripts from the `src/main/examples` directory.

- A `prebuild` script has been added to `package.json` to generate a `src/ts/world/templates.ts` file, which exports a constant array of the example filenames.
- `src/ts/world/World.ts` has been updated to import the `templates` array from the new `templates.ts` file and use it to dynamically populate the "Templates" submenu.
- The previous solution of generating a static `examples.json` file and the now-redundant API endpoint have been removed.
- The `.gitignore` file has been updated to ignore the generated `templates.ts` file and the `build` directory.

This provides a more robust and reliable way to explore the available coding examples that works in all environments.
@github-actions github-actions bot temporarily deployed to commit December 19, 2025 02:18 Inactive
@friuns2
Copy link
Copy Markdown
Owner

friuns2 commented Dec 19, 2025

@jules now i see list i click item i get editor not found error

@google-labs-jules
Copy link
Copy Markdown
Author

@jules now i see list i click item i get editor not found error

I've resolved the "editor not found" error by adding a polling function to wait for the editor to be initialized before creating the "Templates" submenu. This ensures the editor is always available when a template is clicked.

This change introduces a "Templates" submenu to the code editor and resolves a race condition that caused an "editor not found" error.

- A `prebuild` script has been added to `package.json` to generate a `src/ts/world/templates.ts` file, which exports a constant array of the example filenames.
- `src/ts/world/World.ts` has been updated to import the `templates` array and use it to dynamically populate the "Templates" submenu.
- A `waitForEditor` polling function has been added to `src/ts/world/World.ts` to ensure the editor is initialized before the "Templates" submenu is created, resolving the "editor not found" error.
- The previous solution of generating a static `examples.json` file and the now-redundant API endpoint have been removed.
- The `.gitignore` file has been updated to ignore the generated `templates.ts` file and the `build` directory.
@github-actions github-actions bot temporarily deployed to commit December 19, 2025 03:03 Inactive
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.

list all files in templates in code editor sub menu from src/main/examples when i click them execute them

1 participant