Repository navigation
studio-agent: a shader write goes on the live canvas at once, not only with the next compile - #257
Merged
Merged
Conversation
…y with the next compile The visualizer only picked up a new shader in compileSong(), while set_shader/edit_shader only wrote the editor. A shader edit made after the agent's last compile never reached the canvas, and the agent, which cannot see the canvas, still reported it live. The user had to say "it's not showing" or stop and start the song. Every agent shader write (set_shader, edit_shader, run_script setShader) now calls window.applyShaderToCanvas(). The tool result says it is live, or gives the GLSL error verbatim while the canvas keeps the previous shader. compile still saves the shader to the project. The prompt line "compile also applies the shader" now describes this instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying webassemblymusic with
|
| Latest commit: |
35cf6a4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://73bd6133.webassemblymusic.pages.dev |
| Branch Preview URL: | https://agent-shader-applies-live.webassemblymusic.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In a session where the agent built a starfield with text boxes, its shader changes often didn't show. To see them, the user had to say "text is not showing" or stop and start the song.
Cause: the visualizer only picks up a new shader inside
compileSong().set_shader/edit_shaderonly write the editor, and the prompt told the agent "compilealso applies the shader". So a shader edit made after the agent's lastcompilenever reached the canvas. The session log shows this every time:set_shader→compile→edit_shader: the last edit wasn't live.edit_shadercalls and no compile at all.Each time the agent replied "Compiled; live now". It can't see the live canvas, only its own
render_shaderframes.Fix
editorcontroller.js: newwindow.applyShaderToCanvas()puts the shader editor's source on the live canvas and returns the GLSL error or null. A shader that fails to compile throws before it's switched in, so the previous one keeps running.compileSong's change check is untouched, so the next compile still sees the new shader and saves it to the project.client.js: every agent shader write (set_shader,edit_shader,run_script'ssetShader) calls it. The tool result says eitherlive on the canvas now (compile saves it to the project)orERROR: the shader does not compile, so the canvas keeps the previous one:followed by the GLSL log.prompt.js: the one line that said compile applies the shader now describes this. It replaces that line rather than adding a rule.Testing
studio-agent-mock.spec.js, local repo, no NEAR sandbox needed. It reads the live canvas pixels: green afterset_shader, magenta after anedit_shaderwith no compile, and still magenta after a broken edit, which returns the GLSL error. With the fix stashed, it fails.npm run test-agent-tools(160/160), and the studio-agent performance/kit/nearai/abort and video-export specs (17) pass.🤖 Generated with Claude Code